KiCad PCB EDA Suite
RC_TREE_MODEL Class Reference

#include <rc_item.h>

Inheritance diagram for RC_TREE_MODEL:
ERC_TREE_MODEL

Public Member Functions

 RC_TREE_MODEL (EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
 
 ~RC_TREE_MODEL ()
 
void Update (std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
 
void ExpandAll ()
 
void PrevMarker ()
 
void NextMarker ()
 
void SelectMarker (const MARKER_BASE *aMarker)
 
void CenterMarker (const MARKER_BASE *aMarker)
 
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 (const 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)
 

Protected Member Functions

void rebuildModel (std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
 
void onSizeView (wxSizeEvent &aEvent)
 

Protected Attributes

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

Detailed Description

Definition at line 201 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 178 of file rc_item.cpp.

178 :
179 m_editFrame( aParentFrame ),
180 m_view( aView ),
181 m_severities( 0 ),
182 m_rcItemsProvider( nullptr )
183{
184 m_view->GetMainWindow()->Connect( wxEVT_SIZE, wxSizeEventHandler( RC_TREE_MODEL::onSizeView ),
185 nullptr, this );
186}
void onSizeView(wxSizeEvent &aEvent)
Definition: rc_item.cpp:633
int m_severities
Definition: rc_item.h:280
EDA_DRAW_FRAME * m_editFrame
Definition: rc_item.h:278
wxDataViewCtrl * m_view
Definition: rc_item.h:279
std::shared_ptr< RC_ITEMS_PROVIDER > m_rcItemsProvider
Definition: rc_item.h:281

References m_view, and onSizeView().

◆ ~RC_TREE_MODEL()

RC_TREE_MODEL::~RC_TREE_MODEL ( )

Definition at line 189 of file rc_item.cpp.

190{
191 for( RC_TREE_NODE* topLevelNode : m_tree )
192 delete topLevelNode;
193}
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:283

References m_tree.

Member Function Documentation

◆ CenterMarker()

void RC_TREE_MODEL::CenterMarker ( const MARKER_BASE aMarker)

Definition at line 620 of file rc_item.cpp.

621{
622 for( RC_TREE_NODE* candidate : m_tree )
623 {
624 if( candidate->m_RcItem->GetParent() == aMarker )
625 {
626 m_view->EnsureVisible( ToItem( candidate ) );
627 return;
628 }
629 }
630}
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:204

References m_tree, m_view, and ToItem().

Referenced by DIALOG_ERC::centerMarkerIdleHandler(), DIALOG_DRC::centerMarkerIdleHandler(), and DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler().

◆ DeleteCurrentItem()

void RC_TREE_MODEL::DeleteCurrentItem ( bool  aDeep)

Definition at line 463 of file rc_item.cpp.

464{
465 DeleteItems( true, true, aDeep );
466}
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
Definition: rc_item.cpp:469

References DeleteItems().

Referenced by DIALOG_DRC::ExcludeMarker(), DIALOG_ERC::ExcludeMarker(), DIALOG_DRC::OnDeleteOneClick(), DIALOG_ERC::OnDeleteOneClick(), and DIALOG_FOOTPRINT_CHECKER::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.

Keep a vector of elements to free after wxWidgets is definitely done accessing them

Definition at line 469 of file rc_item.cpp.

470{
471 RC_TREE_NODE* current_node = m_view ? ToNode( m_view->GetCurrentItem() ) : nullptr;
472 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->m_RcItem : nullptr;
473
475 std::vector<RC_TREE_NODE*> to_delete;
476
477 if( aCurrentOnly && !current_item )
478 {
479 wxBell();
480 return;
481 }
482
483 int lastGood = -1;
484 bool itemDeleted = false;
485
486 if( m_view )
487 {
488 m_view->UnselectAll();
489 wxSafeYield();
490 m_view->Freeze();
491 }
492
493 if( !m_rcItemsProvider )
494 return;
495
496 for( int i = m_rcItemsProvider->GetCount() - 1; i >= 0; --i )
497 {
498 std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
499 MARKER_BASE* marker = rcItem->GetParent();
500 bool excluded = false;
501
502 if( marker && marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
503 excluded = true;
504
505 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
506 break;
507
508 if( aCurrentOnly && rcItem != current_item )
509 {
510 lastGood = i;
511 continue;
512 }
513
514 if( excluded && !aIncludeExclusions )
515 continue;
516
517 if( i < (int) m_tree.size() ) // Careful; tree is truncated for large datasets
518 {
519 wxDataViewItem markerItem = ToItem( m_tree[i] );
520 wxDataViewItemArray childItems;
521 wxDataViewItem parentItem = ToItem( m_tree[i]->m_Parent );
522
523 for( RC_TREE_NODE* child : m_tree[i]->m_Children )
524 {
525 childItems.push_back( ToItem( child ) );
526 to_delete.push_back( child );
527 }
528
529 m_tree[i]->m_Children.clear();
530 ItemsDeleted( markerItem, childItems );
531
532 to_delete.push_back( m_tree[i] );
533 m_tree.erase( m_tree.begin() + i );
534 ItemDeleted( parentItem, markerItem );
535 }
536
537 // Only deep delete the current item here; others will be done by the caller, which
538 // can more efficiently delete all markers on the board.
539 m_rcItemsProvider->DeleteItem( i, aDeep && aCurrentOnly );
540
541 if( lastGood > i )
542 lastGood--;
543
544 itemDeleted = true;
545 }
546
547 if( m_view && aCurrentOnly && lastGood >= 0 )
548 m_view->Select( ToItem( m_tree[ lastGood ] ) );
549
550 for( RC_TREE_NODE* item : to_delete )
551 delete( item );
552
553 if( m_view )
554 m_view->Thaw();
555}
virtual SEVERITY GetSeverity() const
Definition: marker_base.h:100
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:209
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:194
@ RPT_SEVERITY_EXCLUSION

References MARKER_BASE::GetSeverity(), RC_TREE_NODE::m_RcItem, m_rcItemsProvider, m_tree, m_view, RPT_SEVERITY_EXCLUSION, ToItem(), and ToNode().

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

◆ ExpandAll()

void RC_TREE_MODEL::ExpandAll ( )

Definition at line 295 of file rc_item.cpp.

296{
297 for( RC_TREE_NODE* topLevelNode : m_tree )
298 m_view->Expand( ToItem( topLevelNode ) );
299}

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 if the item has non-default attributes.

Definition at line 406 of file rc_item.cpp.

409{
410 const RC_TREE_NODE* node = ToNode( aItem );
411 wxASSERT( node );
412
413 bool ret = false;
414 bool heading = node->m_Type == RC_TREE_NODE::MARKER;
415
416 if( heading )
417 {
418 aAttr.SetBold( true );
419 ret = true;
420 }
421
422 if( node->m_RcItem->GetParent()
423 && node->m_RcItem->GetParent()->GetSeverity() == RPT_SEVERITY_EXCLUSION )
424 {
425 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
426 double brightness = KIGFX::COLOR4D( textColour ).GetBrightness();
427
428 if( brightness > 0.5 )
429 {
430 int lightness = static_cast<int>( brightness * ( heading ? 50 : 60 ) );
431 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
432 }
433 else
434 {
435 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
436 }
437
438 aAttr.SetItalic( true ); // Strikethrough would be better, if wxWidgets supported it
439 ret = true;
440 }
441
442 return ret;
443}
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double GetBrightness() const
Returns the brightness value of the color ranged from 0.0 to 1.0.
Definition: color4d.h:349
NODE_TYPE m_Type
Definition: rc_item.h:193

References KIGFX::COLOR4D::GetBrightness(), RC_TREE_NODE::m_RcItem, RC_TREE_NODE::m_Type, RC_TREE_NODE::MARKER, RPT_SEVERITY_EXCLUSION, and ToNode().

◆ GetChildren()

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

Definition at line 317 of file rc_item.cpp.

319{
320 const RC_TREE_NODE* node = ToNode( aItem );
321 const std::vector<RC_TREE_NODE*>& children = node ? node->m_Children : m_tree;
322
323 for( const RC_TREE_NODE* child: children )
324 aChildren.push_back( ToItem( child ) );
325
326 return children.size();
327}
std::vector< RC_TREE_NODE * > m_Children
Definition: rc_item.h:197

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

◆ GetColumnCount()

unsigned int RC_TREE_MODEL::GetColumnCount ( ) const
inlineoverride

Definition at line 237 of file rc_item.h.

237{ return 1; }

◆ GetColumnType()

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

Definition at line 238 of file rc_item.h.

238{ return "string"; }

◆ GetParent()

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

Definition at line 311 of file rc_item.cpp.

312{
313 return ToItem( ToNode( aItem)->m_Parent );
314}

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 330 of file rc_item.cpp.

333{
334 const RC_TREE_NODE* node = ToNode( aItem );
335 const std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
336
337 switch( node->m_Type )
338 {
340 {
341 wxString prefix;
342
343 if( rcItem->GetParent() )
344 {
345 SEVERITY severity = rcItem->GetParent()->GetSeverity();
346
347 if( severity == RPT_SEVERITY_EXCLUSION )
348 {
349 if( m_editFrame->GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
350 prefix = _( "Excluded warning: " );
351 else
352 prefix = _( "Excluded error: " );
353 }
354 else if( severity == RPT_SEVERITY_WARNING )
355 {
356 prefix = _( "Warning: " );
357 }
358 else
359 {
360 prefix = _( "Error: " );
361 }
362 }
363
364 aVariant = prefix + rcItem->GetErrorMessage();
365 }
366 break;
367
369 if( rcItem->GetParent() && rcItem->GetParent()->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
370 {
371 aVariant = _( "Drawing Sheet" );
372 break;
373 }
374 else
375 {
376 EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetMainItemID() );
377 aVariant = item->GetItemDescription( m_editFrame );
378 }
379
380 break;
381
383 {
384 EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItemID() );
385 aVariant = item->GetItemDescription( m_editFrame );
386 }
387 break;
388
390 {
391 EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItem2ID() );
392 aVariant = item->GetItemDescription( m_editFrame );
393 }
394 break;
395
397 {
398 EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItem3ID() );
399 aVariant = item->GetItemDescription( m_editFrame );
400 }
401 break;
402 }
403}
virtual SEVERITY GetSeverity(int aErrorCode) const
virtual EDA_ITEM * GetItem(const KIID &aId) const
Fetch an item by KIID.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const
Return a user-visible description string of this item.
Definition: eda_item.cpp:108
@ MARKER_DRAWING_SHEET
Definition: marker_base.h:55
#define _(s)
SEVERITY
@ RPT_SEVERITY_WARNING

References _, RC_TREE_NODE::AUX_ITEM, RC_TREE_NODE::AUX_ITEM2, RC_TREE_NODE::AUX_ITEM3, EDA_DRAW_FRAME::GetItem(), EDA_ITEM::GetItemDescription(), EDA_BASE_FRAME::GetSeverity(), m_editFrame, RC_TREE_NODE::m_RcItem, RC_TREE_NODE::m_Type, RC_TREE_NODE::MAIN_ITEM, RC_TREE_NODE::MARKER, MARKER_BASE::MARKER_DRAWING_SHEET, RPT_SEVERITY_EXCLUSION, RPT_SEVERITY_WARNING, and ToNode().

◆ HasContainerColumns()

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

Definition at line 239 of file rc_item.h.

239{ return true; }

◆ IsContainer()

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

Definition at line 302 of file rc_item.cpp.

303{
304 if( ToNode( aItem ) == nullptr ) // must be tree root...
305 return true;
306 else
307 return ToNode( aItem )->m_Type == RC_TREE_NODE::MARKER;
308}

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

◆ NextMarker()

void RC_TREE_MODEL::NextMarker ( )

Definition at line 579 of file rc_item.cpp.

580{
581 RC_TREE_NODE* currentNode = ToNode( m_view->GetCurrentItem() );
582
583 while( currentNode && currentNode->m_Type != RC_TREE_NODE::MARKER )
584 currentNode = currentNode->m_Parent;
585
586 RC_TREE_NODE* nextMarker = nullptr;
587 bool trigger = currentNode == nullptr;
588
589 for( RC_TREE_NODE* candidate : m_tree )
590 {
591 if( candidate == currentNode )
592 {
593 trigger = true;
594 }
595 else if( trigger )
596 {
597 nextMarker = candidate;
598 break;
599 }
600 }
601
602 if( nextMarker )
603 m_view->Select( ToItem( nextMarker ) );
604}
RC_TREE_NODE * m_Parent
Definition: rc_item.h:196

References RC_TREE_NODE::m_Parent, m_tree, RC_TREE_NODE::m_Type, m_view, RC_TREE_NODE::MARKER, ToItem(), and ToNode().

Referenced by DIALOG_ERC::NextMarker(), and DIALOG_DRC::NextMarker().

◆ onSizeView()

void RC_TREE_MODEL::onSizeView ( wxSizeEvent &  aEvent)
protected

Definition at line 633 of file rc_item.cpp.

634{
635 int width = m_view->GetMainWindow()->GetRect().GetWidth() - WX_DATAVIEW_WINDOW_PADDING;
636
637 if( m_view->GetColumnCount() > 0 )
638 m_view->GetColumn( 0 )->SetWidth( width );
639
640 // Pass size event to other widgets
641 aEvent.Skip();
642}
#define WX_DATAVIEW_WINDOW_PADDING
Definition: rc_item.cpp:35

References m_view, and WX_DATAVIEW_WINDOW_PADDING.

Referenced by RC_TREE_MODEL().

◆ PrevMarker()

void RC_TREE_MODEL::PrevMarker ( )

Definition at line 558 of file rc_item.cpp.

559{
560 RC_TREE_NODE* currentNode = ToNode( m_view->GetCurrentItem() );
561 RC_TREE_NODE* prevMarker = nullptr;
562
563 while( currentNode && currentNode->m_Type != RC_TREE_NODE::MARKER )
564 currentNode = currentNode->m_Parent;
565
566 for( RC_TREE_NODE* candidate : m_tree )
567 {
568 if( candidate == currentNode )
569 break;
570 else
571 prevMarker = candidate;
572 }
573
574 if( prevMarker )
575 m_view->Select( ToItem( prevMarker ) );
576}

References RC_TREE_NODE::m_Parent, m_tree, RC_TREE_NODE::m_Type, m_view, RC_TREE_NODE::MARKER, ToItem(), and ToNode().

Referenced by DIALOG_ERC::PrevMarker(), and DIALOG_DRC::PrevMarker().

◆ rebuildModel()

void RC_TREE_MODEL::rebuildModel ( std::shared_ptr< RC_ITEMS_PROVIDER aProvider,
int  aSeverities 
)
protected

Definition at line 196 of file rc_item.cpp.

197{
198 wxWindowUpdateLocker updateLock( m_view );
199
200 std::shared_ptr<RC_ITEM> selectedRcItem = nullptr;
201
202 if( m_view )
203 {
204 RC_TREE_NODE* selectedNode = ToNode( m_view->GetSelection() );
205 selectedRcItem = selectedNode ? selectedNode->m_RcItem : nullptr;
206
207 // Even with the updateLock, wxWidgets sometimes ties its knickers in a knot trying
208 // to run a wxdataview_selection_changed_callback() on a row that has been deleted.
209 m_view->UnselectAll();
210 }
211
212 BeforeReset();
213
214 m_rcItemsProvider = aProvider;
215
216 if( aSeverities != m_severities )
217 m_severities = aSeverities;
218
220 m_rcItemsProvider->SetSeverities( m_severities );
221
222 for( RC_TREE_NODE* topLevelNode : m_tree )
223 delete topLevelNode;
224
225 m_tree.clear();
226
227 // wxDataView::ExpandAll() pukes with large lists
228 int count = 0;
229
231 count = std::min( 1000, m_rcItemsProvider->GetCount() );
232
233 for( int i = 0; i < count; ++i )
234 {
235 std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
236
237 m_tree.push_back( new RC_TREE_NODE( nullptr, rcItem, RC_TREE_NODE::MARKER ) );
238 RC_TREE_NODE* n = m_tree.back();
239
240 if( rcItem->GetMainItemID() != niluuid )
241 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::MAIN_ITEM ) );
242
243 if( rcItem->GetAuxItemID() != niluuid )
244 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM ) );
245
246 if( rcItem->GetAuxItem2ID() != niluuid )
247 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM2 ) );
248
249 if( rcItem->GetAuxItem3ID() != niluuid )
250 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM3 ) );
251 }
252
253 // Must be called after a significant change of items to force the
254 // wxDataViewModel to reread all of them, repopulating itself entirely.
255 AfterReset();
256
257#ifdef __WXGTK__
258 // The fastest method to update wxDataViewCtrl is to rebuild from
259 // scratch by calling Cleared(). Linux requires to reassociate model to
260 // display data, but Windows will create multiple associations.
261 // On MacOS, this crashes KiCad. See https://gitlab.com/kicad/code/kicad/issues/3666
262 // and https://gitlab.com/kicad/code/kicad/issues/3653
263 m_view->AssociateModel( this );
264#endif
265
266 m_view->ClearColumns();
267 int width = m_view->GetMainWindow()->GetRect().GetWidth() - WX_DATAVIEW_WINDOW_PADDING;
268 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
269
270 ExpandAll();
271
272 // Most annoyingly wxWidgets won't tell us the scroll position (and no, all the usual
273 // routines don't work), so we can only restore the scroll position based on a selection.
274 if( selectedRcItem )
275 {
276 for( RC_TREE_NODE* candidate : m_tree )
277 {
278 if( candidate->m_RcItem == selectedRcItem )
279 {
280 m_view->Select( ToItem( candidate ) );
281 m_view->EnsureVisible( ToItem( candidate ) );
282 break;
283 }
284 }
285 }
286}
void ExpandAll()
Definition: rc_item.cpp:295
KIID niluuid(0)

References RC_TREE_NODE::AUX_ITEM, RC_TREE_NODE::AUX_ITEM2, RC_TREE_NODE::AUX_ITEM3, ExpandAll(), 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, ToItem(), ToNode(), and WX_DATAVIEW_WINDOW_PADDING.

Referenced by Update().

◆ SelectMarker()

void RC_TREE_MODEL::SelectMarker ( const MARKER_BASE aMarker)

Definition at line 607 of file rc_item.cpp.

608{
609 for( RC_TREE_NODE* candidate : m_tree )
610 {
611 if( candidate->m_RcItem->GetParent() == aMarker )
612 {
613 m_view->Select( ToItem( candidate ) );
614 return;
615 }
616 }
617}

References m_tree, m_view, and ToItem().

Referenced by DIALOG_ERC::ExcludeMarker(), DIALOG_DRC::SelectMarker(), DIALOG_FOOTPRINT_CHECKER::SelectMarker(), and DIALOG_ERC::SelectMarker().

◆ 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 250 of file rc_item.h.

252 {
253 // Editing not supported
254 return false;
255 }

◆ ToItem()

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

Definition at line 204 of file rc_item.h.

205 {
206 return wxDataViewItem( const_cast<void*>( static_cast<void const*>( aNode ) ) );
207 }

Referenced by CenterMarker(), DeleteItems(), ExpandAll(), GetChildren(), GetParent(), NextMarker(), PrevMarker(), rebuildModel(), SelectMarker(), and ValueChanged().

◆ ToNode()

◆ ToUUID()

KIID RC_TREE_MODEL::ToUUID ( wxDataViewItem  aItem)
static

Definition at line 149 of file rc_item.cpp.

150{
151 const RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aItem );
152
153 if( node && node->m_RcItem )
154 {
155 const std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
156
157 switch( node->m_Type )
158 {
160 // rc_item->GetParent() can be null, if the parent is not existing
161 // when a RC item has no corresponding ERC/DRC marker
162 if( rc_item->GetParent() )
163 return rc_item->GetParent()->GetUUID();
164
165 break;
166
167 case RC_TREE_NODE::MAIN_ITEM: return rc_item->GetMainItemID();
168 case RC_TREE_NODE::AUX_ITEM: return rc_item->GetAuxItemID();
169 case RC_TREE_NODE::AUX_ITEM2: return rc_item->GetAuxItem2ID();
170 case RC_TREE_NODE::AUX_ITEM3: return rc_item->GetAuxItem3ID();
171 }
172 }
173
174 return niluuid;
175}

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(), DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem(), and DIALOG_FOOTPRINT_CHECKER::OnSelectItem().

