KiCad PCB EDA Suite
edit_tool.cpp File Reference
#include <limits>
#include <class_board.h>
#include <class_module.h>
#include <class_edge_mod.h>
#include <class_zone.h>
#include <collectors.h>
#include <pcb_edit_frame.h>
#include <kiway.h>
#include <class_draw_panel_gal.h>
#include <footprint_edit_frame.h>
#include <array_creator.h>
#include <pcbnew_id.h>
#include <status_popup.h>
#include <tool/tool_manager.h>
#include <view/view_controls.h>
#include <view/view.h>
#include <gal/graphics_abstraction_layer.h>
#include <connectivity/connectivity_data.h>
#include <confirm.h>
#include <bitmaps.h>
#include <hotkeys.h>
#include <cassert>
#include <functional>
#include "pcb_actions.h"
#include "selection_tool.h"
#include "edit_tool.h"
#include "picker_tool.h"
#include "grid_helper.h"
#include "kicad_clipboard.h"
#include "pcbnew_control.h"
#include <router/router_tool.h>
#include <dialogs/dialog_move_exact.h>
#include <dialogs/dialog_track_via_properties.h>
#include <dialogs/dialog_exchange_footprints.h>
#include <tools/tool_event_utils.h>
#include <preview_items/ruler_item.h>
#include <board_commit.h>

Go to the source code of this file.

Classes

class  GAL_ARRAY_CREATOR
 

Functions

void EditToolSelectionFilter (GENERAL_COLLECTOR &aCollector, int aFlags)
 
static wxPoint mirrorPointX (const wxPoint &aPoint, const wxPoint &aMirrorPoint)
 
static void mirrorPadX (D_PAD &aPad, const wxPoint &aMirrorPoint)
 Mirror a pad in the vertical axis passing through a point. More...
 

Function Documentation

◆ EditToolSelectionFilter()

void EditToolSelectionFilter ( GENERAL_COLLECTOR aCollector,
int  aFlags 
)

Definition at line 173 of file edit_tool.cpp.

174 {
175  // Iterate from the back so we don't have to worry about removals.
176  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
177  {
178  BOARD_ITEM* item = aCollector[ i ];
179 
180  if( ( aFlags & EXCLUDE_LOCKED ) && item->IsLocked() )
181  {
182  aCollector.Remove( item );
183  }
184  else if( item->Type() == PCB_PAD_T )
185  {
186  MODULE* mod = static_cast<MODULE*>( item->GetParent() );
187 
188  // case 1: handle locking
189  if( ( aFlags & EXCLUDE_LOCKED ) && mod && mod->IsLocked() )
190  {
191  aCollector.Remove( item );
192  }
193  else if( ( aFlags & EXCLUDE_LOCKED_PADS ) && mod && mod->PadsLocked() )
194  {
195  // Pad locking is considerably "softer" than item locking
196  aCollector.Remove( item );
197 
198  if( !mod->IsLocked() && !aCollector.HasItem( mod ) )
199  aCollector.Append( mod );
200  }
201 
202  // case 2: selection contains both the module and its pads - remove the pads
203  if( mod && aCollector.HasItem( mod ) )
204  aCollector.Remove( item );
205  }
206  else if( ( aFlags & EXCLUDE_TRANSIENTS ) && item->Type() == PCB_MARKER_T )
207  {
208  aCollector.Remove( item );
209  }
210  }
211 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:143
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:133
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
bool HasItem(const EDA_ITEM *aItem) const
Function HasItem tests if aItem has already been collected.
Definition: collector.h:197
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
virtual bool IsLocked() const
Function IsLocked.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
size_t i
Definition: json11.cpp:597
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:46
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
BOARD_ITEM_CONTAINER * GetParent() const
#define mod(a, n)
Definition: greymap.cpp:24
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References COLLECTOR::Append(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, COLLECTOR::GetCount(), BOARD_ITEM::GetParent(), COLLECTOR::HasItem(), i, BOARD_ITEM::IsLocked(), mod, PCB_MARKER_T, PCB_PAD_T, COLLECTOR::Remove(), and EDA_ITEM::Type().

Referenced by EDIT_TOOL::CreateArray(), deleteItem(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), EDIT_TOOL::doCopyToClipboard(), EDIT_TOOL::Duplicate(), EDIT_TOOL::Flip(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), EDIT_TOOL::Rotate(), and POSITION_RELATIVE_TOOL::SelectPositionRelativeItem().

◆ mirrorPadX()

static void mirrorPadX ( D_PAD aPad,
const wxPoint &  aMirrorPoint 
)
static

Mirror a pad in the vertical axis passing through a point.

Definition at line 737 of file edit_tool.cpp.

738 {
739  wxPoint tmpPt = mirrorPointX( aPad.GetPosition(), aMirrorPoint );
740 
741  if( aPad.GetShape() == PAD_SHAPE_CUSTOM )
742  aPad.MirrorXPrimitives( tmpPt.x );
743 
744  aPad.SetPosition( tmpPt );
745 
746  aPad.SetX0( aPad.GetPosition().x );
747 
748  tmpPt = aPad.GetOffset();
749  tmpPt.x = -tmpPt.x;
750  aPad.SetOffset( tmpPt );
751 
752  auto tmpz = aPad.GetDelta();
753  tmpz.x = -tmpz.x;
754  aPad.SetDelta( tmpz );
755 
756  aPad.SetOrientation( -aPad.GetOrientation() );
757 }
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
const wxPoint & GetOffset() const
Definition: class_pad.h:278
const wxSize & GetDelta() const
Definition: class_pad.h:272
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:389
static wxPoint mirrorPointX(const wxPoint &aPoint, const wxPoint &aMirrorPoint)
Definition: edit_tool.cpp:722
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:429
void SetX0(int x)
Definition: class_pad.h:266
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
const wxPoint GetPosition() const override
Definition: class_pad.h:220
void SetOffset(const wxPoint &aOffset)
Definition: class_pad.h:277
void MirrorXPrimitives(int aX)
Mirror the primitives about a coordinate.
Definition: class_pad.cpp:496
void SetDelta(const wxSize &aSize)
Definition: class_pad.h:271

References D_PAD::GetDelta(), D_PAD::GetOffset(), D_PAD::GetOrientation(), D_PAD::GetPosition(), D_PAD::GetShape(), mirrorPointX(), D_PAD::MirrorXPrimitives(), PAD_SHAPE_CUSTOM, D_PAD::SetDelta(), D_PAD::SetOffset(), D_PAD::SetOrientation(), D_PAD::SetPosition(), and D_PAD::SetX0().

Referenced by EDIT_TOOL::Mirror().

◆ mirrorPointX()

static wxPoint mirrorPointX ( const wxPoint &  aPoint,
const wxPoint &  aMirrorPoint 
)
static

Mirror a point about the vertical axis passing through another point

Definition at line 722 of file edit_tool.cpp.

723 {
724  wxPoint mirrored = aPoint;
725 
726  mirrored.x -= aMirrorPoint.x;
727  mirrored.x = -mirrored.x;
728  mirrored.x += aMirrorPoint.x;
729 
730  return mirrored;
731 }

Referenced by mirrorPadX().