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::set< EDA_ITEM * >::iterator
 
using CITER = std::set< 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 idx) 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::set< 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 int index) const
 
EDA_ITEMFront () const
 
std::set< 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
 

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::set< 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

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

Definition at line 57 of file selection.h.

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

Definition at line 45 of file view_group.h.

using SELECTION::ITER = std::set<EDA_ITEM*>::iterator

Definition at line 56 of file selection.h.

Constructor & Destructor Documentation

SELECTION::SELECTION ( )
inline

Definition at line 38 of file selection.h.

References m_isHover.

39  {
40  m_isHover = false;
41  }
bool m_isHover
Definition: selection.h:220
SELECTION::SELECTION ( const SELECTION aOther)
inline

Definition at line 43 of file selection.h.

References m_isHover, and m_items.

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

Member Function Documentation

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.

References KIGFX::VIEW_GROUP::m_groupItems.

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

56 {
57  m_groupItems.push_back( aItem );
58 }
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135
virtual void SELECTION::Add ( EDA_ITEM aItem)
inlinevirtual
ITER SELECTION::begin ( )
inline

Definition at line 59 of file selection.h.

References m_items.

59 { return m_items.begin(); }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
CITER SELECTION::begin ( ) const
inline

Definition at line 61 of file selection.h.

References m_items.

61 { return m_items.cbegin(); }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
virtual void SELECTION::Clear ( )
inlineoverridevirtual

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

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 84 of file selection.h.

References m_items.

Referenced by PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::PlaceDXF(), GERBVIEW_SELECTION_TOOL::Reset(), and SELECTION_TOOL::Reset().

