38 #include <wx/filedlg.h> 39 #include <wx/wupdlock.h> 56 m_footprintTestsRun( false ),
57 m_markersProvider( nullptr ),
58 m_markersTreeModel( nullptr ),
59 m_unconnectedItemsProvider( nullptr ),
60 m_unconnectedTreeModel( nullptr ),
61 m_footprintWarningsProvider( nullptr ),
62 m_footprintWarningsTreeModel( nullptr ),
63 m_centerMarkerOnIdle( nullptr ),
107 if( !
Kiface().IsSingle() )
122 SetReturnCode( wxID_CANCEL );
143 if( !
Kiface().IsSingle() )
160 cur = std::max( 0.0, std::min( cur, 1.0 ) );
206 if( zoneFillerTool->IsBusy() )
226 m_messages->
Report(
_(
"DRC incomplete: could not compile custom design rules. " )
227 + wxT(
"<a href='boardsetup'>" )
228 +
_(
"Show design rules." )
258 drcTool->
RunTests(
this, refillZones, reportAllTrackErrors, testFootprints );
317 auto getActiveLayers =
322 PAD*
pad = static_cast<PAD*>( aItem );
325 for(
int layer : aItem->GetLayerSet().Seq() )
327 if(
pad->FlashLayer( layer ) )
335 return aItem->GetLayerSet();
342 LSET violationLayers;
343 std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
370 if( a || b || c || d )
374 violationLayers &= getActiveLayers( a );
377 violationLayers &= getActiveLayers( b );
380 violationLayers &= getActiveLayers( c );
383 violationLayers &= getActiveLayers( d );
386 if( violationLayers.count() )
387 principalLayer = violationLayers.
Seq().front();
389 violationLayers.set( principalLayer );
401 PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item );
406 std::vector<BOARD_ITEM*> segs;
408 for(
const KIID&
id : rc_item->GetIDs() )
412 if( candidate && candidate->
GetNetCode() == net )
413 segs.push_back( candidate );
440 if( aEvent.GetItem().IsOk() )
460 std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
469 default: listName =
_(
"appropriate" );
break;
472 if( rcItem->GetParent()->IsExcluded() )
474 menu.Append( 1,
_(
"Remove exclusion for this violation" ),
479 menu.Append( 2,
_(
"Exclude this violation" ),
486 menu.Append( 3,
_(
"Run clearance resolution tool..." ) );
489 menu.AppendSeparator();
493 msg.Printf(
_(
"Change severity to Error for all '%s' violations" ),
494 rcItem->GetErrorText(),
495 _(
"Violation severities can also be edited in the Board Setup... dialog" ) );
496 menu.Append( 4, msg );
500 msg.Printf(
_(
"Change severity to Warning for all '%s' violations" ),
501 rcItem->GetErrorText(),
502 _(
"Violation severities can also be edited in the Board Setup... dialog" ) );
503 menu.Append( 5, msg );
506 msg.Printf(
_(
"Ignore all '%s' violations" ),
507 rcItem->GetErrorText(),
508 _(
"Violations will not be checked or reported" ) );
509 menu.Append( 6, msg );
511 menu.AppendSeparator();
513 menu.Append( 7,
_(
"Edit violation severities..." ),
_(
"Open the Board Setup... dialog" ) );
515 bool modified =
false;
517 switch( GetPopupMenuSelectionFromUser( menu ) )
529 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
547 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
549 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem(
false );
571 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
576 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider(
m_markersProvider );
585 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
590 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider(
m_markersProvider );
600 for(
unsigned i = 0; i < markers.size(); )
602 if( markers[i]->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
605 markers.erase( markers.begin() + i );
612 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider(
m_markersProvider );
635 if( aEvent.GetEventObject() ==
m_showAll )
644 if( aEvent.IsChecked() )
646 else if( aEvent.GetEventObject() ==
m_showAll )
671 wxFileDialog dlg(
this,
_(
"Save Report to File" ),
Prj().GetProjectPath(), fn.GetFullName(),
674 if( dlg.ShowModal() != wxID_OK )
679 if( fn.GetExt().IsEmpty() )
682 if( !fn.IsAbsolute() )
685 fn.MakeAbsolute( prj_path );
691 fn.GetFullPath() ) );
696 fn.GetFullPath() ) );
706 wxCommandEvent
dummy;
722 SetReturnCode( wxID_CANCEL );
734 if( aEvent.GetSelection() >= 0 )
735 m_Notebook->ChangeSelection( (
unsigned) aEvent.GetSelection() );
810 if( marker && !marker->IsExcluded() )
839 FILE* fp = wxFopen( aFullFileName, wxT(
"w" ) );
844 std::map<KIID, EDA_ITEM*> itemMap;
853 wxDateTime now = wxDateTime::Now();
855 fprintf( fp,
"** Created on %s **\n",
TO_UTF8( now.Format( wxT(
"%F %T" ) ) ) );
859 fprintf( fp,
"\n** Found %d DRC violations **\n", count );
861 for(
int i = 0; i < count; ++i )
866 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
871 fprintf( fp,
"\n** Found %d unconnected pads **\n", count );
873 for(
int i = 0; i < count; ++i )
878 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
883 fprintf( fp,
"\n** Found %d Footprint errors **\n", count );
885 for(
int i = 0; i < count; ++i )
890 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
894 fprintf( fp,
"\n** End of Report **\n" );
929 static bool s_includeExclusions =
false;
942 if( numExcluded > 0 )
944 wxRichMessageDialog dlg(
this,
_(
"Do you wish to delete excluded markers as well?" ),
945 _(
"Delete All Markers" ),
946 wxOK | wxCANCEL | wxCENTER | wxICON_QUESTION );
947 dlg.ShowCheckBox(
_(
"Delete exclusions" ), s_includeExclusions );
949 int ret = dlg.ShowModal();
951 if( ret == wxID_CANCEL )
954 s_includeExclusions = dlg.IsCheckBoxChecked();
970 int numUnconnected = 0;
971 int numFootprints = 0;
1020 msg.Replace( wxT(
"%d" ),
_(
"not run" ) );
1027 msg.Replace( wxT(
"(%d)" ), wxEmptyString );
1031 msg.Replace( wxT(
"(%d)" ), wxEmptyString );
1035 msg.Replace( wxT(
"(%d)" ), wxEmptyString );
1044 if( !
m_drcRun && numWarnings == 0 )
static TOOL_ACTION selectionClear
Clear the current selection.
wxCheckBox * m_showWarnings
BOARD_ITEM * GetItem(const KIID &aID) const
std::atomic_int m_progress
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
wxCheckBox * m_cbTestFootprints
void OnModify() override
Must be called after a board change to set the modified flag.
std::atomic_int m_maxProgress
void updateDisplayedCounts()
BOARD_DESIGN_SETTINGS & bds()
static int RPT_SEVERITY_ALL
void OnDRCItemRClick(wxDataViewEvent &aEvent) override
#define MALFORMED_B_COURTYARD
void SetProvider(RC_ITEMS_PROVIDER *aProvider)
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
wxCheckBox * m_cbReportAllTrackErrors
void deleteAllMarkers(bool aIncludeExclusions)
wxButton * m_DeleteCurrentMarkerButton
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
void CenterMarker(const MARKER_BASE *aMarker)
This file is part of the common library.
void Clear()
Delete the stored messages.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
wxSimplebook * m_runningResultsBook
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
#define MALFORMED_F_COURTYARD
bool writeReport(const wxString &aFullFileName)
Function writeReport outputs the MARKER items and unconnecte DRC_ITEMs with commentary to an open tex...
void Flush()
Build the HTML messages page.
void UpdateNumber(int aNumber, SEVERITY aSeverity)
Update the number displayed on the badge.
void OnDeleteOneClick(wxCommandEvent &aEvent) override
wxString m_footprintsTitleTemplate
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
class PAD, a pad in a footprint
wxButton * m_sdbSizerCancel
static KIID ToUUID(wxDataViewItem aItem)
RC_ITEMS_PROVIDER * m_markersProvider
void OnDRCItemDClick(wxDataViewEvent &aEvent) override
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
virtual int GetCount(int aSeverity=-1) const =0
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
APPEARANCE_CONTROLS * GetAppearancePanel()
const wxString & GetFileName() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
void DeleteCurrentItem(bool aDeep)
void SetSeverities(int aSeverities)
This file contains miscellaneous commonly used macros and functions.
Provide an abstract interface of a RC_ITEM* list manager.
void OnChangingNotebookPage(wxNotebookEvent &aEvent) override
EDA_UNITS GetUserUnits() const
RC_ITEMS_PROVIDER * m_unconnectedItemsProvider
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxCheckBox * m_showExclusions
wxString m_markersTitleTemplate
void SetImmediateMode()
In immediate mode, messages are flushed as they are added.
wxCheckBox * m_cbRefillZones
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...
LSET is a set of PCB_LAYER_IDs.
void SetExcluded(bool aExcluded)
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
std::shared_ptr< RC_ITEM > m_RcItem
wxDataViewCtrl * m_footprintsDataView
RC_ITEMS_PROVIDER * m_footprintWarningsProvider
wxBoxSizer * m_sizerButtons
wxButton * m_DeleteAllMarkersButton
void OnDeleteAllClick(wxCommandEvent &aEvent) override
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
wxString ReportFileWildcard()
void OnDRCItemSelected(wxDataViewEvent &aEvent) override
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
DIALOG_DRC(PCB_EDIT_FRAME *aEditorFrame, wxWindow *aParent)
Constructors.
RC_TREE_MODEL * m_footprintWarningsTreeModel
void FocusOnItems(std::vector< BOARD_ITEM * > aItems, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
void SetFootprintsProvider(RC_ITEMS_PROVIDER *aProvider)
std::atomic< bool > m_cancelled
Definition of file extensions used in Kicad.
NUMBER_BADGE * m_exclusionsBadge
void SelectMarker(const MARKER_BASE *aMarker)
#define DIALOG_DRC_WINDOW_NAME
Functions to provide common constants and other functions to assist in making a consistent UI.
NUMBER_BADGE * m_errorsBadge
static LSET AllLayersMask()
SEVERITY GetSeverity(int aDRCErrorCode)
void OnClose(wxCloseEvent &event) override
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void OnRunDRCClick(wxCommandEvent &aEvent) override
bool Show(bool show) override
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
RC_TREE_MODEL * m_unconnectedTreeModel
EDA_ITEM_FLAGS GetFlags() const
This implements all the tricky bits for thread safety, but the GUI is left to derived classes.
wxDataViewCtrl * m_unconnectedDataView
void OnCancelClick(wxCommandEvent &aEvent) override
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void SetMarkersProvider(RC_ITEMS_PROVIDER *aProvider)
wxDataViewCtrl * m_markerDataView
virtual std::shared_ptr< RC_ITEM > GetItem(int aIndex) const =0
Retrieve a RC_ITEM by index.
A filename or source description, a problem input line, a line number, a byte offset,...
WX_HTML_REPORT_BOX * m_messages
const std::string ReportFileExtension
Information pertinent to a Pcbnew printed circuit board.
PCB_LAYER_ID
A quick note on layer IDs:
wxCheckBox * m_showErrors
std::map< int, SEVERITY > m_DRCSeverities
NUMBER_BADGE * m_warningsBadge
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...
The main frame for Pcbnew.
PCBNEW_SETTINGS * GetPcbNewSettings() const
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
bool test_all_track_errors
void OnActivateDlg(wxActivateEvent &aEvent) override
void SelectMarker(const PCB_MARKER *aMarker)
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
void ValueChanged(const RC_TREE_NODE *aNode)
virtual void SetCurrentProgress(double aProgress) override
Set the progress value to aProgress (0..1).
RC_TREE_MODEL * m_markersTreeModel
void OnSaveReport(wxCommandEvent &aEvent) override
void centerMarkerIdleHandler(wxIdleEvent &aEvent)
const PCB_MARKER * m_centerMarkerOnIdle
void SetMaximumNumber(int aMax)
Set the maximum number to be shown on the badge.
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
void SetUnconnectedProvider(RC_ITEMS_PROVIDER *aProvider)
wxString m_unconnectedTitleTemplate
void OnSeverity(wxCommandEvent &aEvent) override
Container for design settings for a BOARD object.