Implement a better interface between inspectors and DRC rule editor.

This commit is contained in:
Jeff Young 2020-10-17 00:15:44 +01:00
parent 948036372e
commit 51ab639ce4
4 changed files with 136 additions and 54 deletions

View File

@ -22,11 +22,11 @@
*/
#include <dialog_constraints_reporter.h>
#include <pcb_base_frame.h>
#include <pcb_edit_frame.h>
#include <wx_html_report_box.h>
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;
}

View File

@ -26,22 +26,24 @@
#include <dialog_constraints_reporter_base.h>
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

View File

@ -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( "<a href='boardsetup'>" )
+ _( "Show design rules." )
+ wxT( "</a>" ) );
return;
}
@ -237,7 +247,7 @@ int PCB_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
if( m_inspectClearanceDialog == nullptr )
{
m_inspectClearanceDialog = std::make_unique<DIALOG_HTML_REPORTER>( m_frame );
m_inspectClearanceDialog = std::make_unique<DIALOG_INSPECTION_REPORTER>( 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<BOARD_ITEM*>( 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( "<a href='boardsetup'>" )
+ _( "Show design rules." )
+ wxT( "</a>" ) );
}
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( "<a href='boardsetup'>" )
+ _( "Show design rules." )
+ wxT( "</a>" ) );
}
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( _( "<h7>Via annular width resolution for:</h7>" ) );
@ -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( "<a href='boardsetup'>" )
+ _( "Show design rules." )
+ wxT( "</a>" ) );
}
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( "<a href='boardsetup'>" )
+ _( "Show design rules." )
+ wxT( "</a>" ) );
}
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();
}

View File

@ -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<DIALOG_SELECT_NET_FROM_LIST> m_listNetsDialog;
DIALOG_SELECT_NET_FROM_LIST::SETTINGS m_listNetsDialogSettings;
std::unique_ptr<DIALOG_HTML_REPORTER> m_inspectClearanceDialog;
std::unique_ptr<DIALOG_INSPECTION_REPORTER> m_inspectClearanceDialog;
std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectConstraintsDialog;
};