Don't keep smart pointers to wxWindows, particularly modeless ones.

wxWindows have their own lifecycle management.
This commit is contained in:
Jeff Young 2023-03-11 19:35:13 +00:00
parent 08e6458abc
commit 74f064d3aa
8 changed files with 147 additions and 236 deletions

View File

@ -26,17 +26,22 @@
#include <wx/wxhtml.h>
DIALOG_BOOK_REPORTER::DIALOG_BOOK_REPORTER( KIWAY_PLAYER* aParent ) :
DIALOG_BOOK_REPORTER::DIALOG_BOOK_REPORTER( KIWAY_PLAYER* aParent, const wxString& aDialogName,
const wxString& aDialogTitle ) :
DIALOG_BOOK_REPORTER_BASE( aParent ),
m_frame( aParent )
{
}
SetName( aDialogName );
SetTitle( aDialogTitle );
aParent->Bind( wxEVT_CLOSE_WINDOW,
[this]( wxCloseEvent& aEvent )
{
Close();
aEvent.Skip();
} );
void DIALOG_BOOK_REPORTER::FinishInitialization()
{
SetupStandardButtons();
finishDialogSettings();
}

View File

@ -48,6 +48,9 @@
#include <math/util.h> // for KiROUND
#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
EE_INSPECTION_TOOL::EE_INSPECTION_TOOL() :
EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.InspectionTool" ),
m_ercDialog( nullptr )
@ -252,17 +255,16 @@ int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent )
return 0;
}
if( m_diffSymbolDialog == nullptr )
{
m_diffSymbolDialog = std::make_unique<DIALOG_BOOK_REPORTER>( m_frame );
m_diffSymbolDialog->SetTitle( _( "Diff Symbol with Library" ) );
wxWindow* window = wxWindow::FindWindowByName( DIFF_SYMBOLS_DIALOG_NAME );
DIALOG_BOOK_REPORTER* dialog = dynamic_cast<DIALOG_BOOK_REPORTER*>( window );
m_diffSymbolDialog->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( EE_INSPECTION_TOOL::onDiffSymbolDialogClosed ),
nullptr, this );
if( !dialog )
{
dialog = new DIALOG_BOOK_REPORTER( m_frame, DIFF_SYMBOLS_DIALOG_NAME,
_( "Diff Symbol with Library" ) );
}
m_diffSymbolDialog->DeleteAllPages();
dialog->DeleteAllPages();
SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
wxString symbolDesc = wxString::Format( _( "Symbol %s" ),
@ -271,7 +273,7 @@ int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent )
wxString libName = libId.GetLibNickname();
wxString symbolName = libId.GetLibItemName();
WX_HTML_REPORT_BOX* r = m_diffSymbolDialog->AddHTMLPage( _( "Summary" ) );
WX_HTML_REPORT_BOX* r = dialog->AddHTMLPage( _( "Summary" ) );
r->Report( wxS( "<h7>" ) + _( "Schematic vs library diff for:" ) + wxS( "</h7>" ) );
r->Report( wxS( "<ul><li>" ) + EscapeHTML( symbolDesc ) + wxS( "</li>" )
@ -332,7 +334,7 @@ int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent )
if( flattenedSchSymbol->Compare( *flattenedLibSymbol, 0, r ) == 0 )
r->Report( _( "No relevant differences detected." ) );
wxPanel* panel = m_diffSymbolDialog->AddBlankPage( _( "Visual" ) );
wxPanel* panel = dialog->AddBlankPage( _( "Visual" ) );
SYMBOL_DIFF_WIDGET* diff = constructDiffPanel( panel );
diff->DisplayDiff( flattenedSchSymbol.release(), flattenedLibSymbol.release(),
@ -342,9 +344,8 @@ int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent )
r->Flush();
m_diffSymbolDialog->FinishInitialization();
m_diffSymbolDialog->Raise();
m_diffSymbolDialog->Show( true );
dialog->Raise();
dialog->Show( true );
return 0;
}
@ -364,17 +365,6 @@ SYMBOL_DIFF_WIDGET* EE_INSPECTION_TOOL::constructDiffPanel( wxPanel* aParentPane
}
void EE_INSPECTION_TOOL::onDiffSymbolDialogClosed( wxCommandEvent& aEvent )
{
m_diffSymbolDialog->Disconnect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( EE_INSPECTION_TOOL::onDiffSymbolDialogClosed ),
nullptr, this );
m_diffSymbolDialog->Destroy();
m_diffSymbolDialog.release();
}
int EE_INSPECTION_TOOL::RunSimulation( const TOOL_EVENT& aEvent )
{
#ifdef KICAD_SPICE

View File

@ -72,14 +72,11 @@ public:
private:
SYMBOL_DIFF_WIDGET* constructDiffPanel( wxPanel* aParentPanel );
void onDiffSymbolDialogClosed( wxCommandEvent& aEvent );
///< @copydoc TOOL_INTERACTIVE::setTransitions();
void setTransitions() override;
private:
DIALOG_ERC* m_ercDialog;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_diffSymbolDialog;
DIALOG_ERC* m_ercDialog;
};
#endif /* EE_INSPECTION_TOOL_H */

