KiCad PCB EDA Suite
SELECTION Class Reference

#include <selection.h>

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

Public Types

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

Public Member Functions

 SELECTION ()
 
 SELECTION (const SELECTION &aOther)
 
const SELECTIONoperator= (const SELECTION &aOther)
 
ITER begin ()
 
ITER end ()
 
CITER begin () const
 
CITER end () const
 
void SetIsHover (bool aIsHover)
 
bool IsHover () const
 
virtual void Add (EDA_ITEM *aItem)
 
virtual void Remove (EDA_ITEM *aItem)
 
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
 
VECTOR2I GetCenter () const
 Returns the center point of the selection area bounding box. More...
 
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_ITEMGetTopLeftItem (bool onlyModules=false) const
 
EDA_ITEMGetTopLeftModule () 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...
 
virtual const VIEW_GROUP::ITEMS updateDrawList () const override
 
bool HasReferencePoint () const
 
VECTOR2I GetReferencePoint () const
 
void SetReferencePoint (const VECTOR2I &aP)
 
void ClearReferencePoint ()
 
virtual void Add (VIEW_ITEM *aItem)
 Function Add() Adds an item to the group. More...
 
virtual void Remove (VIEW_ITEM *aItem)
 Function Remove() Removes an item from the group. 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 unsigned int 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 ()
 

Protected Types

typedef std::vector< VIEW_ITEM * > ITEMS
 

Protected Attributes

int m_layer
 Layer on which the group is drawn. More...
 
ITEMS m_groupItems
 Container for storing VIEW_ITEMs. More...
 

Private Attributes

OPT< VECTOR2Im_referencePoint
 
std::deque< EDA_ITEM * > m_items
 Set of selected items. More...
 
bool m_isHover
 

Detailed Description

Definition at line 35 of file selection.h.

Member Typedef Documentation

◆ CITER

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

Definition at line 57 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

Definition at line 56 of file selection.h.

Constructor & Destructor Documentation

◆ SELECTION() [1/2]

SELECTION::SELECTION ( )
inline

Definition at line 38 of file selection.h.

39  {
40  m_isHover = false;
41  }
bool m_isHover
Definition: selection.h:225

References m_isHover.

◆ SELECTION() [2/2]

SELECTION::SELECTION ( const SELECTION aOther)
inline

Definition at line 43 of file selection.h.

44  {
45  m_items = aOther.m_items;
46  m_isHover = aOther.m_isHover;
47  }
bool m_isHover
Definition: selection.h:225
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_isHover, and m_items.

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(), and PCB_EDITOR_CONTROL::PlaceTarget().

◆ Add() [2/2]

virtual void SELECTION::Add ( EDA_ITEM aItem)
inlinevirtual

Definition at line 74 of file selection.h.

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

References i, and m_items.

Referenced by PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), and GERBVIEW_SELECTION_TOOL::select().

◆ begin() [1/2]

ITER SELECTION::begin ( )
inline

Definition at line 59 of file selection.h.

59 { return m_items.begin(); }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by SELECTION_TOOL::RequestSelection().

◆ begin() [2/2]

CITER SELECTION::begin ( ) const
inline

Definition at line 61 of file selection.h.

61 { return m_items.cbegin(); }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

◆ Clear()

virtual void SELECTION::Clear ( )
inlineoverridevirtual

Function Clear() Removes all the stored items from the group.

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 93 of file selection.h.

94  {
95  m_items.clear();
96  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by GERBVIEW_SELECTION_TOOL::clearSelection(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), SELECTION_TOOL::RebuildSelection(), EE_SELECTION_TOOL::RebuildSelection(), GERBVIEW_SELECTION_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), and SELECTION_TOOL::Reset().

◆ ClearReferencePoint()

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 153 of file view_item.h.

