KiCad PCB EDA Suite
GERBVIEW_SELECTION Class Reference

#include <gerbview_selection.h>

Inheritance diagram for GERBVIEW_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

VECTOR2I GetCenter () const override
 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...
 
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
 
VECTOR2I GetPosition () const
 Returns the top left point of the selection area bounding box. More...
 
EDA_RECT GetBoundingBox () const
 
virtual EDA_ITEMGetTopLeftItem (bool onlyModules=false) 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 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 30 of file gerbview_selection.h.

Member Typedef Documentation

◆ CITER

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

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
inherited

Definition at line 56 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 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
Definition: selection.h:255
size_t i
Definition: json11.cpp:649

References i, and SELECTION::m_items.

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

◆ begin() [1/2]

ITER SELECTION::begin ( )
inlineinherited

Definition at line 59 of file selection.h.

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

References SELECTION::m_items.

Referenced by SELECTION_TOOL::RequestSelection().

◆ begin() [2/2]

CITER SELECTION::begin ( ) const
inlineinherited

Definition at line 61 of file selection.h.

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

References SELECTION::m_items.

◆ Clear()

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

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
Definition: selection.h:255
size_t i
Definition: json11.cpp:649

References i, and SELECTION::m_items.

Referenced by SELECTION_TOOL::select().

◆ Empty()

bool SELECTION::Empty ( ) const
inlineinherited

Checks if there is anything selected.

Definition at line 119 of file selection.h.

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

References SELECTION::m_items.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), 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(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), SELECTION_CONDITIONS::NotEmpty(), PCB_SELECTION_CONDITIONS::OnlyConnectedItems(), SELECTION_CONDITIONS::onlyTypeFunc(), SELECTION_CONDITIONS::onlyTypesFunc(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), POSITION_RELATIVE_TOOL::PositionRelative(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), PCB_SELECTION_CONDITIONS::sameLayerFunc(), PCB_SELECTION_CONDITIONS::sameNetFunc(), CLIPBOARD_IO::SaveSelection(), EE_SELECTION_TOOL::SelectConnection(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), EE_INSPECTION_TOOL::ShowDatasheet(), 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 60 of file selection.h.

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

References SELECTION::m_items.

Referenced by SELECTION_TOOL::RequestSelection().

◆ end() [2/2]

CITER SELECTION::end ( ) const
inlineinherited

Definition at line 62 of file selection.h.

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

References SELECTION::m_items.

◆ FirstOfKind()

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

Definition at line 193 of file selection.h.

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

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
size_t i
Definition: json11.cpp:649

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
inlineinherited

Definition at line 182 of file selection.h.

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

References SELECTION::m_items.

Referenced by POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::CleanupSheetPins(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), PL_EDIT_TOOL::DoDelete(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDITOR_CONTROL::FindNext(), EDIT_TOOL::Flip(), SELECTION::GetBoundingBox(), 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(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::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(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and ViewBBox().

◆ GetBoundingBox()

EDA_RECT SELECTION::GetBoundingBox ( ) const
inlineinherited

Definition at line 154 of file selection.h.

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

References SELECTION::Front(), EDA_ITEM::GetBoundingBox(), i, 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()

VECTOR2I GERBVIEW_SELECTION::GetCenter ( ) const
overridevirtual

Returns the center point of the selection area bounding box.

Reimplemented from SELECTION.

Definition at line 26 of file gerbview_selection.cpp.

27 {
28  VECTOR2I centre;
29 
30  if( Size() == 1 )
31  {
32  centre = static_cast<GERBER_DRAW_ITEM*>( Front() )->GetPosition();
33  }
34  else
35  {
36  EDA_RECT bbox = Front()->GetBoundingBox();
37  auto i = m_items.begin();
38  ++i;
39 
40  for( ; i != m_items.end(); ++i )
41  bbox.Merge( (*i)->GetBoundingBox() );
42 
43  centre = bbox.Centre();
44  }
45 
46  return centre;
47 }
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Class VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
std::deque< EDA_ITEM * > m_items
Definition: selection.h:255
size_t i
Definition: json11.cpp:649
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
wxPoint Centre() const
Definition: eda_rect.h:62
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:182

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

◆ GetItem()

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

◆ GetItems()

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

◆ GetPosition()

VECTOR2I SELECTION::GetPosition ( ) const
inlineinherited

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

Definition at line 149 of file selection.h.

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

References SELECTION::GetBoundingBox().

◆ GetReferencePoint()

VECTOR2I SELECTION::GetReferencePoint ( ) const
inlineinherited

Definition at line 238 of file selection.h.

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

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()

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

Reimplemented in PCBNEW_SELECTION, EE_SELECTION, and PL_SELECTION.

Definition at line 169 of file selection.h.

170  {
171  return nullptr;
172  }

◆ HasReferencePoint()

bool SELECTION::HasReferencePoint ( ) const
inlineinherited

◆ HasType()

bool SELECTION::HasType ( KICAD_T  aType) const
inlineinherited

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

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

Definition at line 212 of file selection.h.

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

References SELECTION::m_items.

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

◆ IsHover()

◆ Items()

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

Definition at line 187 of file selection.h.

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

References SELECTION::m_items.

◆ operator[]()

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

Definition at line 174 of file selection.h.

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

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 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
Definition: selection.h:255
size_t i
Definition: json11.cpp:649

References i, and SELECTION::m_items.

Referenced by DRAWING_TOOL::DrawDimension(), PL_SELECTION_TOOL::unhighlight(), 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

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
Definition: selection.h:255

References SELECTION::m_items.

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

◆ updateDrawList()

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

Reimplemented from KIGFX::VIEW_GROUP.

Reimplemented in PCBNEW_SELECTION.

Definition at line 223 of file selection.h.

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

References SELECTION::m_items.

◆ ViewBBox()

const BOX2I GERBVIEW_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 SELECTION.

Definition at line 50 of file gerbview_selection.cpp.

51 {
52  EDA_RECT eda_bbox;
53 
54  if( Size() == 1 )
55  {
56  eda_bbox = Front()->GetBoundingBox();
57  }
58  else if( Size() > 1 )
59  {
60  eda_bbox = Front()->GetBoundingBox();
61  auto i = m_items.begin();
62  ++i;
63 
64  for( ; i != m_items.end(); ++i )
65  eda_bbox.Merge( (*i)->GetBoundingBox() );
66  }
67 
68  return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
69 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:520
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:255
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
size_t i
Definition: json11.cpp:649
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
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:182
const wxSize GetSize() const
Definition: eda_rect.h:103

References SELECTION::Front(), EDA_ITEM::GetBoundingBox(), EDA_RECT::GetOrigin(), EDA_RECT::GetSize(), i, SELECTION::m_items, EDA_RECT::Merge(), and SELECTION::Size().

◆ 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
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
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
size_t i
Definition: json11.cpp:649
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(), 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 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: