KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rc_item.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25#include <wx/wupdlock.h>
26#include <wx/dataview.h>
27#include <wx/settings.h>
28#include <widgets/ui_common.h>
29#include <marker_base.h>
30#include <eda_draw_frame.h>
31#include <rc_item.h>
32#include <rc_json_schema.h>
33#include <eda_item.h>
34#include <base_units.h>
35
36#define WX_DATAVIEW_WINDOW_PADDING 6
37
38
40{
41 if( m_errorMessage.IsEmpty() )
42 return GetErrorText();
43 else
44 return m_errorMessage;
45}
46
47
48static wxString showCoord( UNITS_PROVIDER* aUnitsProvider, const VECTOR2I& aPos )
49{
50 return wxString::Format( wxT( "@(%s, %s)" ),
51 aUnitsProvider->MessageTextFromValue( aPos.x ),
52 aUnitsProvider->MessageTextFromValue( aPos.y ) );
53}
54
55
57{
58 m_ids.push_back( aItem->m_Uuid );
59}
60
61
62void RC_ITEM::SetItems( const EDA_ITEM* aItem, const EDA_ITEM* bItem,
63 const EDA_ITEM* cItem, const EDA_ITEM* dItem )
64{
65 m_ids.clear();
66
67 if( aItem )
68 m_ids.push_back( aItem->m_Uuid );
69
70 if( bItem )
71 m_ids.push_back( bItem->m_Uuid );
72
73 if( cItem )
74 m_ids.push_back( cItem->m_Uuid );
75
76 if( dItem )
77 m_ids.push_back( dItem->m_Uuid );
78}
79
80
82{
83 wxString severity;
84
85 switch( aSeverity )
86 {
87 case RPT_SEVERITY_ERROR: severity = wxS( "error" ); break;
88 case RPT_SEVERITY_WARNING: severity = wxS( "warning" ); break;
89 case RPT_SEVERITY_ACTION: severity = wxS( "action" ); break;
90 case RPT_SEVERITY_INFO: severity = wxS( "info" ); break;
91 case RPT_SEVERITY_EXCLUSION: severity = wxS( "exclusion" ); break;
92 case RPT_SEVERITY_DEBUG: severity = wxS( "debug" ); break;
93 default:;
94 };
95
96 return severity;
97}
98
99
100wxString RC_ITEM::ShowReport( UNITS_PROVIDER* aUnitsProvider, SEVERITY aSeverity,
101 const std::map<KIID, EDA_ITEM*>& aItemMap ) const
102{
103 wxString severity = getSeverityString( aSeverity );
104
105 if( m_parent && m_parent->IsExcluded() )
106 severity += wxT( " (excluded)" );
107
108 EDA_ITEM* mainItem = nullptr;
109 EDA_ITEM* auxItem = nullptr;
110
111 auto ii = aItemMap.find( GetMainItemID() );
112
113 if( ii != aItemMap.end() )
114 mainItem = ii->second;
115
116 ii = aItemMap.find( GetAuxItemID() );
117
118 if( ii != aItemMap.end() )
119 auxItem = ii->second;
120
121 // Note: some customers machine-process these. So:
122 // 1) don't translate
123 // 2) try not to re-order or change syntax
124 // 3) report settings key (which should be more stable) in addition to message
125
126 wxString msg;
127
128 if( mainItem && auxItem )
129 {
130 msg.Printf( wxT( "[%s]: %s\n %s; %s\n %s: %s\n %s: %s\n" ),
134 severity,
135 showCoord( aUnitsProvider, mainItem->GetPosition()),
136 mainItem->GetItemDescription( aUnitsProvider, true ),
137 showCoord( aUnitsProvider, auxItem->GetPosition()),
138 auxItem->GetItemDescription( aUnitsProvider, true ) );
139 }
140 else if( mainItem )
141 {
142 msg.Printf( wxT( "[%s]: %s\n %s; %s\n %s: %s\n" ),
146 severity,
147 showCoord( aUnitsProvider, mainItem->GetPosition()),
148 mainItem->GetItemDescription( aUnitsProvider, true ) );
149 }
150 else
151 {
152 msg.Printf( wxT( "[%s]: %s\n %s; %s\n" ),
156 severity );
157 }
158
159 if( m_parent && m_parent->IsExcluded() && !m_parent->GetComment().IsEmpty() )
160 msg += wxString::Format( wxS( " %s\n" ), m_parent->GetComment() );
161
162 return msg;
163}
164
165
167 SEVERITY aSeverity,
168 const std::map<KIID, EDA_ITEM*>& aItemMap ) const
169{
170 wxString severity = getSeverityString( aSeverity );
171
172 aViolation.severity = severity;
173 aViolation.description = GetErrorMessage();
174 aViolation.type = GetSettingsKey();
175 aViolation.excluded = ( m_parent && m_parent->IsExcluded() );
176
177 EDA_ITEM* mainItem = nullptr;
178 EDA_ITEM* auxItem = nullptr;
179
180 auto ii = aItemMap.find( GetMainItemID() );
181
182 if( ii != aItemMap.end() )
183 mainItem = ii->second;
184
185 ii = aItemMap.find( GetAuxItemID() );
186
187 if( ii != aItemMap.end() )
188 auxItem = ii->second;
189
190 if( mainItem )
191 {
193 item.description = mainItem->GetItemDescription( aUnitsProvider, true );
194 item.uuid = mainItem->m_Uuid.AsString();
195 item.pos.x = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
196 aUnitsProvider->GetUserUnits(),
197 mainItem->GetPosition().x );
198 item.pos.y = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
199 aUnitsProvider->GetUserUnits(),
200 mainItem->GetPosition().y );
201 aViolation.items.emplace_back( item );
202 }
203
204 if( auxItem )
205 {
207 item.description = auxItem->GetItemDescription( aUnitsProvider, true );
208 item.uuid = auxItem->m_Uuid.AsString();
209 item.pos.x = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
210 aUnitsProvider->GetUserUnits(),
211 auxItem->GetPosition().x );
212 item.pos.y = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
213 aUnitsProvider->GetUserUnits(),
214 auxItem->GetPosition().y );
215 aViolation.items.emplace_back( item );
216 }
217}
218
219
220KIID RC_TREE_MODEL::ToUUID( wxDataViewItem aItem )
221{
222 const RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aItem );
223
224 if( node && node->m_RcItem )
225 {
226 const std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
227
228 switch( node->m_Type )
229 {
232 // rc_item->GetParent() can be null, if the parent is not existing
233 // when a RC item has no corresponding ERC/DRC marker
234 if( rc_item->GetParent() )
235 return rc_item->GetParent()->GetUUID();
236
237 break;
238
239 case RC_TREE_NODE::MAIN_ITEM: return rc_item->GetMainItemID();
240 case RC_TREE_NODE::AUX_ITEM: return rc_item->GetAuxItemID();
241 case RC_TREE_NODE::AUX_ITEM2: return rc_item->GetAuxItem2ID();
242 case RC_TREE_NODE::AUX_ITEM3: return rc_item->GetAuxItem3ID();
243 }
244 }
245
246 return niluuid;
247}
248
249
250RC_TREE_MODEL::RC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView ) :
251 m_editFrame( aParentFrame ),
252 m_view( aView ),
253 m_severities( 0 ),
254 m_rcItemsProvider( nullptr )
255{
256}
257
258
260{
261 for( RC_TREE_NODE* topLevelNode : m_tree )
262 delete topLevelNode;
263}
264
265
266void RC_TREE_MODEL::rebuildModel( std::shared_ptr<RC_ITEMS_PROVIDER> aProvider, int aSeverities )
267{
268 wxWindowUpdateLocker updateLock( m_view );
269
270 std::shared_ptr<RC_ITEM> selectedRcItem = nullptr;
271
272 if( m_view )
273 {
274 RC_TREE_NODE* selectedNode = ToNode( m_view->GetSelection() );
275 selectedRcItem = selectedNode ? selectedNode->m_RcItem : nullptr;
276
277 // Even with the updateLock, wxWidgets sometimes ties its knickers in a knot trying
278 // to run a wxdataview_selection_changed_callback() on a row that has been deleted.
279 m_view->UnselectAll();
280 }
281
282 BeforeReset();
283
284 m_rcItemsProvider = std::move( aProvider );
285
286 if( aSeverities != m_severities )
287 m_severities = aSeverities;
288
290 m_rcItemsProvider->SetSeverities( m_severities );
291
292 for( RC_TREE_NODE* topLevelNode : m_tree )
293 delete topLevelNode;
294
295 m_tree.clear();
296
297 // wxDataView::ExpandAll() pukes with large lists
298 int count = 0;
299
301 count = std::min( 1000, m_rcItemsProvider->GetCount() );
302
303 for( int i = 0; i < count; ++i )
304 {
305 std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
306
307 m_tree.push_back( new RC_TREE_NODE( nullptr, rcItem, RC_TREE_NODE::MARKER ) );
308 RC_TREE_NODE* n = m_tree.back();
309
310 if( rcItem->GetMainItemID() != niluuid )
311 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::MAIN_ITEM ) );
312
313 if( rcItem->GetAuxItemID() != niluuid )
314 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM ) );
315
316 if( rcItem->GetAuxItem2ID() != niluuid )
317 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM2 ) );
318
319 if( rcItem->GetAuxItem3ID() != niluuid )
320 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM3 ) );
321
322 if( MARKER_BASE* marker = rcItem->GetParent() )
323 {
324 if( marker->IsExcluded() && !marker->GetComment().IsEmpty() )
325 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::COMMENT ) );
326 }
327 }
328
329 // Must be called after a significant change of items to force the
330 // wxDataViewModel to reread all of them, repopulating itself entirely.
331 AfterReset();
332
333#ifdef __WXGTK__
334 // The fastest method to update wxDataViewCtrl is to rebuild from
335 // scratch by calling Cleared(). Linux requires to reassociate model to
336 // display data, but Windows will create multiple associations.
337 // On MacOS, this crashes KiCad. See https://gitlab.com/kicad/code/kicad/-/issues/3666
338 // and https://gitlab.com/kicad/code/kicad/-/issues/3653
339 m_view->AssociateModel( this );
340#endif
341
342 m_view->ClearColumns();
343 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE );
344
345 ExpandAll();
346
347 // Most annoyingly wxWidgets won't tell us the scroll position (and no, all the usual
348 // routines don't work), so we can only restore the scroll position based on a selection.
349 if( selectedRcItem )
350 {
351 for( RC_TREE_NODE* candidate : m_tree )
352 {
353 if( candidate->m_RcItem == selectedRcItem )
354 {
355 m_view->Select( ToItem( candidate ) );
356 m_view->EnsureVisible( ToItem( candidate ) );
357 break;
358 }
359 }
360 }
361}
362
363
364void RC_TREE_MODEL::Update( std::shared_ptr<RC_ITEMS_PROVIDER> aProvider, int aSeverities )
365{
366 rebuildModel( aProvider, aSeverities );
367}
368
369
371{
372 for( RC_TREE_NODE* topLevelNode : m_tree )
373 m_view->Expand( ToItem( topLevelNode ) );
374}
375
376
377bool RC_TREE_MODEL::IsContainer( wxDataViewItem const& aItem ) const
378{
379 if( ToNode( aItem ) == nullptr ) // must be tree root...
380 return true;
381 else
382 return ToNode( aItem )->m_Type == RC_TREE_NODE::MARKER;
383}
384
385
386wxDataViewItem RC_TREE_MODEL::GetParent( wxDataViewItem const& aItem ) const
387{
388 return ToItem( ToNode( aItem)->m_Parent );
389}
390
391
392unsigned int RC_TREE_MODEL::GetChildren( wxDataViewItem const& aItem,
393 wxDataViewItemArray& aChildren ) const
394{
395 const RC_TREE_NODE* node = ToNode( aItem );
396 const std::vector<RC_TREE_NODE*>& children = node ? node->m_Children : m_tree;
397
398 for( const RC_TREE_NODE* child: children )
399 aChildren.push_back( ToItem( child ) );
400
401 return children.size();
402}
403
404
405void RC_TREE_MODEL::GetValue( wxVariant& aVariant,
406 wxDataViewItem const& aItem,
407 unsigned int aCol ) const
408{
409 const RC_TREE_NODE* node = ToNode( aItem );
410 const std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
411 MARKER_BASE* marker = rcItem->GetParent();
412 EDA_ITEM* item = nullptr;
413 wxString msg;
414
415 switch( node->m_Type )
416 {
418 if( marker )
419 {
420 SEVERITY severity = marker->GetSeverity();
421
422 if( severity == RPT_SEVERITY_EXCLUSION )
423 {
424 if( m_editFrame->GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
425 msg = _( "Excluded warning: " );
426 else
427 msg = _( "Excluded error: " );
428 }
429 else if( severity == RPT_SEVERITY_WARNING )
430 {
431 msg = _( "Warning: " );
432 }
433 else
434 {
435 msg = _( "Error: " );
436 }
437 }
438
439 msg += rcItem->GetErrorMessage();
440 break;
441
443 if( marker && marker->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
444 msg = _( "Drawing Sheet" );
445 else
446 item = m_editFrame->GetItem( rcItem->GetMainItemID() );
447
448 break;
449
451 item = m_editFrame->GetItem( rcItem->GetAuxItemID() );
452 break;
453
455 item = m_editFrame->GetItem( rcItem->GetAuxItem2ID() );
456 break;
457
459 item = m_editFrame->GetItem( rcItem->GetAuxItem3ID() );
460 break;
461
463 if( marker )
464 msg = marker->GetComment();
465
466 break;
467 }
468
469 if( item )
470 msg += item->GetItemDescription( m_editFrame, true );
471
472 msg.Replace( wxS( "\n" ), wxS( " " ) );
473 aVariant = msg;
474}
475
476
477bool RC_TREE_MODEL::GetAttr( wxDataViewItem const& aItem,
478 unsigned int aCol,
479 wxDataViewItemAttr& aAttr ) const
480{
481 const RC_TREE_NODE* node = ToNode( aItem );
482 wxASSERT( node );
483
484 bool ret = false;
485 bool heading = node->m_Type == RC_TREE_NODE::MARKER;
486
487 if( heading )
488 {
489 aAttr.SetBold( true );
490 ret = true;
491 }
492
493 if( node->m_RcItem->GetParent()
494 && node->m_RcItem->GetParent()->GetSeverity() == RPT_SEVERITY_EXCLUSION )
495 {
496 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
497 double brightness = KIGFX::COLOR4D( textColour ).GetBrightness();
498
499 if( brightness > 0.5 )
500 {
501 int lightness = static_cast<int>( brightness * ( heading ? 50 : 60 ) );
502 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
503 }
504 else
505 {
506 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
507 }
508
509 aAttr.SetItalic( true ); // Strikethrough would be better, if wxWidgets supported it
510 ret = true;
511 }
512
513 return ret;
514}
515
516
518{
519 if( aNode->m_Type != RC_TREE_NODE::MARKER )
520 {
521 ValueChanged( aNode->m_Parent );
522 return;
523 }
524
525 wxDataViewItem markerItem = ToItem( aNode );
526
527 wxDataViewModel::ValueChanged( markerItem, 0 );
528
529 for( const RC_TREE_NODE* child : aNode->m_Children )
530 wxDataViewModel::ValueChanged( ToItem( child ), 0 );
531
532 // Comment items can come and go depening on exclusion state and comment content.
533 //
534 const std::shared_ptr<RC_ITEM> rcItem = aNode->m_RcItem;
535 MARKER_BASE* marker = rcItem ? rcItem->GetParent() : nullptr;
536
537 if( marker )
538 {
539 bool needsCommentNode = marker->IsExcluded() && !marker->GetComment().IsEmpty();
540 RC_TREE_NODE* commentNode = aNode->m_Children.back();
541
542 if( commentNode && commentNode->m_Type != RC_TREE_NODE::COMMENT )
543 commentNode = nullptr;
544
545 if( needsCommentNode && !commentNode )
546 {
547 commentNode = new RC_TREE_NODE( aNode, rcItem, RC_TREE_NODE::COMMENT );
548 wxDataViewItemArray newItems;
549 newItems.push_back( ToItem( commentNode ) );
550
551 aNode->m_Children.push_back( commentNode );
552 ItemsAdded( markerItem, newItems );
553 }
554 else if( commentNode && !needsCommentNode )
555 {
556 wxDataViewItemArray deletedItems;
557 deletedItems.push_back( ToItem( commentNode ) );
558
559 aNode->m_Children.erase( aNode->m_Children.end() - 1 );
560 ItemsDeleted( markerItem, deletedItems );
561 }
562 }
563}
564
565
567{
568 DeleteItems( true, true, aDeep );
569}
570
571
572void RC_TREE_MODEL::DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, bool aDeep )
573{
574 RC_TREE_NODE* current_node = m_view ? ToNode( m_view->GetCurrentItem() ) : nullptr;
575 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->m_RcItem : nullptr;
576
578 std::vector<RC_TREE_NODE*> to_delete;
579 std::vector<RC_TREE_NODE*> expanded;
580
581 if( aCurrentOnly && !current_item )
582 {
583 wxBell();
584 return;
585 }
586
587 // wxWidgets 3.1.x on MacOS (at least) loses the expanded state of the tree when deleting
588 // items.
589 if( m_view && aCurrentOnly )
590 {
591 for( RC_TREE_NODE* node : m_tree )
592 {
593 if( m_view->IsExpanded( ToItem( node ) ) )
594 expanded.push_back( node );
595 }
596 }
597
598 int lastGood = -1;
599 bool itemDeleted = false;
600
601 if( m_view )
602 {
603 m_view->UnselectAll();
604 wxSafeYield();
605 m_view->Freeze();
606 }
607
608 if( !m_rcItemsProvider )
609 return;
610
611 for( int i = m_rcItemsProvider->GetCount() - 1; i >= 0; --i )
612 {
613 std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
614 MARKER_BASE* marker = rcItem->GetParent();
615 bool excluded = false;
616
617 if( marker && marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
618 excluded = true;
619
620 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
621 break;
622
623 if( aCurrentOnly && rcItem != current_item )
624 {
625 lastGood = i;
626 continue;
627 }
628
629 if( excluded && !aIncludeExclusions )
630 continue;
631
632 if( i < (int) m_tree.size() ) // Careful; tree is truncated for large datasets
633 {
634 wxDataViewItem markerItem = ToItem( m_tree[i] );
635 wxDataViewItemArray childItems;
636 wxDataViewItem parentItem = ToItem( m_tree[i]->m_Parent );
637
638 for( RC_TREE_NODE* child : m_tree[i]->m_Children )
639 {
640 childItems.push_back( ToItem( child ) );
641 to_delete.push_back( child );
642 }
643
644 m_tree[i]->m_Children.clear();
645 ItemsDeleted( markerItem, childItems );
646
647 to_delete.push_back( m_tree[i] );
648 m_tree.erase( m_tree.begin() + i );
649 ItemDeleted( parentItem, markerItem );
650 }
651
652 // Only deep delete the current item here; others will be done by the caller, which
653 // can more efficiently delete all markers on the board.
654 m_rcItemsProvider->DeleteItem( i, aDeep && aCurrentOnly );
655
656 if( lastGood > i )
657 lastGood--;
658
659 itemDeleted = true;
660 }
661
662 if( m_view && aCurrentOnly && lastGood >= 0 )
663 {
664 for( RC_TREE_NODE* node : expanded )
665 {
666 wxDataViewItem item = ToItem( node );
667
668 if( item.IsOk() )
669 m_view->Expand( item );
670 }
671
672 wxDataViewItem selItem = ToItem( m_tree[ lastGood ] );
673 m_view->Select( selItem );
674
675 // wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED doesn't get propogated from the Select()
676 // call on (at least) MSW.
677 wxDataViewEvent selectEvent( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, m_view, selItem );
678 m_view->GetEventHandler()->ProcessEvent( selectEvent );
679 }
680
681 for( RC_TREE_NODE* item : to_delete )
682 delete( item );
683
684 if( m_view )
685 m_view->Thaw();
686}
687
688
690{
691 RC_TREE_NODE* currentNode = ToNode( m_view->GetCurrentItem() );
692 RC_TREE_NODE* prevMarker = nullptr;
693
694 while( currentNode && currentNode->m_Type != RC_TREE_NODE::MARKER )
695 currentNode = currentNode->m_Parent;
696
697 for( RC_TREE_NODE* candidate : m_tree )
698 {
699 if( candidate == currentNode )
700 break;
701 else
702 prevMarker = candidate;
703 }
704
705 if( prevMarker )
706 m_view->Select( ToItem( prevMarker ) );
707}
708
709
711{
712 RC_TREE_NODE* currentNode = ToNode( m_view->GetCurrentItem() );
713
714 while( currentNode && currentNode->m_Type != RC_TREE_NODE::MARKER )
715 currentNode = currentNode->m_Parent;
716
717 RC_TREE_NODE* nextMarker = nullptr;
718 bool trigger = currentNode == nullptr;
719
720 for( RC_TREE_NODE* candidate : m_tree )
721 {
722 if( candidate == currentNode )
723 {
724 trigger = true;
725 }
726 else if( trigger )
727 {
728 nextMarker = candidate;
729 break;
730 }
731 }
732
733 if( nextMarker )
734 m_view->Select( ToItem( nextMarker ) );
735}
736
737
739{
740 for( RC_TREE_NODE* candidate : m_tree )
741 {
742 if( candidate->m_RcItem->GetParent() == aMarker )
743 {
744 m_view->Select( ToItem( candidate ) );
745 return;
746 }
747 }
748}
749
750
752{
753 for( RC_TREE_NODE* candidate : m_tree )
754 {
755 if( candidate->m_RcItem->GetParent() == aMarker )
756 {
757 m_view->EnsureVisible( ToItem( candidate ) );
758 return;
759 }
760 }
761}
virtual SEVERITY GetSeverity(int aErrorCode) const
The base class for create windows for drawing purpose.
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:89
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:243
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const
Return a user-visible description string of this item.
Definition: eda_item.cpp:111
const KIID m_Uuid
Definition: eda_item.h:489
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:333
Definition: kiid.h:49
wxString AsString() const
Definition: kiid.cpp:246
virtual SEVERITY GetSeverity() const
Definition: marker_base.h:107
bool IsExcluded() const
Definition: marker_base.h:98
@ MARKER_DRAWING_SHEET
Definition: marker_base.h:56
enum MARKER_T GetMarkerType() const
Definition: marker_base.h:96
wxString GetComment() const
Definition: marker_base.h:105
virtual void GetJsonViolation(RC_JSON::VIOLATION &aViolation, UNITS_PROVIDER *aUnitsProvider, SEVERITY aSeverity, const std::map< KIID, EDA_ITEM * > &aItemMap) const
Translate this object into an RC_JSON::VIOLATION object.
Definition: rc_item.cpp:166
static wxString getSeverityString(SEVERITY aSeverity)
Definition: rc_item.cpp:81
void AddItem(EDA_ITEM *aItem)
Definition: rc_item.cpp:56
MARKER_BASE * m_parent
The marker this item belongs to, if any.
Definition: rc_item.h:188
KIIDS m_ids
Definition: rc_item.h:190
virtual KIID GetMainItemID() const
Definition: rc_item.h:121
virtual KIID GetAuxItemID() const
Definition: rc_item.h:122
wxString GetErrorText() const
Definition: rc_item.h:166
virtual wxString ShowReport(UNITS_PROVIDER *aUnitsProvider, SEVERITY aSeverity, const std::map< KIID, EDA_ITEM * > &aItemMap) const
Translate this object into a text string suitable for saving to disk in a report.
Definition: rc_item.cpp:100
virtual wxString GetErrorMessage() const
Definition: rc_item.cpp:39
wxString m_errorMessage
A message describing the details of this specific error.
Definition: rc_item.h:185
wxString GetSettingsKey() const
Definition: rc_item.h:171
virtual wxString GetViolatingRuleDesc() const
Definition: rc_item.h:176
void SetItems(const KIIDS &aIds)
Definition: rc_item.h:103
void ExpandAll()
Definition: rc_item.cpp:370
void PrevMarker()
Definition: rc_item.cpp:689
int m_severities
Definition: rc_item.h:306
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
Called by the wxDataView to fetch an item's value.
Definition: rc_item.cpp:405
std::vector< RC_TREE_NODE * > m_tree
Definition: rc_item.h:309
unsigned int GetChildren(wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override
Definition: rc_item.cpp:392
EDA_DRAW_FRAME * m_editFrame
Definition: rc_item.h:304
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition: rc_item.h:231
void SelectMarker(const MARKER_BASE *aMarker)
Definition: rc_item.cpp:738
RC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
Definition: rc_item.cpp:250
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:236
void ValueChanged(RC_TREE_NODE *aNode)
Definition: rc_item.cpp:517
void Update(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
Definition: rc_item.cpp:364
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
Called by the wxDataView to fetch an item's formatting.
Definition: rc_item.cpp:477
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
Definition: rc_item.cpp:572
void DeleteCurrentItem(bool aDeep)
Definition: rc_item.cpp:566
wxDataViewItem GetParent(wxDataViewItem const &aItem) const override
Definition: rc_item.cpp:386
void CenterMarker(const MARKER_BASE *aMarker)
Definition: rc_item.cpp:751
static KIID ToUUID(wxDataViewItem aItem)
Definition: rc_item.cpp:220
wxDataViewCtrl * m_view
Definition: rc_item.h:305
std::shared_ptr< RC_ITEMS_PROVIDER > m_rcItemsProvider
Definition: rc_item.h:307
void NextMarker()
Definition: rc_item.cpp:710
bool IsContainer(wxDataViewItem const &aItem) const override
Definition: rc_item.cpp:377
void rebuildModel(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
Definition: rc_item.cpp:266
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:221
RC_TREE_NODE * m_Parent
Definition: rc_item.h:223
std::vector< RC_TREE_NODE * > m_Children
Definition: rc_item.h:224
NODE_TYPE m_Type
Definition: rc_item.h:220
const EDA_IU_SCALE & GetIuScale() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
#define _(s)
KIID niluuid(0)
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: eda_units.cpp:259
static wxString showCoord(UNITS_PROVIDER *aUnitsProvider, const VECTOR2I &aPos)
Definition: rc_item.cpp:48
SEVERITY
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_EXCLUSION
@ RPT_SEVERITY_DEBUG
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
std::vector< AFFECTED_ITEM > items
Functions to provide common constants and other functions to assist in making a consistent UI.