KiCad PCB EDA Suite
PCBNEW_SELECTION Class Reference

#include <pcbnew_selection.h>

Inheritance diagram for PCBNEW_SELECTION:
SELECTION KIGFX::VIEW_GROUP KIGFX::VIEW_ITEM INSPECTABLE

Public Types

using ITER = std::deque< EDA_ITEM * >::iterator
 
using CITER = std::deque< EDA_ITEM * >::const_iterator
 

Public Member Functions

EDA_ITEMGetTopLeftItem (bool onlyModules=false) const override
 
const KIGFX::VIEW_GROUP::ITEMS updateDrawList () const override
 
const LSET GetSelectionLayers ()
 
ITER begin ()
 
CITER begin () const
 
ITER end ()
 
CITER end () const
 
void SetIsHover (bool aIsHover)
 
bool IsHover () const
 
virtual void Add (EDA_ITEM *aItem)
 
virtual void Add (VIEW_ITEM *aItem)
 Function Add() Adds an item to the group. More...
 
virtual void Remove (EDA_ITEM *aItem)
 
virtual void Remove (VIEW_ITEM *aItem)
 Function Remove() Removes an item from the group. More...
 
virtual void Clear () override
 Function Clear() Removes all the stored items from the group. More...
 
virtual unsigned int GetSize () const override
 Function GetSize() Returns the number of stored items. More...
 
virtual KIGFX::VIEW_ITEMGetItem (unsigned int aIdx) const override
 
bool Contains (EDA_ITEM *aItem) const
 
bool Empty () const
 Checks if there is anything selected. More...
 
int Size () const
 Returns the number of selected parts. More...
 
const std::deque< EDA_ITEM * > GetItems () const
 
virtual VECTOR2I GetCenter () const
 Returns the center point of the selection area bounding box. More...
 
virtual const BOX2I ViewBBox () const override
 Function ViewBBox() Returns the bounding box for all stored items covering all its layers. More...
 
VECTOR2I GetPosition () const
 Returns the top left point of the selection area bounding box. More...
 
EDA_RECT GetBoundingBox () const
 
EDA_ITEMoperator[] (const size_t aIdx) const
 
EDA_ITEMFront () const
 
std::deque< EDA_ITEM * > & Items ()
 
template<class T >
T * FirstOfKind () const
 
bool HasType (KICAD_T aType) const
 Checks if there is at least one item of requested kind. More...
 
bool HasReferencePoint () const
 
VECTOR2I GetReferencePoint () const
 
void SetReferencePoint (const VECTOR2I &aP)
 
void ClearReferencePoint ()
 
bool AreAllItemsIdentical () const
 Checks if all items in the selection are the same KICAD_T type. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const override
 Function ViewDraw() Draws all the stored items in the group on the given layer. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Function ViewGetLayers() Returns all the layers used by the stored items. More...
 
virtual void SetLayer (int aLayer)
 Function SetLayer() Sets layer used to draw the group. More...
 
void FreeItems ()
 Function FreeItems() Frees all the items that were added to the group. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Function ViewGetLOD() Returns the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 

Protected Types

typedef std::vector< VIEW_ITEM * > ITEMS
 

Protected Attributes

OPT< VECTOR2Im_referencePoint
 
std::deque< EDA_ITEM * > m_items
 
bool m_isHover
 
int m_layer
 Layer on which the group is drawn. More...
 
ITEMS m_groupItems
 Container for storing VIEW_ITEMs. More...
 

Detailed Description

Definition at line 31 of file pcbnew_selection.h.

Member Typedef Documentation

◆ CITER

using SELECTION::CITER = std::deque<EDA_ITEM*>::const_iterator
inherited

Definition at line 59 of file selection.h.

◆ ITEMS

typedef std::vector<VIEW_ITEM*> KIGFX::VIEW_GROUP::ITEMS
protectedinherited

Definition at line 45 of file view_group.h.

◆ ITER

using SELECTION::ITER = std::deque<EDA_ITEM*>::iterator
inherited

Definition at line 58 of file selection.h.

Member Function Documentation

