50#include <wx/filedlg.h>
51#include <wx/hyperlink.h>
62 bool aExcluded,
const wxString& aComment = wxEmptyString )
139 listItem.SetText( str );
140 listItem.SetData( code );
149 { wxID_CANCEL,
_(
"Close" ) } } );
184 g_lastERCIgnored.push_back( { m_ignoredList->GetItemText( ii ), m_ignoredList->GetItemData( ii ) } );
207 m_infoBar->AddLink(
_(
"Show Annotation dialog" ),
208 [&]( wxHyperlinkEvent& aEvent )
210 wxHtmlLinkEvent htmlEvent( aEvent.GetId(), wxHtmlLinkInfo( aEvent.GetURL() ) );
214 m_infoBar->ShowMessage(
_(
"Schematic is not fully annotated. ERC results will be incomplete." ) );
250 menu.Append( 4206,
_(
"Cross-probe Selected Items" ),
251 _(
"Highlight corresponding items on canvas when selected in the ERC list" ),
255 menu.Append( 4207,
_(
"Center on Cross-probe" ),
256 _(
"When cross-probing, scroll the canvas so that the item is visible" ),
260 menu.Append( 4208,
_(
"Show all errors" ),
261 _(
"Show duplicate ERC markers on all applicable pins" ),
266 int menu_id =
m_bMenu->GetPopupMenuSelectionFromUser( menu );
268 if( menu_id == 0 || menu_id == 4206 )
272 else if( menu_id == 1 || menu_id == 4207 )
276 else if( menu_id == 2 || menu_id == 4208 )
285 if(
int hotkey = aEvt.GetKeyCode() )
287 if( aEvt.ControlDown() )
289 if( aEvt.ShiftDown() )
363 bool markersOverflowed =
false;
372 num.Printf( markersOverflowed ? wxT(
"%d+" ) : wxT(
"%d" ), numMarkers );
378 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
391 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
427 bool includeExclusions =
false;
428 size_t numExcluded =
m_parent->Schematic().GetUnresolvedERCExclusionCount();
433 if( numExcluded > 0 )
436 wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION );
437 dlg.SetYesNoLabels(
_(
"Errors and Warnings Only" ),
438 _(
"Errors, Warnings and Exclusions" ) );
440 int ret = dlg.ShowModal();
442 if( ret == wxID_CANCEL )
444 else if( ret == wxID_NO )
445 includeExclusions =
true;
448 if( includeExclusions )
449 m_parent->Schematic().ClearUnresolvedERCExclusions();
481 if( wxWindow* parent = GetParent() )
482 wxQueueEvent( parent,
new wxCommandEvent( EDA_EVT_CLOSE_ERC_DIALOG, wxID_ANY ) );
508 for( std::reference_wrapper<RC_ITEM>& item : violations )
514 listItem.SetText( wxT(
" • " ) + item.get().GetErrorText(
true ) );
515 listItem.SetData( item.get().GetErrorCode() );
538 int itemsNotAnnotated =
m_parent->CheckAnnotate(
546 if( itemsNotAnnotated )
548 m_messages->ReportHead( wxString::Format(
_(
"%d symbol(s) require annotation.<br><br>" ),
595 m_parent->GetCanvas()->GetView()->RefreshDrawingSheetPageInfo();
636 else if( item && item->
GetClass() != wxT(
"DELETED_SHEET_ITEM" ) )
643 std::shared_ptr<ERC_ITEM> ercItem = std::static_pointer_cast<ERC_ITEM>( node->
m_RcItem );
645 if( ercItem->IsSheetSpecific() )
646 sheet = ercItem->GetSpecificSheetPath();
651 if( ercItem->MainItemHasSheetPath() )
652 sheet = ercItem->GetMainItemSheetPath();
657 if( ercItem->AuxItemHasSheetPath() )
658 sheet = ercItem->GetAuxItemSheetPath();
669 const auto currentPath =
m_parent->Schematic().Hierarchy().GetSheetPathByKIIDPath( sheet.
PathRef() );
677 sheet = *currentPath;
698 if( aEvent.GetItem().IsOk() )
722 std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
730 switch( settings.
GetSeverity( rcItem->GetErrorCode() ) )
734 default: listName =
_(
"appropriate" );
break;
739 ID_EDIT_EXCLUSION_COMMENT = 4467,
741 ID_REMOVE_EXCLUSION_ALL,
743 ID_ADD_EXCLUSION_WITH_COMMENT,
744 ID_ADD_EXCLUSION_ALL,
745 ID_INSPECT_VIOLATION,
747 ID_EDIT_PIN_CONFLICT_MAP,
748 ID_EDIT_CONNECTION_GRID,
749 ID_SET_SEVERITY_TO_ERROR,
750 ID_SET_SEVERITY_TO_WARNING,
751 ID_SET_SEVERITY_TO_IGNORE,
757 menu.Append( ID_REMOVE_EXCLUSION,
758 _(
"Remove exclusion for this violation" ),
759 wxString::Format(
_(
"It will be placed back in the %s list" ), listName ) );
761 menu.Append( ID_EDIT_EXCLUSION_COMMENT,
762 _(
"Edit exclusion comment..." ) );
766 menu.Append( ID_ADD_EXCLUSION,
767 _(
"Exclude this violation" ),
768 wxString::Format(
_(
"It will be excluded from the %s list" ), listName ) );
770 menu.Append( ID_ADD_EXCLUSION_WITH_COMMENT,
771 _(
"Exclude with comment..." ),
772 wxString::Format(
_(
"It will be excluded from the %s list" ), listName ) );
775 menu.AppendSeparator();
778 wxString fixERCErrorMenuText = editTool->FixERCErrorMenuText( rcItem );
780 if( !inspectERCErrorMenuText.IsEmpty() || !fixERCErrorMenuText.IsEmpty() )
782 if( !inspectERCErrorMenuText.IsEmpty() )
783 menu.Append( ID_INSPECT_VIOLATION, inspectERCErrorMenuText );
785 if( !fixERCErrorMenuText.IsEmpty() )
786 menu.Append( ID_FIX_VIOLATION, fixERCErrorMenuText );
788 menu.AppendSeparator();
798 menu.Append( ID_SET_SEVERITY_TO_ERROR,
799 wxString::Format(
_(
"Change severity to Error for all '%s' violations" ),
800 rcItem->GetErrorText(
true ) ),
801 _(
"Violation severities can also be edited in Schematic Setup" ) );
805 menu.Append( ID_SET_SEVERITY_TO_WARNING,
806 wxString::Format(
_(
"Change severity to Warning for all '%s' violations" ),
807 rcItem->GetErrorText(
true ) ),
808 _(
"Violation severities can also be edited in Schematic Setup" ) );
811 menu.Append( ID_SET_SEVERITY_TO_IGNORE,
812 wxString::Format(
_(
"Ignore all '%s' violations" ), rcItem->GetErrorText(
true ) ),
813 _(
"Violations will not be checked or reported" ) );
815 menu.AppendSeparator();
820 menu.Append( ID_EDIT_PIN_CONFLICT_MAP,
821 _(
"Edit pin-to-pin conflict map..." ),
822 _(
"Open the Schematic Setup dialog" ) );
826 menu.Append( ID_EDIT_SEVERITIES,
827 _(
"Edit violation severities..." ),
828 _(
"Open the Schematic Setup dialog" ) );
833 menu.Append( ID_EDIT_CONNECTION_GRID,
834 _(
"Edit connection grid spacing..." ),
835 _(
"Open the Schematic Setup dialog" ) );
838 bool modified =
false;
839 int command = GetPopupMenuSelectionFromUser( menu );
845 if( !currentMarker || !node )
850 case ID_EDIT_EXCLUSION_COMMENT:
853 WX_TEXT_ENTRY_DIALOG dlg(
this, wxEmptyString,
_(
"Exclusion Comment" ), marker->GetComment(),
true );
861 if( !marker || !node )
873 case ID_REMOVE_EXCLUSION:
877 m_parent->GetCanvas()->GetView()->Update( marker );
886 case ID_ADD_EXCLUSION:
887 case ID_ADD_EXCLUSION_WITH_COMMENT:
892 if( command == ID_ADD_EXCLUSION_WITH_COMMENT )
902 if( !marker || !node )
910 m_parent->GetCanvas()->GetView()->Update( marker );
919 case ID_INSPECT_VIOLATION:
923 case ID_FIX_VIOLATION:
924 editTool->FixERCError( rcItem );
927 case ID_SET_SEVERITY_TO_ERROR:
935 m_parent->GetCanvas()->GetView()->Update( marker );
943 case ID_SET_SEVERITY_TO_WARNING:
951 m_parent->GetCanvas()->GetView()->Update( marker );
959 case ID_SET_SEVERITY_TO_IGNORE:
968 listItem.SetText( wxT(
" • " ) + rcItem->GetErrorText(
true ) );
969 listItem.SetData( rcItem->GetErrorCode() );
979 m_parent->Schematic().ClearUnresolvedERCExclusions( rcItem->GetErrorCode() );
987 case ID_EDIT_PIN_CONFLICT_MAP:
988 m_parent->ShowSchematicSetupDialog(
_(
"Pin Conflicts Map" ) );
995 case ID_EDIT_SEVERITIES:
996 m_parent->ShowSchematicSetupDialog(
_(
"Violation Severity" ) );
1003 case ID_EDIT_CONNECTION_GRID:
1004 m_parent->ShowSchematicSetupDialog(
_(
"Formatting" ) );
1020 int errorCode = (int) event.m_item.GetData();
1027 menu.Check( settings.
GetSeverity( errorCode ),
true );
1029 int severity = GetPopupMenuSelectionFromUser( menu );
1033 if( settings.
GetSeverity( errorCode ) != severity )
1100 if( marker !=
nullptr )
1105 if( !marker &&
m_notebook->GetSelection() == 0 )
1119 m_parent->GetCanvas()->GetView()->Update( marker );
1132 m_parent->ShowSchematicSetupDialog(
_(
"Violation Severity" ) );
1138 if( aEvent.GetEventObject() ==
m_showAll )
1175 wxFileDialog dlg(
this,
_(
"Save Report File" ),
Prj().GetProjectPath(), fn.GetFullName(),
1177 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1181 if( dlg.ShowModal() != wxID_OK )
1186 if( fn.GetExt().IsEmpty() )
1189 if( !fn.IsAbsolute() )
1192 fn.MakeAbsolute( prj_path );
1197 bool success =
false;
1205 m_messages->Report( wxString::Format(
_(
"Report file '%s' created." ), fn.GetFullPath() ) );
1207 DisplayErrorMessage(
this, wxString::Format(
_(
"Failed to create file '%s'." ), 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 DeleteAllMarkers(bool aIncludeExclusions)
void OnDeleteAllClick(wxCommandEvent &event) override
void OnLinkClicked(wxHtmlLinkEvent &event) override
void OnCharHook(wxKeyEvent &aEvt) override
void OnRunERCClick(wxCommandEvent &event) override
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::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)
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
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
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.
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
void ValueChanged(RC_TREE_NODE *aNode)
void Update(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
static KIID ToUUID(wxDataViewItem aItem)
std::shared_ptr< RC_ITEM > m_RcItem
Holds all the data relating to one schematic.
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.
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.
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.
const KIID_PATH & PathRef() const
Borrow the cached path until this sheet path is modified or destroyed.
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
void SetMarkerExcluded(SCH_MARKER *aMarker, bool aExcluded, const wxString &aComment=wxEmptyString)
Set the exclusion state of a marker while keeping the cached severity counts in sync.
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.
#define KICAD_MESSAGE_DIALOG
static SCH_MARKER * findMarker(SCHEMATIC *aSchematic, const std::shared_ptr< RC_ITEM > &aItem)
static void setMarkerExcluded(const std::shared_ptr< RC_ITEMS_PROVIDER > &aProvider, SCH_MARKER *aMarker, bool aExcluded, const wxString &aComment=wxEmptyString)
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()
@ ANNOTATE_ALL
Annotate the full schematic.
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
Definition of file extensions used in Kicad.