KiCad PCB EDA Suite
EE_SELECTION Class Reference

#include <ee_selection.h>

Inheritance diagram for EE_SELECTION:
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

EDA_ITEMGetTopLeftItem (bool onlyModules=false) const override
 
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...
 
virtual const VIEW_GROUP::ITEMS updateDrawList () const override
 
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 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

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 ee_selection.h.

Member Typedef Documentation

◆ CITER

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

Definition at line 58 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 57 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(), and PCB_EDITOR_CONTROL::PlaceTarget().

◆ Add() [2/2]

virtual void SELECTION::Add ( EDA_ITEM aItem)
inlinevirtualinherited

Definition at line 75 of file selection.h.

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

References SELECTION::m_items.

Referenced by PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), DRAWING_TOOL::PlaceImportedGraphics(), 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 259 of file selection.h.

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

References SELECTION::m_items.

Referenced by SCH_EDIT_TOOL::Properties().

◆ begin() [1/2]

ITER SELECTION::begin ( )
inlineinherited

Definition at line 60 of file selection.h.

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

References SELECTION::m_items.

Referenced by SELECTION_TOOL::RequestSelection().

◆ begin() [2/2]

CITER SELECTION::begin ( ) const
inlineinherited

Definition at line 62 of file selection.h.

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

References SELECTION::m_items.

◆ Clear()

virtual void SELECTION::Clear ( )
inlineoverridevirtualinherited

◆ ClearReferencePoint()

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 153 of file view_item.h.

154  {
156  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:161
#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 112 of file selection.h.

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

References SELECTION::m_items.

Referenced by SELECTION_TOOL::select().

◆ Empty()

bool SELECTION::Empty ( ) const
inlineinherited

Checks if there is anything selected.

Definition at line 120 of file selection.h.

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

References SELECTION::m_items.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), EDIT_TOOL::EditFpInFpEditor(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), SELECTION_CONDITIONS::NotEmpty(), PCB_SELECTION_CONDITIONS::OnlyConnectedItems(), SELECTION_CONDITIONS::onlyTypeFunc(), SELECTION_CONDITIONS::onlyTypesFunc(), LIB_EDIT_TOOL::Paste(), 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(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), EE_INSPECTION_TOOL::ShowDatasheet(), EE_INSPECTION_TOOL::ShowMarkerInfo(), GERBVIEW_SELECTION_TOOL::unselect(), SELECTION_TOOL::unselect(), and PCB_INSPECTION_TOOL::UpdateSelectionRatsnest().

◆ end() [1/2]

ITER SELECTION::end ( )
inlineinherited

Definition at line 61 of file selection.h.

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

References SELECTION::m_items.

Referenced by SELECTION_TOOL::RequestSelection().

◆ end() [2/2]

CITER SELECTION::end ( ) const
inlineinherited

Definition at line 63 of file selection.h.

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

References SELECTION::m_items.

◆ FirstOfKind()

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

Definition at line 194 of file selection.h.

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

References SELECTION::m_items.

Referenced by EDIT_TOOL::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 183 of file selection.h.

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

References SELECTION::m_items.

Referenced by POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::CleanupSheetPins(), SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), 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(), 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(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), DRAWING_TOOL::PlaceImportedGraphics(), 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(), EE_SELECTION_TOOL::SelectConnection(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), EE_INSPECTION_TOOL::ShowDatasheet(), EE_INSPECTION_TOOL::ShowMarkerInfo(), 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(), EDIT_TOOL::updateModificationPoint(), and GERBVIEW_SELECTION::ViewBBox().

◆ GetBoundingBox()

EDA_RECT SELECTION::GetBoundingBox ( ) const
inlineinherited

Definition at line 155 of file selection.h.

156  {
157  EDA_RECT bbox;
158 
159  if( Front() )
160  {
161  bbox = Front()->GetBoundingBox();
162 
163  for( auto i = m_items.begin() + 1; i != m_items.end(); ++i )
164  bbox.Merge( (*i)->GetBoundingBox() );
165  }
166 
167  return bbox;
168  }
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:270
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:183

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(), and EDIT_TOOL::MoveExact().

◆ GetCenter()

virtual VECTOR2I SELECTION::GetCenter ( ) const
inlinevirtualinherited

