KiCad PCB EDA Suite
KIGFX::VIEW_GROUP Class Reference

#include <view_group.h>

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

Public Member Functions

 VIEW_GROUP (VIEW *aView=NULL)
 
virtual ~VIEW_GROUP ()
 
virtual unsigned int GetSize () const
 Function GetSize() Returns the number of stored items. More...
 
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 Clear ()
 Function Clear() Removes all the stored items from the group. More...
 
virtual VIEW_ITEMGetItem (unsigned int aIdx) const
 
virtual const BOX2I ViewBBox () const override
 Function ViewBBox() Returns the bounding box for all stored items covering all its layers. 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 of the item. More...
 
VIEW_ITEM_DATAviewPrivData () const
 

Protected Types

typedef std::vector< VIEW_ITEM * > ITEMS
 

Protected Member Functions

virtual const ITEMS updateDrawList () const
 

Protected Attributes

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 42 of file view_group.h.

Member Typedef Documentation

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

Definition at line 45 of file view_group.h.

Constructor & Destructor Documentation

VIEW_GROUP::VIEW_GROUP ( VIEW aView = NULL)

Definition at line 43 of file view_group.cpp.

43  :
45 {
46 }
int m_layer
Layer on which the group is drawn.
Definition: view_group.h:131
general purpose overlay
VIEW_GROUP::~VIEW_GROUP ( )
virtual

Definition at line 49 of file view_group.cpp.

50 {
51  // VIEW_ITEM destructor removes the object from its parent view
52 }

Member Function Documentation

void VIEW_GROUP::Add ( VIEW_ITEM aItem)
virtual

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 m_groupItems.

Referenced by PNS_PCBNEW_DEBUG_DECORATOR::AddLine(), PNS_KICAD_IFACE::DisplayItem(), PCB_TOOL::doInteractiveItemPlacement(), MODULE_EDITOR_TOOLS::PasteItems(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), 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
void VIEW_GROUP::Clear ( )
virtual

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

Reimplemented in SELECTION.

Definition at line 74 of file view_group.cpp.

References m_groupItems.

Referenced by FreeItems(), MODULE_EDITOR_TOOLS::PasteItems(), and MODULE_EDITOR_TOOLS::PlacePad().

75 {
76  m_groupItems.clear();
77 }
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135
void VIEW_GROUP::FreeItems ( )

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

Definition at line 141 of file view_group.cpp.

References Clear(), GetItem(), and 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
VIEW_ITEM * VIEW_GROUP::GetItem ( unsigned int  aIdx) const
virtual

Reimplemented in SELECTION.

Definition at line 86 of file view_group.cpp.

References m_groupItems.

Referenced by KIGFX::VIEW::draw(), and FreeItems().

87 {
88  return m_groupItems[idx];
89 }
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135
unsigned int VIEW_GROUP::GetSize ( ) const
virtual

Function GetSize() Returns the number of stored items.

Returns
Number of stored items.

Reimplemented in SELECTION.

Definition at line 80 of file view_group.cpp.

References m_groupItems.

Referenced by KIGFX::VIEW::draw(), and FreeItems().

81 {
82  return m_groupItems.size();
83 }
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135
void VIEW_GROUP::Remove ( VIEW_ITEM aItem)
virtual

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 m_groupItems.

Referenced by PCB_TOOL::doInteractiveItemPlacement(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), 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 KIGFX::VIEW_GROUP::SetLayer ( int  aLayer)
inlinevirtual

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 m_layer.

Referenced by 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
const VIEW_GROUP::ITEMS VIEW_GROUP::updateDrawList ( ) const
protectedvirtual

Reimplemented in SELECTION.

Definition at line 150 of file view_group.cpp.

References m_groupItems.

Referenced by ViewDraw().

151 {
152  return m_groupItems;
153 }
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135
const BOX2I VIEW_GROUP::ViewBBox ( ) const
overridevirtual

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

Returns
The current bounding box

Implements KIGFX::VIEW_ITEM.

Reimplemented in SELECTION.

Definition at line 92 of file view_group.cpp.

References BOX2< Vec >::SetMaximum().

93 {
94  BOX2I maxBox;
95 
96  maxBox.SetMaximum();
97  return maxBox;
98 }
void SetMaximum()
Definition: box2.h:61
void VIEW_GROUP::ViewDraw ( int  aLayer,
VIEW aView 
) const
overridevirtual

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(), 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:603
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:641
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
overridevirtual

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

Reimplemented in MODULE, D_PAD, VIA, TRACK, and TEXTE_MODULE.

Definition at line 133 of file view_item.h.

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

134  {
135  // By default always show the item
136  return 0;
137  }

Member Data Documentation

ITEMS KIGFX::VIEW_GROUP::m_groupItems
protected

Container for storing VIEW_ITEMs.

Definition at line 135 of file view_group.h.

Referenced by Add(), Clear(), GetItem(), GetSize(), Remove(), and updateDrawList().

int KIGFX::VIEW_GROUP::m_layer
protected

Layer on which the group is drawn.

Definition at line 131 of file view_group.h.

Referenced by SetLayer(), and ViewGetLayers().


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