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

Constructor & Destructor Documentation

SELECTION::SELECTION ( )
inline

Definition at line 38 of file selection.h.

38 {};
SELECTION::SELECTION ( const SELECTION aOther)
inline

Definition at line 40 of file selection.h.

References m_isHover, and m_items.

41  {
42  m_items = aOther.m_items;
43  m_isHover = aOther.m_isHover;
44  }
bool m_isHover
Definition: selection.h:200
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198

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 PNS_PCBNEW_DEBUG_DECORATOR::AddLine(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), PNS_KICAD_IFACE::DisplayItem(), 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 56 of file selection.h.

References m_items.

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

Definition at line 58 of file selection.h.

References m_items.

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

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

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 81 of file selection.h.

References m_items.

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

82  {
83  m_items.clear();
84  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
void SELECTION::ClearReferencePoint ( )
inline

Definition at line 188 of file selection.h.

References m_referencePoint, and NULLOPT.

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

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

Definition at line 100 of file selection.h.

References m_items.

Referenced by SELECTION_TOOL::select().

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

Checks if there is anything selected.

Definition at line 106 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(), 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().

107  {
108  return ( m_items.size() == 0 );
109  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
ITER SELECTION::end ( )
inline

Definition at line 57 of file selection.h.

References m_items.

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

Definition at line 59 of file selection.h.

References m_items.

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

Definition at line 158 of file selection.h.

References m_items.

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

159  {
160  auto refType = T( nullptr ).Type();
161 
162  for( auto item : m_items )
163  {
164  if( item->Type() == refType )
165  return static_cast<T*> ( item );
166  }
167 
168  return nullptr;
169  }
T
enum T contains all this lexer's tokens.
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
void VIEW_GROUP::FreeItems ( )
inherited

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

Definition at line 141 of file view_group.cpp.

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(), DRAWING_TOOL::PlaceDXF(), PNS_KICAD_IFACE::SetView(), and PNS_KICAD_IFACE::~PNS_KICAD_IFACE().

142 {
143  for( unsigned int i = 0 ; i < GetSize(); i++ )
144  delete GetItem( i );
145 
146  Clear();
147 }
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
EDA_RECT SELECTION::GetBoundingBox ( ) const

Definition at line 73 of file selection.cpp.

References EDA_RECT::Merge().

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), and ALIGN_DISTRIBUTE_TOOL::doAlignRight().

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:144
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
Class EDA_RECT handles the component boundary box.
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(), GAL_ARRAY_CREATOR::getRotationCentre(), 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
virtual KIGFX::VIEW_ITEM* SELECTION::GetItem ( unsigned int  idx) const
inlineoverridevirtual

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 91 of file selection.h.

References m_items.

92  {
93  auto iter = m_items.begin();
94 
95  std::advance( iter, idx );
96 
97  return *iter;
98  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
const std::set<EDA_ITEM*> SELECTION::GetItems ( ) const
inline

Definition at line 117 of file selection.h.

References m_items.

Referenced by SELECTION_TOOL::filterSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), and SELECTION_TOOL::selectNet().

118  {
119  return m_items;
120  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
VECTOR2I SELECTION::GetPosition ( ) const

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

Definition at line 61 of file selection.cpp.

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

Definition at line 178 of file selection.h.

References m_referencePoint.

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

179  {
180  return *m_referencePoint;
181  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:195
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 86 of file selection.h.

References m_items.

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

87  {
88  return m_items.size();
89  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
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().

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:225
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:198
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
EDA_ITEM * SELECTION::GetTopLeftModule ( ) const

Definition at line 126 of file selection.cpp.

Referenced by getAnchorPoint().

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

References m_referencePoint, and NULLOPT.

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

174  {
175  return m_referencePoint != NULLOPT;
176  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:195
const auto NULLOPT
Definition: optional.h:9
bool SELECTION::IsHover ( ) const
inline

Definition at line 66 of file selection.h.

References m_isHover.

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

67  {
68  return m_isHover;
69  }
bool m_isHover
Definition: selection.h:200
std::set<EDA_ITEM*>& SELECTION::Items ( )
inline

Definition at line 152 of file selection.h.

References m_items.

153  {
154  return m_items;
155  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
const SELECTION& SELECTION::operator= ( const SELECTION aOther)
inline

Definition at line 46 of file selection.h.

References m_isHover, and m_items.

47  {
48  m_items = aOther.m_items;
49  m_isHover = aOther.m_isHover;
50  return *this;
51  }
bool m_isHover
Definition: selection.h:200
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
EDA_ITEM* SELECTION::operator[] ( const int  index) const
inline

Definition at line 134 of file selection.h.

References m_items.

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

Definition at line 76 of file selection.h.

References m_items.

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

77  {
78  m_items.erase( aItem );
79  }
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
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::m_layer.

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

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

References m_referencePoint.

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

184  {
185  m_referencePoint = aP;
186  }
OPT< VECTOR2I > m_referencePoint
Definition: selection.h:195
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList ( ) const
overridevirtual

Reimplemented from KIGFX::VIEW_GROUP.

Definition at line 159 of file selection.cpp.

References PCB_MODULE_T, and MODULE::RunOnChildren().

160 {
161  std::vector<VIEW_ITEM*> items;
162 
163  for( auto item : m_items )
164  {
165  items.push_back( item );
166 
167  if( item->Type() == PCB_MODULE_T )
168  {
169  MODULE* module = static_cast<MODULE*>( item );
170  module->RunOnChildren( [&] ( BOARD_ITEM* bitem ) { items.push_back( bitem ); } );
171  }
172  }
173 
174  return items;
175 }
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:198
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 EDA_RECT::GetOrigin(), EDA_RECT::GetSize(), EDA_RECT::Merge(), and BOX2< Vec >::SetMaximum().

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

133 {
134  BOX2I r;
135  r.SetMaximum();
136  return r;
137  EDA_RECT eda_bbox;
138 
139  if( Size() == 1 )
140  {
141  eda_bbox = Front()->GetBoundingBox();
142  }
143  else if( Size() > 1 )
144  {
145  eda_bbox = Front()->GetBoundingBox();
146  auto i = m_items.begin();
147  ++i;
148 
149  for( ; i != m_items.end(); ++i )
150  {
151  eda_bbox.Merge( (*i)->GetBoundingBox() );
152  }
153  }
154 
155  return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
156 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
BOX2< VECTOR2I > BOX2I
Definition: box2.h:468
const wxPoint GetOrigin() const
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect...
const wxSize GetSize() const
EDA_ITEM * Front() const
Definition: selection.h:144
void SetMaximum()
Definition: box2.h:61
std::set< EDA_ITEM * > m_items
Set of selected items.
Definition: selection.h:198
Class EDA_RECT handles the component boundary box.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
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(), 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  // Draw all items immediately (without caching)
109  for( auto item : drawList )
110  {
111  gal->PushDepth();
112 
113  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
114  item->ViewGetLayers( layers, layers_count );
115  aView->SortLayers( layers, layers_count );
116 
117  for( int i = 0; i < layers_count; i++ )
118  {
119  if( aView->IsLayerVisible( layers[i] ) )
120  {
121  gal->AdvanceDepth();
122 
123  if( !painter->Draw( item, layers[i] ) )
124  item->ViewDraw( layers[i], aView ); // Alternative drawing method
125  }
126  }
127 
128  gal->PopDepth();
129  }
130 }
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:150
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:604
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:652
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...
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 133 of file view_group.cpp.

References KIGFX::VIEW_GROUP::m_layer.

134 {
135  // Everything is displayed on a single layer
136  aLayers[0] = m_layer;
137  aCount = 1;
138 }
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, and TEXTE_MODULE.

Definition at line 139 of file view_item.h.

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

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

Member Data Documentation

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

Definition at line 200 of file selection.h.

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

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

Set of selected items.

Definition at line 198 of file selection.h.

Referenced by Add(), begin(), Clear(), Contains(), Empty(), end(), FirstOfKind(), Front(), GetItem(), GetItems(), GetSize(), Items(), operator=(), operator[](), Remove(), SELECTION(), and Size().

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: