KiCad PCB EDA Suite
RC_TREE_MODEL Class Reference

#include <rc_item.h>

Inheritance diagram for RC_TREE_MODEL:

Public Member Functions

 RC_TREE_MODEL (EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
 
 ~RC_TREE_MODEL ()
 
void SetProvider (RC_ITEMS_PROVIDER *aProvider)
 
void SetSeverities (int aSeverities)
 
int GetDRCItemCount () const
 
void ExpandAll ()
 
bool IsContainer (wxDataViewItem const &aItem) const override
 
wxDataViewItem GetParent (wxDataViewItem const &aItem) const override
 
unsigned int GetChildren (wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override
 
unsigned int GetColumnCount () const override
 
wxString GetColumnType (unsigned int aCol) const override
 
bool HasContainerColumns (wxDataViewItem const &aItem) const override
 
void GetValue (wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
 Called by the wxDataView to fetch an item's value. More...
 
bool SetValue (wxVariant const &aVariant, wxDataViewItem const &aItem, unsigned int aCol) override
 Called by the wxDataView to edit an item's content. More...
 
bool GetAttr (wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
 Called by the wxDataView to fetch an item's formatting. More...
 
void ValueChanged (RC_TREE_NODE *aNode)
 
void DeleteCurrentItem (bool aDeep)
 
void DeleteItems (bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
 Deletes the current item or all items. More...
 

Static Public Member Functions

static wxDataViewItem ToItem (RC_TREE_NODE const *aNode)
 
static RC_TREE_NODEToNode (wxDataViewItem aItem)
 
static KIID ToUUID (wxDataViewItem aItem)
 

Private Member Functions

void rebuildModel (RC_ITEMS_PROVIDER *aProvider, int aSeverities)
 
void onSizeView (wxSizeEvent &aEvent)
 

Private Attributes

EDA_DRAW_FRAMEm_editFrame
 
wxDataViewCtrl * m_view
 
int m_severities
 
RC_ITEMS_PROVIDERm_rcItemsProvider
 
std::vector< RC_TREE_NODE * > m_tree
 

Detailed Description

Definition at line 209 of file rc_item.h.

Constructor & Destructor Documentation

◆ RC_TREE_MODEL()

RC_TREE_MODEL::RC_TREE_MODEL ( EDA_DRAW_FRAME aParentFrame,
wxDataViewCtrl *  aView 
)

Definition at line 147 of file rc_item.cpp.

147  :
148  m_editFrame( aParentFrame ),
149  m_view( aView ),
150  m_severities( 0 ),
151  m_rcItemsProvider( nullptr )
152 {
153  m_view->GetMainWindow()->Connect( wxEVT_SIZE,
154  wxSizeEventHandler( RC_TREE_MODEL::onSizeView ),
155  NULL, this );
156 }
wxDataViewCtrl * m_view
Definition: rc_item.h:291
RC_ITEMS_PROVIDER * m_rcItemsProvider
Definition: rc_item.h:293
#define NULL
EDA_DRAW_FRAME * m_editFrame
Definition: rc_item.h:290
void onSizeView(wxSizeEvent &aEvent)
Definition: rc_item.cpp:493
int m_severities
Definition: rc_item.h:292

References m_view, NULL, and onSizeView().

◆ ~RC_TREE_MODEL()

RC_TREE_MODEL::~RC_TREE_MODEL ( )

Definition at line 159 of file rc_item.cpp.

160 {
161  delete m_rcItemsProvider;
162 
163  for( RC_TREE_NODE* topLevelNode : m_tree )
164  delete topLevelNode;
165 }
RC_ITEMS_PROVIDER * m_rcItemsProvider
Definition: rc_item.h:293
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:295

References m_rcItemsProvider, and m_tree.

Member Function Documentation

◆ DeleteCurrentItem()

void RC_TREE_MODEL::DeleteCurrentItem ( bool  aDeep)

Definition at line 418 of file rc_item.cpp.

419 {
420  DeleteItems( true, true, aDeep );
421 }
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
Definition: rc_item.cpp:424

References DeleteItems().

Referenced by DIALOG_DRC::OnDeleteOneClick().

◆ DeleteItems()

void RC_TREE_MODEL::DeleteItems ( bool  aCurrentOnly,
bool  aIncludeExclusions,
bool  aDeep 
)

Deletes the current item or all items.

If all, aIncludeExclusions determines whether or not exclusions are also deleted.

Definition at line 424 of file rc_item.cpp.

425 {
426  RC_TREE_NODE* current_node = ToNode( m_view->GetCurrentItem() );
427  const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->m_RcItem : nullptr;
428 
429  if( aCurrentOnly && !current_item )
430  {
431  wxBell();
432  return;
433  }
434 
435  int lastGood = -1;
436  bool found = false;
437 
438  if( m_view )
439  m_view->UnselectAll();
440 
441  for( int i = m_rcItemsProvider->GetCount() - 1; i >= 0; --i )
442  {
443  std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
444  MARKER_BASE* marker = rcItem->GetParent();
445  bool excluded = marker ? marker->IsExcluded() : false;
446 
447  if( aCurrentOnly && rcItem != current_item )
448  {
449  if( found && lastGood >= 0 )
450  break;
451 
452  lastGood = i;
453  continue;
454  }
455 
456  if( excluded && !aIncludeExclusions )
457  continue;
458 
459  found = true;
460 
461  wxDataViewItem markerItem = ToItem( m_tree[i] );
462  wxDataViewItemArray childItems;
463  wxDataViewItem parentItem = ToItem( m_tree[i]->m_Parent );
464 
465  for( RC_TREE_NODE* child : m_tree[i]->m_Children )
466  {
467  childItems.push_back( ToItem( child ) );
468  delete child;
469  }
470 
471  m_tree[i]->m_Children.clear();
472  ItemsDeleted( markerItem, childItems );
473 
474  delete m_tree[i];
475  m_tree.erase( m_tree.begin() + i );
476  ItemDeleted( parentItem, markerItem );
477 
478  // Only deep delete the current item here; others will be done through the
479  // DeleteAllItems() call below, which is more efficient.
480  m_rcItemsProvider->DeleteItem( i, aDeep && aCurrentOnly );
481  }
482 
483  if( m_view && aCurrentOnly && lastGood >= 0 )
484  m_view->Select( ToItem( m_tree[ lastGood ] ) );
485 
486  if( !aCurrentOnly )
487  {
488  m_rcItemsProvider->DeleteAllItems( aIncludeExclusions, aDeep );
489  }
490 }
virtual void DeleteAllItems(bool aIncludeExclusions, bool aDeep)=0
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:212
virtual int GetCount(int aSeverity=-1)=0
wxDataViewCtrl * m_view
Definition: rc_item.h:291
virtual std::shared_ptr< RC_ITEM > GetItem(int aIndex)=0
Function GetItem retrieves a RC_ITEM by index.
RC_ITEMS_PROVIDER * m_rcItemsProvider
Definition: rc_item.h:293
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:202
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
bool IsExcluded() const
Definition: marker_base.h:109
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:295
virtual void DeleteItem(int aIndex, bool aDeep)=0
Function DeleteItem removes (and optionally deletes) the indexed item from the list.

References RC_ITEMS_PROVIDER::DeleteAllItems(), RC_ITEMS_PROVIDER::DeleteItem(), RC_ITEMS_PROVIDER::GetCount(), RC_ITEMS_PROVIDER::GetItem(), MARKER_BASE::IsExcluded(), RC_TREE_NODE::m_RcItem, m_rcItemsProvider, m_tree, m_view, ToItem(), and ToNode().

Referenced by DIALOG_ERC::deleteAllMarkers(), DIALOG_DRC::deleteAllMarkers(), DeleteCurrentItem(), and DIALOG_DRC::OnRunDRCClick().

◆ ExpandAll()

void RC_TREE_MODEL::ExpandAll ( )

Definition at line 269 of file rc_item.cpp.

270 {
271  for( RC_TREE_NODE* topLevelNode : m_tree )
272  m_view->Expand( ToItem( topLevelNode ) );
273 }
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:212
wxDataViewCtrl * m_view
Definition: rc_item.h:291
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:295

References m_tree, m_view, and ToItem().

Referenced by rebuildModel().

◆ GetAttr()

bool RC_TREE_MODEL::GetAttr ( wxDataViewItem const &  aItem,
unsigned int  aCol,
wxDataViewItemAttr &  aAttr 
) const
override

Called by the wxDataView to fetch an item's formatting.

Return true iff the item has non-default attributes.

Definition at line 368 of file rc_item.cpp.

371 {
372  const RC_TREE_NODE* node = ToNode( aItem );
373  wxASSERT( node );
374 
375  bool ret = false;
376  bool heading = node->m_Type == RC_TREE_NODE::MARKER;
377 
378  if( heading )
379  {
380  aAttr.SetBold( true );
381  ret = true;
382  }
383 
384  if( node->m_RcItem->GetParent() && node->m_RcItem->GetParent()->IsExcluded() )
385  {
386  wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
387 
388  if( KIGFX::COLOR4D( textColour ).GetBrightness() > 0.5 )
389  aAttr.SetColour( textColour.ChangeLightness( heading ? 30 : 35 ) );
390  else
391  aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
392 
393  aAttr.SetItalic( true ); // Strikethrough would be better, if wxWidgets supported it
394  ret = true;
395  }
396 
397  return ret;
398 }
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:202
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
NODE_TYPE m_Type
Definition: rc_item.h:201
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References RC_TREE_NODE::m_RcItem, RC_TREE_NODE::m_Type, RC_TREE_NODE::MARKER, and ToNode().

◆ GetChildren()

unsigned int RC_TREE_MODEL::GetChildren ( wxDataViewItem const &  aItem,
wxDataViewItemArray &  aChildren 
) const
override

Definition at line 291 of file rc_item.cpp.

293 {
294  const RC_TREE_NODE* node = ToNode( aItem );
295  const std::vector<RC_TREE_NODE*>& children = node ? node->m_Children : m_tree;
296 
297  for( const RC_TREE_NODE* child: children )
298  aChildren.push_back( ToItem( child ) );
299 
300  return children.size();
301 }
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:212
std::vector< RC_TREE_NODE * > m_Children
Definition: rc_item.h:205
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:295

References RC_TREE_NODE::m_Children, m_tree, ToItem(), and ToNode().

◆ GetColumnCount()

unsigned int RC_TREE_MODEL::GetColumnCount ( ) const
inlineoverride

Definition at line 245 of file rc_item.h.

245 { return 1; }

◆ GetColumnType()

wxString RC_TREE_MODEL::GetColumnType ( unsigned int  aCol) const
inlineoverride

Definition at line 246 of file rc_item.h.

246 { return "string"; }

◆ GetDRCItemCount()

int RC_TREE_MODEL::GetDRCItemCount ( ) const
inline

Definition at line 233 of file rc_item.h.

233 { return m_tree.size(); }
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:295

References m_tree.

Referenced by DIALOG_DRC::updateDisplayedCounts().

◆ GetParent()

wxDataViewItem RC_TREE_MODEL::GetParent ( wxDataViewItem const &  aItem) const
override

Definition at line 285 of file rc_item.cpp.

286 {
287  return ToItem( ToNode( aItem)->m_Parent );
288 }
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:212
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217

References ToItem(), and ToNode().

◆ GetValue()

void RC_TREE_MODEL::GetValue ( wxVariant &  aVariant,
wxDataViewItem const &  aItem,
unsigned int  aCol 
) const
override

Called by the wxDataView to fetch an item's value.

Definition at line 307 of file rc_item.cpp.

310 {
311  const RC_TREE_NODE* node = ToNode( aItem );
312  const std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
313 
314  switch( node->m_Type )
315  {
317  {
318  wxString prefix;
319 
320  if( rcItem->GetParent() && rcItem->GetParent()->IsExcluded() )
321  prefix = _( "Excluded " );
322 
323  switch( m_editFrame->GetSeverity( rcItem->GetErrorCode() ) )
324  {
325  case RPT_SEVERITY_ERROR: prefix += _( "Error: " ); break;
326  case RPT_SEVERITY_WARNING: prefix += _( "Warning: " ); break;
327  }
328 
329  aVariant = prefix + rcItem->GetErrorMessage();
330  }
331  break;
332 
334  {
335  EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetMainItemID() );
336  aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() );
337  }
338  break;
339 
341  {
342  EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItemID() );
343  aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() );
344  }
345  break;
346 
348  {
349  EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItem2ID() );
350  aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() );
351  }
352  break;
353 
355  {
356  EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItem3ID() );
357  aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() );
358  }
359  break;
360  }
361 }
virtual EDA_ITEM * GetItem(const KIID &aId)
Fetch an item by KIID.
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:202
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
EDA_DRAW_FRAME * m_editFrame
Definition: rc_item.h:290
virtual int GetSeverity(int aErrorCode) const
NODE_TYPE m_Type
Definition: rc_item.h:201
#define _(s)
Definition: 3d_actions.cpp:33
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, RC_TREE_NODE::AUX_ITEM, RC_TREE_NODE::AUX_ITEM2, RC_TREE_NODE::AUX_ITEM3, EDA_DRAW_FRAME::GetItem(), EDA_ITEM::GetSelectMenuText(), EDA_BASE_FRAME::GetSeverity(), EDA_BASE_FRAME::GetUserUnits(), m_editFrame, RC_TREE_NODE::m_RcItem, RC_TREE_NODE::m_Type, RC_TREE_NODE::MAIN_ITEM, RC_TREE_NODE::MARKER, RPT_SEVERITY_ERROR, RPT_SEVERITY_WARNING, and ToNode().

◆ HasContainerColumns()

bool RC_TREE_MODEL::HasContainerColumns ( wxDataViewItem const &  aItem) const
inlineoverride

Definition at line 247 of file rc_item.h.

247 { return true; }

◆ IsContainer()

bool RC_TREE_MODEL::IsContainer ( wxDataViewItem const &  aItem) const
override

Definition at line 276 of file rc_item.cpp.

277 {
278  if( ToNode( aItem ) == nullptr ) // must be tree root...
279  return true;
280  else
281  return ToNode( aItem )->m_Type == RC_TREE_NODE::MARKER;
282 }
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
NODE_TYPE m_Type
Definition: rc_item.h:201

References RC_TREE_NODE::m_Type, RC_TREE_NODE::MARKER, and ToNode().

◆ onSizeView()

void RC_TREE_MODEL::onSizeView ( wxSizeEvent &  aEvent)
private

Definition at line 493 of file rc_item.cpp.

494 {
495  int width = m_view->GetMainWindow()->GetRect().GetWidth() - WX_DATAVIEW_WINDOW_PADDING;
496 
497  if( m_view->GetColumnCount() > 0 )
498  m_view->GetColumn( 0 )->SetWidth( width );
499 
500  // Pass size event to other widgets
501  aEvent.Skip();
502 }
wxDataViewCtrl * m_view
Definition: rc_item.h:291
#define WX_DATAVIEW_WINDOW_PADDING
Definition: rc_item.cpp:33