◆ Add() [1/2]

void VIEW_GROUP::Add ( VIEW_ITEM aItem)
virtualinherited

Function Add() Adds an item to the group.

Parameters
aItemis the item to be added.

Definition at line 55 of file view_group.cpp.

56 {
57  m_groupItems.push_back( aItem );
58 }
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135

References KIGFX::VIEW_GROUP::m_groupItems.

Referenced by PNS_PCBNEW_DEBUG_DECORATOR::AddLine(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PNS_KICAD_IFACE::DisplayItem(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SELECTION_TOOL::EnterGroup(), and PCB_EDITOR_CONTROL::PlaceTarget().

◆ Add() [2/2]

virtual void SELECTION::Add ( EDA_ITEM aItem)
inlinevirtualinherited

Definition at line 76 of file selection.h.

77  {
78  // We're not sorting here; this is just a time-optimized way to do an
79  // inclusion check. std::lower_bound will return the first i >= aItem
80  // and the second i > aItem check rules out i == aItem.
81  ITER i = std::lower_bound( m_items.begin(), m_items.end(), aItem );
82 
83  if( i == m_items.end() || *i > aItem )
84  m_items.insert( i, aItem );
85  }
PTREE::iterator ITER
Definition: ptree.cpp:36
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawDimension(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlightInternal(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), DRAWING_TOOL::PlaceImportedGraphics(), EDIT_TOOL::Remove(), and GERBVIEW_SELECTION_TOOL::select().

◆ AreAllItemsIdentical()

bool SELECTION::AreAllItemsIdentical ( ) const
inlineinherited

Checks if all items in the selection are the same KICAD_T type.

Returns
True if all items are the same type, this includes zero or single items

Definition at line 260 of file selection.h.

261  {
262  return ( std::all_of( m_items.begin() + 1, m_items.end(),
263  [&]( const EDA_ITEM* r )
264  {
265  return r->Type() == m_items.front()->Type();
266  } ) );
267  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

References SELECTION::m_items.

Referenced by SCH_EDIT_TOOL::Init(), and SCH_EDIT_TOOL::Properties().

◆ begin() [1/2]

ITER SELECTION::begin ( )
inlineinherited

Definition at line 61 of file selection.h.

61 { return m_items.begin(); }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by PCB_INSPECTION_TOOL::calculateSelectionRatsnest().

◆ begin() [2/2]

CITER SELECTION::begin ( ) const
inlineinherited

Definition at line 63 of file selection.h.

63 { return m_items.cbegin(); }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

◆ Clear()

◆ ClearReferencePoint()

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 154 of file view_item.h.

155  {
157  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:162
#define NULL

References KIGFX::VIEW_ITEM::m_viewPrivData, and NULL.

Referenced by KIGFX::VIEW::OnDestroy().

◆ Contains()

bool SELECTION::Contains ( EDA_ITEM aItem) const
inlineinherited

Definition at line 113 of file selection.h.

114  {
115  CITER i = std::lower_bound( m_items.begin(), m_items.end(), aItem );
116 
117  return !( i == m_items.end() || *i > aItem );
118  }
PTREE::const_iterator CITER
Definition: ptree.cpp:35
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by SELECTION_TOOL::select().

◆ Empty()

bool SELECTION::Empty ( ) const
inlineinherited

Checks if there is anything selected.

Definition at line 121 of file selection.h.

122  {
123  return m_items.empty();
124  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::ChangeSymbols(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), ZONE_CREATE_HELPER::createNewZone(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PCB_INSPECTION_TOOL::doHideNet(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), SELECTION_CONDITIONS::Empty(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), PCB_EDITOR_CONTROL::Group(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SELECTION_CONDITIONS::NotEmpty(), PCB_SELECTION_CONDITIONS::OnlyConnectedItems(), PCB_SELECTION_CONDITIONS::onlyGraphicShapeTypesFunc(), SELECTION_CONDITIONS::onlyTypeFunc(), SELECTION_CONDITIONS::onlyTypesFunc(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), GROUP_TOOL::PickNewMember(), POSITION_RELATIVE_TOOL::PositionRelative(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RefreshSymbolFromLibrary(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::RemoveFromGroup(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), PCB_SELECTION_CONDITIONS::sameLayerFunc(), PCB_SELECTION_CONDITIONS::sameNetFunc(), CLIPBOARD_IO::SaveSelection(), EE_SELECTION_TOOL::SelectConnection(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), EE_INSPECTION_TOOL::ShowDatasheet(), PCB_EDITOR_CONTROL::Ungroup(), GERBVIEW_SELECTION_TOOL::unselect(), SELECTION_TOOL::unselect(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), and SCH_EDIT_FRAME::UpdateSymbolFromEditor().

◆ end() [1/2]

ITER SELECTION::end ( )
inlineinherited

Definition at line 62 of file selection.h.

62 { return m_items.end(); }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by PCB_INSPECTION_TOOL::calculateSelectionRatsnest().

◆ end() [2/2]

CITER SELECTION::end ( ) const
inlineinherited

Definition at line 64 of file selection.h.

64 { return m_items.cend(); }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

◆ FirstOfKind()

template<class T >
T* SELECTION::FirstOfKind ( ) const
inlineinherited

Definition at line 195 of file selection.h.

196  {
197  auto refType = T( nullptr ).Type();
198 
199  for( auto item : m_items )
200  {
201  if( item->Type() == refType )
202  return static_cast<T*> ( item );
203  }
204 
205  return nullptr;
206  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by PCB_EDITOR_CONTROL::EditFpInFpEditor(), and GLOBAL_EDIT_TOOL::ExchangeFootprints().

◆ FreeItems()

void VIEW_GROUP::FreeItems ( )
inherited

Function FreeItems() Frees all the items that were added to the group.

Definition at line 197 of file view_group.cpp.

198 {
199  for( unsigned int i = 0 ; i < GetSize(); i++ )
200  delete GetItem( i );
201 
202  Clear();
203 }
virtual void Clear()
Function Clear() Removes all the stored items from the group.
Definition: view_group.cpp:74
virtual VIEW_ITEM * GetItem(unsigned int aIdx) const
Definition: view_group.cpp:86
virtual unsigned int GetSize() const
Function GetSize() Returns the number of stored items.
Definition: view_group.cpp:80

References KIGFX::VIEW_GROUP::Clear(), KIGFX::VIEW_GROUP::GetItem(), and KIGFX::VIEW_GROUP::GetSize().

Referenced by PNS_PCBNEW_DEBUG_DECORATOR::Clear(), PNS_KICAD_IFACE::EraseView(), PNS_KICAD_IFACE::SetView(), and PNS_KICAD_IFACE::~PNS_KICAD_IFACE().

◆ Front()

EDA_ITEM* SELECTION::Front ( ) const
inlineinherited

Definition at line 184 of file selection.h.

185  {
186  return m_items.size() ? m_items.front() : nullptr;
187  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeSymbols(), SCH_EDIT_TOOL::CleanupSheetPins(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), PL_EDIT_TOOL::DoDelete(), EDIT_TOOL::doMoveSelection(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDITOR_CONTROL::FindNext(), EDIT_TOOL::Flip(), SELECTION::GetBoundingBox(), GERBVIEW_SELECTION::GetCenter(), SCH_EDITOR_CONTROL::HasMatch(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), LIB_PIN_TOOL::PushPinProperties(), SCH_EDITOR_CONTROL::ReplaceAndFindNext(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), CLIPBOARD_IO::SaveSelection(), EE_SELECTION_TOOL::SelectConnection(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), EE_INSPECTION_TOOL::ShowDatasheet(), SCH_DRAWING_TOOLS::SingleClickPlace(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), BUS_UNFOLD_MENU::update(), PCBNEW_CONTROL::UpdateMessagePanel(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and GERBVIEW_SELECTION::ViewBBox().

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 84 of file inspectable.h.

85  {
87  TYPE_ID thisType = TYPE_HASH( *this );
88  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
89  return object ? aProperty->getter( object ) : wxAny();
90  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual wxAny getter(void *aObject) const =0
Provides class metadata.
Definition: property_mgr.h:58
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::getter(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

Referenced by CLASS_D_DESC::CLASS_D_DESC(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [2/3]

template<typename T >
T INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 93 of file inspectable.h.

94  {
96  TYPE_ID thisType = TYPE_HASH( *this );
97  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
98  return object ? aProperty->get<T>( object ) : T();
99  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
Provides class metadata.
Definition: property_mgr.h:58
T get(void *aObject)
Definition: property.h:273
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::get(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Get() [3/3]

template<typename T >
boost::optional<T> INSPECTABLE::Get ( const wxString &  aProperty)
inlineinherited

Definition at line 102 of file inspectable.h.

103  {
105  TYPE_ID thisType = TYPE_HASH( *this );
106  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
107  boost::optional<T> ret;
108 
109  if( prop )
110  {
111  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
112 
113  if( object )
114  ret = prop->get<T>( object );
115  }
116 
117  return ret;
118  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:58
T get(void *aObject)
Definition: property.h:273
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::get(), PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ GetBoundingBox()

EDA_RECT SELECTION::GetBoundingBox ( ) const
inlineinherited

Definition at line 156 of file selection.h.

157  {
158  EDA_RECT bbox;
159 
160  if( Front() )
161  {
162  bbox = Front()->GetBoundingBox();
163 
164  for( auto i = m_items.begin() + 1; i != m_items.end(); ++i )
165  bbox.Merge( (*i)->GetBoundingBox() );
166  }
167 
168  return bbox;
169  }
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: base_struct.cpp:97
EDA_ITEM * Front() const
Definition: selection.h:184

References SELECTION::Front(), EDA_ITEM::GetBoundingBox(), SELECTION::m_items, and EDA_RECT::Merge().

Referenced by SELECTION::GetCenter(), SELECTION::GetPosition(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), EDIT_TOOL::MoveExact(), and SELECTION_TOOL::zoomFitSelection().

◆ GetCenter()

virtual VECTOR2I SELECTION::GetCenter ( ) const
inlinevirtualinherited

Returns the center point of the selection area bounding box.

Reimplemented in GERBVIEW_SELECTION.

Definition at line 138 of file selection.h.

139  {
140  return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
141  }
EDA_RECT GetBoundingBox() const
Definition: selection.h:156

References SELECTION::GetBoundingBox().

Referenced by EDIT_TOOL::Flip(), ARRAY_CREATOR::Invoke(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), LIB_EDIT_TOOL::Rotate(), and SCH_EDIT_TOOL::Rotate().

◆ GetItem()

◆ GetItems()

const std::deque<EDA_ITEM*> SELECTION::GetItems ( ) const
inlineinherited

◆ GetPosition()

VECTOR2I SELECTION::GetPosition ( ) const
inlineinherited

Returns the top left point of the selection area bounding box.

Definition at line 151 of file selection.h.

152  {
153  return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
154  }
VECTOR2I GetPosition() const
Returns the top left point of the selection area bounding box.
Definition: selection.h:151
EDA_RECT GetBoundingBox() const
Definition: selection.h:156

References SELECTION::GetBoundingBox().

◆ GetReferencePoint()

VECTOR2I SELECTION::GetReferencePoint ( ) const
inlineinherited

Definition at line 240 of file selection.h.

241  {
242  return *m_referencePoint;
243  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:270

References SELECTION::m_referencePoint.

Referenced by EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Mirror(), EDIT_TOOL::Rotate(), and CLIPBOARD_IO::SaveSelection().

◆ GetSelectionLayers()

const LSET PCBNEW_SELECTION::GetSelectionLayers ( )

Definition at line 137 of file pcbnew_selection.cpp.

138 {
139  LSET retval;
140 
141  for( auto item : m_items )
142  {
143  if( auto board_item = dynamic_cast<BOARD_ITEM*>( item ) )
144  retval |= board_item->GetLayerSet();
145  }
146 
147  return retval;
148 }
LSET is a set of PCB_LAYER_IDs.
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

Referenced by EDIT_TOOL::doMoveSelection().

◆ GetSize()

◆ GetTopLeftItem()

EDA_ITEM * PCBNEW_SELECTION::GetTopLeftItem ( bool  onlyModules = false) const
overridevirtual

Reimplemented from SELECTION.

Definition at line 58 of file pcbnew_selection.cpp.

59 {
60  EDA_ITEM* topLeftItem = nullptr;
61 
62  wxPoint pnt;
63 
64  // find the leftmost (smallest x coord) and highest (smallest y with the smallest x) item in the selection
65  for( EDA_ITEM* item : m_items )
66  {
67  pnt = item->GetPosition();
68 
69  if( ( item->Type() != PCB_MODULE_T ) && onlyModules )
70  {
71  continue;
72  }
73  else
74  {
75  if( topLeftItem == nullptr )
76  {
77  topLeftItem = item;
78  }
79  else if( ( pnt.x < topLeftItem->GetPosition().x ) ||
80  ( ( topLeftItem->GetPosition().x == pnt.x ) &&
81  ( pnt.y < topLeftItem->GetPosition().y ) ) )
82  {
83  topLeftItem = item;
84  }
85  }
86  }
87 
88  return topLeftItem;
89 }
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
class MODULE, a footprint
Definition: typeinfo.h:89
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

References EDA_ITEM::GetPosition(), PCB_MODULE_T, wxPoint::x, and wxPoint::y.

Referenced by POSITION_RELATIVE_TOOL::GetSelectionAnchorPosition(), and PCBNEW_CONTROL::placeBoardItems().

◆ HasReferencePoint()

bool SELECTION::HasReferencePoint ( ) const
inlineinherited

◆ HasType()

bool SELECTION::HasType ( KICAD_T  aType) const
inlineinherited

Checks if there is at least one item of requested kind.

Parameters
aTypeis the type to check for.
Returns
True if there is at least one item of such kind.

Definition at line 214 of file selection.h.

215  {
216  for( auto item : m_items )
217  {
218  if( item->Type() == aType )
219  return true;
220  }
221 
222  return false;
223  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by EDIT_TOOL::Remove().

◆ IsHover()

◆ Items()

std::deque<EDA_ITEM*>& SELECTION::Items ( )
inlineinherited

Definition at line 189 of file selection.h.

190  {
191  return m_items;
192  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by SCH_EDIT_TOOL::Properties().

◆ operator[]()

EDA_ITEM* SELECTION::operator[] ( const size_t  aIdx) const
inlineinherited

Definition at line 176 of file selection.h.

177  {
178  if( aIdx < m_items.size() )
179  return m_items[ aIdx ];
180 
181  return nullptr;
182  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

◆ Remove() [1/2]

void VIEW_GROUP::Remove ( VIEW_ITEM aItem)
virtualinherited

Function Remove() Removes an item from the group.

Parameters
aItemis the item to be removed.

Definition at line 61 of file view_group.cpp.

62 {
63  for( auto iter = m_groupItems.begin(); iter != m_groupItems.end(); ++iter )
64  {
65  if( aItem == *iter )
66  {
67  m_groupItems.erase( iter );
68  break;
69  }
70  }
71 }
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135

References KIGFX::VIEW_GROUP::m_groupItems.

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), and PCB_EDITOR_CONTROL::PlaceTarget().

◆ Remove() [2/2]

virtual void SELECTION::Remove ( EDA_ITEM aItem)
inlinevirtualinherited

Definition at line 87 of file selection.h.

88  {
89  ITER i = std::lower_bound( m_items.begin(), m_items.end(), aItem );
90 
91  if( !( i == m_items.end() || *i > aItem ) )
92  m_items.erase( i );
93  }
PTREE::iterator ITER
Definition: ptree.cpp:36
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by DRAWING_TOOL::DrawDimension(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlightInternal(), and GERBVIEW_SELECTION_TOOL::unselect().

◆ Set() [1/3]

bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
wxAny &  aValue 
)
inlineinherited

Definition at line 40 of file inspectable.h.

41  {
43  TYPE_ID thisType = TYPE_HASH( *this );
44  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
45 
46  if( object )
47  aProperty->setter( object, aValue );
48 
49  return object != nullptr;
50  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual void setter(void *aObject, wxAny &aValue)=0
Provides class metadata.
Definition: property_mgr.h:58
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::setter(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [2/3]

template<typename T >
bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
aValue 
)
inlineinherited

Definition at line 53 of file inspectable.h.

54  {
56  TYPE_ID thisType = TYPE_HASH( *this );
57  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
58 
59  if( object )
60  aProperty->set<T>( object, aValue );
61 
62  return object != nullptr;
63  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
Provides class metadata.
Definition: property_mgr.h:58
void set(void *aObject, T aValue)
Definition: property.h:266
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [3/3]

template<typename T >
bool INSPECTABLE::Set ( const wxString &  aProperty,
aValue 
)
inlineinherited

Definition at line 66 of file inspectable.h.

67  {
69  TYPE_ID thisType = TYPE_HASH( *this );
70  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
71  void* object = nullptr;
72 
73  if( prop )
74  {
75  object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
76 
77  if( object )
78  prop->set<T>( object, aValue );
79  }
80 
81  return object != nullptr;
82  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:58
void set(void *aObject, T aValue)
Definition: property.h:266
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ SetIsHover()

◆ SetLayer()

virtual void KIGFX::VIEW_GROUP::SetLayer ( int  aLayer)
inlinevirtualinherited

Function SetLayer() Sets layer used to draw the group.

Parameters
aLayeris the layer used for drawing.

Definition at line 115 of file view_group.h.

116  {
117  m_layer = aLayer;
118  }
int m_layer
Layer on which the group is drawn.
Definition: view_group.h:131

References KIGFX::VIEW_GROUP::m_layer.

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), PNS_KICAD_IFACE::SetView(), and PNS_PCBNEW_DEBUG_DECORATOR::SetView().

◆ SetReferencePoint()

◆ Size()

int SELECTION::Size ( ) const
inlineinherited

Returns the number of selected parts.

Definition at line 127 of file selection.h.

128  {
129  return m_items.size();
130  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271

References SELECTION::m_items.

Referenced by POINT_EDITOR::addCornerCondition(), ROUTER_TOOL::CanInlineDrag(), PAD_TOOL::copyPadSettings(), SELECTION_CONDITIONS::countFunc(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), PL_EDIT_TOOL::DoDelete(), EDIT_TOOL::Duplicate(), PAD_TOOL::EditPad(), SELECTION_TOOL::expandConnection(), GERBVIEW_SELECTION::GetCenter(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), ARRAY_CREATOR::Invoke(), SELECTION_CONDITIONS::lessThanFunc(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SELECTION_CONDITIONS::moreThanFunc(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::placeBoardItems(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), CLIPBOARD_IO::SaveSelection(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), EE_SELECTION_TOOL::updateReferencePoint(), GERBVIEW_SELECTION::ViewBBox(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ updateDrawList()

const KIGFX::VIEW_GROUP::ITEMS PCBNEW_SELECTION::updateDrawList ( ) const
overridevirtual

Reimplemented from SELECTION.

Definition at line 92 of file pcbnew_selection.cpp.

93 {
94  std::vector<VIEW_ITEM*> items;
95 
96  std::function<void ( EDA_ITEM* )> addItem;
97  addItem = [&]( EDA_ITEM* item ) {
98  items.push_back( item );
99 
100  if( item->Type() == PCB_MODULE_T )
101  {
102  MODULE* module = static_cast<MODULE*>( item );
103  module->RunOnChildren( [&] ( BOARD_ITEM* bitem ) { addItem( bitem ); } );
104  }
105  else if( item->Type() == PCB_GROUP_T )
106  {
107  PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
108  group->RunOnChildren( [&] ( BOARD_ITEM* bitem ) { addItem( bitem ); } );
109  }
110  };
111 
112  for( auto item : m_items )
113  {
114  addItem( item );
115  }
116 #if 0
117  for( auto item : m_items )
118  {
119  items.push_back( item );
120 
121  if( item->Type() == PCB_MODULE_T )
122  {
123  MODULE* module = static_cast<MODULE*>( item );
124  module->RunOnChildren( [&] ( BOARD_ITEM* bitem ) { items.push_back( bitem ); } );
125  }
126  else if( item->Type() == PCB_GROUP_T )
127  {
128  PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
129  group->RunOnChildren( [&] ( BOARD_ITEM* bitem ) { items.push_back( bitem ); } );
130  }
131  }
132 #endif
133  return items;
134 }
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Invokes a function on all members of the group.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:109
PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates)
class MODULE, a footprint
Definition: typeinfo.h:89
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

References PCB_GROUP_T, PCB_MODULE_T, PCB_GROUP::RunOnChildren(), and MODULE::RunOnChildren().

◆ ViewBBox()

virtual const BOX2I SELECTION::ViewBBox ( ) const
inlineoverridevirtualinherited

Function ViewBBox() Returns the bounding box for all stored items covering all its layers.

Returns
The current bounding box

Reimplemented from KIGFX::VIEW_GROUP.

Reimplemented in GERBVIEW_SELECTION.

Definition at line 143 of file selection.h.

144  {
145  BOX2I r;
146  r.SetMaximum();
147  return r;
148  }
void SetMaximum()
Definition: box2.h:73

References BOX2< Vec >::SetMaximum().

◆ ViewDraw()

void VIEW_GROUP::ViewDraw ( int  aLayer,
VIEW aView 
) const
overridevirtualinherited

Function ViewDraw() Draws all the stored items in the group on the given layer.

Parameters
aLayeris the layer which should be drawn.
aViewis the VIEW that should be used for drawing.

Reimplemented from KIGFX::VIEW_ITEM.

Definition at line 112 of file view_group.cpp.

113 {
114  KIGFX::GAL* gal = aView->GetGAL();
115  PAINTER* painter = aView->GetPainter();
116  bool isSelection = m_layer == LAYER_SELECT_OVERLAY;
117  const auto drawList = updateDrawList();
118 
119  std::unordered_map<int, std::vector<VIEW_ITEM*>> layer_item_map;
120 
121  // Build a list of layers used by the items in the group
122  for( auto item : drawList )
123  {
124  int item_layers[VIEW::VIEW_MAX_LAYERS], item_layers_count;
125  item->ViewGetLayers( item_layers, item_layers_count );
126 
127  for( int i = 0; i < item_layers_count; i++ )
128  {
129  if( layer_item_map.count( item_layers[i] ) == 0 )
130  {
131  layer_item_map.emplace( std::make_pair( item_layers[i],
132  std::vector<VIEW_ITEM*>() ) );
133  }
134 
135  layer_item_map[ item_layers[i] ].push_back( item );
136  }
137  }
138 
139  int layers[VIEW::VIEW_MAX_LAYERS] = { 0 };
140  int layers_count = 0;
141 
142  for( const auto& entry : layer_item_map )
143  {
144  layers[ layers_count++ ] = entry.first;
145  }
146 
147  aView->SortLayers( layers, layers_count );
148 
149  // Now draw the layers in sorted order
150 
151  gal->PushDepth();
152 
153  for( int i = 0; i < layers_count; i++ )
154  {
155  int layer = layers[i];
156  bool draw = aView->IsLayerVisible( layer );
157 
158  if( isSelection )
159  {
160  switch( layer )
161  {
162  case LAYER_PADS_TH:
164  case LAYER_PAD_FR:
165  case LAYER_PAD_BK:
166  draw = true;
167  break;
168  default:
169  break;
170  }
171  }
172 
173  if( draw )
174  {
175  gal->AdvanceDepth();
176 
177  for( auto item : layer_item_map[ layers[i] ] )
178  {
179  if( !painter->Draw( item, layers[i] ) )
180  item->ViewDraw( layers[i], aView ); // Alternative drawing method
181  }
182  }
183  }
184 
185  gal->PopDepth();
186 }
multilayer pads, usually with holes
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:692
void SortLayers(int aLayers[], int &aCount) const
Function SortLayers() Changes the order of given layer ids, so after sorting the order corresponds to...
Definition: view.cpp:677
virtual const ITEMS updateDrawList() const
Definition: view_group.cpp:206
PAINTER contains all the knowledge about how to draw graphical object onto any particular output devi...
Definition: painter.h:58
void PopDepth()
Restores previously stored drawing depth for the depth stack.
int m_layer
Layer on which the group is drawn.
Definition: view_group.h:131
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer)=0
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
void PushDepth()
Stores current drawing depth on the depth stack.
smd pads, front layer
currently selected items overlay
void AdvanceDepth()
Changes the current depth to deeper, so it is possible to draw objects right beneath other.
Class GAL is the abstract interface for drawing on a 2D-surface.
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:400

References KIGFX::GAL::AdvanceDepth(), KIGFX::PAINTER::Draw(), KIGFX::VIEW::GetGAL(), KIGFX::VIEW::GetPainter(), KIGFX::VIEW::IsLayerVisible(), LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH, LAYER_SELECT_OVERLAY, KIGFX::VIEW_GROUP::m_layer, KIGFX::GAL::PopDepth(), KIGFX::GAL::PushDepth(), KIGFX::VIEW::SortLayers(), KIGFX::VIEW_GROUP::updateDrawList(), and KIGFX::VIEW::VIEW_MAX_LAYERS.

◆ ViewGetLayers()

void VIEW_GROUP::ViewGetLayers ( int  aLayers[],
int &  aCount 
) const
overridevirtualinherited

Function ViewGetLayers() Returns all the layers used by the stored items.

Parameters
aLayers[]is the output layer index array.
aCountis the number of layer indices in aLayers[].

Implements KIGFX::VIEW_ITEM.

Definition at line 189 of file view_group.cpp.

190 {
191  // Everything is displayed on a single layer
192  aLayers[0] = m_layer;
193  aCount = 1;
194 }
int m_layer
Layer on which the group is drawn.
Definition: view_group.h:131

References KIGFX::VIEW_GROUP::m_layer.

◆ ViewGetLOD()

virtual double KIGFX::VIEW_ITEM::ViewGetLOD ( int  aLayer,
VIEW aView 
) const
inlinevirtualinherited

Function ViewGetLOD() Returns the level of detail (LOD) of the item.

A level of detail is the minimal VIEW scale that is sufficient for an item to be shown on a given layer.

Parameters
aLayercurrent drawing layer
aViewpointer to the VIEW device we are drawing on
Returns
the level of detail. 0 always show the item, because the actual zoom level (or VIEW scale) is always > 0

Reimplemented in MODULE_ZONE_CONTAINER, MODULE, D_PAD, VIA, GERBER_DRAW_ITEM, TEXTE_MODULE, TRACK, ZONE_CONTAINER, EDGE_MODULE, and PCB_GROUP.

Definition at line 141 of file view_item.h.

142  {
143  // By default always show the item
144  return 0.0;
145  }

Referenced by KIGFX::VIEW::drawItem::operator()(), EE_GRID_HELPER::queryVisible(), GRID_HELPER::queryVisible(), and SELECTION_TOOL::Selectable().

◆ viewPrivData()

Member Data Documentation

◆ m_groupItems

ITEMS KIGFX::VIEW_GROUP::m_groupItems
protectedinherited

◆ m_isHover

bool SELECTION::m_isHover
protectedinherited

◆ m_items

◆ m_layer

int KIGFX::VIEW_GROUP::m_layer
protectedinherited

Layer on which the group is drawn.

Definition at line 131 of file view_group.h.

Referenced by KIGFX::VIEW_GROUP::SetLayer(), KIGFX::VIEW_GROUP::ViewDraw(), and KIGFX::VIEW_GROUP::ViewGetLayers().

◆ m_referencePoint

OPT<VECTOR2I> SELECTION::m_referencePoint
protectedinherited

The documentation for this class was generated from the following files: