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

Go to the source code of this file.

Classes

class  EDIT_TOOL
 EDIT_TOOL. More...
 

Namespaces

 KIGFX
 Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
 
 KIGFX::PREVIEW
 

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

◆ EXCLUDE_LOCKED

#define EXCLUDE_LOCKED   0x0001

Function EditToolSelectionFilter.

A CLIENT_SELECTION_FILTER which promotes pad selections to their parent modules and optionally excludes locked items and/or transient items (such as markers).

Definition at line 53 of file edit_tool.h.

◆ EXCLUDE_LOCKED_PADS

#define EXCLUDE_LOCKED_PADS   0x0002

Definition at line 54 of file edit_tool.h.

◆ EXCLUDE_TRANSIENTS

#define EXCLUDE_TRANSIENTS   0x0004

Definition at line 55 of file edit_tool.h.

Function Documentation

◆ EditToolSelectionFilter()

void EditToolSelectionFilter ( GENERAL_COLLECTOR aCollector,
int  aFlags 
)

Definition at line 59 of file edit_tool.cpp.

60 {
61  // Iterate from the back so we don't have to worry about removals.
62  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
63  {
64  BOARD_ITEM* item = aCollector[ i ];
65 
66  if( ( aFlags & EXCLUDE_LOCKED ) && item->IsLocked() )
67  {
68  aCollector.Remove( item );
69  }
70  else if( item->Type() == PCB_PAD_T )
71  {
72  MODULE* mod = static_cast<MODULE*>( item->GetParent() );
73 
74  // case 1: handle locking
75  if( ( aFlags & EXCLUDE_LOCKED ) && mod && mod->IsLocked() )
76  {
77  aCollector.Remove( item );
78  }
79  else if( ( aFlags & EXCLUDE_LOCKED_PADS ) && mod && mod->PadsLocked() )
80  {
81  // Pad locking is considerably "softer" than item locking
82  aCollector.Remove( item );
83 
84  if( !mod->IsLocked() && !aCollector.HasItem( mod ) )
85  aCollector.Append( mod );
86  }
87 
88  // case 2: selection contains both the module and its pads - remove the pads
89  if( mod && aCollector.HasItem( mod ) )
90  aCollector.Remove( item );
91  }
92  else if( ( aFlags & EXCLUDE_TRANSIENTS ) && item->Type() == PCB_MARKER_T )
93  {
94  aCollector.Remove( item );
95  }
96  }
97 }
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:145
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:135
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:116
bool HasItem(const EDA_ITEM *aItem) const
Function HasItem tests if aItem has already been collected.
Definition: collector.h:199
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:301
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
virtual bool IsLocked() const
Function IsLocked.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:98
bool PadsLocked() const
Definition: class_module.h:337
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:53
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

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

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