Returns the center point of the selection area bounding box.

Reimplemented in GERBVIEW_SELECTION.

Definition at line 137 of file selection.h.

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

References SELECTION::GetBoundingBox().

Referenced by EDIT_TOOL::Flip(), ARRAY_CREATOR::Invoke(), LIB_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
inlineoverridevirtualinherited

◆ GetItems()

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

Definition at line 131 of file selection.h.

132  {
133  return m_items;
134  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:270

References SELECTION::m_items.

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

◆ GetPosition()

VECTOR2I SELECTION::GetPosition ( ) const
inlineinherited

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

Definition at line 150 of file selection.h.

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

References SELECTION::GetBoundingBox().

◆ GetReferencePoint()

VECTOR2I SELECTION::GetReferencePoint ( ) const
inlineinherited

Definition at line 239 of file selection.h.

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

References SELECTION::m_referencePoint.

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

◆ GetSize()

◆ GetTopLeftItem()

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

Reimplemented from SELECTION.

Definition at line 31 of file ee_selection.cpp.

32 {
33  EDA_ITEM* topLeftItem = nullptr;
34  wxPoint topLeftPos;
35  wxPoint pos;
36 
37  // find the leftmost (smallest x coord) and highest (smallest y with the smallest x) item in the selection
38  for( auto item : m_items )
39  {
40  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
41  LIB_ITEM* lib_item = dynamic_cast<LIB_ITEM*>( item );
42 
43  if( sch_item )
44  pos = sch_item->GetPosition();
45  else if( lib_item )
46  pos = lib_item->GetPosition();
47 
48  if( ( topLeftItem == nullptr )
49  || ( pos.x < topLeftPos.x )
50  || ( topLeftPos.x == pos.x && pos.y < topLeftPos.y ) )
51  {
52  topLeftItem = item;
53  topLeftPos = pos;
54  }
55  }
56 
57  return static_cast<EDA_ITEM*>( topLeftItem );
58 }
virtual wxPoint GetPosition() const =0
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
virtual wxPoint GetPosition() const =0
Function GetPosition.
std::deque< EDA_ITEM * > m_items
Definition: selection.h:270
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136

References LIB_ITEM::GetPosition(), SCH_ITEM::GetPosition(), SELECTION::m_items, wxPoint::x, and wxPoint::y.

Referenced by SCH_EDITOR_CONTROL::Paste(), and EE_SELECTION_TOOL::updateReferencePoint().

◆ HasReferencePoint()

bool SELECTION::HasReferencePoint ( ) const
inlineinherited

Definition at line 234 of file selection.h.

235  {
236  return m_referencePoint != NULLOPT;
237  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:269
const auto NULLOPT
Definition: optional.h:9

References SELECTION::m_referencePoint, and NULLOPT.

Referenced by EDIT_TOOL::Move(), CLIPBOARD_IO::SaveSelection(), LIB_MOVE_TOOL::updateModificationPoint(), and EDIT_TOOL::updateModificationPoint().

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

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

References SELECTION::m_items.

Referenced by EDIT_TOOL::Remove().

◆ IsHover()

◆ Items()

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

Definition at line 188 of file selection.h.

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

References SELECTION::m_items.

Referenced by SCH_EDIT_TOOL::Properties().

◆ operator[]()

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

Definition at line 175 of file selection.h.

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

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

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

References SELECTION::m_items.

Referenced by 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
inlineinherited

◆ updateDrawList()

virtual const VIEW_GROUP::ITEMS SELECTION::updateDrawList ( ) const
inlineoverridevirtualinherited

Reimplemented from KIGFX::VIEW_GROUP.

Reimplemented in PCBNEW_SELECTION.

Definition at line 224 of file selection.h.

225  {
226  std::vector<VIEW_ITEM*> items;
227 
228  for( auto item : m_items )
229  items.push_back( item );
230 
231  return items;
232  }
std::deque< EDA_ITEM * > m_items
Definition: selection.h:270

References SELECTION::m_items.

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

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

References BOX2< Vec >::SetMaximum().

Referenced by 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:701
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:678
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:313
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:416

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 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 MODULE_ZONE_CONTAINER, D_PAD, MODULE, VIA, GERBER_DRAW_ITEM, TEXTE_MODULE, TRACK, 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()(), 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: