KiCad PCB EDA Suite
KIGFX::VIEW_ITEM_DATA Class Reference

Public Member Functions

 VIEW_ITEM_DATA ()
 
 ~VIEW_ITEM_DATA ()
 
int GetFlags () const
 

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...
 
std::pair< int, int > * m_groups
 layer_number:group_id pairs for each layer the item occupies. More...
 
int m_groupsSize
 
std::vector< int > m_layers
 

Friends

class VIEW
 

Detailed Description

Definition at line 53 of file view.cpp.

Constructor & Destructor Documentation

◆ VIEW_ITEM_DATA()

KIGFX::VIEW_ITEM_DATA::VIEW_ITEM_DATA ( )
inline

Definition at line 56 of file view.cpp.

56  :
57  m_view( nullptr ),
60  m_drawPriority( 0 ),
61  m_groups( nullptr ),
62  m_groupsSize( 0 ) {}
VIEW * m_view
Current dynamic view the item is assigned to.
Definition: view.cpp:232
int m_drawPriority
Order to draw this item in a layer, lowest first.
Definition: view.cpp:235
Item is visible (in general)
Definition: view_item.h:60
std::pair< int, int > * m_groups
layer_number:group_id pairs for each layer the item occupies.
Definition: view.cpp:237
No updates are required.
Definition: view_item.h:46
int m_flags
Visibility flags.
Definition: view.cpp:233
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:234

◆ ~VIEW_ITEM_DATA()

KIGFX::VIEW_ITEM_DATA::~VIEW_ITEM_DATA ( )
inline

Definition at line 64 of file view.cpp.

65  {
66  deleteGroups();
67  }
void deleteGroups()
Remove all of the stored group ids.
Definition: view.cpp:145

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 219 of file view.cpp.

220  {
222  }
No updates are required.
Definition: view_item.h:46
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:234

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 145 of file view.cpp.

146  {
147  delete[] m_groups;
148  m_groups = nullptr;
149  m_groupsSize = 0;
150  }
std::pair< int, int > * m_groups
layer_number:group_id pairs for each layer the item occupies.
Definition: view.cpp:237

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 69 of file view.cpp.

70  {
71  return m_flags;
72  }
int m_flags
Visibility flags.
Definition: view.cpp:233

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 99 of file view.cpp.

100  {
101  for( int i = 0; i < m_groupsSize; ++i )
102  {
103  if( m_groups[i].first == aLayer )
104  return m_groups[i].second;
105  }
106 
107  return -1;
108  }
std::pair< int, int > * m_groups
layer_number:group_id pairs for each layer the item occupies.
Definition: view.cpp:237

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 83 of file view.cpp.

84  {
85  int* layersPtr = aLayers;
86 
87  for( int layer : m_layers )
88  *layersPtr++ = layer;
89 
90  aCount = m_layers.size();
91  }
std::vector< int > m_layers
Definition: view.cpp:241

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 227 of file view.cpp.

228  {
229  return m_flags == VISIBLE;
230  }
Item is visible (in general)
Definition: view_item.h:60
int m_flags
Visibility flags.
Definition: view.cpp:233

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 171 of file view.cpp.

172  {
173  for( int i = 0; i < m_groupsSize; ++i )
174  {
175  int orig_layer = m_groups[i].first;
176  int new_layer = orig_layer;
177 
178  try
179  {
180  new_layer = aReorderMap.at( orig_layer );
181  }
182  catch( const std::out_of_range& )
183  {}
184 
185  m_groups[i].first = new_layer;
186  }
187  }
std::pair< int, int > * m_groups
layer_number:group_id pairs for each layer the item occupies.
Definition: view.cpp:237

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 211 of file view.cpp.

212  {
213  return m_requiredUpdate;
214  }
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:234

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 195 of file view.cpp.

196  {
197  m_layers.clear();
198 
199  for( int i = 0; i < aCount; ++i )
200  {
201  // this fires on some eagle board after EAGLE_PLUGIN::Load()
202  wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
203 
204  m_layers.push_back( aLayers[i] );
205  }
206  }
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
std::vector< int > m_layers
Definition: view.cpp:241

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 116 of file view.cpp.

117  {
118  // Look if there is already an entry for the layer
119  for( int i = 0; i < m_groupsSize; ++i )
120  {
121  if( m_groups[i].first == aLayer )
122  {
123  m_groups[i].second = aGroup;
124  return;
125  }
126  }
127 
128  // If there was no entry for the given layer - create one
129  std::pair<int, int>* newGroups = new std::pair<int, int>[m_groupsSize + 1];
130 
131  if( m_groupsSize > 0 )
132  {
133  std::copy( m_groups, m_groups + m_groupsSize, newGroups );
134  delete[] m_groups;
135  }
136 
137  m_groups = newGroups;
138  newGroups[m_groupsSize++] = { aLayer, aGroup };
139  }
std::pair< int, int > * m_groups
layer_number:group_id pairs for each layer the item occupies.
Definition: view.cpp:237

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 158 of file view.cpp.

159  {
160  return m_groupsSize > 0;
161  }

References m_groupsSize.

Friends And Related Function Documentation

◆ VIEW

friend class VIEW
friend

Definition at line 75 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.

Definition at line 235 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 233 of file view.cpp.

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

◆ m_groups

std::pair<int, int>* KIGFX::VIEW_ITEM_DATA::m_groups
private

layer_number:group_id pairs for each layer the item occupies.

Definition at line 237 of file view.cpp.

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

◆ m_groupsSize

int KIGFX::VIEW_ITEM_DATA::m_groupsSize
private

Definition at line 239 of file view.cpp.

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

◆ m_layers

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

Definition at line 241 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 234 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 232 of file view.cpp.

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


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