85  {
86  m_items.clear();
87  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
void SELECTION::ClearReferencePoint ( )
inline

Definition at line 208 of file selection.h.

References m_referencePoint, and NULLOPT.

Referenced by EDIT_TOOL::Main(), SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::selectMultiple(), and SELECTION_TOOL::selectPoint().

209  {
211  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:215
const auto NULLOPT
Definition: optional.h:9
bool SELECTION::Contains ( EDA_ITEM aItem) const
inline

Definition at line 103 of file selection.h.

References m_items.

Referenced by SELECTION_TOOL::select().

104  {
105  return m_items.find( aItem ) != m_items.end();
106  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
bool SELECTION::Empty ( ) const
inline

Checks if there is anything selected.

Definition at line 109 of file selection.h.

References m_items.

Referenced by GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), GERBVIEW_SELECTION_TOOL::CursorSelection(), SELECTION_TOOL::CursorSelection(), deleteItem(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::Flip(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SELECTION_CONDITIONS::NotEmpty(), PCB_SELECTION_CONDITIONS::OnlyConnectedItems(), SELECTION_CONDITIONS::onlyTypeFunc(), SELECTION_CONDITIONS::onlyTypesFunc(), SELECTION_CONDITIONS::onlyTypesFuncArr(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), PCB_SELECTION_CONDITIONS::sameLayerFunc(), PCB_SELECTION_CONDITIONS::sameNetFunc(), CLIPBOARD_IO::SaveSelection(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), selectPRitem(), showLocalRatsnest(), GERBVIEW_SELECTION_TOOL::unselect(), and SELECTION_TOOL::unselect().

110  {
111  return ( m_items.size() == 0 );
112  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
ITER SELECTION::end ( )
inline

Definition at line 60 of file selection.h.

References m_items.

60 { return m_items.end(); }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
CITER SELECTION::end ( ) const
inline

Definition at line 62 of file selection.h.

References m_items.

62 { return m_items.cend(); }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
template<class T >
T* SELECTION::FirstOfKind ( ) const
inline

Definition at line 161 of file selection.h.

References m_items.

Referenced by EDIT_TOOL::editFootprintInFpEditor(), and EDIT_TOOL::ExchangeFootprints().

162  {
163  auto refType = T( nullptr ).Type();
164 
165  for( auto item : m_items )
166  {
167  if( item->Type() == refType )
168  return static_cast<T*> ( item );
169  }
170 
171  return nullptr;
172  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
void VIEW_GROUP::FreeItems ( )
inherited

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

Definition at line 167 of file view_group.cpp.

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

Referenced by DRAWING_TOOL::PlaceDXF(), and KIGFX::VIEW_GROUP::SetLayer().

168 {
169  for( unsigned int i = 0 ; i < GetSize(); i++ )
170  delete GetItem( i );
171 
172  Clear();
173 }
virtual VIEW_ITEM * GetItem(unsigned int aIdx) const
Definition: view_group.cpp:86
virtual void Clear()
Function Clear() Removes all the stored items from the group.
Definition: view_group.cpp:74
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
EDA_RECT SELECTION::GetBoundingBox ( ) const

Definition at line 73 of file selection.cpp.

References i, and EDA_RECT::Merge().

Referenced by GetItems().

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 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect...
EDA_ITEM * Front() const
Definition: selection.h:147
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
VECTOR2I SELECTION::GetCenter ( ) const

Returns the center point of the selection area bounding box.

Definition at line 67 of file selection.cpp.

Referenced by getAnchorPoint(), GetItems(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), and POSITION_RELATIVE_TOOL::RelativeItemSelectionMove().

68 {
69  return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
70 }
EDA_RECT GetBoundingBox() const
Definition: selection.cpp:73
wxPoint Centre() const
Definition: eda_rect.h:60
virtual KIGFX::VIEW_ITEM* SELECTION::GetItem ( unsigned int  idx) const
inlineoverridevirtual

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 94 of file selection.h.

References m_items.

95  {
96  auto iter = m_items.begin();
97 
98  std::advance( iter, idx );
99 
100  return *iter;
101  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
const std::set<EDA_ITEM*> SELECTION::GetItems ( ) const
inline
VECTOR2I SELECTION::GetPosition ( ) const

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

Definition at line 61 of file selection.cpp.

Referenced by GetItems().

62 {
63  return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
64 }
EDA_RECT GetBoundingBox() const
Definition: selection.cpp:73
const wxPoint GetPosition() const
Definition: eda_rect.h:113
VECTOR2I SELECTION::GetReferencePoint ( ) const
inline

Definition at line 198 of file selection.h.

References m_referencePoint.

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

199  {
200  return *m_referencePoint;
201  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:215
virtual unsigned int SELECTION::GetSize ( ) const
inlineoverridevirtual

Function GetSize() Returns the number of stored items.

Returns
Number of stored items.

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 89 of file selection.h.

References m_items.

Referenced by getAnchorPoint(), GERBVIEW_SELECTION_TOOL::RequestSelection(), and SELECTION_TOOL::RequestSelection().

90  {
91  return m_items.size();
92  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
EDA_ITEM * SELECTION::GetTopLeftItem ( bool  onlyModules = false) const

Definition at line 90 of file selection.cpp.

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

Referenced by getAnchorPoint(), and GetItems().

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 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
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
virtual const wxPoint GetPosition() const =0
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
EDA_ITEM * SELECTION::GetTopLeftModule ( ) const

Definition at line 126 of file selection.cpp.

Referenced by getAnchorPoint(), and GetItems().

127 {
128  return GetTopLeftItem( true );
129 }
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const
Definition: selection.cpp:90
bool SELECTION::HasReferencePoint ( ) const
inline

Definition at line 193 of file selection.h.

References m_referencePoint, and NULLOPT.

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

194  {
195  return m_referencePoint != NULLOPT;
196  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:215
const auto NULLOPT
Definition: optional.h:9
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 180 of file selection.h.

References m_items, and updateDrawList().

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

181  {
182  for( auto item : m_items )
183  {
184  if( item->Type() == aType )
185  return true;
186  }
187 
188  return false;
189  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
bool SELECTION::IsHover ( ) const
inline

Definition at line 69 of file selection.h.

References m_isHover.

Referenced by EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::Main(), and EDIT_TOOL::Remove().

70  {
71  return m_isHover;
72  }
bool m_isHover
Definition: selection.h:220
std::set<EDA_ITEM*>& SELECTION::Items ( )
inline

Definition at line 155 of file selection.h.

References m_items.

156  {
157  return m_items;
158  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
const SELECTION& SELECTION::operator= ( const SELECTION aOther)
inline

Definition at line 49 of file selection.h.

References m_isHover, and m_items.

50  {
51  m_items = aOther.m_items;
52  m_isHover = aOther.m_isHover;
53  return *this;
54  }
bool m_isHover
Definition: selection.h:220
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
EDA_ITEM* SELECTION::operator[] ( const int  index) const
inline

Definition at line 137 of file selection.h.

References m_items.

138  {
139  if( index < 0 || (unsigned int) index >= m_items.size() )
140  return nullptr;
141 
142  auto iter = m_items.begin();
143  std::advance( iter, index );
144  return *iter;
145  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
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.

References KIGFX::VIEW_GROUP::m_groupItems.

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

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
virtual void SELECTION::Remove ( EDA_ITEM aItem)
inlinevirtual
void SELECTION::SetIsHover ( bool  aIsHover)
inline
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.

References KIGFX::VIEW_GROUP::FreeItems(), KIGFX::VIEW_GROUP::m_layer, and KIGFX::VIEW_GROUP::updateDrawList().

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

116  {
117  m_layer = aLayer;
118  }
int m_layer
Layer on which the group is drawn.
Definition: view_group.h:131
void SELECTION::SetReferencePoint ( const VECTOR2I aP)
inline

Definition at line 203 of file selection.h.

References m_referencePoint.

Referenced by EDIT_TOOL::copyToClipboard(), SELECTION_TOOL::findMove(), EDIT_TOOL::Main(), and EDIT_TOOL::updateModificationPoint().

204  {
205  m_referencePoint = aP;
206  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:215
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList ( ) const
overridevirtual

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 140 of file selection.cpp.

References PCB_MODULE_T, and MODULE::RunOnChildren().

Referenced by HasType(), and GERBVIEW_SELECTION_TOOL::MeasureTool().

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::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:218
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 selection.cpp.

References BOX2< Vec >::SetMaximum().

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

133 {
134  BOX2I r;
135  r.SetMaximum();
136  return r;
137 }
void SetMaximum()
Definition: box2.h:61
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 101 of file view_group.cpp.

References KIGFX::PAINTER::Draw(), KIGFX::VIEW::GetGAL(), KIGFX::VIEW::GetPainter(), i, KIGFX::VIEW::IsLayerVisible(), KIGFX::VIEW::SortLayers(), KIGFX::VIEW_GROUP::updateDrawList(), and KIGFX::VIEW::VIEW_MAX_LAYERS.

102 {
103  auto gal = aView->GetGAL();
104  PAINTER* painter = aView->GetPainter();
105 
106  const auto drawList = updateDrawList();
107 
108  std::unordered_map<int, std::vector<VIEW_ITEM*>> layer_item_map;
109 
110  // Build a list of layers used by the items in the group
111  for( auto item : drawList )
112  {
113  int item_layers[VIEW::VIEW_MAX_LAYERS], item_layers_count;
114  item->ViewGetLayers( item_layers, item_layers_count );
115 
116  for( int i = 0; i < item_layers_count; i++ )
117  {
118  if( layer_item_map.count( item_layers[i] ) == 0 )
119  {
120  layer_item_map.emplace( std::make_pair( item_layers[i],
121  std::vector<VIEW_ITEM*>() ) );
122  }
123 
124  layer_item_map[ item_layers[i] ].push_back( item );
125  }
126  }
127 
128  int layers[VIEW::VIEW_MAX_LAYERS], layers_count = 0;
129 
130  for( const auto& entry : layer_item_map )
131  {
132  layers[ layers_count++ ] = entry.first;
133  }
134 
135  aView->SortLayers( layers, layers_count );
136 
137  // Now draw the layers in sorted order
138 
139  gal->PushDepth();
140 
141  for( int i = 0; i < layers_count; i++ )
142  {
143  if( aView->IsLayerVisible( layers[i] ) )
144  {
145  gal->AdvanceDepth();
146 
147  for( auto item : layer_item_map[ layers[i] ] )
148  {
149  if( !painter->Draw( item, layers[i] ) )
150  item->ViewDraw( layers[i], aView ); // Alternative drawing method
151  }
152  }
153  }
154 
155  gal->PopDepth();
156 }
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:404
virtual const ITEMS updateDrawList() const
Definition: view_group.cpp:176
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:626
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:278
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:675
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
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...
size_t i
Definition: json11.cpp:597
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 159 of file view_group.cpp.

References KIGFX::VIEW_GROUP::m_layer.

160 {
161  // Everything is displayed on a single layer
162  aLayers[0] = m_layer;
163  aCount = 1;
164 }
int m_layer
Layer on which the group is drawn.
Definition: view_group.h:131
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.

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

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

Member Data Documentation

ITEMS KIGFX::VIEW_GROUP::m_groupItems
protectedinherited
bool SELECTION::m_isHover
private

Definition at line 220 of file selection.h.

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

std::set<EDA_ITEM*> SELECTION::m_items
private
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(), and KIGFX::VIEW_GROUP::ViewGetLayers().

OPT<VECTOR2I> SELECTION::m_referencePoint
private

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