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 The 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
39wxString RC_ITEM::GetErrorMessage( bool aTranslate ) const
40{
41 if( m_errorMessage.IsEmpty() )
42 return GetErrorText( aTranslate );
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" ),
132 GetErrorMessage( false ),
133 GetViolatingRuleDesc( false ),
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" ),
144 GetErrorMessage( false ),
145 GetViolatingRuleDesc( false ),
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" ),
154 GetErrorMessage( false ),
155 GetViolatingRuleDesc( false ),
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, const std::map<KIID, EDA_ITEM*>& aItemMap ) const
168{
169 aViolation.severity = getSeverityString( aSeverity );
170 aViolation.description = GetErrorMessage( false );
171 aViolation.type = GetSettingsKey();
172
173 if( m_parent && m_parent->IsExcluded() )
174 {
175 aViolation.excluded = true;
176 aViolation.comment = m_parent->GetComment();
177 }
178 else
179 {
180 aViolation.excluded = false;
181 }
182
183 EDA_ITEM* mainItem = nullptr;
184 EDA_ITEM* auxItem = nullptr;
185
186 auto ii = aItemMap.find( GetMainItemID() );
187
188 if( ii != aItemMap.end() )
189 mainItem = ii->second;
190
191 ii = aItemMap.find( GetAuxItemID() );
192
193 if( ii != aItemMap.end() )
194 auxItem = ii->second;
195
196 if( mainItem )
197 {
199 item.description = mainItem->GetItemDescription( aUnitsProvider, true );
200 item.uuid = mainItem->m_Uuid.AsString();
201 item.pos.x = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
202 aUnitsProvider->GetUserUnits(),
203 mainItem->GetPosition().x );
204 item.pos.y = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
205 aUnitsProvider->GetUserUnits(),
206 mainItem->GetPosition().y );
207 aViolation.items.emplace_back( item );
208 }
209
210 if( auxItem )
211 {
213 item.description = auxItem->GetItemDescription( aUnitsProvider, true );
214 item.uuid = auxItem->m_Uuid.AsString();
215 item.pos.x = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
216 aUnitsProvider->GetUserUnits(),
217 auxItem->GetPosition().x );
218 item.pos.y = EDA_UNIT_UTILS::UI::ToUserUnit( aUnitsProvider->GetIuScale(),
219 aUnitsProvider->GetUserUnits(),
220 auxItem->GetPosition().y );
221 aViolation.items.emplace_back( item );
222 }
223}
224
225
226KIID RC_TREE_MODEL::ToUUID( wxDataViewItem aItem )
227{
228 const RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aItem );
229
230 if( node && node->m_RcItem )
231 {
232 const std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
233
234 switch( node->m_Type )
235 {
238 // rc_item->GetParent() can be null, if the parent is not existing
239 // when a RC item has no corresponding ERC/DRC marker
240 if( rc_item->GetParent() )
241 return rc_item->GetParent()->GetUUID();
242
243 break;
244
245 case RC_TREE_NODE::MAIN_ITEM: return rc_item->GetMainItemID();
246 case RC_TREE_NODE::AUX_ITEM: return rc_item->GetAuxItemID();
247 case RC_TREE_NODE::AUX_ITEM2: return rc_item->GetAuxItem2ID();
248 case RC_TREE_NODE::AUX_ITEM3: return rc_item->GetAuxItem3ID();
249 }
250 }
251
252 return niluuid;
253}
254
255
256RC_TREE_MODEL::RC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView ) :
257 m_editFrame( aParentFrame ),
258 m_view( aView ),
259 m_severities( 0 ),
260 m_rcItemsProvider( nullptr )
261{
262}
263
264
266{
267 for( RC_TREE_NODE* topLevelNode : m_tree )
268 delete topLevelNode;
269}
270
271
272void RC_TREE_MODEL::rebuildModel( std::shared_ptr<RC_ITEMS_PROVIDER> aProvider, int aSeverities )
273{
274 wxWindowUpdateLocker updateLock( m_view );
275
276 std::shared_ptr<RC_ITEM> selectedRcItem = nullptr;
277
278 if( m_view )
279 {
280 RC_TREE_NODE* selectedNode = ToNode( m_view->GetSelection() );
281 selectedRcItem = selectedNode ? selectedNode->m_RcItem : nullptr;
282
283 // Even with the updateLock, wxWidgets sometimes ties its knickers in a knot trying
284 // to run a wxdataview_selection_changed_callback() on a row that has been deleted.
285 m_view->UnselectAll();
286 }
287
288 BeforeReset();
289
290 m_rcItemsProvider = std::move( aProvider );
291
292 if( aSeverities != m_severities )
293 m_severities = aSeverities;
294
296 m_rcItemsProvider->SetSeverities( m_severities );
297
298 for( RC_TREE_NODE* topLevelNode : m_tree )
299 delete topLevelNode;
300
301 m_tree.clear();
302
303 // wxDataView::ExpandAll() pukes with large lists
304 int count = 0;
305
307 count = std::min( 1000, m_rcItemsProvider->GetCount() );
308
309 for( int i = 0; i < count; ++i )
310 {
311 std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
312
313 m_tree.push_back( new RC_TREE_NODE( nullptr, rcItem, RC_TREE_NODE::MARKER ) );
314 RC_TREE_NODE* n = m_tree.back();
315
316 if( rcItem->GetMainItemID() != niluuid )
317 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::MAIN_ITEM ) );
318
319 if( rcItem->GetAuxItemID() != niluuid )
320 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM ) );
321
322 if( rcItem->GetAuxItem2ID() != niluuid )
323 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM2 ) );
324
325 if( rcItem->GetAuxItem3ID() != niluuid )
326 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::AUX_ITEM3 ) );
327
328 if( MARKER_BASE* marker = rcItem->GetParent() )
329 {
330 if( marker->IsExcluded() && !marker->GetComment().IsEmpty() )
331 n->m_Children.push_back( new RC_TREE_NODE( n, rcItem, RC_TREE_NODE::COMMENT ) );
332 }
333 }
334
335 // Must be called after a significant change of items to force the
336 // wxDataViewModel to reread all of them, repopulating itself entirely.
337 AfterReset();
338
339#ifdef __WXGTK__
340 // The fastest method to update wxDataViewCtrl is to rebuild from
341 // scratch by calling Cleared(). Linux requires to reassociate model to
342 // display data, but Windows will create multiple associations.
343 // On MacOS, this crashes KiCad. See https://gitlab.com/kicad/code/kicad/-/issues/3666
344 // and https://gitlab.com/kicad/code/kicad/-/issues/3653
345 m_view->AssociateModel( this );
346#endif
347
348 m_view->ClearColumns();
349 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE );
350
351 ExpandAll();
352
353 // Most annoyingly wxWidgets won't tell us the scroll position (and no, all the usual
354 // routines don't work), so we can only restore the scroll position based on a selection.
355 if( selectedRcItem )
356 {
357 for( RC_TREE_NODE* candidate : m_tree )
358 {
359 if( candidate->m_RcItem == selectedRcItem )
360 {
361 m_view->Select( ToItem( candidate ) );
362 m_view->EnsureVisible( ToItem( candidate ) );
363 break;
364 }
365 }
366 }
367}
368
369
370void RC_TREE_MODEL::Update( std::shared_ptr<RC_ITEMS_PROVIDER> aProvider, int aSeverities )
371{
372 rebuildModel( aProvider, aSeverities );
373}
374
375
377{
378 for( RC_TREE_NODE* topLevelNode : m_tree )
379 m_view->Expand( ToItem( topLevelNode ) );
380}
381
382
383bool RC_TREE_MODEL::IsContainer( wxDataViewItem const& aItem ) const
384{
385 if( ToNode( aItem ) == nullptr ) // must be tree root...
386 return true;
387 else
388 return ToNode( aItem )->m_Type == RC_TREE_NODE::MARKER;
389}
390
391
392wxDataViewItem RC_TREE_MODEL::GetParent( wxDataViewItem const& aItem ) const
393{
394 return ToItem( ToNode( aItem)->m_Parent );
395}
396
397
398unsigned int RC_TREE_MODEL::GetChildren( wxDataViewItem const& aItem,
399 wxDataViewItemArray& aChildren ) const
400{
401 const RC_TREE_NODE* node = ToNode( aItem );
402 const std::vector<RC_TREE_NODE*>& children = node ? node->m_Children : m_tree;
403
404 for( const RC_TREE_NODE* child: children )
405 aChildren.push_back( ToItem( child ) );
406
407 return children.size();
408}
409
410
411void RC_TREE_MODEL::GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
412 unsigned int aCol ) const
413{
414 if( !aItem.IsOk() || m_view->IsFrozen() )
415 return;
416
417 const RC_TREE_NODE* node = ToNode( aItem );
418 const std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
419 MARKER_BASE* marker = rcItem->GetParent();
420 EDA_ITEM* item = nullptr;
421 wxString msg;
422
423 switch( node->m_Type )
424 {
426 if( marker )
427 {
428 SEVERITY severity = marker->GetSeverity();
429
430 if( severity == RPT_SEVERITY_EXCLUSION )
431 {
432 if( m_editFrame->GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
433 msg = _( "Excluded warning: " );
434 else
435 msg = _( "Excluded error: " );
436 }
437 else if( severity == RPT_SEVERITY_WARNING )
438 {
439 msg = _( "Warning: " );
440 }
441 else
442 {
443 msg = _( "Error: " );
444 }
445 }
446
447 msg += rcItem->GetErrorMessage( true );
448 break;
449
451 if( marker && marker->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
452 msg = _( "Drawing Sheet" );
453 else
454 item = m_editFrame->ResolveItem( rcItem->GetMainItemID() );
455
456 break;
457
459 item = m_editFrame->ResolveItem( rcItem->GetAuxItemID() );
460 break;
461
463 item = m_editFrame->ResolveItem( rcItem->GetAuxItem2ID() );
464 break;
465
467 item = m_editFrame->ResolveItem( rcItem->GetAuxItem3ID() );
468 break;
469
471 if( marker )
472 msg = marker->GetComment();
473
474 break;
475 }
476
477 if( item )
478 msg += item->GetItemDescription( m_editFrame, true );
479
480 msg.Replace( wxS( "\n" ), wxS( " " ) );
481 aVariant = msg;
482}
483
484
485bool RC_TREE_MODEL::GetAttr( wxDataViewItem const& aItem,
486 unsigned int aCol,
487 wxDataViewItemAttr& aAttr ) const
488{
489 if( !aItem.IsOk() || m_view->IsFrozen() )
490 return false;
491
492 const RC_TREE_NODE* node = ToNode( aItem );
493
494 bool ret = false;
495 bool heading = node->m_Type == RC_TREE_NODE::MARKER;
496
497 if( heading )
498 {
499 aAttr.SetBold( true );
500 ret = true;
501 }
502
503 if( node->m_RcItem->GetParent()
505 {
506 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
507 double brightness = KIGFX::COLOR4D( textColour ).GetBrightness();
508
509 if( brightness > 0.5 )
510 {
511 int lightness = static_cast<int>( brightness * ( heading ? 50 : 60 ) );
512 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
513 }
514 else
515 {
516 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
517 }
518
519 aAttr.SetItalic( true ); // Strikethrough would be better, if wxWidgets supported it
520 ret = true;
521 }
522
523 return ret;
524}
525
526
528{
529 if( aNode->m_Type != RC_TREE_NODE::MARKER )
530 {
531 ValueChanged( aNode->m_Parent );
532 return;
533 }
534
535 wxDataViewItem markerItem = ToItem( aNode );
536
537 wxDataViewModel::ValueChanged( markerItem, 0 );
538
539 for( const RC_TREE_NODE* child : aNode->m_Children )
540 wxDataViewModel::ValueChanged( ToItem( child ), 0 );
541
542 // Comment items can come and go depening on exclusion state and comment content.
543 //
544 const std::shared_ptr<RC_ITEM> rcItem = aNode->m_RcItem;
545 MARKER_BASE* marker = rcItem ? rcItem->GetParent() : nullptr;
546
547 if( marker )
548 {
549 bool needsCommentNode = marker->IsExcluded() && !marker->GetComment().IsEmpty();
550 RC_TREE_NODE* commentNode = aNode->m_Children.back();
551
552 if( commentNode && commentNode->m_Type != RC_TREE_NODE::COMMENT )
553 commentNode = nullptr;
554
555 if( needsCommentNode && !commentNode )
556 {
557 commentNode = new RC_TREE_NODE( aNode, rcItem, RC_TREE_NODE::COMMENT );
558 wxDataViewItemArray newItems;
559 newItems.push_back( ToItem( commentNode ) );
560
561 aNode->m_Children.push_back( commentNode );
562 ItemsAdded( markerItem, newItems );
563 }
564 else if( commentNode && !needsCommentNode )
565 {
566 wxDataViewItemArray deletedItems;
567 deletedItems.push_back( ToItem( commentNode ) );
568
569 aNode->m_Children.erase( aNode->m_Children.end() - 1 );
570 ItemsDeleted( markerItem, deletedItems );
571 }
572 }
573}
574
575
577{
578 DeleteItems( true, true, aDeep );
579}
580
581
582void RC_TREE_MODEL::DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, bool aDeep )
583{
584 RC_TREE_NODE* current_node = m_view ? ToNode( m_view->GetCurrentItem() ) : nullptr;
585 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->m_RcItem : nullptr;
586
588 std::vector<RC_TREE_NODE*> to_delete;
589 std::vector<RC_TREE_NODE*> expanded;
590
591 if( aCurrentOnly && !current_item )
592 {
593 wxBell();
594 return;
595 }
596
597 // wxWidgets 3.1.x on MacOS (at least) loses the expanded state of the tree when deleting
598 // items.
599 if( m_view && aCurrentOnly )
600 {
601 for( RC_TREE_NODE* node : m_tree )
602 {
603 if( m_view->IsExpanded( ToItem( node ) ) )
604 expanded.push_back( node );
605 }
606 }
607
608 int lastGood = -1;
609 bool itemDeleted = false;
610
611 if( m_view )
612 {
613 m_view->UnselectAll();
614 wxSafeYield();
615 m_view->Freeze();
616 }
617
618 if( !m_rcItemsProvider )
619 return;
620
621 for( int i = m_rcItemsProvider->GetCount() - 1; i >= 0; --i )
622 {
623 std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
624 MARKER_BASE* marker = rcItem->GetParent();
625 bool excluded = false;
626
627 if( marker && marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
628 excluded = true;
629
630 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
631 break;
632
633 if( aCurrentOnly && rcItem != current_item )
634 {
635 lastGood = i;
636 continue;
637 }
638
639 if( excluded && !aIncludeExclusions )
640 continue;
641
642 if( i < (int) m_tree.size() ) // Careful; tree is truncated for large datasets
643 {
644 wxDataViewItem markerItem = ToItem( m_tree[i] );
645 wxDataViewItemArray childItems;
646 wxDataViewItem parentItem = ToItem( m_tree[i]->m_Parent );
647
648 for( RC_TREE_NODE* child : m_tree[i]->m_Children )
649 {
650 childItems.push_back( ToItem( child ) );
651 to_delete.push_back( child );
652 }
653
654 m_tree[i]->m_Children.clear();
655 ItemsDeleted( markerItem, childItems );
656
657 to_delete.push_back( m_tree[i] );
658 m_tree.erase( m_tree.begin() + i );
659 ItemDeleted( parentItem, markerItem );
660 }
661
662 // Only deep delete the current item here; others will be done by the caller, which
663 // can more efficiently delete all markers on the board.
664 m_rcItemsProvider->DeleteItem( i, aDeep && aCurrentOnly );
665
666 if( lastGood > i )
667 lastGood--;
668
669 itemDeleted = true;
670 }
671
672 if( m_view && aCurrentOnly && lastGood >= 0 )
673 {
674 for( RC_TREE_NODE* node : expanded )
675 {
676 wxDataViewItem item = ToItem( node );
677
678 if( item.IsOk() )
679 m_view->Expand( item );
680 }
681
682 wxDataViewItem selItem = ToItem( m_tree[ lastGood ] );
683 m_view->Select( selItem );
684
685 // wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED doesn't get propogated from the Select()
686 // call on (at least) MSW.
687 wxDataViewEvent selectEvent( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, m_view, selItem );
688 m_view->GetEventHandler()->ProcessEvent( selectEvent );
689 }
690
691 for( RC_TREE_NODE* item : to_delete )
692 delete( item );
693
694 if( m_view )
695 m_view->Thaw();
696}
697
698
700{
701 RC_TREE_NODE* currentNode = ToNode( m_view->GetCurrentItem() );
702 RC_TREE_NODE* prevMarker = nullptr;
703
704 while( currentNode && currentNode->m_Type != RC_TREE_NODE::MARKER )
705 currentNode = currentNode->m_Parent;
706
707 for( RC_TREE_NODE* candidate : m_tree )
708 {
709 if( candidate == currentNode )
710 break;
711 else
712 prevMarker = candidate;
713 }
714
715 if( prevMarker )
716 m_view->Select( ToItem( prevMarker ) );
717}
718
719
721{
722 RC_TREE_NODE* currentNode = ToNode( m_view->GetCurrentItem() );
723
724 while( currentNode && currentNode->m_Type != RC_TREE_NODE::MARKER )
725 currentNode = currentNode->m_Parent;
726
727 RC_TREE_NODE* nextMarker = nullptr;
728 bool trigger = currentNode == nullptr;
729
730 for( RC_TREE_NODE* candidate : m_tree )
731 {
732 if( candidate == currentNode )
733 {
734 trigger = true;
735 }
736 else if( trigger )
737 {
738 nextMarker = candidate;
739 break;
740 }
741 }
742
743 if( nextMarker )
744 m_view->Select( ToItem( nextMarker ) );
745}
746
747
749{
750 wxCHECK( !m_view->IsFrozen(), /* void */ );
751
752 for( RC_TREE_NODE* candidate : m_tree )
753 {
754 if( candidate->m_RcItem->GetParent() == aMarker )
755 {
756 m_view->Select( ToItem( candidate ) );
757 return;
758 }
759 }
760}
761
762
764{
765 wxCHECK( !m_view->IsFrozen(), /* void */ );
766
767 for( RC_TREE_NODE* candidate : m_tree )
768 {
769 if( candidate->m_RcItem->GetParent() == aMarker )
770 {
771 m_view->EnsureVisible( ToItem( candidate ) );
772 return;
773 }
774 }
775}
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual VECTOR2I GetPosition() const
Definition eda_item.h:272
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const
Return a user-visible description string of this item.
Definition eda_item.cpp:144
const KIID m_Uuid
Definition eda_item.h:516
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
double GetBrightness() const
Returns the brightness value of the color ranged from 0.0 to 1.0.
Definition color4d.h:334
Definition kiid.h:49
wxString AsString() const
Definition kiid.cpp:246
Marker are mainly used to show a DRC or ERC error or warning.
Definition marker_base.h:49
virtual SEVERITY GetSeverity() const
bool IsExcluded() const
Definition marker_base.h:93
@ MARKER_DRAWING_SHEET
Definition marker_base.h:56
enum MARKER_T GetMarkerType() const
Definition marker_base.h:91
wxString GetComment() const
wxString GetErrorText(bool aTranslate) const
Definition rc_item.h:171
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
virtual wxString GetViolatingRuleDesc(bool aTranslate) const
Definition rc_item.h:184
MARKER_BASE * GetParent() const
Definition rc_item.h:133
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:196
KIIDS m_ids
Definition rc_item.h:198
virtual KIID GetMainItemID() const
Definition rc_item.h:125
virtual KIID GetAuxItemID() const
Definition rc_item.h:126
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
wxString m_errorMessage
A message describing the details of this specific error.
Definition rc_item.h:193
wxString GetSettingsKey() const
Definition rc_item.h:179
virtual wxString GetErrorMessage(bool aTranslate) const
Definition rc_item.cpp:39
void SetItems(const KIIDS &aIds)
Definition rc_item.h:107
void ExpandAll()
Definition rc_item.cpp:376
void PrevMarker()
Definition rc_item.cpp:699
int m_severities
Definition rc_item.h:336
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:411
std::vector< RC_TREE_NODE * > m_tree
Definition rc_item.h:339
unsigned int GetChildren(wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override
Definition rc_item.cpp:398
EDA_DRAW_FRAME * m_editFrame
Definition rc_item.h:334
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
Definition rc_item.h:245
void SelectMarker(const MARKER_BASE *aMarker)
Definition rc_item.cpp:748
RC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
Definition rc_item.cpp:256
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition rc_item.h:250
void ValueChanged(RC_TREE_NODE *aNode)
Definition rc_item.cpp:527
void Update(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
Definition rc_item.cpp:370
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:485
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Delete the current item or all items.
Definition rc_item.cpp:582
void DeleteCurrentItem(bool aDeep)
Definition rc_item.cpp:576
wxDataViewItem GetParent(wxDataViewItem const &aItem) const override
Definition rc_item.cpp:392
void CenterMarker(const MARKER_BASE *aMarker)
Definition rc_item.cpp:763
static KIID ToUUID(wxDataViewItem aItem)
Definition rc_item.cpp:226
wxDataViewCtrl * m_view
Definition rc_item.h:335
std::shared_ptr< RC_ITEMS_PROVIDER > m_rcItemsProvider
Definition rc_item.h:337
void NextMarker()
Definition rc_item.cpp:720
bool IsContainer(wxDataViewItem const &aItem) const override
Definition rc_item.cpp:383
void rebuildModel(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
Definition rc_item.cpp:272
std::shared_ptr< RC_ITEM > m_RcItem
Definition rc_item.h:235
RC_TREE_NODE * m_Parent
Definition rc_item.h:237
std::vector< RC_TREE_NODE * > m_Children
Definition rc_item.h:238
NODE_TYPE m_Type
Definition rc_item.h:234
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)
Convert aValue in internal units to the appropriate user units defined by aUnit.
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.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695