References m_view, and WX_DATAVIEW_WINDOW_PADDING.

Referenced by RC_TREE_MODEL().

◆ rebuildModel()

void RC_TREE_MODEL::rebuildModel ( RC_ITEMS_PROVIDER aProvider,
int  aSeverities 
)
private

Definition at line 168 of file rc_item.cpp.

169 {
170  wxWindowUpdateLocker updateLock( m_view );
171 
172  std::shared_ptr<RC_ITEM> selectedRcItem = nullptr;
173 
174  if( m_view )
175  {
176  RC_TREE_NODE* selectedNode = ToNode( m_view->GetSelection() );
177  selectedRcItem = selectedNode ? selectedNode->m_RcItem : nullptr;
178 
179  // Even with the updateLock, wxWidgets sometimes ties its knickers in a knot trying
180  // to run a wxdataview_selection_changed_callback() on a row that has been deleted.
181  m_view->UnselectAll();
182  }
183 
184  if( aProvider != m_rcItemsProvider )
185  {
186  delete m_rcItemsProvider;
187  m_rcItemsProvider = aProvider;
188  }
189 
190  if( aSeverities != m_severities )
191  m_severities = aSeverities;
192 
193  if( m_rcItemsProvider )
195 
196  for( RC_TREE_NODE* topLevelNode : m_tree )
197  delete topLevelNode;
198 
199  m_tree.clear();
200 
201  for( int i = 0; m_rcItemsProvider && i < m_rcItemsProvider->GetCount(); ++i )
202  {
203  std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
204 
205  m_tree.push_back( new RC_TREE_NODE( nullptr, rcItem, RC_TREE_NODE::MARKER ) );
206  RC_TREE_NODE* n = m_tree.back();
207 
208  if( rcItem->GetMainItemID() != niluuid )
209  n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::MAIN_ITEM ) );
210 
211  if( rcItem->GetAuxItemID() != niluuid )
212  n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM ) );
213 
214  if( rcItem->GetAuxItem2ID() != niluuid )
215  n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM2 ) );
216 
217  if( rcItem->GetAuxItem3ID() != niluuid )
218  n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM3 ) );
219  }
220 
221  // Must be called after a significant change of items to force the
222  // wxDataViewModel to reread all of them, repopulating itself entirely.
223  Cleared();
224 
225 #ifdef __WXGTK__
226  // The fastest method to update wxDataViewCtrl is to rebuild from
227  // scratch by calling Cleared(). Linux requires to reassociate model to
228  // display data, but Windows will create multiple associations.
229  // On MacOS, this crashes kicad. See https://gitlab.com/kicad/code/kicad/issues/3666
230  // and https://gitlab.com/kicad/code/kicad/issues/3653
231  m_view->AssociateModel( this );
232 #endif
233 
234  m_view->ClearColumns();
235  int width = m_view->GetMainWindow()->GetRect().GetWidth() - WX_DATAVIEW_WINDOW_PADDING;
236  m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
237 
238  ExpandAll();
239 
240  // Most annoyingly wxWidgets won't tell us the scroll position (and no, all the usual
241  // routines don't work), so we can only restore the scroll position based on a selection.
242  if( selectedRcItem )
243  {
244  for( RC_TREE_NODE* candidate : m_tree )
245  {
246  if( candidate->m_RcItem == selectedRcItem )
247  {
248  m_view->Select( ToItem( candidate ) );
249  m_view->EnsureVisible( ToItem( candidate ) );
250  break;
251  }
252  }
253  }
254 }
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:212
virtual int GetCount(int aSeverity=-1)=0
wxDataViewCtrl * m_view
Definition: rc_item.h:291
#define WX_DATAVIEW_WINDOW_PADDING
Definition: rc_item.cpp:33
virtual std::shared_ptr< RC_ITEM > GetItem(int aIndex)=0
Function GetItem retrieves a RC_ITEM by index.
std::vector< RC_TREE_NODE * > m_Children
Definition: rc_item.h:205
RC_ITEMS_PROVIDER * m_rcItemsProvider
Definition: rc_item.h:293
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:202
void ExpandAll()
Definition: rc_item.cpp:269
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
KIID niluuid(0)
virtual void SetSeverities(int aSeverities)=0
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:295
int m_severities
Definition: rc_item.h:292

