Move DRC dialog to same DRC rule reporting mechanism as inspectors.

This commit is contained in:
Jeff Young 2020-10-17 20:15:26 +01:00
parent 81e1bc9df0
commit c5d45f8a78
6 changed files with 42 additions and 24 deletions

View File

@ -38,7 +38,7 @@
#include <widgets/appearance_controls.h>
#include <widgets/ui_common.h>
#include <widgets/progress_reporter.h>
#include <drc/drc_engine.h>
#include <dialogs/wx_html_report_box.h>
#include <dialogs/panel_setup_rules_base.h>
#include <tools/drc_tool.h>
#include <kiplatform/ui.h>
@ -167,7 +167,7 @@ void DIALOG_DRC::AdvancePhase( const wxString& aMessage )
PROGRESS_REPORTER::AdvancePhase( aMessage );
SetCurrentProgress( 0.0 );
m_Messages->AppendText( aMessage + "\n" );
m_Messages->Report( aMessage + "<br>" );
}
@ -190,6 +190,12 @@ void DIALOG_DRC::syncCheckboxes()
}
void DIALOG_DRC::OnErrorLinkClicked( wxHtmlLinkEvent& event )
{
m_brdEditor->ShowBoardSetupDialog( _( "Rules" ) );
}
void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
{
DRC_TOOL* drcTool = m_brdEditor->GetToolManager()->GetTool<DRC_TOOL>();
@ -206,12 +212,19 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
}
catch( PARSE_ERROR& pe )
{
// Shouldn't be necessary, but we get into all kinds of wxWidgets window ordering
// issues (on at least OSX) if we don't.
drcTool->DestroyDRCDialog();
m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
m_DeleteCurrentMarkerButton->Enable( false );
m_DeleteAllMarkersButton->Enable( false );
m_saveReport->Enable( false );
m_brdEditor->ShowBoardSetupDialog( _( "Rules" ) );
m_Messages->Clear();
m_Messages->Report( _( "DRC incomplete: could not compile design rules. " )
+ wxT( "<a href='boardsetup'>" )
+ _( "Show design rules." )
+ wxT( "</a>" ) );
m_Messages->Flush();
Raise();
return;
}
@ -241,9 +254,9 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
testFootprints );
if( m_cancelled )
m_Messages->AppendText( _( "-------- DRC cancelled by user.\n\n" ) );
m_Messages->Report( _( "-------- DRC cancelled by user.<br><br>" ) );
else
m_Messages->AppendText( _( "Done.\n\n" ) );
m_Messages->Report( _( "Done.<br><br>" ) );
Raise();
wxYield(); // Allow time slice to refresh Messages
@ -579,8 +592,8 @@ void DIALOG_DRC::OnSaveReport( wxCommandEvent& aEvent )
if( writeReport( fn.GetFullPath() ) )
{
m_Messages->AppendText( wxString::Format( _( "Report file '%s' created\n" ),
fn.GetFullPath() ) );
m_Messages->Report( wxString::Format( _( "Report file '%s' created<br>" ),
fn.GetFullPath() ) );
}
else
{

View File

@ -80,6 +80,8 @@ private:
void OnDeleteAllClick( wxCommandEvent& aEvent ) override;
void OnRunDRCClick( wxCommandEvent& aEvent ) override;
void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override;
// These require special handling while the DRC tests are running.
void OnCancelClick( wxCommandEvent& aEvent ) override;
void OnClose( wxCloseEvent& event ) override;

View File

@ -5,6 +5,8 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialogs/wx_html_report_box.h"
#include "dialog_drc_base.h"
///////////////////////////////////////////////////////////////////////////
@ -60,7 +62,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxVERTICAL );
m_Messages = new wxTextCtrl( m_panelMessages, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTE_MULTILINE|wxTE_READONLY );
m_Messages = new WX_HTML_REPORT_BOX( m_panelMessages, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
bSizer10->Add( m_Messages, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bGaugeMargins;
@ -222,6 +224,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
// Connect Events
this->Connect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_BASE::OnActivateDlg ) );
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_DRC_BASE::OnClose ) );
m_Messages->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DRC_BASE::OnErrorLinkClicked ), NULL, this );
m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_BASE::OnChangingNotebookPage ), NULL, this );
m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemDClick ), NULL, this );
m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemRClick ), NULL, this );
@ -246,6 +249,7 @@ DIALOG_DRC_BASE::~DIALOG_DRC_BASE()
// Disconnect Events
this->Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_BASE::OnActivateDlg ) );
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_DRC_BASE::OnClose ) );
m_Messages->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DRC_BASE::OnErrorLinkClicked ), NULL, this );
m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_BASE::OnChangingNotebookPage ), NULL, this );
m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemDClick ), NULL, this );
m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemRClick ), NULL, this );

View File

@ -580,11 +580,11 @@
<property name="name">bSizer10</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="0">
<object class="wxHtmlWindow" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -615,10 +615,9 @@
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength">0</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,-1</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Messages</property>
<property name="pane_border">1</property>
@ -630,18 +629,14 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxHSCROLL|wxTE_MULTILINE|wxTE_READONLY</property>
<property name="subclass"></property>
<property name="style">wxHW_SCROLLBAR_AUTO</property>
<property name="subclass">WX_HTML_REPORT_BOX; dialogs/wx_html_report_box.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnHtmlLinkClicked">OnErrorLinkClicked</event>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -10,6 +10,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_HTML_REPORT_BOX;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/checkbox.h>
@ -18,7 +20,7 @@
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/html/htmlwin.h>
#include <wx/gauge.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
@ -54,7 +56,7 @@ class DIALOG_DRC_BASE : public DIALOG_SHIM
wxPanel* running;
wxNotebook* m_runningNotebook;
wxPanel* m_panelMessages;
wxTextCtrl* m_Messages;
WX_HTML_REPORT_BOX* m_Messages;
wxGauge* m_gauge;
wxPanel* results;
wxNotebook* m_Notebook;
@ -83,6 +85,7 @@ class DIALOG_DRC_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void OnActivateDlg( wxActivateEvent& event ) { event.Skip(); }
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnErrorLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); }
virtual void OnChangingNotebookPage( wxNotebookEvent& event ) { event.Skip(); }
virtual void OnDRCItemDClick( wxDataViewEvent& event ) { event.Skip(); }
virtual void OnDRCItemRClick( wxDataViewEvent& event ) { event.Skip(); }

View File

@ -52,6 +52,7 @@ DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) :
m_board( aBoard ),
m_worksheet( nullptr ),
m_schematicNetlist( nullptr ),
m_rulesValid( false ),
m_userUnits( EDA_UNITS::MILLIMETRES ),
m_testTracksAgainstZones( false ),
m_reportAllTrackErrors( false ),