51#include <wx/filedlg.h>
52#include <wx/hyperlink.h>
54#include <wx/wupdlock.h>
108 listItem.SetText( str );
109 listItem.SetData( code );
118 { wxID_CANCEL,
_(
"Close" ) } } );
152 g_lastERCIgnored.push_back( { m_ignoredList->GetItemText( ii ), m_ignoredList->GetItemData( ii ) } );
173 wxHyperlinkCtrl* button =
new wxHyperlinkCtrl(
m_infoBar, wxID_ANY,
_(
"Show Annotation dialog" ),
176 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<
void( wxHyperlinkEvent& aEvent )>(
177 [&]( wxHyperlinkEvent& aEvent )
179 wxHtmlLinkEvent htmlEvent( aEvent.GetId(), wxHtmlLinkInfo( aEvent.GetURL() ) );
185 m_infoBar->ShowMessage(
_(
"Schematic is not fully annotated. ERC results will be incomplete." ) );
221 menu.Append( 4206,
_(
"Cross-probe Selected Items" ),
222 _(
"Highlight corresponding items on canvas when selected in the ERC list" ),
226 menu.Append( 4207,
_(
"Center on Cross-probe" ),
227 _(
"When cross-probing, scroll the canvas so that the item is visible" ),
232 int menu_id =
m_bMenu->GetPopupMenuSelectionFromUser( menu );
234 if( menu_id == 0 || menu_id == 4206 )
238 else if( menu_id == 1 || menu_id == 4207 )
247 if(
int hotkey = aEvt.GetKeyCode() )
249 if( aEvt.ControlDown() )
251 if( aEvt.ShiftDown() )
325 bool markersOverflowed =
false;
334 num.Printf( markersOverflowed ? wxT(
"%d+" ) : wxT(
"%d" ), numMarkers );
340 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
353 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
389 bool includeExclusions =
false;
395 if( numExcluded > 0 )
397 wxMessageDialog dlg(
this,
_(
"Delete exclusions too?" ),
_(
"Delete All Markers" ),
398 wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION );
399 dlg.SetYesNoLabels(
_(
"Errors and Warnings Only" ),
400 _(
"Errors, Warnings and Exclusions" ) );
402 int ret = dlg.ShowModal();
404 if( ret == wxID_CANCEL )
406 else if( ret == wxID_NO )
407 includeExclusions =
true;
440 if( wxWindow* parent = GetParent() )
441 wxQueueEvent( parent,
new wxCommandEvent( EDA_EVT_CLOSE_ERC_DIALOG, wxID_ANY ) );
468 for( std::reference_wrapper<RC_ITEM>& item : violations )
474 listItem.SetText( wxT(
" • " ) + item.get().GetErrorText() );
475 listItem.SetData( item.get().GetErrorCode() );
497 int itemsNotAnnotated =
m_parent->CheckAnnotate(
501 ercItem->SetErrorMessage( aMsg );
506 ercItem->SetItems( aItemA->
GetSymbol() );
514 if( itemsNotAnnotated )
516 m_messages->ReportHead( wxString::Format(
_(
"%d symbol(s) require annotation.<br><br>" ),
588 m_parent->GetCanvas()->GetView()->Remove( marker );
589 m_parent->GetCanvas()->GetView()->Add( marker );
613 else if( item && item->
GetClass() != wxT(
"DELETED_SHEET_ITEM" ) )
620 std::shared_ptr<ERC_ITEM> ercItem = std::static_pointer_cast<ERC_ITEM>( node->
m_RcItem );
625 if( ercItem->IsSheetSpecific() )
626 sheet = ercItem->GetSpecificSheetPath();
629 if( ercItem->MainItemHasSheetPath() )
630 sheet = ercItem->GetMainItemSheetPath();
633 if( ercItem->AuxItemHasSheetPath() )
634 sheet = ercItem->GetAuxItemSheetPath();
659 if( aEvent.GetItem().IsOk() )
682 std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
686 switch( settings.
GetSeverity( rcItem->GetErrorCode() ) )
690 default: listName =
_(
"appropriate" );
break;
695 ID_EDIT_EXCLUSION_COMMENT = 4467,
697 ID_REMOVE_EXCLUSION_ALL,
699 ID_ADD_EXCLUSION_WITH_COMMENT,
700 ID_ADD_EXCLUSION_ALL,
701 ID_INSPECT_VIOLATION,
702 ID_EDIT_PIN_CONFLICT_MAP,
703 ID_EDIT_CONNECTION_GRID,
704 ID_SET_SEVERITY_TO_ERROR,
705 ID_SET_SEVERITY_TO_WARNING,
706 ID_SET_SEVERITY_TO_IGNORE,
710 if( rcItem->GetParent()->IsExcluded() )
712 menu.Append( ID_REMOVE_EXCLUSION,
713 _(
"Remove exclusion for this violation" ),
714 wxString::Format(
_(
"It will be placed back in the %s list" ), listName ) );
716 menu.Append( ID_EDIT_EXCLUSION_COMMENT,
717 _(
"Edit exclusion comment..." ) );
721 menu.Append( ID_ADD_EXCLUSION,
722 _(
"Exclude this violation" ),
723 wxString::Format(
_(
"It will be excluded from the %s list" ), listName ) );
725 menu.Append( ID_ADD_EXCLUSION_WITH_COMMENT,
726 _(
"Exclude with comment..." ),
727 wxString::Format(
_(
"It will be excluded from the %s list" ), listName ) );
732 if( !inspectERCErrorMenuText.IsEmpty() )
733 menu.Append( ID_INSPECT_VIOLATION, inspectERCErrorMenuText );
735 menu.AppendSeparator();
744 menu.Append( ID_SET_SEVERITY_TO_ERROR,
745 wxString::Format(
_(
"Change severity to Error for all '%s' violations" ),
746 rcItem->GetErrorText() ),
747 _(
"Violation severities can also be edited in the Schematic Setup... dialog" ) );
751 menu.Append( ID_SET_SEVERITY_TO_WARNING,
752 wxString::Format(
_(
"Change severity to Warning for all '%s' violations" ),
753 rcItem->GetErrorText() ),
754 _(
"Violation severities can also be edited in the Schematic Setup... "
758 menu.Append( ID_SET_SEVERITY_TO_IGNORE,
759 wxString::Format(
_(
"Ignore all '%s' violations" ), rcItem->GetErrorText() ),
760 _(
"Violations will not be checked or reported" ) );
762 menu.AppendSeparator();
767 menu.Append( ID_EDIT_PIN_CONFLICT_MAP,
768 _(
"Edit pin-to-pin conflict map..." ),
769 _(
"Open the Schematic Setup... dialog" ) );
773 menu.Append( ID_EDIT_SEVERITIES,
774 _(
"Edit violation severities..." ),
775 _(
"Open the Schematic Setup... dialog" ) );
780 menu.Append( ID_EDIT_CONNECTION_GRID,
781 _(
"Edit connection grid spacing..." ),
782 _(
"Open the Schematic Setup... dialog" ) );
785 bool modified =
false;
786 int command = GetPopupMenuSelectionFromUser( menu );
790 case ID_EDIT_EXCLUSION_COMMENT:
794 marker->GetComment(),
true );
799 marker->SetExcluded(
true, dlg.
GetValue() );
808 case ID_REMOVE_EXCLUSION:
811 marker->SetExcluded(
false );
812 m_parent->GetCanvas()->GetView()->Update( marker );
821 case ID_ADD_EXCLUSION:
822 case ID_ADD_EXCLUSION_WITH_COMMENT:
827 if( command == ID_ADD_EXCLUSION_WITH_COMMENT )
830 wxEmptyString,
true );
838 marker->SetExcluded(
true, comment );
840 m_parent->GetCanvas()->GetView()->Update( marker );
853 case ID_INSPECT_VIOLATION:
857 case ID_SET_SEVERITY_TO_ERROR:
865 m_parent->GetCanvas()->GetView()->Update( marker );
873 case ID_SET_SEVERITY_TO_WARNING:
881 m_parent->GetCanvas()->GetView()->Update( marker );
889 case ID_SET_SEVERITY_TO_IGNORE:
898 listItem.SetText( wxT(
" • " ) + rcItem->GetErrorText() );
899 listItem.SetData( rcItem->GetErrorCode() );
916 case ID_EDIT_PIN_CONFLICT_MAP:
917 m_parent->ShowSchematicSetupDialog(
_(
"Pin Conflicts Map" ) );
920 case ID_EDIT_SEVERITIES:
921 m_parent->ShowSchematicSetupDialog(
_(
"Violation Severity" ) );
924 case ID_EDIT_CONNECTION_GRID:
925 m_parent->ShowSchematicSetupDialog(
_(
"Formatting" ) );
941 int errorCode = (int) event.m_item.GetData();
948 menu.Check( settings.
GetSeverity( errorCode ),
true );
950 int severity = GetPopupMenuSelectionFromUser( menu );
954 if( settings.
GetSeverity( errorCode ) != severity )
1020 if( marker !=
nullptr )
1031 if( node && marker && !marker->
IsExcluded() )
1034 m_parent->GetCanvas()->GetView()->Update( marker );
1051 m_parent->ShowSchematicSetupDialog(
_(
"Violation Severity" ) );
1057 if( aEvent.GetEventObject() ==
m_showAll )
1073 wxWindowUpdateLocker updateLock(
this );
1088 wxFileDialog dlg(
this,
_(
"Save Report File" ),
Prj().GetProjectPath(), fn.GetFullName(),
1090 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1092 if( dlg.ShowModal() != wxID_OK )
1097 if( fn.GetExt().IsEmpty() )
1100 if( !fn.IsAbsolute() )
1103 fn.MakeAbsolute( prj_path );
1108 bool success =
false;
1116 m_messages->Report( wxString::Format(
_(
"Report file '%s' created." ),
1117 fn.GetFullPath() ) );
1122 fn.GetFullPath() ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
static TOOL_ACTION excludeMarker
static TOOL_ACTION selectionClear
Clear the current selection.
wxButton * m_sdbSizer1Cancel
wxSimplebook * m_runningResultsBook
wxCheckBox * m_showExclusions
NUMBER_BADGE * m_errorsBadge
STD_BITMAP_BUTTON * m_bMenu
wxCheckBox * m_showErrors
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
DIALOG_ERC_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Electrical Rules Checker"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnMenu(wxCommandEvent &aEvent) override
void ExcludeMarker(SCH_MARKER *aMarker=nullptr)
Exclude aMarker from the ERC list.
void OnIgnoredItemRClick(wxListEvent &aEvent) override
const SCH_MARKER * m_centerMarkerOnIdle
void OnERCItemDClick(wxDataViewEvent &aEvent) override
std::shared_ptr< RC_ITEMS_PROVIDER > m_markerProvider
bool TransferDataToWindow() override
DIALOG_ERC(SCH_EDIT_FRAME *parent)
bool m_scroll_on_crossprobe
void SelectMarker(const SCH_MARKER *aMarker)
SCH_EDIT_FRAME * m_parent
wxString m_violationsTitleTemplate
void OnERCItemRClick(wxDataViewEvent &aEvent) override
void centerMarkerIdleHandler(wxIdleEvent &aEvent)
void OnDeleteAllClick(wxCommandEvent &event) override
void OnLinkClicked(wxHtmlLinkEvent &event) override
void OnCharHook(wxKeyEvent &aEvt) override
void OnRunERCClick(wxCommandEvent &event) override
void deleteAllMarkers(bool aIncludeExclusions)
wxString m_ignoredTitleTemplate
void OnDeleteOneClick(wxCommandEvent &event) override
void OnSaveReport(wxCommandEvent &aEvent) override
SCHEMATIC * m_currentSchematic
void OnEditViolationSeverities(wxHyperlinkEvent &aEvent) override
void UpdateAnnotationWarning()
void Report(const wxString &aMessage) override
Display aMessage in the progress bar dialog.
void OnERCItemSelected(wxDataViewEvent &aEvent) override
RC_TREE_MODEL * m_markerTreeModel
void updateDisplayedCounts()
void OnSeverity(wxCommandEvent &aEvent) override
void OnCloseErcDialog(wxCloseEvent &event) override
void OnCancelClick(wxCommandEvent &event) override
bool Show(bool show) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
bool IsQuasiModal() const
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual void OnCharHook(wxKeyEvent &aEvt)
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
bool WriteJsonReport(const wxString &aFullFileName)
Writes a JSON formatted ERC Report to the given file path in the c-locale.
bool WriteTextReport(const wxString &aFullFileName)
Writes the text report also available via GetTextReport directly to a given file path.
Container for ERC settings.
SEVERITY GetSeverity(int aErrorCode) const
void SetSeverity(int aErrorCode, SEVERITY aSeverity)
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
A specialisation of the RC_TREE_MODEL class to enable ERC errors / warnings to be resolved in a speci...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
std::shared_ptr< RC_ITEM > GetRCItem() const
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
PROGRESS_REPORTER_BASE(int aNumPhases)
virtual void SetCurrentProgress(double aProgress) override
Set the progress value to aProgress (0..1).
std::atomic_bool m_cancelled
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.
MARKER_BASE * GetParent() const
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
void ValueChanged(RC_TREE_NODE *aNode)
void Update(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
void DeleteCurrentItem(bool aDeep)
static KIID ToUUID(wxDataViewItem aItem)
std::shared_ptr< RC_ITEM > m_RcItem
Holds all the data relating to one schematic.
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
ERC_SETTINGS & ErcSettings() const
static TOOL_ACTION changeSheet
Schematic editor (Eeschema) main window.
SCHEMATIC & Schematic() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
wxString GetClass() const override
Return the class name.
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.
void DeleteMarkers(enum MARKER_BASE::MARKER_T aMarkerTyp, int aErrorCode, bool aIncludeExclusions=true)
Delete all markers of a particular type and error code.
void DeleteAllMarkers(enum MARKER_BASE::MARKER_T 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)
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
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
wxString GetValue() const
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
wxDEFINE_EVENT(EDA_EVT_CLOSE_ERC_DIALOG, wxCommandEvent)
static std::vector< std::pair< wxString, int > > g_lastERCIgnored
static SCHEMATIC * g_lastERCSchematic
#define DIALOG_ERC_WINDOW_NAME
static int DEFAULT_SINGLE_COL_WIDTH
@ ERCE_ENDPOINT_OFF_GRID
Pin or wire-end off grid.
@ ERCE_PIN_TO_PIN_WARNING
static const std::string ReportFileExtension
static const std::string JsonFileExtension
static wxString JsonFileWildcard()
static wxString ReportFileWildcard()
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
Definition of file extensions used in Kicad.