References RC_TREE_NODE::AUX_ITEM, RC_TREE_NODE::AUX_ITEM2, RC_TREE_NODE::AUX_ITEM3, ExpandAll(), RC_ITEMS_PROVIDER::GetCount(), RC_ITEMS_PROVIDER::GetItem(), RC_TREE_NODE::m_Children, RC_TREE_NODE::m_RcItem, m_rcItemsProvider, m_severities, m_tree, m_view, RC_TREE_NODE::MAIN_ITEM, RC_TREE_NODE::MARKER, niluuid, RC_ITEMS_PROVIDER::SetSeverities(), ToItem(), ToNode(), and WX_DATAVIEW_WINDOW_PADDING.

Referenced by SetProvider(), and SetSeverities().

◆ SetProvider()

◆ SetSeverities()

void RC_TREE_MODEL::SetSeverities ( int  aSeverities)

◆ SetValue()

bool RC_TREE_MODEL::SetValue ( wxVariant const &  aVariant,
wxDataViewItem const &  aItem,
unsigned int  aCol 
)
inlineoverride

Called by the wxDataView to edit an item's content.

Definition at line 259 of file rc_item.h.

262  {
263  // Editing not supported
264  return false;
265  }

◆ ToItem()

static wxDataViewItem RC_TREE_MODEL::ToItem ( RC_TREE_NODE const *  aNode)
inlinestatic