154  {
155  m_viewPrivData = NULL;
156  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:161

References KIGFX::VIEW_ITEM::m_viewPrivData.

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

◆ Contains()

bool SELECTION::Contains ( EDA_ITEM aItem) const
inline

Definition at line 111 of file selection.h.

112  {
113  CITER i = std::lower_bound( m_items.begin(), m_items.end(), aItem );
114 
115  return !( i == m_items.end() || *i > aItem );
116  }
PTREE::const_iterator CITER
Definition: ptree.cpp:35
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223
size_t i
Definition: json11.cpp:597

References i, and m_items.

Referenced by SELECTION_TOOL::select().

◆ Empty()

bool SELECTION::Empty ( ) const
inline

Checks if there is anything selected.

Definition at line 119 of file selection.h.

120  {
121  return ( m_items.size() == 0 );
122  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), EDIT_TOOL::CreateArray(), GERBVIEW_SELECTION_TOOL::CursorSelection(), deleteItem(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), EDIT_TOOL::doCopyToClipboard(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineDrag(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SELECTION_CONDITIONS::NotEmpty(), PCB_SELECTION_CONDITIONS::OnlyConnectedItems(), SELECTION_CONDITIONS::onlyTypeFunc(), SELECTION_CONDITIONS::onlyTypesFunc(), SCH_EDITOR_CONTROL::Paste(), POSITION_RELATIVE_TOOL::PositionRelative(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), 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(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), EE_INSPECTION_TOOL::ShowDatasheet(), showLocalRatsnest(), EE_INSPECTION_TOOL::ShowMarkerInfo(), GERBVIEW_SELECTION_TOOL::unselect(), SELECTION_TOOL::unselect(), and PCB_EDITOR_CONTROL::UpdateSelectionRatsnest().

◆ end() [1/2]

ITER SELECTION::end ( )
inline

Definition at line 60 of file selection.h.

60 { return m_items.end(); }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by SELECTION_TOOL::RequestSelection().

◆ end() [2/2]

CITER SELECTION::end ( ) const
inline

Definition at line 62 of file selection.h.

62 { return m_items.cend(); }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

◆ FirstOfKind()

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

Definition at line 166 of file selection.h.

167  {
168  auto refType = T( nullptr ).Type();
169 
170  for( auto item : m_items )
171  {
172  if( item->Type() == refType )
173  return static_cast<T*> ( item );
174  }
175 
176  return nullptr;
177  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by EDIT_TOOL::editFootprintInFpEditor(), and 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
size_t i
Definition: json11.cpp:597

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

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
inline

Definition at line 155 of file selection.h.

156  {
157  return m_items.size() ? m_items.front() : nullptr;
158  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::CleanupSheetPins(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SCH_DRAWING_TOOLS::doTwoClickPlace(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), EDIT_TOOL::Flip(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), SCH_WIRE_BUS_TOOL::IsDrawingBus(), SCH_WIRE_BUS_TOOL::IsDrawingLine(), SCH_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), SCH_WIRE_BUS_TOOL::IsDrawingWire(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), DRAWING_TOOL::PlaceImportedGraphics(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), LIB_PIN_TOOL::PushPinProperties(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), EE_SELECTION_TOOL::SelectConnection(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), EE_INSPECTION_TOOL::ShowDatasheet(), EE_INSPECTION_TOOL::ShowMarkerInfo(), BUS_UNFOLD_MENU::update(), LIB_MOVE_TOOL::updateModificationPoint(), SCH_MOVE_TOOL::updateModificationPoint(), and EDIT_TOOL::updateModificationPoint().

◆ GetBoundingBox()

EDA_RECT SELECTION::GetBoundingBox ( ) const

Definition at line 73 of file pcbnew/tools/selection.cpp.

74 {
75  EDA_RECT bbox;
76 
77  bbox = Front()->GetBoundingBox();
78  auto i = m_items.begin();
79  ++i;
80 
81  for( ; i != m_items.end(); ++i )
82  {
83  bbox.Merge( (*i)->GetBoundingBox() );
84  }
85 
86  return bbox;
87 }
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
Set of selected items.
Definition: selection.h:223
size_t i
Definition: json11.cpp:597
Class 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.
EDA_ITEM * Front() const
Definition: selection.h:155

References i, and EDA_RECT::Merge().

◆ GetCenter()

VECTOR2I SELECTION::GetCenter ( ) const

Returns the center point of the selection area bounding box.

Definition at line 67 of file pcbnew/tools/selection.cpp.

68 {
69  return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
70 }
EDA_RECT GetBoundingBox() const

Referenced by GAL_ARRAY_CREATOR::getRotationCentre(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), LIB_EDIT_TOOL::Rotate(), and SCH_EDIT_TOOL::Rotate().

◆ GetItem()

virtual KIGFX::VIEW_ITEM* SELECTION::GetItem ( unsigned int  aIdx) const
inlineoverridevirtual

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 103 of file selection.h.

104  {
105  if( aIdx < m_items.size() )
106  return m_items[ aIdx ];
107 
108  return nullptr;
109  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by SCH_MOVE_TOOL::addJunctionsIfNeeded(), SCH_EDIT_TOOL::ChangeShape(), SCH_EDIT_TOOL::ChangeTextType(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), SCH_LEGACY_PLUGIN::Format(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EE_SELECTION_TOOL::RequestSelection(), LIB_EDIT_TOOL::Rotate(), and SCH_EDIT_TOOL::Rotate().

◆ GetItems()

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

Definition at line 130 of file selection.h.

131  {
132  return m_items;
133  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SELECTION_TOOL::expandConnection(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::selectCopper(), and SELECTION_TOOL::selectNet().

◆ GetPosition()

VECTOR2I SELECTION::GetPosition ( ) const

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

Definition at line 61 of file pcbnew/tools/selection.cpp.

62 {
63  return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
64 }
VECTOR2I GetPosition() const
Returns the top left point of the selection area bounding box.
EDA_RECT GetBoundingBox() const

◆ GetReferencePoint()

VECTOR2I SELECTION::GetReferencePoint ( ) const
inline

Definition at line 203 of file selection.h.

204  {
205  return *m_referencePoint;
206  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:220

References m_referencePoint.

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

◆ GetSize()

◆ GetTopLeftItem()

EDA_ITEM * SELECTION::GetTopLeftItem ( bool  onlyModules = false) const

Definition at line 90 of file pcbnew/tools/selection.cpp.

91 {
92  BOARD_ITEM* topLeftItem = nullptr;
93  BOARD_ITEM* currentItem;
94 
95  wxPoint pnt;
96 
97  // find the leftmost (smallest x coord) and highest (smallest y with the smallest x) item in the selection
98  for( auto item : m_items )
99  {
100  currentItem = static_cast<BOARD_ITEM*>( item );
101  pnt = currentItem->GetPosition();
102 
103  if( ( currentItem->Type() != PCB_MODULE_T ) && onlyModules )
104  {
105  continue;
106  }
107  else
108  {
109  if( topLeftItem == nullptr )
110  {
111  topLeftItem = currentItem;
112  }
113  else if( ( pnt.x < topLeftItem->GetPosition().x ) ||
114  ( ( topLeftItem->GetPosition().x == pnt.x ) &&
115  ( pnt.y < topLeftItem->GetPosition().y ) ) )
116  {
117  topLeftItem = currentItem;
118  }
119  }
120  }
121 
122  return static_cast<EDA_ITEM*>( topLeftItem );
123 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class MODULE, a footprint
Definition: typeinfo.h:89
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223
virtual const wxPoint GetPosition() const =0
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References BOARD_ITEM::GetPosition(), PCB_MODULE_T, and EDA_ITEM::Type().

Referenced by SCH_EDITOR_CONTROL::Paste().

◆ GetTopLeftModule()

EDA_ITEM * SELECTION::GetTopLeftModule ( ) const

Definition at line 126 of file pcbnew/tools/selection.cpp.

127 {
128  return GetTopLeftItem( true );
129 }
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const

◆ HasReferencePoint()

bool SELECTION::HasReferencePoint ( ) const
inline

◆ HasType()

bool SELECTION::HasType ( KICAD_T  aType) const
inline

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 185 of file selection.h.

186  {
187  for( auto item : m_items )
188  {
189  if( item->Type() == aType )
190  return true;
191  }
192 
193  return false;
194  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by EDIT_TOOL::Remove(), and SELECTION_TOOL::selectConnection().

◆ IsHover()

◆ Items()

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

Definition at line 160 of file selection.h.

161  {
162  return m_items;
163  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

◆ operator=()

const SELECTION& SELECTION::operator= ( const SELECTION aOther)
inline

Definition at line 49 of file selection.h.

50  {
51  m_items = aOther.m_items;
52  m_isHover = aOther.m_isHover;
53  return *this;
54  }
bool m_isHover
Definition: selection.h:225
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_isHover, and m_items.

◆ operator[]()

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

Definition at line 147 of file selection.h.

148  {
149  if( aIdx < m_items.size() )
150  return m_items[ aIdx ];
151 
152  return nullptr;
153  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References 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(), PCB_TOOL_BASE::doInteractiveItemPlacement(), and PCB_EDITOR_CONTROL::PlaceTarget().

◆ Remove() [2/2]

virtual void SELECTION::Remove ( EDA_ITEM aItem)
inlinevirtual

Definition at line 85 of file selection.h.

86  {
87  ITER i = std::lower_bound( m_items.begin(), m_items.end(), aItem );
88 
89  if( !( i == m_items.end() || *i > aItem ) )
90  m_items.erase( i );
91  }
PTREE::iterator ITER
Definition: ptree.cpp:36
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223
size_t i
Definition: json11.cpp:597

References i, and m_items.

Referenced by PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawDimension(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), and GERBVIEW_SELECTION_TOOL::unselect().

◆ 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
inline

Returns the number of selected parts.

Definition at line 125 of file selection.h.

126  {
127  return m_items.size();
128  }
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References m_items.

Referenced by POINT_EDITOR::addCornerCondition(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::changeTrackWidthOnClick(), PAD_TOOL::copyPadSettings(), SELECTION_CONDITIONS::countFunc(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), EDIT_TOOL::Duplicate(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), GAL_ARRAY_CREATOR::getNumberOfItemsToArray(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), SELECTION_CONDITIONS::lessThanFunc(), EE_POINT_EDITOR::Main(), EDIT_TOOL::Main(), SELECTION_CONDITIONS::moreThanFunc(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), GERBVIEW_SELECTION_TOOL::select(), SELECTION_TOOL::select(), SELECTION_TOOL::selectCopper(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), LIB_MOVE_TOOL::updateModificationPoint(), SCH_MOVE_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ updateDrawList()

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

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 140 of file pcbnew/tools/selection.cpp.

141 {
142  std::vector<VIEW_ITEM*> items;
143 
144  for( auto item : m_items )
145  {
146  items.push_back( item );
147 
148  if( item->Type() == PCB_MODULE_T )
149  {
150  MODULE* module = static_cast<MODULE*>( item );
151  module->RunOnChildren( [&] ( BOARD_ITEM* bitem ) { items.push_back( bitem ); } );
152  }
153  }
154 
155  return items;
156 }
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class MODULE, a footprint
Definition: typeinfo.h:89
std::deque< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:223

References PCB_MODULE_T, and MODULE::RunOnChildren().

◆ ViewBBox()

const BOX2I SELECTION::ViewBBox ( ) const
overridevirtual

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

Returns
The current bounding box

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 132 of file pcbnew/tools/selection.cpp.

133 {
134  BOX2I r;
135  r.SetMaximum();
136  return r;
137 }
void SetMaximum()
Definition: box2.h:71

References BOX2< Vec >::SetMaximum().

Referenced by GERBVIEW_SELECTION_TOOL::zoomFitSelection(), and SELECTION_TOOL::zoomFitSelection().

◆ 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:712
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
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:308
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
size_t i
Definition: json11.cpp:597
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:427

References KIGFX::GAL::AdvanceDepth(), KIGFX::PAINTER::Draw(), KIGFX::VIEW::GetGAL(), KIGFX::VIEW::GetPainter(), i, 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 unsigned int 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 D_PAD, MODULE, VIA, GERBER_DRAW_ITEM, TRACK, TEXTE_MODULE, and EDGE_MODULE.

Definition at line 140 of file view_item.h.

141  {
142  // By default always show the item
143  return 0;
144  }

Referenced by KIGFX::VIEW::drawItem::operator()().

◆ viewPrivData()

Member Data Documentation

◆ m_groupItems

ITEMS KIGFX::VIEW_GROUP::m_groupItems
protectedinherited

◆ m_isHover

bool SELECTION::m_isHover
private

Definition at line 225 of file selection.h.

Referenced by IsHover(), operator=(), SELECTION(), and SetIsHover().

◆ m_items

std::deque<EDA_ITEM*> SELECTION::m_items
private

◆ 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
private

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