KiCad PCB EDA Suite
KIGFX::VIEW_ITEM_DATA Class Reference

Public Member Functions

 VIEW_ITEM_DATA ()
 
 ~VIEW_ITEM_DATA ()
 
int getFlags () const
 

Private Types

typedef std::pair< int, int > GroupPair
 Indexes of cached GAL display lists corresponding to the item (for every layer it. More...
 

Private Member Functions

void getLayers (int *aLayers, int &aCount) const
 Return layer numbers used by the item. More...
 
int getGroup (int aLayer) const
 Return number of the group id for the given layer, or -1 in case it was not cached before. More...
 
void setGroup (int aLayer, int aGroup)
 Set a group id for the item and the layer combination. More...
 
void deleteGroups ()
 Remove all of the stored group ids. More...
 
bool storesGroups () const
 Return information if the item uses at least one group id (ie. More...
 
void reorderGroups (std::unordered_map< int, int > aReorderMap)
 Reorder the stored groups (to facilitate reordering of layers). More...
 
void saveLayers (int *aLayers, int aCount)
 Save layers used by the item. More...
 
int requiredUpdate () const
 Return current update flag for an item. More...
 
void clearUpdateFlags ()
 Mark an item as already updated, so it is not going to be redrawn. More...
 
bool isRenderable () const
 Return if the item should be drawn or not. More...
 

Private Attributes

VIEWm_view
 Current dynamic view the item is assigned to. More...
 
int m_flags
 Visibility flags. More...
 
int m_requiredUpdate
 Flag required for updating. More...
 
int m_drawPriority
 Order to draw this item in a layer, lowest first. More...
 
GroupPairm_groups
 
int m_groupsSize
 
std::vector< int > m_layers
 Stores layer numbers used by the item. More...
 

Friends

class VIEW
 

Detailed Description

Definition at line 51 of file view.cpp.

Member Typedef Documentation

◆ GroupPair

typedef std::pair<int, int> KIGFX::VIEW_ITEM_DATA::GroupPair
private

Indexes of cached GAL display lists corresponding to the item (for every layer it.

occupies)(in the std::pair "first" stores layer number, "second" stores group id).

Definition at line 97 of file view.cpp.

Constructor & Destructor Documentation

◆ VIEW_ITEM_DATA()

KIGFX::VIEW_ITEM_DATA::VIEW_ITEM_DATA ( )
inline

Definition at line 54 of file view.cpp.

54  :
55  m_view( nullptr ),
58  m_drawPriority( 0 ),
59  m_groups( nullptr ),
60  m_groupsSize( 0 ) {}
VIEW * m_view
Current dynamic view the item is assigned to.
Definition: view.cpp:91
int m_drawPriority
Order to draw this item in a layer, lowest first.
Definition: view.cpp:94
GroupPair * m_groups
Definition: view.cpp:101
Item is visible (in general)
Definition: view_item.h:65
No updates are required.
Definition: view_item.h:51
int m_flags
Visibility flags.
Definition: view.cpp:92
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:93

◆ ~VIEW_ITEM_DATA()

KIGFX::VIEW_ITEM_DATA::~VIEW_ITEM_DATA ( )
inline

Definition at line 62 of file view.cpp.

63  {
64  deleteGroups();
65  }
void deleteGroups()
Remove all of the stored group ids.
Definition: view.cpp:156

References deleteGroups().

Member Function Documentation

◆ clearUpdateFlags()

void KIGFX::VIEW_ITEM_DATA::clearUpdateFlags ( )
inlineprivate

Mark an item as already updated, so it is not going to be redrawn.

Definition at line 233 of file view.cpp.

234  {
236  }
No updates are required.
Definition: view_item.h:51
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:93

References m_requiredUpdate, and KIGFX::NONE.

Referenced by KIGFX::VIEW::invalidateItem().

◆ deleteGroups()

void KIGFX::VIEW_ITEM_DATA::deleteGroups ( )
inlineprivate

Remove all of the stored group ids.

Forces recaching of the item.

Definition at line 156 of file view.cpp.

157  {
158  delete[] m_groups;
159  m_groups = nullptr;
160  m_groupsSize = 0;
161  }
GroupPair * m_groups
Definition: view.cpp:101

References m_groups, and m_groupsSize.

Referenced by KIGFX::VIEW::CLEAR_LAYER_CACHE_VISITOR::operator()(), and ~VIEW_ITEM_DATA().

◆ getFlags()

int KIGFX::VIEW_ITEM_DATA::getFlags ( ) const
inline

Definition at line 67 of file view.cpp.

68  {
69  return m_flags;
70  }
int m_flags
Visibility flags.
Definition: view.cpp:92

References m_flags.

Referenced by KIGFX::QUERY_VISITOR< CONTAINER >::operator()().

◆ getGroup()

int KIGFX::VIEW_ITEM_DATA::getGroup ( int  aLayer) const
inlineprivate

Return number of the group id for the given layer, or -1 in case it was not cached before.

Parameters
aLayeris the layer number for which group id is queried.
Returns
group id or -1 in case there is no group id (ie. item is not cached).

Definition at line 110 of file view.cpp.

111  {
112  for( int i = 0; i < m_groupsSize; ++i )
113  {
114  if( m_groups[i].first == aLayer )
115  return m_groups[i].second;
116  }
117 
118  return -1;
119  }
GroupPair * m_groups
Definition: view.cpp:101

References m_groups, and m_groupsSize.

Referenced by KIGFX::VIEW::draw(), KIGFX::VIEW::UPDATE_COLOR_VISITOR::operator()(), KIGFX::VIEW::UPDATE_DEPTH_VISITOR::operator()(), KIGFX::VIEW::RECACHE_ITEM_VISITOR::operator()(), KIGFX::VIEW::UpdateAllLayersColor(), KIGFX::VIEW::UpdateAllLayersOrder(), KIGFX::VIEW::updateItemColor(), KIGFX::VIEW::updateItemGeometry(), and KIGFX::VIEW::updateLayers().

◆ getLayers()

void KIGFX::VIEW_ITEM_DATA::getLayers ( int *  aLayers,
int &  aCount 
) const
inlineprivate

Return layer numbers used by the item.

Parameters
aLayers[]output layer index array
aCountnumber of layer indices in aLayers[]

Definition at line 81 of file view.cpp.

82  {
83  int* layersPtr = aLayers;
84 
85  for( int layer : m_layers )
86  *layersPtr++ = layer;
87 
88  aCount = m_layers.size();
89  }
std::vector< int > m_layers
Stores layer numbers used by the item.
Definition: view.cpp:201

References m_layers.

Referenced by KIGFX::VIEW::UpdateAllLayersColor(), KIGFX::VIEW::UpdateAllLayersOrder(), and KIGFX::VIEW::updateLayers().

◆ isRenderable()

bool KIGFX::VIEW_ITEM_DATA::isRenderable ( ) const
inlineprivate

Return if the item should be drawn or not.

Definition at line 241 of file view.cpp.

242  {
243  return m_flags == VISIBLE;
244  }
Item is visible (in general)
Definition: view_item.h:65
int m_flags
Visibility flags.
Definition: view.cpp:92

References m_flags, and KIGFX::VISIBLE.

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

◆ reorderGroups()

void KIGFX::VIEW_ITEM_DATA::reorderGroups ( std::unordered_map< int, int >  aReorderMap)
inlineprivate

Reorder the stored groups (to facilitate reordering of layers).

See also
VIEW::ReorderLayerData
Parameters
aReorderMapis the mapping of old to new layer ids

Definition at line 182 of file view.cpp.

183  {
184  for( int i = 0; i < m_groupsSize; ++i )
185  {
186  int orig_layer = m_groups[i].first;
187  int new_layer = orig_layer;
188 
189  try
190  {
191  new_layer = aReorderMap.at( orig_layer );
192  }
193  catch( const std::out_of_range& ) {}
194 
195  m_groups[i].first = new_layer;
196  }
197  }
GroupPair * m_groups
Definition: view.cpp:101

References m_groups, and m_groupsSize.

Referenced by KIGFX::VIEW::ReorderLayerData().

◆ requiredUpdate()

int KIGFX::VIEW_ITEM_DATA::requiredUpdate ( ) const
inlineprivate

Return current update flag for an item.

Definition at line 225 of file view.cpp.

226  {
227  return m_requiredUpdate;
228  }
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:93

References m_requiredUpdate.

◆ saveLayers()

void KIGFX::VIEW_ITEM_DATA::saveLayers ( int *  aLayers,
int  aCount 
)
inlineprivate

Save layers used by the item.

Parameters
aLayersis an array containing layer numbers to be saved.
aCountis the size of the array.

Definition at line 209 of file view.cpp.

210  {
211  m_layers.clear();
212 
213  for( int i = 0; i < aCount; ++i )
214  {
215  // this fires on some eagle board after EAGLE_PLUGIN::Load()
216  wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
217 
218  m_layers.push_back( aLayers[i] );
219  }
220  }
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:700
std::vector< int > m_layers
Stores layer numbers used by the item.
Definition: view.cpp:201

References m_layers, and KIGFX::VIEW::VIEW_MAX_LAYERS.

Referenced by KIGFX::VIEW::Add(), KIGFX::VIEW::ReorderLayerData(), and KIGFX::VIEW::updateLayers().

◆ setGroup()

void KIGFX::VIEW_ITEM_DATA::setGroup ( int  aLayer,
int  aGroup 
)
inlineprivate

Set a group id for the item and the layer combination.

Parameters
aLayeris the layer number.
aGroupis the group id.

Definition at line 127 of file view.cpp.

128  {
129  // Look if there is already an entry for the layer
130  for( int i = 0; i < m_groupsSize; ++i )
131  {
132  if( m_groups[i].first == aLayer )
133  {
134  m_groups[i].second = aGroup;
135  return;
136  }
137  }
138 
139  // If there was no entry for the given layer - create one
140  GroupPair* newGroups = new GroupPair[m_groupsSize + 1];
141 
142  if( m_groupsSize > 0 )
143  {
144  std::copy( m_groups, m_groups + m_groupsSize, newGroups );
145  delete[] m_groups;
146  }
147 
148  m_groups = newGroups;
149  newGroups[m_groupsSize++] = GroupPair( aLayer, aGroup );
150  }
GroupPair * m_groups
Definition: view.cpp:101
std::pair< int, int > GroupPair
Indexes of cached GAL display lists corresponding to the item (for every layer it.
Definition: view.cpp:97

References m_groups, and m_groupsSize.

Referenced by KIGFX::VIEW::RECACHE_ITEM_VISITOR::operator()(), KIGFX::VIEW::updateItemGeometry(), and KIGFX::VIEW::updateLayers().

◆ storesGroups()

bool KIGFX::VIEW_ITEM_DATA::storesGroups ( ) const
inlineprivate

Return information if the item uses at least one group id (ie.

if it is cached at all).

Returns
true in case it is cached at least for one layer.

Definition at line 169 of file view.cpp.

170  {
171  return m_groupsSize > 0;
172  }

References m_groupsSize.

Friends And Related Function Documentation

◆ VIEW

friend class VIEW
friend

Definition at line 73 of file view.cpp.

Member Data Documentation

◆ m_drawPriority

int KIGFX::VIEW_ITEM_DATA::m_drawPriority
private

Order to draw this item in a layer, lowest first.

Helper for storing cached items group ids

Definition at line 94 of file view.cpp.

Referenced by KIGFX::VIEW::Add(), and KIGFX::VIEW::DRAW_ITEM_VISITOR::deferredDraw().

◆ m_flags

int KIGFX::VIEW_ITEM_DATA::m_flags
private

Visibility flags.

Definition at line 92 of file view.cpp.

Referenced by getFlags(), KIGFX::VIEW::Hide(), isRenderable(), KIGFX::VIEW::IsVisible(), and KIGFX::VIEW::SetVisible().

◆ m_groups

GroupPair* KIGFX::VIEW_ITEM_DATA::m_groups
private

Definition at line 101 of file view.cpp.

Referenced by deleteGroups(), getGroup(), reorderGroups(), and setGroup().

◆ m_groupsSize

int KIGFX::VIEW_ITEM_DATA::m_groupsSize
private

Definition at line 102 of file view.cpp.

Referenced by deleteGroups(), getGroup(), reorderGroups(), setGroup(), and storesGroups().

◆ m_layers

std::vector<int> KIGFX::VIEW_ITEM_DATA::m_layers
private

Stores layer numbers used by the item.

Definition at line 201 of file view.cpp.

Referenced by getLayers(), and saveLayers().

◆ m_requiredUpdate

int KIGFX::VIEW_ITEM_DATA::m_requiredUpdate
private

Flag required for updating.

Definition at line 93 of file view.cpp.

Referenced by clearUpdateFlags(), KIGFX::VIEW::ReorderLayerData(), requiredUpdate(), and KIGFX::VIEW::Update().

◆ m_view

VIEW* KIGFX::VIEW_ITEM_DATA::m_view
private

Current dynamic view the item is assigned to.

Definition at line 91 of file view.cpp.

Referenced by KIGFX::VIEW::Add(), and KIGFX::VIEW::OnDestroy().


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