Definition at line 212 of file rc_item.h.

213  {
214  return wxDataViewItem( const_cast<void*>( static_cast<void const*>( aNode ) ) );
215  }

Referenced by DeleteItems(), ExpandAll(), GetChildren(), GetParent(), rebuildModel(), and ValueChanged().

◆ ToNode()

static RC_TREE_NODE* RC_TREE_MODEL::ToNode ( wxDataViewItem  aItem)
inlinestatic

Definition at line 217 of file rc_item.h.

218  {
219  return static_cast<RC_TREE_NODE*>( aItem.GetID() );
220  }

Referenced by DeleteItems(), GetAttr(), GetChildren(), GetParent(), GetValue(), IsContainer(), DIALOG_DRC::OnDRCItemRClick(), DIALOG_DRC::OnDRCItemSelected(), DIALOG_ERC::OnERCItemRClick(), rebuildModel(), and ToUUID().

◆ ToUUID()

KIID RC_TREE_MODEL::ToUUID ( wxDataViewItem  aItem)
static

Definition at line 118 of file rc_item.cpp.

119 {
120  const RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aItem );
121 
122  if( node && node->m_RcItem )
123  {
124  const std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
125 
126  switch( node->m_Type )
127  {
129  // rc_item->GetParent() can be null, if the parent is not existing
130  // when a RC item has no corresponding ERC/DRC marker
131  if( rc_item->GetParent() )
132  return rc_item->GetParent()->GetUUID();
133 
134  break;
135 
136  case RC_TREE_NODE::MAIN_ITEM: return rc_item->GetMainItemID();
137  case RC_TREE_NODE::AUX_ITEM: return rc_item->GetAuxItemID();
138  case RC_TREE_NODE::AUX_ITEM2: return rc_item->GetAuxItem2ID();
139  case RC_TREE_NODE::AUX_ITEM3: return rc_item->GetAuxItem3ID();
140  }
141  }
142 
143  return niluuid;
144 }
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:202
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
KIID niluuid(0)
NODE_TYPE m_Type
Definition: rc_item.h:201

