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
 

Helper for storing cached items group ids

More...
 

Private Member Functions

void getLayers (int *aLayers, int &aCount) const
 Function getLayers() Returns layer numbers used by the item. More...
 
int getGroup (int aLayer) const
 Function getGroup() Returns number of the group id for the given layer, or -1 in case it was not cached before. More...
 
std::vector< int > getAllGroups () const
 Function getAllGroups() Returns all group ids for the item (collected from all layers the item occupies). More...
 
void setGroup (int aLayer, int aGroup)
 Function setGroup() Sets a group id for the item and the layer combination. More...
 
void deleteGroups ()
 Function deleteGroups() Removes all of the stored group ids. More...
 
bool storesGroups () const
 Function storesGroups() Returns information if the item uses at least one group id (ie. More...
 
void reorderGroups (std::unordered_map< int, int > aReorderMap)
 Reorders the stored groups (to facilitate reordering of layers) More...
 
void saveLayers (int *aLayers, int aCount)
 Function saveLayers() Saves layers used by the item. More...
 
int requiredUpdate () const
 Function viewRequiredUpdate() Returns current update flag for an item. More...
 
void clearUpdateFlags ()
 Function clearUpdateFlags() Marks an item as already updated, so it is not going to be redrawn. More...
 
bool isRenderable () const
 Function isRenderable() Returns 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
 

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

More...
 
int m_groupsSize
 
std::vector< int > m_layers
 Stores layer numbers used by the item. More...
 

Friends

class VIEW
 

Detailed Description

Definition at line 46 of file view.cpp.

Member Typedef Documentation

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

Helper for storing cached items group ids

Definition at line 93 of file view.cpp.

Constructor & Destructor Documentation

KIGFX::VIEW_ITEM_DATA::VIEW_ITEM_DATA ( )
inline

Definition at line 49 of file view.cpp.

49  :
50  m_view( nullptr ),
53  m_drawPriority( 0 ),
54  m_groups( nullptr ),
55  m_groupsSize( 0 ) {}
VIEW * m_view
Current dynamic view the item is assigned to.
Definition: view.cpp:87
int m_drawPriority
Order to draw this item in a layer, lowest first.
Definition: view.cpp:90
GroupPair * m_groups
Indexes of cached GAL display lists corresponding to the item (for every layer it occupies)...
Definition: view.cpp:97
int m_flags
Visibility flags.
Definition: view.cpp:88
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:89
KIGFX::VIEW_ITEM_DATA::~VIEW_ITEM_DATA ( )
inline

Definition at line 57 of file view.cpp.

References deleteGroups().

58  {
59  deleteGroups();
60  }
void deleteGroups()
Function deleteGroups() Removes all of the stored group ids.
Definition: view.cpp:173

Member Function Documentation

void KIGFX::VIEW_ITEM_DATA::clearUpdateFlags ( )
inlineprivate

Function clearUpdateFlags() Marks an item as already updated, so it is not going to be redrawn.

Definition at line 253 of file view.cpp.

References KIGFX::NONE.

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

254  {
256  }
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:89
void KIGFX::VIEW_ITEM_DATA::deleteGroups ( )
inlineprivate

Function deleteGroups() Removes all of the stored group ids.

Forces recaching of the item.

Definition at line 173 of file view.cpp.

References m_groups.

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

174  {
175  delete[] m_groups;
176  m_groups = nullptr;
177  m_groupsSize = 0;
178  }
GroupPair * m_groups
Indexes of cached GAL display lists corresponding to the item (for every layer it occupies)...
Definition: view.cpp:97
std::vector<int> KIGFX::VIEW_ITEM_DATA::getAllGroups ( ) const
inlineprivate

Function getAllGroups() Returns all group ids for the item (collected from all layers the item occupies).

Returns
vector of group ids.

Definition at line 124 of file view.cpp.

References i, and m_groupsSize.

125  {
126  std::vector<int> groups( m_groupsSize );
127 
128  for( int i = 0; i < m_groupsSize; ++i )
129  {
130  groups[i] = m_groups[i].second;
131  }
132 
133  return groups;
134  }
GroupPair * m_groups
Indexes of cached GAL display lists corresponding to the item (for every layer it occupies)...
Definition: view.cpp:97
size_t i
Definition: json11.cpp:597
int KIGFX::VIEW_ITEM_DATA::getFlags ( ) const
inline

Definition at line 62 of file view.cpp.

References m_flags.

Referenced by KIGFX::queryVisitor< Container >::operator()().

63  {
64  return m_flags;
65  }
int m_flags
Visibility flags.
Definition: view.cpp:88
int KIGFX::VIEW_ITEM_DATA::getGroup ( int  aLayer) const
inlineprivate

Function getGroup() Returns 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 107 of file view.cpp.

References i, and m_groupsSize.

Referenced by KIGFX::VIEW::draw(), KIGFX::VIEW::updateItemsColor::operator()(), KIGFX::VIEW::changeItemsDepth::operator()(), and KIGFX::VIEW::recacheItem::operator()().

108  {
109  for( int i = 0; i < m_groupsSize; ++i )
110  {
111  if( m_groups[i].first == aLayer )
112  return m_groups[i].second;
113  }
114 
115  return -1;
116  }
GroupPair * m_groups
Indexes of cached GAL display lists corresponding to the item (for every layer it occupies)...
Definition: view.cpp:97
size_t i
Definition: json11.cpp:597
void KIGFX::VIEW_ITEM_DATA::getLayers ( int *  aLayers,
int &  aCount 
) const
inlineprivate

Function getLayers() Returns layer numbers used by the item.

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

Definition at line 77 of file view.cpp.

References m_layers.

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

78  {
79  int* layersPtr = aLayers;
80 
81  for( auto layer : m_layers )
82  *layersPtr++ = layer;
83 
84  aCount = m_layers.size();
85  }
std::vector< int > m_layers
Stores layer numbers used by the item.
Definition: view.cpp:218
bool KIGFX::VIEW_ITEM_DATA::isRenderable ( ) const
inlineprivate

Function isRenderable() Returns if the item should be drawn or not.

Definition at line 262 of file view.cpp.

References KIGFX::VISIBLE.

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

263  {
264  return m_flags == VISIBLE;
265  }
int m_flags
Visibility flags.
Definition: view.cpp:88
void KIGFX::VIEW_ITEM_DATA::reorderGroups ( std::unordered_map< int, int >  aReorderMap)
inlineprivate

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

References i, and m_groupsSize.

200  {
201  for( int i = 0; i < m_groupsSize; ++i )
202  {
203  int orig_layer = m_groups[i].first;
204  int new_layer = orig_layer;
205 
206  try
207  {
208  new_layer = aReorderMap.at( orig_layer );
209  }
210  catch( std::out_of_range ) {}
211 
212  m_groups[i].first = new_layer;
213  }
214  }
GroupPair * m_groups
Indexes of cached GAL display lists corresponding to the item (for every layer it occupies)...
Definition: view.cpp:97
size_t i
Definition: json11.cpp:597
int KIGFX::VIEW_ITEM_DATA::requiredUpdate ( ) const
inlineprivate

Function viewRequiredUpdate() Returns current update flag for an item.

Definition at line 244 of file view.cpp.

References m_requiredUpdate.

245  {
246  return m_requiredUpdate;
247  }
int m_requiredUpdate
Flag required for updating.
Definition: view.cpp:89
void KIGFX::VIEW_ITEM_DATA::saveLayers ( int *  aLayers,
int  aCount 
)
inlineprivate

Function saveLayers() Saves layers used by the item.

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

Definition at line 227 of file view.cpp.

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

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

228  {
229  m_layers.clear();
230 
231  for( int i = 0; i < aCount; ++i )
232  {
233  // this fires on some eagle board after EAGLE_PLUGIN::Load()
234  wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
235 
236  m_layers.push_back( aLayers[i] );
237  }
238  }
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:675
size_t i
Definition: json11.cpp:597
std::vector< int > m_layers
Stores layer numbers used by the item.
Definition: view.cpp:218
void KIGFX::VIEW_ITEM_DATA::setGroup ( int  aLayer,
int  aGroup 
)
inlineprivate

Function setGroup() Sets a group id for the item and the layer combination.

Parameters
aLayeris the layer numbe.
aGroupis the group id.

Definition at line 143 of file view.cpp.

References i, m_groups, and m_groupsSize.

144  {
145  // Look if there is already an entry for the layer
146  for( int i = 0; i < m_groupsSize; ++i )
147  {
148  if( m_groups[i].first == aLayer )
149  {
150  m_groups[i].second = aGroup;
151  return;
152  }
153  }
154 
155  // If there was no entry for the given layer - create one
156  GroupPair* newGroups = new GroupPair[m_groupsSize + 1];
157 
158  if( m_groupsSize > 0 )
159  {
160  std::copy( m_groups, m_groups + m_groupsSize, newGroups );
161  delete[] m_groups;
162  }
163 
164  m_groups = newGroups;
165  newGroups[m_groupsSize++] = GroupPair( aLayer, aGroup );
166  }
GroupPair * m_groups
Indexes of cached GAL display lists corresponding to the item (for every layer it occupies)...
Definition: view.cpp:97
size_t i
Definition: json11.cpp:597
std::pair< int, int > GroupPair
Helper for storing cached items group ids
Definition: view.cpp:93
bool KIGFX::VIEW_ITEM_DATA::storesGroups ( ) const
inlineprivate

Function storesGroups() Returns 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 187 of file view.cpp.

188  {
189  return m_groupsSize > 0;
190  }

Friends And Related Function Documentation

friend class VIEW
friend

Definition at line 68 of file view.cpp.

Member Data Documentation

int KIGFX::VIEW_ITEM_DATA::m_drawPriority
private

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

Definition at line 90 of file view.cpp.

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

int KIGFX::VIEW_ITEM_DATA::m_flags
private

Visibility flags.

Definition at line 88 of file view.cpp.

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

GroupPair* KIGFX::VIEW_ITEM_DATA::m_groups
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.

Referenced by deleteGroups(), and setGroup().

int KIGFX::VIEW_ITEM_DATA::m_groupsSize
private

Definition at line 98 of file view.cpp.

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

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

Stores layer numbers used by the item.

Definition at line 218 of file view.cpp.

Referenced by getLayers().

int KIGFX::VIEW_ITEM_DATA::m_requiredUpdate
private

Flag required for updating.

Definition at line 89 of file view.cpp.

Referenced by requiredUpdate().

VIEW* KIGFX::VIEW_ITEM_DATA::m_view
private

Current dynamic view the item is assigned to.

Definition at line 87 of file view.cpp.

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


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