KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_erc.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <advanced_config.h>
27#include <gestfich.h>
28#include <sch_screen.h>
29#include <sch_edit_frame.h>
30#include <schematic.h>
31#include <project.h>
32#include <kiface_base.h>
33#include <reporter.h>
35#include <sch_marker.h>
36#include <connection_graph.h>
37#include <tools/ee_actions.h>
39#include <dialog_erc.h>
40#include <erc.h>
41#include <erc_report.h>
42#include <id.h>
43#include <confirm.h>
44#include <common.h>
46#include <wx/ffile.h>
47#include <wx/filedlg.h>
48#include <wx/hyperlink.h>
49#include <erc_item.h>
50#include <eeschema_settings.h>
51#include <string_utils.h>
52#include <kiplatform/ui.h>
53
54
55wxDEFINE_EVENT( EDA_EVT_CLOSE_ERC_DIALOG, wxCommandEvent );
56
57
58// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or
59// not, in repeatedly creating/destroying a wxDC to do the measurement in).
60// Use default column widths instead.
61static int DEFAULT_SINGLE_COL_WIDTH = 660;
62
63
64static SCHEMATIC* g_lastERCSchematic = nullptr;
65static bool g_lastERCRun = false;
66static std::vector<wxString> g_lastERCIgnored;
67
68
70 DIALOG_ERC_BASE( parent ),
72 m_parent( parent ),
73 m_markerTreeModel( nullptr ),
74 m_running( false ),
75 m_ercRun( false ),
76 m_centerMarkerOnIdle( nullptr ),
77 m_severities( 0 )
78{
79 m_currentSchematic = &parent->Schematic();
80
81 SetName( DIALOG_ERC_WINDOW_NAME ); // Set a window name to be able to find it
82
83 EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
85
87
88 m_markerProvider = std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( &m_parent->Schematic() );
89
91 m_markerDataView->AssociateModel( m_markerTreeModel );
93
94 m_ignoredList->InsertColumn( 0, wxEmptyString, wxLIST_FORMAT_LEFT, DEFAULT_SINGLE_COL_WIDTH );
95
97 {
99
100 for( const wxString& str : g_lastERCIgnored )
101 m_ignoredList->InsertItem( m_ignoredList->GetItemCount(), str );
102 }
103
104 m_notebook->SetSelection( 0 );
105
106 SetupStandardButtons( { { wxID_OK, _( "Run ERC" ) },
107 { wxID_CANCEL, _( "Close" ) } } );
108
109 m_violationsTitleTemplate = m_notebook->GetPageText( 0 );
110 m_ignoredTitleTemplate = m_notebook->GetPageText( 1 );
111
115
117
118 Layout();
119
120 SetFocus();
121
124
125 // Now all widgets have the size fixed, call FinishDialogSettings
127}
128
129
131{
134
135 g_lastERCIgnored.clear();
136
137 for( int ii = 0; ii < m_ignoredList->GetItemCount(); ++ii )
138 g_lastERCIgnored.push_back( m_ignoredList->GetItemText( ii ) );
139
140 EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
141 wxASSERT( settings );
142
143 if( settings )
145
146 m_markerTreeModel->DecRef();
147}
148
149
151{
152 if( m_parent->CheckAnnotate( []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
153 { } ) )
154 {
155 if( !m_infoBar->IsShown() )
156 {
157 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( m_infoBar, wxID_ANY,
158 _( "Show Annotation dialog" ),
159 wxEmptyString );
160
161 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
162 [&]( wxHyperlinkEvent& aEvent )
163 {
164 wxHtmlLinkEvent htmlEvent( aEvent.GetId(),
165 wxHtmlLinkInfo( aEvent.GetURL() ) );
166 OnLinkClicked( htmlEvent );
167 } ) );
168
170 m_infoBar->AddButton( button );
171 m_infoBar->ShowMessage( _( "Schematic is not fully annotated. "
172 "ERC results will be incomplete." ) );
173 }
174 }
175 else
176 {
177 if( m_infoBar->IsShown() )
178 {
180 m_infoBar->Hide();
181 }
182 }
183}
184
185
187{
188 // If ERC checks ever get slow enough we'll want a progress indicator...
189 //
190 // double cur = (double) m_progress.load() / m_maxProgress;
191 // cur = std::max( 0.0, std::min( cur, 1.0 ) );
192 //
193 // m_gauge->SetValue( KiROUND( cur * 1000.0 ) );
194 // wxSafeYield( this );
195
196 return !m_cancelled;
197}
198
199
200void DIALOG_ERC::AdvancePhase( const wxString& aMessage )
201{
202 // Will also call Report( aMessage ):
204 SetCurrentProgress( 0.0 );
205}
206
207
208void DIALOG_ERC::Report( const wxString& aMessage )
209{
210 m_messages->Report( aMessage );
211}
212
213
215{
216 int numErrors = 0;
217 int numWarnings = 0;
218 int numExcluded = 0;
219
220 int numMarkers = 0;
221
222 if( m_markerProvider )
223 {
224 numMarkers += m_markerProvider->GetCount();
225 numErrors += m_markerProvider->GetCount( RPT_SEVERITY_ERROR );
226 numWarnings += m_markerProvider->GetCount( RPT_SEVERITY_WARNING );
227 numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION );
228 }
229
230 bool markersOverflowed = false;
231
232 // We don't currently have a limit on ERC violations, so the above is always false.
233
234 wxString num;
235 wxString msg;
236
237 if( m_ercRun )
238 {
239 num.Printf( markersOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numMarkers );
240 msg.Printf( m_violationsTitleTemplate, num );
241 }
242 else
243 {
245 msg.Replace( wxT( "(%s)" ), wxEmptyString );
246 }
247
248 m_notebook->SetPageText( 0, msg );
249
250 if( m_ercRun )
251 {
252 num.Printf( wxT( "%d" ), m_ignoredList->GetItemCount() );
253 msg.sprintf( m_ignoredTitleTemplate, num );
254 }
255 else
256 {
258 msg.Replace( wxT( "(%s)" ), wxEmptyString );
259 }
260
261 m_notebook->SetPageText( 1, msg );
262
263 if( !m_ercRun && numErrors == 0 )
264 numErrors = -1;
265
266 if( !m_ercRun && numWarnings == 0 )
267 numWarnings = -1;
268
272}
273
274
275void DIALOG_ERC::OnDeleteOneClick( wxCommandEvent& aEvent )
276{
277 if( m_notebook->GetSelection() == 0 )
278 {
279 // Clear the selection. It may be the selected ERC marker.
281
283
284 // redraw the schematic
286 }
287
289}
290
291
292void DIALOG_ERC::OnDeleteAllClick( wxCommandEvent& event )
293{
294 bool includeExclusions = false;
295 int numExcluded = 0;
296
297 if( m_markerProvider )
298 numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION );
299
300 if( numExcluded > 0 )
301 {
302 wxMessageDialog dlg( this, _( "Delete exclusions too?" ), _( "Delete All Markers" ),
303 wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION );
304 dlg.SetYesNoLabels( _( "Errors and Warnings Only" ),
305 _( "Errors, Warnings and Exclusions" ) );
306
307 int ret = dlg.ShowModal();
308
309 if( ret == wxID_CANCEL )
310 return;
311 else if( ret == wxID_NO )
312 includeExclusions = true;
313 }
314
315 deleteAllMarkers( includeExclusions );
316
317 // redraw the schematic
320}
321
322
323void DIALOG_ERC::OnCancelClick( wxCommandEvent& aEvent )
324{
325 if( m_running )
326 {
327 m_cancelled = true;
328 return;
329 }
330
331 m_parent->FocusOnItem( nullptr );
332
333 aEvent.Skip();
334}
335
336
337void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& aEvent )
338{
339 m_parent->FocusOnItem( nullptr );
340
341 // Dialog is mode-less so let the parent know that it needs to be destroyed.
342 if( !IsModal() && !IsQuasiModal() )
343 {
344 wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_ERC_DIALOG, wxID_ANY );
345
346 wxWindow* parent = GetParent();
347
348 if( parent )
349 wxQueueEvent( parent, evt );
350 }
351
352 aEvent.Skip();
353}
354
355
357
358
360{
365}
366
367
368void DIALOG_ERC::OnLinkClicked( wxHtmlLinkEvent& event )
369{
370 wxCommandEvent dummy;
372}
373
374
375void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event )
376{
377 wxBusyCursor busy;
378
379 SCHEMATIC* sch = &m_parent->Schematic();
380
382
383 sch->RecordERCExclusions();
384 deleteAllMarkers( true );
385
386 std::vector<std::reference_wrapper<RC_ITEM>> violations = ERC_ITEM::GetItemsWithSeverities();
387 m_ignoredList->DeleteAllItems();
388
389 for( std::reference_wrapper<RC_ITEM>& item : violations )
390 {
391 if( sch->ErcSettings().GetSeverity( item.get().GetErrorCode() ) == RPT_SEVERITY_IGNORE )
392 {
393 m_ignoredList->InsertItem( m_ignoredList->GetItemCount(),
394 wxT( " • " ) + item.get().GetErrorText() );
395 }
396 }
397
398 m_ignoredList->SetColumnWidth( 0, m_ignoredList->GetParent()->GetClientSize().x - 20 );
399
400 Raise();
401
402 m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
403 m_messages->Clear();
404 wxYield(); // Allow time slice to refresh Messages
405
406 m_running = true;
407 m_sdbSizer1Cancel->SetLabel( _( "Cancel" ) );
408 m_sdbSizer1OK->Enable( false );
409 m_deleteOneMarker->Enable( false );
410 m_deleteAllMarkers->Enable( false );
411 m_saveReport->Enable( false );
412
414
415 int itemsNotAnnotated = m_parent->CheckAnnotate(
416 []( ERCE_T aType, const wxString& aMsg, SCH_REFERENCE* aItemA, SCH_REFERENCE* aItemB )
417 {
418 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( aType );
419 ercItem->SetErrorMessage( aMsg );
420
421 if( aItemB )
422 ercItem->SetItems( aItemA->GetSymbol(), aItemB->GetSymbol() );
423 else
424 ercItem->SetItems( aItemA->GetSymbol() );
425
426 SCH_MARKER* marker = new SCH_MARKER( ercItem, aItemA->GetSymbol()->GetPosition() );
427 aItemA->GetSheetPath().LastScreen()->Append( marker );
428 } );
429
430 testErc();
431
432 if( itemsNotAnnotated )
433 m_messages->ReportHead( wxString::Format( _( "%d symbol(s) require annotation.<br><br>" ),
434 itemsNotAnnotated ), RPT_SEVERITY_INFO );
435
436 if( m_cancelled )
437 m_messages->Report( _( "-------- ERC cancelled by user.<br><br>" ), RPT_SEVERITY_INFO );
438 else
439 m_messages->Report( _( "Done.<br><br>" ), RPT_SEVERITY_INFO );
440
441 Raise();
442 wxYield(); // Allow time slice to refresh Messages
443
444 m_running = false;
445 m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
446 m_sdbSizer1OK->Enable( true );
447 m_deleteOneMarker->Enable( true );
448 m_deleteAllMarkers->Enable( true );
449 m_saveReport->Enable( true );
450
451 if( !m_cancelled )
452 {
453 wxMilliSleep( 500 );
454 m_runningResultsBook->ChangeSelection( 1 );
456 }
457
458 m_ercRun = true;
461}
462
463
465{
466 WINDOW_THAWER thawer( m_parent );
467
469}
470
471
473{
474 wxFileName fn;
475
476 SCHEMATIC* sch = &m_parent->Schematic();
477
478 SCH_SCREENS screens( sch->Root() );
479 ERC_TESTER tester( sch );
480
481 {
482 wxBusyCursor dummy;
483 tester.RunTests( m_parent->GetCanvas()->GetView()->GetDrawingSheet(), m_parent, this );
484 }
485
486 // Update marker list:
488
489 // Display new markers from the current screen:
490 for( SCH_ITEM* marker : m_parent->GetScreen()->Items().OfType( SCH_MARKER_T ) )
491 {
492 m_parent->GetCanvas()->GetView()->Remove( marker );
493 m_parent->GetCanvas()->GetView()->Add( marker );
494 }
495
497}
498
499
500void DIALOG_ERC::OnERCItemSelected( wxDataViewEvent& aEvent )
501{
502 const KIID& itemID = RC_TREE_MODEL::ToUUID( aEvent.GetItem() );
503 SCH_SHEET_PATH sheet;
504 SCH_ITEM* item = m_parent->Schematic().GetSheets().GetItem( itemID, &sheet );
505
507 {
508 // we already came from a cross-probe of the marker in the document; don't go
509 // around in circles
510 }
511 else if( item && item->GetClass() != wxT( "DELETED_SHEET_ITEM" ) )
512 {
513 const RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
514
515 if( node )
516 {
517 // Determine the owning sheet for sheet-specific items
518 std::shared_ptr<ERC_ITEM> ercItem =
519 std::static_pointer_cast<ERC_ITEM>( node->m_RcItem );
520 switch( node->m_Type )
521 {
523 if( ercItem->IsSheetSpecific() )
524 sheet = ercItem->GetSpecificSheetPath();
525 break;
527 if( ercItem->MainItemHasSheetPath() )
528 sheet = ercItem->GetMainItemSheetPath();
529 break;
531 if( ercItem->AuxItemHasSheetPath() )
532 sheet = ercItem->GetAuxItemSheetPath();
533 break;
534 default:
535 break;
536 }
537 }
538
539 WINDOW_THAWER thawer( m_parent );
540
541 if( !sheet.empty() && sheet != m_parent->GetCurrentSheet() )
542 {
545
546 m_parent->SetCurrentSheet( sheet );
549 }
550
551 m_parent->FocusOnItem( item );
553 }
554
555 aEvent.Skip();
556}
557
558
559void DIALOG_ERC::OnERCItemDClick( wxDataViewEvent& aEvent )
560{
561 if( aEvent.GetItem().IsOk() )
562 {
563 // turn control over to m_parent, hide this DIALOG_ERC window,
564 // no destruction so we can preserve listbox cursor
565 if( !IsModal() )
566 Show( false );
567 }
568
569 aEvent.Skip();
570}
571
572
573void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
574{
575 RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
576
577 if( !node )
578 return;
579
581
582 std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
583 wxString listName;
584 wxMenu menu;
585
586 switch( settings.GetSeverity( rcItem->GetErrorCode() ) )
587 {
588 case RPT_SEVERITY_ERROR: listName = _( "errors" ); break;
589 case RPT_SEVERITY_WARNING: listName = _( "warnings" ); break;
590 default: listName = _( "appropriate" ); break;
591 }
592
593 if( rcItem->GetParent()->IsExcluded() )
594 {
595 menu.Append( 1, _( "Remove exclusion for this violation" ),
596 wxString::Format( _( "It will be placed back in the %s list" ), listName ) );
597 }
598 else
599 {
600 menu.Append( 2, _( "Exclude this violation" ),
601 wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
602 }
603
604 menu.AppendSeparator();
605
606 if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_WARNING
607 || rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
608 {
609 // Pin to pin severities edited through pin conflict map
610 }
611 else if( settings.GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
612 {
613 menu.Append( 4, wxString::Format( _( "Change severity to Error for all '%s' violations" ),
614 rcItem->GetErrorText() ),
615 _( "Violation severities can also be edited in the Schematic Setup... dialog" ) );
616 }
617 else
618 {
619 menu.Append( 5, wxString::Format( _( "Change severity to Warning for all '%s' violations" ),
620 rcItem->GetErrorText() ),
621 _( "Violation severities can also be edited in the Schematic Setup... dialog" ) );
622 }
623
624 menu.Append( 6, wxString::Format( _( "Ignore all '%s' violations" ), rcItem->GetErrorText() ),
625 _( "Violations will not be checked or reported" ) );
626
627 menu.AppendSeparator();
628
629 if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_WARNING
630 || rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
631 {
632 menu.Append( 7, _( "Edit pin-to-pin conflict map..." ) );
633 }
634 else
635 {
636 menu.Append( 8, _( "Edit violation severities..." ),
637 _( "Open the Schematic Setup... dialog" ) );
638 }
639
640 bool modified = false;
641
642 switch( GetPopupMenuSelectionFromUser( menu ) )
643 {
644 case 1:
645 {
646 SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() );
647
648 if( marker )
649 {
650 marker->SetExcluded( false );
651 m_parent->GetCanvas()->GetView()->Update( marker );
652
653 // Update view
654 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
655 modified = true;
656 }
657 }
658 break;
659
660 case 2:
661 {
662 SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() );
663
664 if( marker )
665 {
666 marker->SetExcluded( true );
667 m_parent->GetCanvas()->GetView()->Update( marker );
668
669 // Update view
671 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
672 else
673 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false );
674
675 modified = true;
676 }
677 }
678 break;
679
680 case 4:
681 settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_ERROR );
682
683 for( SCH_ITEM* item : m_parent->GetScreen()->Items().OfType( SCH_MARKER_T ) )
684 {
685 SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
686
687 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
688 m_parent->GetCanvas()->GetView()->Update( marker );
689 }
690
691 // Rebuild model and view
692 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markerProvider, m_severities );
693 modified = true;
694 break;
695
696 case 5:
697 settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_WARNING );
698
699 for( SCH_ITEM* item : m_parent->GetScreen()->Items().OfType( SCH_MARKER_T ) )
700 {
701 SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
702
703 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
704 m_parent->GetCanvas()->GetView()->Update( marker );
705 }
706
707 // Rebuild model and view
708 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markerProvider, m_severities );
709 modified = true;
710 break;
711
712 case 6:
713 {
714 settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_IGNORE );
715
716 if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
718
719 SCH_SCREENS ScreenList( m_parent->Schematic().Root() );
720 ScreenList.DeleteMarkers( MARKER_BASE::MARKER_ERC, rcItem->GetErrorCode() );
721
722 // Rebuild model and view
723 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markerProvider, m_severities );
724 modified = true;
725 }
726 break;
727
728 case 7:
729 m_parent->ShowSchematicSetupDialog( _( "Pin Conflicts Map" ) );
730 break;
731
732 case 8:
733 m_parent->ShowSchematicSetupDialog( _( "Violation Severity" ) );
734 break;
735 }
736
737 if( modified )
738 {
742 }
743}
744
745
747{
748 if( m_notebook->IsShown() )
749 {
750 if( m_notebook->GetSelection() != 0 )
751 m_notebook->SetSelection( 0 );
752
754 }
755}
756
757
759{
760 if( m_notebook->IsShown() )
761 {
762 if( m_notebook->GetSelection() != 0 )
763 m_notebook->SetSelection( 0 );
764
766 }
767}
768
769
771{
772 if( m_notebook->IsShown() )
773 {
774 m_notebook->SetSelection( 0 );
776
777 // wxWidgets on some platforms fails to correctly ensure that a selected item is
778 // visible, so we have to do it in a separate idle event.
779 m_centerMarkerOnIdle = aMarker;
780 Bind( wxEVT_IDLE, &DIALOG_ERC::centerMarkerIdleHandler, this );
781 }
782}
783
784
785void DIALOG_ERC::centerMarkerIdleHandler( wxIdleEvent& aEvent )
786{
788 m_centerMarkerOnIdle = nullptr;
789 Unbind( wxEVT_IDLE, &DIALOG_ERC::centerMarkerIdleHandler, this );
790}
791
792
794{
795 SCH_MARKER* marker = aMarker;
796
797 if( marker != nullptr )
799
800 if( m_notebook->GetSelection() != 0 )
801 return;
802
803 RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( m_markerDataView->GetCurrentItem() );
804
805 if( node && node->m_RcItem )
806 marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() );
807
808 if( node && marker && !marker->IsExcluded() )
809 {
810 marker->SetExcluded( true );
811 m_parent->GetCanvas()->GetView()->Update( marker );
812
813 // Update view
816 else
818
822 }
823}
824
825
826void DIALOG_ERC::OnEditViolationSeverities( wxHyperlinkEvent& aEvent )
827{
828 m_parent->ShowSchematicSetupDialog( _( "Violation Severity" ) );
829}
830
831
832void DIALOG_ERC::OnSeverity( wxCommandEvent& aEvent )
833{
834 int flag = 0;
835
836 if( aEvent.GetEventObject() == m_showAll )
838 else if( aEvent.GetEventObject() == m_showErrors )
840 else if( aEvent.GetEventObject() == m_showWarnings )
842 else if( aEvent.GetEventObject() == m_showExclusions )
844
845 if( aEvent.IsChecked() )
847 else if( aEvent.GetEventObject() == m_showAll )
849 else
850 m_severities &= ~flag;
851
853
856}
857
858
859void DIALOG_ERC::deleteAllMarkers( bool aIncludeExclusions )
860{
861 // Clear current selection list to avoid selection of deleted items
863
864 m_markerTreeModel->DeleteItems( false, aIncludeExclusions, false );
865
866 SCH_SCREENS screens( m_parent->Schematic().Root() );
867 screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC, aIncludeExclusions );
868}
869
870
871void DIALOG_ERC::OnSaveReport( wxCommandEvent& aEvent )
872{
873 wxFileName fn( wxS( "ERC." ) + ReportFileExtension );
874
875 wxFileDialog dlg( this, _( "Save Report to File" ), Prj().GetProjectPath(), fn.GetFullName(),
876 ReportFileWildcard() + wxS( "|" ) + JsonFileWildcard(),
877 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
878
879 if( dlg.ShowModal() != wxID_OK )
880 return;
881
882 fn = dlg.GetPath();
883
884 if( fn.GetExt().IsEmpty() )
885 fn.SetExt( ReportFileExtension );
886
887 if( !fn.IsAbsolute() )
888 {
889 wxString prj_path = Prj().GetProjectPath();
890 fn.MakeAbsolute( prj_path );
891 }
892
893 ERC_REPORT reportWriter( &m_parent->Schematic(), m_parent->GetUserUnits() );
894
895 bool success = false;
896 if( fn.GetExt() == JsonFileExtension )
897 success = reportWriter.WriteJsonReport( fn.GetFullPath() );
898 else
899 success = reportWriter.WriteTextReport( fn.GetFullPath() );
900
901 if( success )
902 {
903 m_messages->Report( wxString::Format( _( "Report file '%s' created." ),
904 fn.GetFullPath() ) );
905 }
906 else
907 {
908 DisplayError( this, wxString::Format( _( "Failed to create file '%s'." ),
909 fn.GetFullPath() ) );
910 }
911}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
VECTOR2D m_ScrollCenter
Current scroll center point in logical units.
Definition: base_screen.h:100
Class DIALOG_ERC_BASE.
wxButton * m_saveReport
wxButton * m_sdbSizer1Cancel
wxSimplebook * m_runningResultsBook
wxCheckBox * m_showExclusions
NUMBER_BADGE * m_errorsBadge
WX_INFOBAR * m_infoBar
wxCheckBox * m_showErrors
wxNotebook * m_notebook
wxCheckBox * m_showAll
NUMBER_BADGE * m_exclusionsBadge
wxListCtrl * m_ignoredList
WX_HTML_REPORT_BOX * m_messages
wxDataViewCtrl * m_markerDataView
wxButton * m_deleteAllMarkers
NUMBER_BADGE * m_warningsBadge
wxButton * m_deleteOneMarker
wxCheckBox * m_showWarnings
wxButton * m_sdbSizer1OK
void ExcludeMarker(SCH_MARKER *aMarker=nullptr)
Exclude aMarker from the ERC list.
Definition: dialog_erc.cpp:793
const SCH_MARKER * m_centerMarkerOnIdle
Definition: dialog_erc.h:116
void OnERCItemDClick(wxDataViewEvent &aEvent) override
Definition: dialog_erc.cpp:559
std::shared_ptr< RC_ITEMS_PROVIDER > m_markerProvider
Definition: dialog_erc.h:110
void syncCheckboxes()
Definition: dialog_erc.cpp:359
bool m_ercRun
Definition: dialog_erc.h:114
DIALOG_ERC(SCH_EDIT_FRAME *parent)
Definition: dialog_erc.cpp:69
void testErc()
Definition: dialog_erc.cpp:472
void SelectMarker(const SCH_MARKER *aMarker)
Definition: dialog_erc.cpp:770
bool updateUI() override
Definition: dialog_erc.cpp:186
SCH_EDIT_FRAME * m_parent
Definition: dialog_erc.h:104
wxString m_violationsTitleTemplate
Definition: dialog_erc.h:107
void OnERCItemRClick(wxDataViewEvent &aEvent) override
Definition: dialog_erc.cpp:573
void centerMarkerIdleHandler(wxIdleEvent &aEvent)
Definition: dialog_erc.cpp:785
void OnDeleteAllClick(wxCommandEvent &event) override
Definition: dialog_erc.cpp:292
void OnLinkClicked(wxHtmlLinkEvent &event) override
Definition: dialog_erc.cpp:368
int m_severities
Definition: dialog_erc.h:118
void OnRunERCClick(wxCommandEvent &event) override
Definition: dialog_erc.cpp:375
void deleteAllMarkers(bool aIncludeExclusions)
Definition: dialog_erc.cpp:859
wxString m_ignoredTitleTemplate
Definition: dialog_erc.h:108
void OnDeleteOneClick(wxCommandEvent &event) override
Definition: dialog_erc.cpp:275
void OnSaveReport(wxCommandEvent &aEvent) override
Definition: dialog_erc.cpp:871
void PrevMarker()
Definition: dialog_erc.cpp:746
void NextMarker()
Definition: dialog_erc.cpp:758
SCHEMATIC * m_currentSchematic
Definition: dialog_erc.h:105
void OnEditViolationSeverities(wxHyperlinkEvent &aEvent) override
Definition: dialog_erc.cpp:826
void UpdateAnnotationWarning()
Definition: dialog_erc.cpp:150
void redrawDrawPanel()
Definition: dialog_erc.cpp:464
void Report(const wxString &aMessage) override
Display aMessage in the progress bar dialog.
Definition: dialog_erc.cpp:208
void OnERCItemSelected(wxDataViewEvent &aEvent) override
Definition: dialog_erc.cpp:500
RC_TREE_MODEL * m_markerTreeModel
Definition: dialog_erc.h:111
void updateDisplayedCounts()
Definition: dialog_erc.cpp:214
void OnSeverity(wxCommandEvent &aEvent) override
Definition: dialog_erc.cpp:832
bool m_running
Definition: dialog_erc.h:113
void OnCloseErcDialog(wxCloseEvent &event) override
Definition: dialog_erc.cpp:337
void OnCancelClick(wxCommandEvent &event) override
Definition: dialog_erc.cpp:323
bool Show(bool show) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
bool IsQuasiModal() const
Definition: dialog_shim.h:106
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition: erc_item.cpp:232
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
Definition: erc_item.h:76
bool WriteJsonReport(const wxString &aFullFileName)
Definition: erc_report.cpp:107
bool WriteTextReport(const wxString &aFullFileName)
Definition: erc_report.cpp:44
Container for ERC settings.
Definition: erc_settings.h:114
SEVERITY GetSeverity(int aErrorCode) const
void SetSeverity(int aErrorCode, SEVERITY aSeverity)
Definition: erc.h:50
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, PROGRESS_REPORTER *aProgressReporter)
Definition: erc.cpp:1097
A specialisation of the RC_TREE_MODEL class to enable ERC errors / warnings to be resolved in a speci...
Definition: erc_item.h:38
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:103
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:314
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1608
Definition: kiid.h:49
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
bool IsExcluded() const
Definition: marker_base.h:97
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:105
void SetExcluded(bool aExcluded)
Definition: marker_base.h:98
void SetMaximumNumber(int aMax)
Set the maximum number to be shown on the badge.
void UpdateNumber(int aNumber, SEVERITY aSeverity)
Update the number displayed on the badge.
This implements all the tricky bits for thread safety, but the GUI is left to derived classes.
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
virtual void SetCurrentProgress(double aProgress) override
Set the progress value to aProgress (0..1).
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:143
void PrevMarker()
Definition: rc_item.cpp:610
void SelectMarker(const MARKER_BASE *aMarker)
Definition: rc_item.cpp:659
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:226
void Update(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
Definition: rc_item.cpp:351
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
Definition: rc_item.cpp:521
void DeleteCurrentItem(bool aDeep)
Definition: rc_item.cpp:515
void CenterMarker(const MARKER_BASE *aMarker)
Definition: rc_item.cpp:672
static KIID ToUUID(wxDataViewItem aItem)
Definition: rc_item.cpp:211
void NextMarker()
Definition: rc_item.cpp:631
void ValueChanged(const RC_TREE_NODE *aNode)
Definition: rc_item.cpp:498
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:211
NODE_TYPE m_Type
Definition: rc_item.h:210
virtual REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the beginning of the list for objects that support ordering.
Definition: reporter.h:108
Holds all the data relating to one schematic.
Definition: schematic.h:75
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
Definition: schematic.cpp:731
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:100
SCH_SHEET & Root() const
Definition: schematic.h:105
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:216
virtual void RedrawScreen(const VECTOR2I &aCenterPoint, bool aWarpPointer)
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
void ShowSchematicSetupDialog(const wxString &aInitialPage=wxEmptyString)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void OnAnnotate(wxCommandEvent &event)
int CheckAnnotate(ANNOTATION_ERROR_HANDLER aErrorHandler, ANNOTATE_SCOPE_T aAnnotateScope=ANNOTATE_ALL, bool aRecursive=true)
Check for annotation errors.
Definition: annotate.cpp:441
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void DisplayCurrentSheet()
Draw the current sheet on the display.
void FocusOnItem(SCH_ITEM *aItem)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:150
virtual wxString GetClass() const override
Return the class name.
Definition: sch_item.h:160
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
SCH_SYMBOL * GetSymbol() const
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:673
void DeleteMarkers(enum MARKER_BASE::TYPEMARKER aMarkerTyp, int aErrorCode, bool aIncludeExclusions=true)
Delete all markers of a particular type and error code.
void DeleteAllMarkers(enum MARKER_BASE::TYPEMARKER aMarkerType, bool aIncludeExclusions)
Delete all electronic rules check markers of aMarkerType from all the screens in the list.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:151
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool empty() const
Forwarded method from std::vector.
SCH_SCREEN * LastScreen()
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:703
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:145
EDA_UNITS GetUserUnits() const
void Clear()
Delete the stored messages.
void SetImmediateMode()
In immediate mode, messages are flushed as they are added.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:301
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: wx_infobar.cpp:260
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: wx_infobar.cpp:154
The common library.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
This file is part of the common library.
static int RPT_SEVERITY_ALL
Definition: dialog_erc.cpp:356
static std::vector< wxString > g_lastERCIgnored
Definition: dialog_erc.cpp:66
static int DEFAULT_SINGLE_COL_WIDTH
Definition: dialog_erc.cpp:61
static bool g_lastERCRun
Definition: dialog_erc.cpp:65
wxDEFINE_EVENT(EDA_EVT_CLOSE_ERC_DIALOG, wxCommandEvent)
static SCHEMATIC * g_lastERCSchematic
Definition: dialog_erc.cpp:64
#define DIALOG_ERC_WINDOW_NAME
Definition: dialog_erc.h:42
#define _(s)
static int DEFAULT_SINGLE_COL_WIDTH
ERCE_T
ERC error codes.
Definition: erc_settings.h:37
@ ERCE_PIN_TO_PIN_WARNING
Definition: erc_settings.h:85
@ ERCE_PIN_TO_PIN_ERROR
Definition: erc_settings.h:86
const std::string JsonFileExtension
const std::string ReportFileExtension
wxString ReportFileWildcard()
wxString JsonFileWildcard()
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition: gtk/ui.cpp:67
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_EXCLUSION
@ RPT_SEVERITY_IGNORE
@ RPT_SEVERITY_INFO
std::vector< FAB_LAYER_COLOR > dummy
@ SCH_MARKER_T
Definition: typeinfo.h:140
Definition of file extensions used in Kicad.
static int RPT_SEVERITY_ALL