KiCad PCB EDA Suite
edit_tool.h File Reference
#include <math/vector2d.h>
#include <tools/pcb_tool.h>
#include <tools/selection_tool.h>

Go to the source code of this file.

Classes

class  EDIT_TOOL
 Class EDIT_TOOL. More...
 

Macros

#define EXCLUDE_LOCKED   0x0001
 Function EditToolSelectionFilter. More...
 
#define EXCLUDE_LOCKED_PADS   0x0002
 
#define EXCLUDE_TRANSIENTS   0x0004
 

Functions

void EditToolSelectionFilter (GENERAL_COLLECTOR &aCollector, int aFlags)
 

Macro Definition Documentation

Function Documentation

void EditToolSelectionFilter ( GENERAL_COLLECTOR aCollector,
int  aFlags 
)

Definition at line 173 of file edit_tool.cpp.

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

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), EDIT_TOOL::CreateArray(), deleteItem(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), EDIT_TOOL::doCopyToClipboard(), EDIT_TOOL::Duplicate(), EDIT_TOOL::Flip(), 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().

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 }
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
BOARD_ITEM_CONTAINER * GetParent() const
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
bool PadsLocked() const
Definition: class_module.h:304
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:268
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
virtual bool IsLocked() const
Function IsLocked.
size_t i
Definition: json11.cpp:597
bool HasItem(const EDA_ITEM *aItem) const
Function HasItem tests if aItem has already been collected.
Definition: collector.h:197
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:45
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
#define mod(a, n)
Definition: greymap.cpp:24