View File

@ -33,13 +33,12 @@ class wxHtmlLinkEvent;
class DIALOG_BOOK_REPORTER : public DIALOG_BOOK_REPORTER_BASE
{
public:
DIALOG_BOOK_REPORTER( KIWAY_PLAYER* aParent );
void FinishInitialization();
DIALOG_BOOK_REPORTER( KIWAY_PLAYER* aParent, const wxString& aDialogName,
const wxString& aDialogTitle );
void OnOK( wxCommandEvent& aEvent ) override
{
Close();
Destroy();
}
void OnErrorLinkClicked( wxHtmlLinkEvent& aEvent );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2020 Oleg Endo <olegendo@gcc.gnu.org>
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -49,6 +49,10 @@
#include <bitset>
#include <vector>
static DIALOG_NET_INSPECTOR::SETTINGS g_settings;
enum class CSV_COLUMN_DESC : int
{
CSV_NONE = 0,
@ -955,12 +959,13 @@ protected:
};
DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent,
const SETTINGS& aSettings ) :
DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent, const wxString& aDialogName ) :
DIALOG_NET_INSPECTOR_BASE( aParent ),
m_zero_netitem( nullptr ),
m_frame( aParent )
{
SetName( aDialogName );
m_columns.emplace_back( 0u, UNDEFINED_LAYER, _( "Net" ), _( "Net Code" ), CSV_COLUMN_DESC::CSV_NONE );
m_columns.emplace_back( 1u, UNDEFINED_LAYER, _( "Name" ), _( "Net Name" ), CSV_COLUMN_DESC::CSV_QUOTE );
m_columns.emplace_back( 2u, UNDEFINED_LAYER, _( "Pad Count" ), _( "Pad Count" ), CSV_COLUMN_DESC::CSV_NONE );
@ -1027,7 +1032,7 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent,
}
};
std::vector<int> col_order = aSettings.column_order;
std::vector<int> col_order = g_settings.column_order;
if( col_order.size() != add_col.size() )
{
@ -1046,7 +1051,7 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent,
continue;
m_columns.emplace_back( m_columns.size(), layer, m_brd->GetLayerName( layer ),
m_brd->GetLayerName( layer ), CSV_COLUMN_DESC::CSV_NONE );
m_brd->GetLayerName( layer ), CSV_COLUMN_DESC::CSV_NONE );
m_netsList->AppendTextColumn( m_brd->GetLayerName( layer ), m_columns.back(),
wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
@ -1059,11 +1064,11 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent,
// list over and over again.
m_filter_change_no_rebuild = true;
m_textCtrlFilter->SetValue( aSettings.filter_string );
m_cbShowZeroPad->SetValue( aSettings.show_zero_pad_nets );
m_groupBy->SetValue( aSettings.group_by );
m_groupByKind->SetSelection( aSettings.group_by_kind );
m_groupByText->SetValue( aSettings.group_by_text );
m_textCtrlFilter->SetValue( g_settings.filter_string );
m_cbShowZeroPad->SetValue( g_settings.show_zero_pad_nets );
m_groupBy->SetValue( g_settings.group_by );
m_groupByKind->SetSelection( g_settings.group_by_kind );
m_groupByText->SetValue( g_settings.group_by_text );
m_filter_change_no_rebuild = false;
buildNetsList();
@ -1079,20 +1084,24 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent,
m_renameNet->Disable();
m_deleteNet->Disable();
if( aSettings.sorting_column != -1 )
if( g_settings.sorting_column != -1 )
{
if( wxDataViewColumn* c = m_netsList->GetColumn( aSettings.sorting_column ) )
if( wxDataViewColumn* c = m_netsList->GetColumn( g_settings.sorting_column ) )
{
c->SetSortOrder( aSettings.sort_order_asc );
c->SetSortOrder( g_settings.sort_order_asc );
m_data_model->Resort();
}
}
finishDialogSettings();
m_frame->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( DIALOG_NET_INSPECTOR::onParentWindowClosed ),
nullptr, this );
m_frame->Bind( wxEVT_CLOSE_WINDOW,
[this]( wxCloseEvent& aEvent )
{
Close();
aEvent.Skip();
} );
m_frame->Connect( UNITS_CHANGED,
wxCommandEventHandler( DIALOG_NET_INSPECTOR::onUnitsChanged ),
nullptr, this );
@ -1112,14 +1121,27 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent,
DIALOG_NET_INSPECTOR::~DIALOG_NET_INSPECTOR()
{
std::vector<int> column_order( m_data_model->columnCount() );
for( unsigned int i = 0; i < column_order.size(); ++i )
column_order[i] = m_netsList->GetColumn( i )->GetModelColumn();
wxDataViewColumn* sorting_column = m_netsList->GetSortingColumn();
g_settings.filter_string = m_textCtrlFilter->GetValue();
g_settings.show_zero_pad_nets = m_cbShowZeroPad->IsChecked();
g_settings.group_by = m_groupBy->IsChecked();
g_settings.group_by_kind = m_groupByKind->GetSelection();
g_settings.group_by_text = m_groupByText->GetValue();
g_settings.sorting_column = sorting_column ? static_cast<int>( sorting_column->GetModelColumn() ) : -1;
g_settings.sort_order_asc = sorting_column ? sorting_column->IsSortOrderAscending() : true;
g_settings.column_order = column_order;
// the displayed list elements are going to be deleted before the list view itself.
// in some cases it might still do queries on the data model, which would crash
// from now on. so just disassociate it.
m_netsList->AssociateModel( nullptr );
m_frame->Disconnect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( DIALOG_NET_INSPECTOR::onParentWindowClosed ),
nullptr, this );
m_frame->Disconnect( UNITS_CHANGED,
wxCommandEventHandler( DIALOG_NET_INSPECTOR::onUnitsChanged ),
nullptr, this );
@ -1134,36 +1156,6 @@ DIALOG_NET_INSPECTOR::~DIALOG_NET_INSPECTOR()
}
DIALOG_NET_INSPECTOR::SETTINGS DIALOG_NET_INSPECTOR::Settings() const
{
std::vector<int> column_order( m_data_model->columnCount() );
for( unsigned int i = 0; i < column_order.size(); ++i )
column_order[i] = m_netsList->GetColumn( i )->GetModelColumn();
wxDataViewColumn* sorting_column = m_netsList->GetSortingColumn();
SETTINGS r;
r.filter_string = m_textCtrlFilter->GetValue();
r.show_zero_pad_nets = m_cbShowZeroPad->IsChecked();
r.group_by = m_groupBy->IsChecked();
r.group_by_kind = m_groupByKind->GetSelection();
r.group_by_text = m_groupByText->GetValue();
r.sorting_column = sorting_column ? static_cast<int>( sorting_column->GetModelColumn() ) : -1;
r.sort_order_asc = sorting_column ? sorting_column->IsSortOrderAscending() : true;
r.column_order = column_order;
return r;
}
void DIALOG_NET_INSPECTOR::onParentWindowClosed( wxCommandEvent& event )
{
Close();
event.Skip();
}
void DIALOG_NET_INSPECTOR::onUnitsChanged( wxCommandEvent& event )
{
this->m_units = m_frame->GetUserUnits();

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2020 Oleg Endo <olegendo@gcc.gnu.org>
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -53,11 +53,9 @@ public:
std::vector<int> column_order;
};
DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent, const SETTINGS& aSettings );
DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent, const wxString& aDialogName );
~DIALOG_NET_INSPECTOR();
SETTINGS Settings() const;
virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) override;
virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
@ -101,7 +99,6 @@ private:
void buildNetsList();
void adjustListColumns();
void onParentWindowClosed( wxCommandEvent& event );
void onUnitsChanged( wxCommandEvent& event );
void onBoardChanged( wxCommandEvent& event );

View File

@ -44,6 +44,12 @@
#include <pad.h>
#define LIST_NETS_DIALOG_NAME wxT( "ListNetsDialog" )
#define INSPECT_CLEARANCE_DIALOG_NAME wxT( "InspectClearanceDialog" )
#define INSPECT_CONSTRAINTS_DIALOG_NAME wxT( "InspectConstraintsDialog" )
#define DIFF_FOOTPRINTS_DIALOG_NAME wxT( "DiffFootprintsDialog" )
BOARD_INSPECTION_TOOL::BOARD_INSPECTION_TOOL() :
PCB_TOOL_BASE( "pcbnew.InspectionTool" ),
m_frame( nullptr )
@ -242,15 +248,13 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
BOARD_CONNECTED_ITEM* ac = dynamic_cast<BOARD_CONNECTED_ITEM*>( a );
BOARD_CONNECTED_ITEM* bc = dynamic_cast<BOARD_CONNECTED_ITEM*>( b );
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
wxWindow* window = wxWindow::FindWindowByName( INSPECT_CLEARANCE_DIALOG_NAME );
DIALOG_BOOK_REPORTER* dialog = dynamic_cast<DIALOG_BOOK_REPORTER*>( window );
if( m_inspectClearanceDialog == nullptr )
if( !dialog )
{
m_inspectClearanceDialog = std::make_unique<DIALOG_BOOK_REPORTER>( m_frame );
m_inspectClearanceDialog->SetTitle( _( "Violation Report" ) );
m_inspectClearanceDialog->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onInspectClearanceDialogClosed ),
nullptr, this );
dialog = new DIALOG_BOOK_REPORTER( m_frame, INSPECT_CLEARANCE_DIALOG_NAME,
_( "Violation Report" ) );
}
WX_HTML_REPORT_BOX* r = nullptr;
@ -272,7 +276,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
}
r = m_inspectClearanceDialog->AddHTMLPage( _( "Uncoupled Length" ) );
r = dialog->AddHTMLPage( _( "Uncoupled Length" ) );
reportHeader( _( "Diff pair uncoupled length resolution for:" ), ac, bc, r );
if( compileError )
@ -287,7 +291,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
}
case DRCE_TEXT_HEIGHT:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Text Height" ) );
r = dialog->AddHTMLPage( _( "Text Height" ) );
reportHeader( _( "Text height resolution for:" ), a, r );
if( compileError )
@ -302,7 +306,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_TEXT_THICKNESS:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Text Thickness" ) );
r = dialog->AddHTMLPage( _( "Text Thickness" ) );
reportHeader( _( "Text thickness resolution for:" ), a, r );
if( compileError )
@ -317,7 +321,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_TRACK_WIDTH:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Track Width" ) );
r = dialog->AddHTMLPage( _( "Track Width" ) );
reportHeader( _( "Track width resolution for:" ), a, r );
if( compileError )
@ -332,7 +336,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_CONNECTION_WIDTH:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Connection Width" ) );
r = dialog->AddHTMLPage( _( "Connection Width" ) );
reportHeader( _( "Connection width resolution for:" ), a, b, r );
if( compileError )
@ -346,7 +350,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_VIA_DIAMETER:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Via Diameter" ) );
r = dialog->AddHTMLPage( _( "Via Diameter" ) );
reportHeader( _( "Via diameter resolution for:" ), a, r );
if( compileError )
@ -361,7 +365,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_ANNULAR_WIDTH:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Via Annulus" ) );
r = dialog->AddHTMLPage( _( "Via Annulus" ) );
reportHeader( _( "Via annular width resolution for:" ), a, r );
if( compileError )
@ -377,7 +381,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
case DRCE_DRILL_OUT_OF_RANGE:
case DRCE_MICROVIA_DRILL_OUT_OF_RANGE:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole Size" ) );
r = dialog->AddHTMLPage( _( "Hole Size" ) );
reportHeader( _( "Hole diameter resolution for:" ), a, r );
if( compileError )
@ -392,7 +396,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_HOLE_CLEARANCE:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole Clearance" ) );
r = dialog->AddHTMLPage( _( "Hole Clearance" ) );
reportHeader( _( "Hole clearance resolution for:" ), a, b, r );
if( compileError )
@ -436,7 +440,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_DRILLED_HOLES_TOO_CLOSE:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole to Hole" ) );
r = dialog->AddHTMLPage( _( "Hole to Hole" ) );
reportHeader( _( "Hole to hole clearance resolution for:" ), a, b, r );
if( compileError )
@ -451,7 +455,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
break;
case DRCE_EDGE_CLEARANCE:
r = m_inspectClearanceDialog->AddHTMLPage( _( "Edge Clearance" ) );
r = dialog->AddHTMLPage( _( "Edge Clearance" ) );
reportHeader( _( "Edge clearance resolution for:" ), a, b, r );
if( compileError )
@ -493,7 +497,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
layer = B_Cu;
}
r = m_inspectClearanceDialog->AddHTMLPage( _( "Clearance" ) );
r = dialog->AddHTMLPage( _( "Clearance" ) );
reportHeader( _( "Clearance resolution for:" ), a, b, layer, r );
if( compileError )
@ -542,8 +546,8 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
r->Flush();
m_inspectClearanceDialog->Raise();
m_inspectClearanceDialog->Show( true );
dialog->Raise();
dialog->Show( true );
}
@ -592,17 +596,16 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
// a and b could be null after group tests above.
wxCHECK( a && b, 0 );
if( m_inspectClearanceDialog == nullptr )
{
m_inspectClearanceDialog = std::make_unique<DIALOG_BOOK_REPORTER>( m_frame );
m_inspectClearanceDialog->SetTitle( _( "Clearance Report" ) );
wxWindow* window = wxWindow::FindWindowByName( INSPECT_CLEARANCE_DIALOG_NAME );
DIALOG_BOOK_REPORTER* dialog = dynamic_cast<DIALOG_BOOK_REPORTER*>( window );
m_inspectClearanceDialog->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onInspectClearanceDialogClosed ),
nullptr, this );
if( !dialog )
{
dialog = new DIALOG_BOOK_REPORTER( m_frame, INSPECT_CLEARANCE_DIALOG_NAME,
_( "Clearance Report" ) );
}
m_inspectClearanceDialog->DeleteAllPages();
dialog->DeleteAllPages();
if( a->Type() != PCB_ZONE_T && b->Type() == PCB_ZONE_T )
std::swap( a, b );
@ -634,7 +637,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
else if( zone->GetLayerSet().count() > 0 )
layer = zone->GetLayerSet().Seq().front();
r = m_inspectClearanceDialog->AddHTMLPage( _( "Zone" ) );
r = dialog->AddHTMLPage( _( "Zone" ) );
reportHeader( _( "Zone connection resolution for:" ), a, b, layer, r );
constraint = drcEngine.EvalZoneConnection( pad, zone, layer, r );
@ -757,7 +760,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
if( !copperIntersection.test( layer ) )
layer = copperIntersection.Seq().front();
r = m_inspectClearanceDialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
r = dialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
reportHeader( _( "Clearance resolution for:" ), a, b, layer, r );
if( ac && bc && ac->GetNetCode() > 0 && ac->GetNetCode() == bc->GetNetCode() )
@ -800,7 +803,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
if( DRC_ENGINE::MatchDpSuffix( refNet->GetNetname(), coupledNet, dummy )
&& bc->GetNetname() == coupledNet )
{
r = m_inspectClearanceDialog->AddHTMLPage( _( "Diff Pair" ) );
r = dialog->AddHTMLPage( _( "Diff Pair" ) );
reportHeader( _( "Diff pair gap resolution for:" ), ac, bc, active, r );
constraint = drcEngine.EvalRules( DIFF_PAIR_GAP_CONSTRAINT, ac, bc, active, r );
@ -867,7 +870,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
if( ( a->IsOnLayer( layer ) && isOnCorrespondingLayer( b, layer, &warning ) )
|| ( b->IsOnLayer( layer ) && isOnCorrespondingLayer( a, layer, &warning ) ) )
{
r = m_inspectClearanceDialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
r = dialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
reportHeader( _( "Silkscreen clearance resolution for:" ), a, b, layer, r );
constraint = drcEngine.EvalRules( SILK_CLEARANCE_CONSTRAINT, a, b, layer, r );
@ -895,7 +898,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
if( aCourtyard && bCourtyard )
{
r = m_inspectClearanceDialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
r = dialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
reportHeader( _( "Courtyard clearance resolution for:" ), a, b, layer, r );
constraint = drcEngine.EvalRules( COURTYARD_CLEARANCE_CONSTRAINT, a, b, layer, r );
@ -930,7 +933,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
{
if( !pageAdded )
{
r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole" ) );
r = dialog->AddHTMLPage( _( "Hole" ) );
pageAdded = true;
}
else
@ -959,7 +962,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
{
if( !pageAdded )
{
r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole" ) );
r = dialog->AddHTMLPage( _( "Hole" ) );
pageAdded = true;
}
else
@ -1007,7 +1010,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
if( layer >= 0 )
{
wxString layerName = m_frame->GetBoard()->GetLayerName( edgeLayer );
r = m_inspectClearanceDialog->AddHTMLPage( layerName + wxS( " " ) + _( "Clearance" ) );
r = dialog->AddHTMLPage( layerName + wxS( " " ) + _( "Clearance" ) );
reportHeader( _( "Edge clearance resolution for:" ), a, b, layer, r );
constraint = drcEngine.EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer, r );
@ -1024,7 +1027,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
}
}
r = m_inspectClearanceDialog->AddHTMLPage( _( "Physical Clearances" ) );
r = dialog->AddHTMLPage( _( "Physical Clearances" ) );
auto reportPhysicalClearance =
[&]( PCB_LAYER_ID aLayer )
@ -1119,8 +1122,8 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
r->Flush();
m_inspectClearanceDialog->Raise();
m_inspectClearanceDialog->Show( true );
dialog->Raise();
dialog->Show( true );
return 0;
}
@ -1138,17 +1141,16 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
return 0;
}
if( m_inspectConstraintsDialog == nullptr )
{
m_inspectConstraintsDialog = std::make_unique<DIALOG_BOOK_REPORTER>( m_frame );
m_inspectConstraintsDialog->SetTitle( _( "Constraints Report" ) );
wxWindow* window = wxWindow::FindWindowByName( INSPECT_CONSTRAINTS_DIALOG_NAME );
DIALOG_BOOK_REPORTER* dialog = dynamic_cast<DIALOG_BOOK_REPORTER*>( window );
m_inspectConstraintsDialog->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onInspectConstraintsDialogClosed ),
nullptr, this );
if( !dialog )
{
dialog = new DIALOG_BOOK_REPORTER( m_frame, INSPECT_CONSTRAINTS_DIALOG_NAME,
_( "Constraints Report" ) );
}
m_inspectConstraintsDialog->DeleteAllPages();
dialog->DeleteAllPages();
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
bool compileError = false;
@ -1160,7 +1162,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
if( item->Type() == PCB_TRACE_T )
{
r = m_inspectConstraintsDialog->AddHTMLPage( _( "Track Width" ) );
r = dialog->AddHTMLPage( _( "Track Width" ) );
reportHeader( _( "Track width resolution for:" ), item, r );
constraint = EVAL_RULES( TRACK_WIDTH_CONSTRAINT, item, nullptr, item->GetLayer(), r );
@ -1179,7 +1181,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
if( item->Type() == PCB_VIA_T )
{
r = m_inspectConstraintsDialog->AddHTMLPage( _( "Via Diameter" ) );
r = dialog->AddHTMLPage( _( "Via Diameter" ) );
reportHeader( _( "Via diameter resolution for:" ), item, r );
// PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
@ -1196,7 +1198,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
r->Flush();
r = m_inspectConstraintsDialog->AddHTMLPage( _( "Via Annular Width" ) );
r = dialog->AddHTMLPage( _( "Via Annular Width" ) );
reportHeader( _( "Via annular width resolution for:" ), item, r );
// PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
@ -1217,7 +1219,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
if( ( item->Type() == PCB_PAD_T && static_cast<PAD*>( item )->GetDrillSize().x > 0 )
|| item->Type() == PCB_VIA_T )
{
r = m_inspectConstraintsDialog->AddHTMLPage( _( "Hole Size" ) );
r = dialog->AddHTMLPage( _( "Hole Size" ) );
reportHeader( _( "Hole diameter resolution for:" ), item, r );
// PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
@ -1239,7 +1241,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
|| item->Type() == PCB_TEXTBOX_T
|| item->Type() == PCB_FP_TEXT_T )
{
r = m_inspectConstraintsDialog->AddHTMLPage( _( "Text Size" ) );
r = dialog->AddHTMLPage( _( "Text Size" ) );
reportHeader( _( "Text height resolution for:" ), item, r );
constraint = EVAL_RULES( TEXT_HEIGHT_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
@ -1272,7 +1274,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
r->Flush();
}
r = m_inspectConstraintsDialog->AddHTMLPage( _( "Keepouts" ) );
r = dialog->AddHTMLPage( _( "Keepouts" ) );
reportHeader( _( "Keepout resolution for:" ), item, r );
constraint = EVAL_RULES( DISALLOW_CONSTRAINT, item, nullptr, item->GetLayer(), r );
@ -1297,7 +1299,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
r->Flush();
r = m_inspectConstraintsDialog->AddHTMLPage( _( "Assertions" ) );
r = dialog->AddHTMLPage( _( "Assertions" ) );
reportHeader( _( "Assertions for:" ), item, r );
if( compileError )
@ -1314,9 +1316,8 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
drcEngine.ProcessAssertions( item, []( const DRC_CONSTRAINT* c ){}, r );
r->Flush();
m_inspectConstraintsDialog->FinishInitialization();
m_inspectConstraintsDialog->Raise();
m_inspectConstraintsDialog->Show( true );
dialog->Raise();
dialog->Show( true );
return 0;
}
@ -1344,17 +1345,16 @@ int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent )
return 0;
}
if( m_diffFootprintDialog == nullptr )
{
m_diffFootprintDialog = std::make_unique<DIALOG_BOOK_REPORTER>( m_frame );
m_diffFootprintDialog->SetTitle( _( "Diff Footprint with Library" ) );
wxWindow* window = wxWindow::FindWindowByName( DIFF_FOOTPRINTS_DIALOG_NAME );
DIALOG_BOOK_REPORTER* dialog = dynamic_cast<DIALOG_BOOK_REPORTER*>( window );
m_diffFootprintDialog->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onDiffFootprintDialogClosed ),
nullptr, this );
if( !dialog )
{
dialog = new DIALOG_BOOK_REPORTER( m_frame, DIFF_FOOTPRINTS_DIALOG_NAME,
_( "Diff Footprint with Library" ) );
}
m_diffFootprintDialog->DeleteAllPages();
dialog->DeleteAllPages();
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( selection.GetItem( 0 ) );
LIB_ID fpID = footprint->GetFPID();
@ -1362,7 +1362,7 @@ int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent )
wxString fpName = fpID.GetLibItemName();
WX_HTML_REPORT_BOX* r = nullptr;
r = m_diffFootprintDialog->AddHTMLPage( _( "Summary" ) );
r = dialog->AddHTMLPage( _( "Summary" ) );
r->Report( wxS( "<h7>" ) + _( "Board vs library diff for:" ) + wxS( "</h7>" ) );
r->Report( wxS( "<ul><li>" ) + EscapeHTML( getItemDescription( footprint ) ) + wxS( "</li>" )
@ -1419,7 +1419,7 @@ int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent )
if( !footprint->FootprintNeedsUpdate( libFootprint.get(), r ) )
r->Report( _( "No relevant differences detected." ) );
wxPanel* panel = m_diffFootprintDialog->AddBlankPage( _( "Visual" ) );
wxPanel* panel = dialog->AddBlankPage( _( "Visual" ) );
FOOTPRINT_DIFF_WIDGET* diff = constructDiffPanel( panel );
diff->DisplayDiff( footprint, libFootprint );
@ -1428,9 +1428,8 @@ int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent )
r->Flush();
m_diffFootprintDialog->FinishInitialization();
m_diffFootprintDialog->Raise();
m_diffFootprintDialog->Show( true );
dialog->Raise();
dialog->Show( true );
return 0;
}
@ -1871,74 +1870,18 @@ void BOARD_INSPECTION_TOOL::calculateSelectionRatsnest( const VECTOR2I& aDelta )
int BOARD_INSPECTION_TOOL::ListNets( const TOOL_EVENT& aEvent )
{
if( m_listNetsDialog == nullptr )
{
m_listNetsDialog =
std::make_unique<DIALOG_NET_INSPECTOR>( m_frame, m_listNetsDialogSettings );
wxWindow* window = wxWindow::FindWindowByName( LIST_NETS_DIALOG_NAME );
DIALOG_NET_INSPECTOR* dialog = dynamic_cast<DIALOG_NET_INSPECTOR*>( window );
m_listNetsDialog->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
this );
if( !dialog )
dialog = new DIALOG_NET_INSPECTOR( m_frame, LIST_NETS_DIALOG_NAME );
m_listNetsDialog->Connect( wxEVT_BUTTON,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
this );
}
m_listNetsDialog->Raise();
m_listNetsDialog->Show( true );
dialog->Raise();
dialog->Show( true );
return 0;
}
void BOARD_INSPECTION_TOOL::onListNetsDialogClosed( wxCommandEvent& event )
{
m_listNetsDialogSettings = m_listNetsDialog->Settings();
m_listNetsDialog->Disconnect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
m_listNetsDialog->Disconnect( wxEVT_BUTTON,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
m_listNetsDialog->Destroy();
m_listNetsDialog.release();
}
void BOARD_INSPECTION_TOOL::onInspectClearanceDialogClosed( wxCommandEvent& event )
{
m_inspectClearanceDialog->Disconnect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onInspectClearanceDialogClosed ),
nullptr, this );
m_inspectClearanceDialog->Destroy();
m_inspectClearanceDialog.release();
}
void BOARD_INSPECTION_TOOL::onInspectConstraintsDialogClosed( wxCommandEvent& event )
{
m_inspectConstraintsDialog->Disconnect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onInspectConstraintsDialogClosed ),
nullptr, this );
m_inspectConstraintsDialog->Destroy();
m_inspectConstraintsDialog.release();
}
void BOARD_INSPECTION_TOOL::onDiffFootprintDialogClosed( wxCommandEvent& event )
{
m_diffFootprintDialog->Disconnect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( BOARD_INSPECTION_TOOL::onDiffFootprintDialogClosed ),
nullptr, this );
m_diffFootprintDialog->Destroy();
m_diffFootprintDialog.release();
}
int BOARD_INSPECTION_TOOL::HideNetInRatsnest( const TOOL_EVENT& aEvent )
{
doHideRatsnestNet( aEvent.Parameter<intptr_t>(), true );

View File

@ -117,11 +117,6 @@ private:
///< Bind handlers to corresponding TOOL_ACTIONs.
void setTransitions() override;
void onListNetsDialogClosed( wxCommandEvent& aEvent );
void onInspectClearanceDialogClosed( wxCommandEvent& aEvent );
void onInspectConstraintsDialogClosed( wxCommandEvent& aEvent );
void onDiffFootprintDialogClosed( wxCommandEvent& event );
DRC_ENGINE makeDRCEngine( bool* aCompileError, bool* aCourtyardError = nullptr );
wxString getItemDescription( BOARD_ITEM* aItem );
@ -141,13 +136,6 @@ private:
std::set<int> m_lastHighlighted; // For toggling between last two highlighted nets
CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
std::unique_ptr<DIALOG_NET_INSPECTOR> m_listNetsDialog;
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_inspectClearanceDialog;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_inspectConstraintsDialog;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_diffFootprintDialog;
};
#endif //BOARD_INSPECTION_TOOL_H