diff --git a/pcbnew/dialogs/dialog_constraints_reporter.cpp b/pcbnew/dialogs/dialog_constraints_reporter.cpp index 5f58a6aade..17f72e4d80 100644 --- a/pcbnew/dialogs/dialog_constraints_reporter.cpp +++ b/pcbnew/dialogs/dialog_constraints_reporter.cpp @@ -22,11 +22,11 @@ */ #include -#include +#include #include -DIALOG_CONSTRAINTS_REPORTER::DIALOG_CONSTRAINTS_REPORTER( PCB_BASE_FRAME* aParent ) : +DIALOG_CONSTRAINTS_REPORTER::DIALOG_CONSTRAINTS_REPORTER( PCB_EDIT_FRAME* aParent ) : DIALOG_CONSTRAINTS_REPORTER_BASE( aParent ), m_frame( aParent ) { @@ -45,6 +45,12 @@ void DIALOG_CONSTRAINTS_REPORTER::DeleteAllPages() } +void DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& event ) +{ + m_frame->ShowBoardSetupDialog( _( "Rules" ) ); +} + + WX_HTML_REPORT_BOX* DIALOG_CONSTRAINTS_REPORTER::AddPage( const wxString& aTitle ) { wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -61,6 +67,7 @@ WX_HTML_REPORT_BOX* DIALOG_CONSTRAINTS_REPORTER::AddPage( const wxString& aTitle m_notebook->AddPage( panel, aTitle ); reporter->SetUnits( m_frame->GetUserUnits() ); + reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked ), NULL, this ); return reporter; } diff --git a/pcbnew/dialogs/dialog_constraints_reporter.h b/pcbnew/dialogs/dialog_constraints_reporter.h index 3da443c2ce..647c69bfef 100644 --- a/pcbnew/dialogs/dialog_constraints_reporter.h +++ b/pcbnew/dialogs/dialog_constraints_reporter.h @@ -26,22 +26,24 @@ #include -class PCB_BASE_FRAME; +class PCB_EDIT_FRAME; class WX_HTML_REPORT_BOX; class DIALOG_CONSTRAINTS_REPORTER : public DIALOG_CONSTRAINTS_REPORTER_BASE { public: - DIALOG_CONSTRAINTS_REPORTER( PCB_BASE_FRAME* aParent ); + DIALOG_CONSTRAINTS_REPORTER( PCB_EDIT_FRAME* aParent ); void FinishInitialization(); + void OnErrorLinkClicked( wxHtmlLinkEvent& event ); + void DeleteAllPages(); WX_HTML_REPORT_BOX* AddPage( const wxString& pageTitle ); protected: - PCB_BASE_FRAME* m_frame; + PCB_EDIT_FRAME* m_frame; }; #endif // DIALOG_CONSTRAINTS_REPORTER_H diff --git a/pcbnew/tools/pcb_inspection_tool.cpp b/pcbnew/tools/pcb_inspection_tool.cpp index 13f861887c..f2747c5846 100644 --- a/pcbnew/tools/pcb_inspection_tool.cpp +++ b/pcbnew/tools/pcb_inspection_tool.cpp @@ -37,6 +37,12 @@ #include "pcb_inspection_tool.h" +void DIALOG_INSPECTION_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& event ) +{ + m_frame->ShowBoardSetupDialog( _( "Rules" ) ); +} + + PCB_INSPECTION_TOOL::PCB_INSPECTION_TOOL() : PCB_TOOL_BASE( "pcbnew.InspectionTool" ), m_frame( nullptr ) @@ -197,7 +203,11 @@ void PCB_INSPECTION_TOOL::reportClearance( DRC_CONSTRAINT_TYPE_T aClearanceType, } catch( PARSE_ERROR& pe ) { - m_frame->ShowBoardSetupDialog( _( "Rules" ) ); + r->Report( "" ); + r->Report( _( "Report incomplete: could not compile design rules. " ) + + wxT( "" ) + + _( "Show design rules." ) + + wxT( "" ) ); return; } @@ -237,7 +247,7 @@ int PCB_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) if( m_inspectClearanceDialog == nullptr ) { - m_inspectClearanceDialog = std::make_unique( m_frame ); + m_inspectClearanceDialog = std::make_unique( m_frame ); m_inspectClearanceDialog->SetTitle( _( "Clearance Report" ) ); m_inspectClearanceDialog->Connect( wxEVT_CLOSE_WINDOW, @@ -382,6 +392,7 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) BOARD_ITEM* item = static_cast( selection.GetItem( 0 ) ); DRC_ENGINE drcEngine( m_frame->GetBoard(), &m_frame->GetBoard()->GetDesignSettings() ); + bool compileError = false; try { @@ -389,8 +400,7 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) } catch( PARSE_ERROR& pe ) { - m_frame->ShowBoardSetupDialog( _( "Rules" ) ); - return 1; + compileError = true; } if( item->Type() == PCB_TRACE_T ) @@ -402,22 +412,34 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) item->GetSelectMenuText( r->GetUnits() ) ) ); r->Report( "" ); - auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_TRACK_WIDTH, item, - nullptr, UNDEFINED_LAYER, r ); + if( compileError ) + { + r->Report( "" ); + r->Report( _( "Report incomplete: could not compile design rules. " ) + + wxT( "" ) + + _( "Show design rules." ) + + wxT( "" ) ); + } + else + { + auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_TRACK_WIDTH, item, + nullptr, UNDEFINED_LAYER, r ); - wxString min = _( "undefined" ); - wxString max = _( "undefined" ); + wxString min = _( "undefined" ); + wxString max = _( "undefined" ); - if( constraint.m_Value.HasMin() ) - min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); + if( constraint.m_Value.HasMin() ) + min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); - if( constraint.m_Value.HasMax() ) - max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true ); + if( constraint.m_Value.HasMax() ) + max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true ); + + r->Report( "" ); + r->Report( wxString::Format( _( "Width constraints: min %s max %s." ), + min, + max ) ); + } - r->Report( "" ); - r->Report( wxString::Format( _( "Width constraints: min %s max %s." ), - min, - max ) ); r->Flush(); } @@ -430,25 +452,36 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) item->GetSelectMenuText( r->GetUnits() ) ) ); r->Report( "" ); - auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_VIA_DIAMETER, item, - nullptr, UNDEFINED_LAYER, r ); + if( compileError ) + { + r->Report( "" ); + r->Report( _( "Report incomplete: could not compile design rules. " ) + + wxT( "" ) + + _( "Show design rules." ) + + wxT( "" ) ); + } + else + { + auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_VIA_DIAMETER, + item, nullptr, UNDEFINED_LAYER, r ); - wxString min = _( "undefined" ); - wxString max = _( "undefined" ); + wxString min = _( "undefined" ); + wxString max = _( "undefined" ); - if( constraint.m_Value.HasMin() ) - min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); + if( constraint.m_Value.HasMin() ) + min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); - if( constraint.m_Value.HasMax() ) - max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true ); + if( constraint.m_Value.HasMax() ) + max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true ); + + r->Report( "" ); + r->Report( wxString::Format( _( "Diameter constraints: min %s max %s." ), + min, + max ) ); + } - r->Report( "" ); - r->Report( wxString::Format( _( "Diameter constraints: min %s max %s." ), - min, - max ) ); r->Flush(); - r = m_inspectConstraintsDialog->AddPage( "Via Annular Width" ); r->Report( _( "Via annular width resolution for:" ) ); @@ -456,22 +489,34 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) item->GetSelectMenuText( r->GetUnits() ) ) ); r->Report( "" ); - constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, item, - nullptr, UNDEFINED_LAYER, r ); + if( compileError ) + { + r->Report( "" ); + r->Report( _( "Report incomplete: could not compile design rules. " ) + + wxT( "" ) + + _( "Show design rules." ) + + wxT( "" ) ); + } + else + { + auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, + item, nullptr, UNDEFINED_LAYER, r ); - min = _( "undefined" ); - max = _( "undefined" ); + wxString min = _( "undefined" ); + wxString max = _( "undefined" ); - if( constraint.m_Value.HasMin() ) - min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); + if( constraint.m_Value.HasMin() ) + min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); - if( constraint.m_Value.HasMax() ) - max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true ); + if( constraint.m_Value.HasMax() ) + max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true ); + + r->Report( "" ); + r->Report( wxString::Format( _( "Annular width constraints: min %s max %s." ), + min, + max ) ); + } - r->Report( "" ); - r->Report( wxString::Format( _( "Annular width constraints: min %s max %s." ), - min, - max ) ); r->Flush(); } @@ -485,16 +530,28 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) item->GetSelectMenuText( r->GetUnits() ) ) ); r->Report( "" ); - auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_SIZE, item, - nullptr, UNDEFINED_LAYER, r ); + if( compileError ) + { + r->Report( "" ); + r->Report( _( "Report incomplete: could not compile design rules. " ) + + wxT( "" ) + + _( "Show design rules." ) + + wxT( "" ) ); + } + else + { + auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_SIZE, item, + nullptr, UNDEFINED_LAYER, r ); - wxString min = _( "undefined" ); + wxString min = _( "undefined" ); - if( constraint.m_Value.HasMin() ) - min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); + if( constraint.m_Value.HasMin() ) + min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true ); + + r->Report( "" ); + r->Report( wxString::Format( _( "Hole constraint: min %s." ), min ) ); + } - r->Report( "" ); - r->Report( wxString::Format( _( "Hole constraint: min %s." ), min ) ); r->Flush(); } diff --git a/pcbnew/tools/pcb_inspection_tool.h b/pcbnew/tools/pcb_inspection_tool.h index c887aa79c2..3d68eb54de 100644 --- a/pcbnew/tools/pcb_inspection_tool.h +++ b/pcbnew/tools/pcb_inspection_tool.h @@ -34,6 +34,22 @@ class CONNECTIVITY_DATA; + +class DIALOG_INSPECTION_REPORTER : public DIALOG_HTML_REPORTER +{ +public: + DIALOG_INSPECTION_REPORTER( PCB_EDIT_FRAME* aFrame ) : + DIALOG_HTML_REPORTER( aFrame ), + m_frame( aFrame ) + { } + + void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override; + +protected: + PCB_EDIT_FRAME* m_frame; +}; + + /** * PCB_INSPECTION_TOOL * @@ -130,7 +146,7 @@ private: std::unique_ptr m_listNetsDialog; DIALOG_SELECT_NET_FROM_LIST::SETTINGS m_listNetsDialogSettings; - std::unique_ptr m_inspectClearanceDialog; + std::unique_ptr m_inspectClearanceDialog; std::unique_ptr m_inspectConstraintsDialog; };