References RC_TREE_NODE::AUX_ITEM, RC_TREE_NODE::AUX_ITEM2, RC_TREE_NODE::AUX_ITEM3, RC_TREE_NODE::m_RcItem, RC_TREE_NODE::m_Type, RC_TREE_NODE::MAIN_ITEM, RC_TREE_NODE::MARKER, niluuid, and ToNode().

Referenced by DIALOG_DRC::OnDRCItemSelected(), DIALOG_ERC::OnERCItemSelected(), DIALOG_CLEANUP_GRAPHICS::OnSelectItem(), and DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem().

◆ ValueChanged()

void RC_TREE_MODEL::ValueChanged ( RC_TREE_NODE aNode)

Definition at line 401 of file rc_item.cpp.

402 {
403  if( aNode->m_Type == RC_TREE_NODE::MAIN_ITEM || aNode->m_Type == RC_TREE_NODE::AUX_ITEM )
404  {
405  ValueChanged( aNode->m_Parent );
406  }
407 
408  if( aNode->m_Type == RC_TREE_NODE::MARKER )
409  {
410  wxDataViewModel::ValueChanged( ToItem( aNode ), 0 );
411 
412  for( RC_TREE_NODE* child : aNode->m_Children )
413  wxDataViewModel::ValueChanged( ToItem( child ), 0 );
414  }
415 }
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:212
RC_TREE_NODE * m_Parent
Definition: rc_item.h:204
std::vector< RC_TREE_NODE * > m_Children
Definition: rc_item.h:205
NODE_TYPE m_Type
Definition: rc_item.h:201
void ValueChanged(RC_TREE_NODE *aNode)
Definition: rc_item.cpp:401

References RC_TREE_NODE::AUX_ITEM, RC_TREE_NODE::m_Children, RC_TREE_NODE::m_Parent, RC_TREE_NODE::m_Type, RC_TREE_NODE::MAIN_ITEM, RC_TREE_NODE::MARKER, and ToItem().

Member Data Documentation

◆ m_editFrame

EDA_DRAW_FRAME* RC_TREE_MODEL::m_editFrame
private

Definition at line 290 of file rc_item.h.

Referenced by GetValue().

◆ m_rcItemsProvider

RC_ITEMS_PROVIDER* RC_TREE_MODEL::m_rcItemsProvider
private

Definition at line 293 of file rc_item.h.

Referenced by DeleteItems(), rebuildModel(), SetSeverities(), and ~RC_TREE_MODEL().

◆ m_severities

int RC_TREE_MODEL::m_severities
private

Definition at line 292 of file rc_item.h.

Referenced by rebuildModel(), and SetProvider().

◆ m_tree

std::vector<RC_TREE_NODE*> RC_TREE_MODEL::m_tree
private

◆ m_view

wxDataViewCtrl* RC_TREE_MODEL::m_view
private

Definition at line 291 of file rc_item.h.

Referenced by DeleteItems(), ExpandAll(), onSizeView(), RC_TREE_MODEL(), and rebuildModel().


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