37 #include <wx/wupdlock.h> 53 m_footprintTestsRun( false ),
54 m_markersProvider( nullptr ),
55 m_markerTreeModel( nullptr ),
56 m_unconnectedItemsProvider( nullptr ),
57 m_unconnectedTreeModel( nullptr ),
58 m_footprintWarningsProvider( nullptr ),
59 m_footprintWarningsTreeModel( nullptr ),
103 if( !
Kiface().IsSingle() )
118 SetReturnCode( wxID_CANCEL );
139 if( !
Kiface().IsSingle() )
158 cur = std::max( 0.0, std::min( cur, 1.0 ) );
216 m_messages->
Report(
_(
"DRC incomplete: could not compile custom design rules. " )
217 + wxT(
"<a href='boardsetup'>" )
218 +
_(
"Show design rules." )
248 drcTool->
RunTests(
this, refillZones, reportAllTrackErrors, testFootprints );
307 auto getActiveLayers =
312 PAD* pad = static_cast<PAD*>( aItem );
315 for(
int layer : aItem->GetLayerSet().Seq() )
325 return aItem->GetLayerSet();
332 LSET violationLayers;
333 std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
360 if( a || b || c || d )
364 violationLayers &= getActiveLayers( a );
367 violationLayers &= getActiveLayers( b );
370 violationLayers &= getActiveLayers( c );
373 violationLayers &= getActiveLayers( d );
376 if( violationLayers.count() )
377 principalLayer = violationLayers.
Seq().front();
379 violationLayers.set( principalLayer );
402 if( aEvent.GetItem().IsOk() )
422 std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
431 default: listName =
_(
"appropriate" );
break;
434 if( rcItem->GetParent()->IsExcluded() )
436 menu.Append( 1,
_(
"Remove exclusion for this violation" ),
441 menu.Append( 2,
_(
"Exclude this violation" ),
445 menu.AppendSeparator();
449 msg.Printf(
_(
"Change severity to Error for all '%s' violations" ),
450 rcItem->GetErrorText(),
451 _(
"Violation severities can also be edited in the Board Setup... dialog" ) );
452 menu.Append( 3, msg );
456 msg.Printf(
_(
"Change severity to Warning for all '%s' violations" ),
457 rcItem->GetErrorText(),
458 _(
"Violation severities can also be edited in the Board Setup... dialog" ) );
459 menu.Append( 4, msg );
462 msg.Printf(
_(
"Ignore all '%s' violations" ),
463 rcItem->GetErrorText(),
464 _(
"Violations will not be checked or reported" ) );
465 menu.Append( 5, msg );
467 menu.AppendSeparator();
469 menu.Append( 6,
_(
"Edit violation severities..." ),
_(
"Open the Board Setup... dialog" ) );
471 bool modified =
false;
473 switch( GetPopupMenuSelectionFromUser( menu ) )
485 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
502 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
504 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem(
false );
516 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
521 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider(
m_markersProvider );
530 if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
535 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider(
m_markersProvider );
545 for(
unsigned i = 0; i < markers.size(); )
547 if( markers[i]->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
550 markers.erase( markers.begin() + i );
557 static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider(
m_markersProvider );
580 if( aEvent.GetEventObject() ==
m_showAll )
589 if( aEvent.IsChecked() )
591 else if( aEvent.GetEventObject() ==
m_showAll )
616 wxFileDialog dlg(
this,
_(
"Save Report to File" ), fn.GetPath(), fn.GetFullName(),
619 if( dlg.ShowModal() != wxID_OK )
624 if( fn.GetExt().IsEmpty() )
627 if( !fn.IsAbsolute() )
630 fn.MakeAbsolute( prj_path );
636 fn.GetFullPath() ) );
641 fn.GetFullPath() ) );
651 wxCommandEvent
dummy;
667 SetReturnCode( wxID_CANCEL );
679 if( aEvent.GetSelection() >= 0 )
680 m_Notebook->ChangeSelection( (
unsigned) aEvent.GetSelection() );
732 if( marker && !marker->IsExcluded() )
761 FILE* fp = wxFopen( aFullFileName, wxT(
"w" ) );
766 std::map<KIID, EDA_ITEM*> itemMap;
775 wxDateTime now = wxDateTime::Now();
777 fprintf( fp,
"** Created on %s **\n",
TO_UTF8( now.Format( wxT(
"%F %T" ) ) ) );
781 fprintf( fp,
"\n** Found %d DRC violations **\n", count );
783 for(
int i = 0; i < count; ++i )
788 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
793 fprintf( fp,
"\n** Found %d unconnected pads **\n", count );
795 for(
int i = 0; i < count; ++i )
800 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
805 fprintf( fp,
"\n** Found %d Footprint errors **\n", count );
807 for(
int i = 0; i < count; ++i )
812 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
816 fprintf( fp,
"\n** End of Report **\n" );
851 static bool s_includeExclusions =
false;
864 if( numExcluded > 0 )
866 wxRichMessageDialog dlg(
this,
_(
"Do you wish to delete excluded markers as well?" ),
867 _(
"Delete All Markers" ),
868 wxOK | wxCANCEL | wxCENTER | wxICON_QUESTION );
869 dlg.ShowCheckBox(
_(
"Delete exclusions" ), s_includeExclusions );
871 int ret = dlg.ShowModal();
873 if( ret == wxID_CANCEL )
876 s_includeExclusions = dlg.IsCheckBoxChecked();
892 int numUnconnected = 0;
893 int numFootprints = 0;
940 msg.Replace( wxT(
"%d" ),
_(
"not run" ) );
947 msg.Replace( wxT(
"(%d)" ), wxEmptyString );
951 msg.Replace( wxT(
"(%d)" ), wxEmptyString );
955 msg.Replace( wxT(
"(%d)" ), wxEmptyString );
static TOOL_ACTION selectionClear
Clear the current selection.
wxCheckBox * m_showWarnings
BOARD_ITEM * GetItem(const KIID &aID) const
virtual void AdvancePhase()
Uses the next vailable virtual zone of the dialog progress bar.
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.
void updateDisplayedCounts()
BOARD_DESIGN_SETTINGS & bds()
static int RPT_SEVERITY_ALL
void OnDRCItemRClick(wxDataViewEvent &aEvent) override
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.
This file is part of the common library.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
RC_TREE_MODEL * m_markerTreeModel
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
A progress reporter for use in multi-threaded environments.
std::atomic_int m_progress
PCB_EDIT_FRAME * m_brdEditor
wxSimplebook * m_runningResultsBook
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool writeReport(const wxString &aFullFileName)
Function writeReport outputs the MARKER items and unconnecte DRC_ITEMs with commentary to an open tex...
void refreshBoardEditor()
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 Returns a bit-mask of all t...
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
virtual int GetCount(int aSeverity=-1)=0
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.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
const wxString & GetFileName() const
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual std::shared_ptr< RC_ITEM > GetItem(int aIndex)=0
Retrieve a RC_ITEM by index.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
void DeleteCurrentItem(bool aDeep)
void SetSeverities(int aSeverities)
Provide an abstract interface of a RC_ITEM* list manager.
void OnChangingNotebookPage(wxNotebookEvent &aEvent) override
EDA_UNITS GetUserUnits() const
RC_ITEMS_PROVIDER * m_unconnectedItemsProvider
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxCheckBox * m_showExclusions
wxString m_markersTitleTemplate
virtual void SetCurrentProgress(double aProgress)
Set the progress value to aProgress (0..1)
PCB_LAYER_ID
A quick note on layer IDs:
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...
bool FlashLayer(int aLayer) const
Check to see whether the pad should be flashed on the specific layer.
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
#define MALFORMED_B_COURTYARD
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.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
RC_TREE_MODEL * m_footprintWarningsTreeModel
void SetFootprintsProvider(RC_ITEMS_PROVIDER *aProvider)
std::atomic< bool > m_cancelled
Definition of file extensions used in Kicad.
NUMBER_BADGE * m_exclusionsBadge
#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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
RC_TREE_MODEL * m_unconnectedTreeModel
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.
#define MALFORMED_F_COURTYARD
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
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.
wxCheckBox * m_showErrors
std::map< int, SEVERITY > m_DRCSeverities
NUMBER_BADGE * m_warningsBadge
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 SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
std::atomic_int m_maxProgress
APPEARANCE_CONTROLS * GetAppearancePanel()
STATUS_FLAGS GetFlags() const
void OnSaveReport(wxCommandEvent &aEvent) override
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 FocusOnItem(BOARD_ITEM *aItem)
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
void SetUnconnectedProvider(RC_ITEMS_PROVIDER *aProvider)
wxString m_unconnectedTitleTemplate
void ValueChanged(RC_TREE_NODE *aNode)
void OnSeverity(wxCommandEvent &aEvent) override
Container for design settings for a BOARD object.