42#include <wx/filedlg.h>
43#include <wx/wupdlock.h>
70 m_footprintTestsRun( false ),
71 m_markersTreeModel( nullptr ),
72 m_unconnectedTreeModel( nullptr ),
73 m_fpWarningsTreeModel( nullptr ),
74 m_centerMarkerOnIdle( nullptr ),
126 { wxID_CANCEL,
_(
"Close" ) } } );
166 if( !
Kiface().IsSingle() )
183 SetReturnCode( wxID_CANCEL );
197 cur = std::max( 0.0, std::min( cur, 1.0 ) );
243 if( zoneFillerTool->IsBusy() )
263 m_messages->
Report(
_(
"DRC incomplete: could not compile custom design rules. " )
264 + wxT(
"<a href='boardsetup'>" )
265 +
_(
"Show design rules." )
282 for( std::reference_wrapper<RC_ITEM>& item : violations )
287 wxT(
" • " ) + item.get().GetErrorText() );
306 drcTool->
RunTests(
this, refillZones, reportAllTrackErrors, testFootprints );
350 auto getActiveLayers =
358 for(
int layer : aItem->GetLayerSet().Seq() )
360 if(
pad->FlashLayer( layer ) )
368 return aItem->GetLayerSet();
389 std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
412 LSET violationLayers;
438 if( a || b || c || d )
449 LSET layersList = getActiveLayers( it );
450 violationLayers &= layersList;
453 principalLayer = layersList.
Seq().front();
457 if( violationLayers.count() )
458 principalLayer = violationLayers.
Seq().front();
460 violationLayers.set( principalLayer );
484 m_frame->FocusOnLocation( edge.GetSourcePos() );
486 m_frame->FocusOnLocation( edge.GetTargetPos() );
502 std::vector<BOARD_ITEM*> items;
510 for(
const KIID&
id : rc_item->GetIDs() )
514 if( candidate && candidate->GetNetCode() == net )
515 items.push_back( candidate );
520 items.push_back( item );
536 if( aEvent.GetItem().IsOk() )
556 std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
567 default: listName =
_(
"appropriate" );
break;
570 if( rcItem->GetParent()->IsExcluded() )
572 menu.Append( 1,
_(
"Remove exclusion for this violation" ),
577 msg.Printf(
_(
"Remove all exclusions for violations of rule '%s'" ),
579 menu.Append( 11, msg );
584 menu.Append( 2,
_(
"Exclude this violation" ),
589 msg.Printf(
_(
"Exclude all violations of rule '%s'" ),
591 menu.Append( 21, msg );
600 menu.Append( 3,
_(
"Run clearance resolution tool..." ) );
612 menu.Append( 3,
_(
"Run constraints resolution tool..." ) );
615 menu.AppendSeparator();
619 msg.Printf(
_(
"Change severity to Error for all '%s' violations" ),
620 rcItem->GetErrorText(),
621 _(
"Violation severities can also be edited in the Board Setup... dialog" ) );
622 menu.Append( 4, msg );
626 msg.Printf(
_(
"Change severity to Warning for all '%s' violations" ),
627 rcItem->GetErrorText(),
628 _(
"Violation severities can also be edited in the Board Setup... dialog" ) );
629 menu.Append( 5, msg );
632 msg.Printf(
_(
"Ignore all '%s' violations" ),
633 rcItem->GetErrorText(),
634 _(
"Violations will not be checked or reported" ) );
635 menu.Append( 6, msg );
637 menu.AppendSeparator();
639 menu.Append( 7,
_(
"Edit violation severities..." ),
_(
"Open the Board Setup... dialog" ) );
641 bool modified =
false;
643 switch( GetPopupMenuSelectionFromUser( menu ) )
664 static_cast<RC_TREE_MODEL*
>( aEvent.GetModel() )->ValueChanged( node );
691 static_cast<RC_TREE_MODEL*
>( aEvent.GetModel() )->ValueChanged( node );
693 static_cast<RC_TREE_MODEL*
>( aEvent.GetModel() )->DeleteCurrentItem(
false );
705 DRC_ITEM* candidateDrcItem =
static_cast<DRC_ITEM*
>( marker->GetRCItem().get() );
708 marker->SetExcluded(
false );
721 DRC_ITEM* candidateDrcItem =
static_cast<DRC_ITEM*
>( marker->GetRCItem().get() );
724 marker->SetExcluded(
true );
747 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
761 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
775 wxT(
" • " ) + rcItem->GetErrorText() );
779 for(
unsigned i = 0; i < markers.size(); )
781 if( markers[i]->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
784 markers.erase( markers.begin() + i );
825 if( aEvent.GetEventObject() ==
m_showAll )
834 if( aEvent.IsChecked() )
836 else if( aEvent.GetEventObject() ==
m_showAll )
850 wxFileDialog dlg(
this,
_(
"Save Report to File" ),
Prj().GetProjectPath(), fn.GetFullName(),
853 if( dlg.ShowModal() != wxID_OK )
858 if( fn.GetExt().IsEmpty() )
861 if( !fn.IsAbsolute() )
864 fn.MakeAbsolute( prj_path );
870 fn.GetFullPath() ) );
875 fn.GetFullPath() ) );
885 wxCommandEvent
dummy;
901 SetReturnCode( wxID_CANCEL );
913 if( aEvent.GetSelection() >= 0 )
914 m_Notebook->ChangeSelection( (
unsigned) aEvent.GetSelection() );
1024 FILE* fp = wxFopen( aFullFileName, wxT(
"w" ) );
1029 std::map<KIID, EDA_ITEM*> itemMap;
1038 wxDateTime now = wxDateTime::Now();
1040 fprintf( fp,
"** Created on %s **\n",
TO_UTF8( now.Format( wxT(
"%F %T" ) ) ) );
1044 fprintf( fp,
"\n** Found %d DRC violations **\n", count );
1046 for(
int i = 0; i < count; ++i )
1049 SEVERITY severity = item->GetParent()->GetSeverity();
1054 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
1059 fprintf( fp,
"\n** Found %d unconnected pads **\n", count );
1061 for(
int i = 0; i < count; ++i )
1066 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
1071 fprintf( fp,
"\n** Found %d Footprint errors **\n", count );
1073 for(
int i = 0; i < count; ++i )
1078 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
1082 fprintf( fp,
"\n** End of Report **\n" );
1117 static bool s_includeExclusions =
false;
1119 int numExcluded = 0;
1130 if( numExcluded > 0 )
1132 wxRichMessageDialog dlg(
this,
_(
"Do you wish to delete excluded markers as well?" ),
1133 _(
"Delete All Markers" ),
1134 wxOK | wxCANCEL | wxCENTER | wxICON_QUESTION );
1135 dlg.ShowCheckBox(
_(
"Delete exclusions" ), s_includeExclusions );
1137 int ret = dlg.ShowModal();
1139 if( ret == wxID_CANCEL )
1142 s_includeExclusions = dlg.IsCheckBoxChecked();
1161 int numUnconnected = 0;
1162 int numFootprints = 0;
1165 int numWarnings = 0;
1166 int numExcluded = 0;
1194 bool errorsOverflowed =
false;
1195 bool warningsOverflowed =
false;
1196 bool markersOverflowed =
false;
1197 bool unconnectedOverflowed =
false;
1198 bool footprintsOverflowed =
false;
1202 if( drcEngine->IsErrorLimitExceeded( ii ) )
1205 errorsOverflowed =
true;
1207 warningsOverflowed =
true;
1212 unconnectedOverflowed =
true;
1214 unconnectedOverflowed =
true;
1222 footprintsOverflowed =
true;
1224 footprintsOverflowed =
true;
1229 markersOverflowed =
true;
1231 markersOverflowed =
true;
1243 num.Printf( markersOverflowed ? wxT(
"%d+" ) : wxT(
"%d" ), numMarkers );
1249 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
1256 num.Printf( unconnectedOverflowed ? wxT(
"%d+" ) : wxT(
"%d" ), numUnconnected );
1262 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
1269 num.Printf( footprintsOverflowed ? wxT(
"%d+" ) : wxT(
"%d" ), numFootprints );
1275 msg.Replace( wxT(
"%s" ),
_(
"not run" ) );
1280 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
1293 msg.Replace( wxT(
"(%s)" ), wxEmptyString );
1303 if( !
m_drcRun && numWarnings == 0 )
constexpr EDA_IU_SCALE pcbIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void SetLayerVisible(int aLayer, bool isVisible)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
SEVERITY GetSeverity(int aDRCErrorCode)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
BOARD_ITEM * GetItem(const KIID &aID) const
const wxString & GetFileName() const
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
void DeleteMARKERs()
Delete all MARKERS from the board.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
std::shared_ptr< const CN_ANCHOR > GetSourceNode() const
std::shared_ptr< const CN_ANCHOR > GetTargetNode() const
static DELETED_BOARD_ITEM * GetInstance()
wxCheckBox * m_cbRefillZones
wxButton * m_DeleteAllMarkersButton
wxCheckBox * m_showExclusions
wxCheckBox * m_showErrors
wxDataViewCtrl * m_unconnectedDataView
wxDataViewCtrl * m_footprintsDataView
NUMBER_BADGE * m_warningsBadge
wxCheckBox * m_cbReportAllTrackErrors
NUMBER_BADGE * m_exclusionsBadge
wxSimplebook * m_runningResultsBook
wxButton * m_DeleteCurrentMarkerButton
wxButton * m_sdbSizerCancel
wxCheckBox * m_cbTestFootprints
wxCheckBox * m_showWarnings
wxListCtrl * m_ignoredList
NUMBER_BADGE * m_errorsBadge
WX_HTML_REPORT_BOX * m_messages
wxDataViewCtrl * m_markerDataView
void centerMarkerIdleHandler(wxIdleEvent &aEvent)
void OnDRCItemSelected(wxDataViewEvent &aEvent) override
wxString m_footprintsTitleTemplate
void UpdateData()
Rebuild the contents of the violation tabs based on the current markers and severties.
const PCB_MARKER * m_centerMarkerOnIdle
std::shared_ptr< RC_ITEMS_PROVIDER > m_ratsnestProvider
wxString m_markersTitleTemplate
DIALOG_DRC(PCB_EDIT_FRAME *aEditorFrame, wxWindow *aParent)
Constructors.
void OnEditViolationSeverities(wxHyperlinkEvent &aEvent) override
void OnDeleteOneClick(wxCommandEvent &aEvent) override
RC_TREE_MODEL * m_fpWarningsTreeModel
void OnDeleteAllClick(wxCommandEvent &aEvent) override
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
BOARD_DESIGN_SETTINGS & bds()
void SelectMarker(const PCB_MARKER *aMarker)
void OnClose(wxCloseEvent &event) override
bool writeReport(const wxString &aFullFileName)
Function writeReport outputs the MARKER items with commentary to an open text file.
void OnDRCItemRClick(wxDataViewEvent &aEvent) override
void OnRunDRCClick(wxCommandEvent &aEvent) override
wxString m_ignoredTitleTemplate
void OnDRCItemDClick(wxDataViewEvent &aEvent) override
void deleteAllMarkers(bool aIncludeExclusions)
void updateDisplayedCounts()
RC_TREE_MODEL * m_unconnectedTreeModel
wxString m_unconnectedTitleTemplate
std::shared_ptr< RC_ITEMS_PROVIDER > m_fpWarningsProvider
std::shared_ptr< RC_ITEMS_PROVIDER > m_markersProvider
void OnSeverity(wxCommandEvent &aEvent) override
void OnCancelClick(wxCommandEvent &aEvent) override
void OnActivateDlg(wxActivateEvent &aEvent) override
void OnChangingNotebookPage(wxNotebookEvent &aEvent) override
void OnSaveReport(wxCommandEvent &aEvent) override
RC_TREE_MODEL * m_markersTreeModel
bool Show(bool show) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_UNITS GetUserUnits() const
Design Rule Checker object that performs all the DRC tests.
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
DRC_RULE * GetViolatingRule() const
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
KICAD_T Type() const
Returns the type of object.
EDA_ITEM_FLAGS GetFlags() const
bool IsSingle() const
Is this KIFACE running under single_top?
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
void SetExcluded(bool aExcluded)
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.
DISPLAY_OPTIONS m_Display
static TOOL_ACTION showRatsnest
static TOOL_ACTION selectionClear
Clear the current selection.
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
APPEARANCE_CONTROLS * GetAppearancePanel()
void FocusOnItems(std::vector< BOARD_ITEM * > aItems, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
The main frame for Pcbnew.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
void OnModify() override
Must be called after a board change to set the modified flag.
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
SEVERITY GetSeverity() const override
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
std::atomic_int m_progress
std::atomic_int m_maxProgress
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 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)
void ValueChanged(const RC_TREE_NODE *aNode)
std::shared_ptr< RC_ITEM > m_RcItem
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 Flush()
Build the HTML messages page.
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 std::vector< wxString > g_lastIgnored
static int RPT_SEVERITY_ALL
static int DEFAULT_SINGLE_COL_WIDTH
static BOARD * g_lastDRCBoard
static bool g_lastFootprintTestsRun
#define DIALOG_DRC_WINDOW_NAME
@ DRCE_DRILL_OUT_OF_RANGE
@ DRCE_DRILLED_HOLES_TOO_CLOSE
@ DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG
@ DRCE_MICROVIA_DRILL_OUT_OF_RANGE
@ DRCE_MALFORMED_COURTYARD
@ DRCE_UNRESOLVED_VARIABLE
@ DRCE_DUPLICATE_FOOTPRINT
#define MALFORMED_F_COURTYARD
#define MALFORMED_B_COURTYARD
const std::string ReportFileExtension
wxString ReportFileWildcard()
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::vector< FAB_LAYER_COLOR > dummy
A filename or source description, a problem input line, a line number, a byte offset,...
bool test_all_track_errors
bool m_ShowGlobalRatsnest
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_PAD_T
class PAD, a pad in a footprint
Functions to provide common constants and other functions to assist in making a consistent UI.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition of file extensions used in Kicad.