53#include <wx/filedlg.h>
54#include <wx/hyperlink.h>
77 m_markerTreeModel( nullptr ),
80 m_centerMarkerOnIdle( nullptr ),
109 listItem.SetText( str );
110 listItem.SetData( code );
119 { wxID_CANCEL,
_(
"Close" ) } } );
156 wxASSERT( settings );
172 wxHyperlinkCtrl* button =
new wxHyperlinkCtrl(
m_infoBar, wxID_ANY,
173 _(
"Show Annotation dialog" ),
176 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<
void( wxHyperlinkEvent& aEvent )>(
177 [&]( wxHyperlinkEvent& aEvent )
179 wxHtmlLinkEvent htmlEvent( aEvent.GetId(),
180 wxHtmlLinkInfo( aEvent.GetURL() ) );
187 "ERC results will be incomplete." ) );
245 bool markersOverflowed =
false;
254 num.Printf( markersOverflowed ? wxT(
"%d+" ) : wxT(
"%d" ), numMarkers );
260 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
273 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
309 bool includeExclusions =
false;
315 if( numExcluded > 0 )
317 wxMessageDialog dlg(
this,
_(
"Delete exclusions too?" ),
_(
"Delete All Markers" ),
318 wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION );
319 dlg.SetYesNoLabels(
_(
"Errors and Warnings Only" ),
320 _(
"Errors, Warnings and Exclusions" ) );
322 int ret = dlg.ShowModal();
324 if( ret == wxID_CANCEL )
326 else if( ret == wxID_NO )
327 includeExclusions =
true;
359 wxCommandEvent* evt =
new wxCommandEvent( EDA_EVT_CLOSE_ERC_DIALOG, wxID_ANY );
361 wxWindow* parent = GetParent();
364 wxQueueEvent( parent, evt );
385 wxCommandEvent
dummy;
404 for( std::reference_wrapper<RC_ITEM>& item : violations )
410 listItem.SetText( wxT(
" • " ) + item.get().GetErrorText() );
411 listItem.SetData( item.get().GetErrorCode() );
437 ercItem->SetErrorMessage( aMsg );
442 ercItem->SetItems( aItemA->
GetSymbol() );
450 if( itemsNotAnnotated )
539 else if( item && item->
GetClass() != wxT(
"DELETED_SHEET_ITEM" ) )
546 std::shared_ptr<ERC_ITEM> ercItem =
547 std::static_pointer_cast<ERC_ITEM>( node->
m_RcItem );
551 if( ercItem->IsSheetSpecific() )
552 sheet = ercItem->GetSpecificSheetPath();
555 if( ercItem->MainItemHasSheetPath() )
556 sheet = ercItem->GetMainItemSheetPath();
559 if( ercItem->AuxItemHasSheetPath() )
560 sheet = ercItem->GetAuxItemSheetPath();
589 if( aEvent.GetItem().IsOk() )
612 std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
616 switch( settings.
GetSeverity( rcItem->GetErrorCode() ) )
620 default: listName =
_(
"appropriate" );
break;
625 ID_EDIT_EXCLUSION_COMMENT = 4467,
627 ID_REMOVE_EXCLUSION_ALL,
629 ID_ADD_EXCLUSION_WITH_COMMENT,
630 ID_ADD_EXCLUSION_ALL,
631 ID_INSPECT_VIOLATION,
632 ID_EDIT_PIN_CONFLICT_MAP,
633 ID_EDIT_CONNECTION_GRID,
634 ID_SET_SEVERITY_TO_ERROR,
635 ID_SET_SEVERITY_TO_WARNING,
636 ID_SET_SEVERITY_TO_IGNORE,
640 if( rcItem->GetParent()->IsExcluded() )
642 menu.Append( ID_REMOVE_EXCLUSION,
643 _(
"Remove exclusion for this violation" ),
644 wxString::Format(
_(
"It will be placed back in the %s list" ), listName ) );
646 menu.Append( ID_EDIT_EXCLUSION_COMMENT,
647 _(
"Edit exclusion comment..." ) );
651 menu.Append( ID_ADD_EXCLUSION,
652 _(
"Exclude this violation" ),
653 wxString::Format(
_(
"It will be excluded from the %s list" ), listName ) );
655 menu.Append( ID_ADD_EXCLUSION_WITH_COMMENT,
656 _(
"Exclude with comment..." ),
657 wxString::Format(
_(
"It will be excluded from the %s list" ), listName ) );
662 if( !inspectERCErrorMenuText.IsEmpty() )
663 menu.Append( ID_INSPECT_VIOLATION, inspectERCErrorMenuText );
665 menu.AppendSeparator();
674 menu.Append( ID_SET_SEVERITY_TO_ERROR,
675 wxString::Format(
_(
"Change severity to Error for all '%s' violations" ),
676 rcItem->GetErrorText() ),
677 _(
"Violation severities can also be edited in the Schematic Setup... dialog" ) );
681 menu.Append( ID_SET_SEVERITY_TO_WARNING,
682 wxString::Format(
_(
"Change severity to Warning for all '%s' violations" ),
683 rcItem->GetErrorText() ),
684 _(
"Violation severities can also be edited in the Schematic Setup... dialog" ) );
687 menu.Append( ID_SET_SEVERITY_TO_IGNORE,
688 wxString::Format(
_(
"Ignore all '%s' violations" ), rcItem->GetErrorText() ),
689 _(
"Violations will not be checked or reported" ) );
691 menu.AppendSeparator();
696 menu.Append( ID_EDIT_PIN_CONFLICT_MAP,
697 _(
"Edit pin-to-pin conflict map..." ),
698 _(
"Open the Schematic Setup... dialog" ) );
702 menu.Append( ID_EDIT_SEVERITIES,
703 _(
"Edit violation severities..." ),
704 _(
"Open the Schematic Setup... dialog" ) );
709 menu.Append( ID_EDIT_CONNECTION_GRID,
710 _(
"Edit connection grid spacing..." ),
711 _(
"Open the Schematic Setup... dialog" ) );
714 bool modified =
false;
715 int command = GetPopupMenuSelectionFromUser( menu );
719 case ID_EDIT_EXCLUSION_COMMENT:
723 marker->GetComment(),
true );
725 if( dlg.ShowModal() == wxID_CANCEL )
728 marker->SetExcluded(
true, dlg.
GetValue() );
731 static_cast<RC_TREE_MODEL*
>( aEvent.GetModel() )->ValueChanged( node );
737 case ID_REMOVE_EXCLUSION:
740 marker->SetExcluded(
false );
744 static_cast<RC_TREE_MODEL*
>( aEvent.GetModel() )->ValueChanged( node );
750 case ID_ADD_EXCLUSION:
751 case ID_ADD_EXCLUSION_WITH_COMMENT:
756 if( command == ID_ADD_EXCLUSION_WITH_COMMENT )
759 wxEmptyString,
true );
761 if( dlg.ShowModal() == wxID_CANCEL )
767 marker->SetExcluded(
true, comment );
773 static_cast<RC_TREE_MODEL*
>( aEvent.GetModel() )->ValueChanged( node );
775 static_cast<RC_TREE_MODEL*
>( aEvent.GetModel() )->DeleteCurrentItem(
false );
782 case ID_INSPECT_VIOLATION:
786 case ID_SET_SEVERITY_TO_ERROR:
793 if( marker->
GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
802 case ID_SET_SEVERITY_TO_WARNING:
809 if( marker->
GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
818 case ID_SET_SEVERITY_TO_IGNORE:
827 listItem.SetText( wxT(
" • " ) + rcItem->GetErrorText() );
828 listItem.SetData( rcItem->GetErrorCode() );
845 case ID_EDIT_PIN_CONFLICT_MAP:
849 case ID_EDIT_SEVERITIES:
853 case ID_EDIT_CONNECTION_GRID:
870 int errorCode = (int) event.m_item.GetData();
877 menu.Check( settings.
GetSeverity( errorCode ), true );
879 int severity = GetPopupMenuSelectionFromUser( menu );
883 if( settings.
GetSeverity( errorCode ) != severity )
946 if( marker !=
nullptr )
985 if( aEvent.GetEventObject() ==
m_showAll )
994 if( aEvent.IsChecked() )
996 else if( aEvent.GetEventObject() ==
m_showAll )
1024 wxFileDialog dlg(
this,
_(
"Save Report File" ),
Prj().GetProjectPath(), fn.GetFullName(),
1026 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1028 if( dlg.ShowModal() != wxID_OK )
1033 if( fn.GetExt().IsEmpty() )
1036 if( !fn.IsAbsolute() )
1039 fn.MakeAbsolute( prj_path );
1044 bool success =
false;
1053 fn.GetFullPath() ) );
1057 DisplayError(
this, wxString::Format(
_(
"Failed to create file '%s'." ),
1058 fn.GetFullPath() ) );
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION cancelInteractive
VECTOR2D m_ScrollCenter
Current scroll center point in logical units.
wxButton * m_sdbSizer1Cancel
wxSimplebook * m_runningResultsBook
wxCheckBox * m_showExclusions
NUMBER_BADGE * m_errorsBadge
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
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
DIALOG_ERC(SCH_EDIT_FRAME *parent)
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 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 Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
static TOOL_ACTION clearSelection
Clears the current selection.
EE_TYPE OfType(KICAD_T aType) const
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.
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...
APP_SETTINGS_BASE * KifaceSettings() const
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
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...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
std::shared_ptr< RC_ITEM > GetRCItem() const
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
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).
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.
void SelectMarker(const MARKER_BASE *aMarker)
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 DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
void DeleteCurrentItem(bool aDeep)
void CenterMarker(const MARKER_BASE *aMarker)
static KIID ToUUID(wxDataViewItem aItem)
std::shared_ptr< RC_ITEM > m_RcItem
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.
Holds all the data relating to one schematic.
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
ERC_SETTINGS & ErcSettings() const
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.
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,...
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)
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
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
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.
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
wxString GetValue() const
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
static int RPT_SEVERITY_ALL
static int DEFAULT_SINGLE_COL_WIDTH
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()
std::vector< FAB_LAYER_COLOR > dummy
Definition of file extensions used in Kicad.
static int RPT_SEVERITY_ALL