◆ Update()

void RC_TREE_MODEL::Update ( std::shared_ptr< RC_ITEMS_PROVIDER aProvider,
int  aSeverities 
)

◆ ValueChanged()

void RC_TREE_MODEL::ValueChanged ( const RC_TREE_NODE aNode)

Definition at line 446 of file rc_item.cpp.

447{
449 {
450 ValueChanged( aNode->m_Parent );
451 }
452
453 if( aNode->m_Type == RC_TREE_NODE::MARKER )
454 {
455 wxDataViewModel::ValueChanged( ToItem( aNode ), 0 );
456
457 for( const RC_TREE_NODE* child : aNode->m_Children )
458 wxDataViewModel::ValueChanged( ToItem( child ), 0 );
459 }
460}
void ValueChanged(const RC_TREE_NODE *aNode)
Definition: rc_item.cpp:446

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, ToItem(), and ValueChanged().

Referenced by DIALOG_DRC::ExcludeMarker(), DIALOG_ERC::ExcludeMarker(), and ValueChanged().

Member Data Documentation

◆ m_editFrame

EDA_DRAW_FRAME* RC_TREE_MODEL::m_editFrame
protected

Definition at line 278 of file rc_item.h.

Referenced by ERC_TREE_MODEL::GetValue(), and GetValue().

◆ m_rcItemsProvider

std::shared_ptr<RC_ITEMS_PROVIDER> RC_TREE_MODEL::m_rcItemsProvider
protected

Definition at line 281 of file rc_item.h.

Referenced by DeleteItems(), and rebuildModel().

◆ m_severities

int RC_TREE_MODEL::m_severities
protected

Definition at line 280 of file rc_item.h.

Referenced by rebuildModel().

◆ m_tree

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

◆ m_view

wxDataViewCtrl* RC_TREE_MODEL::m_view
protected

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