Make plot dialog modeless.

Fixes: lp:1496617
* https://bugs.launchpad.net/kicad/+bug/1496617
This commit is contained in:
Jeff Young 2018-02-22 15:25:31 +00:00 committed by Wayne Stambaugh
parent 7bd2f14342
commit 2473cf6d45
4 changed files with 29 additions and 17 deletions

View File

@ -46,8 +46,7 @@
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
DIALOG_PLOT_BASE( aParent ), m_parent( aParent ), DIALOG_PLOT_BASE( aParent ), m_parent( aParent )
m_board( aParent->GetBoard() )
{ {
m_config = Kiface().KifaceSettings(); m_config = Kiface().KifaceSettings();
m_plotOpts = aParent->GetPlotSettings(); m_plotOpts = aParent->GetPlotSettings();
@ -60,6 +59,7 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
void DIALOG_PLOT::init_Dialog() void DIALOG_PLOT::init_Dialog()
{ {
BOARD* board = m_parent->GetBoard();
wxString msg; wxString msg;
wxFileName fileName; wxFileName fileName;
@ -75,8 +75,8 @@ void DIALOG_PLOT::init_Dialog()
// The reasonable width correction value must be in a range of // The reasonable width correction value must be in a range of
// [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils. // [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
m_widthAdjustMinValue = -( m_board->GetDesignSettings().m_TrackMinWidth - 1 ); m_widthAdjustMinValue = -( board->GetDesignSettings().m_TrackMinWidth - 1 );
m_widthAdjustMaxValue = m_board->GetDesignSettings().GetSmallestClearanceValue() - 1; m_widthAdjustMaxValue = board->GetDesignSettings().GetSmallestClearanceValue() - 1;
switch( m_plotOpts.GetFormat() ) switch( m_plotOpts.GetFormat() )
{ {
@ -106,9 +106,9 @@ void DIALOG_PLOT::init_Dialog()
break; break;
} }
msg = StringFromValue( g_UserUnit, m_board->GetDesignSettings().m_SolderMaskMargin, true ); msg = StringFromValue( g_UserUnit, board->GetDesignSettings().m_SolderMaskMargin, true );
m_SolderMaskMarginCurrValue->SetLabel( msg ); m_SolderMaskMarginCurrValue->SetLabel( msg );
msg = StringFromValue( g_UserUnit, m_board->GetDesignSettings().m_SolderMaskMinWidth, true ); msg = StringFromValue( g_UserUnit, board->GetDesignSettings().m_SolderMaskMinWidth, true );
m_SolderMaskMinWidthCurrValue->SetLabel( msg ); m_SolderMaskMinWidthCurrValue->SetLabel( msg );
// Set units and value for HPGL pen size (this param in in mils). // Set units and value for HPGL pen size (this param in in mils).
@ -146,14 +146,14 @@ void DIALOG_PLOT::init_Dialog()
m_forcePSA4OutputOpt->SetValue( m_plotOpts.GetA4Output() ); m_forcePSA4OutputOpt->SetValue( m_plotOpts.GetA4Output() );
// Could devote a PlotOrder() function in place of UIOrder(). // Could devote a PlotOrder() function in place of UIOrder().
m_layerList = m_board->GetEnabledLayers().UIOrder(); m_layerList = board->GetEnabledLayers().UIOrder();
// Populate the check list box by all enabled layers names // Populate the check list box by all enabled layers names
for( LSEQ seq = m_layerList; seq; ++seq ) for( LSEQ seq = m_layerList; seq; ++seq )
{ {
PCB_LAYER_ID layer = *seq; PCB_LAYER_ID layer = *seq;
int checkIndex = m_layerCheckListBox->Append( m_board->GetLayerName( layer ) ); int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
if( m_plotOpts.GetLayerSelection()[layer] ) if( m_plotOpts.GetLayerSelection()[layer] )
m_layerCheckListBox->Check( checkIndex ); m_layerCheckListBox->Check( checkIndex );
@ -239,14 +239,19 @@ void DIALOG_PLOT::reInitDialog()
void DIALOG_PLOT::OnQuit( wxCommandEvent& event ) void DIALOG_PLOT::OnQuit( wxCommandEvent& event )
{ {
Close( true ); // true is to force the frame to close // Put a wxID_CANCEL event through the dialog infrastrucutre
event.SetId( wxID_CANCEL );
event.Skip();
} }
void DIALOG_PLOT::OnClose( wxCloseEvent& event ) void DIALOG_PLOT::OnClose( wxCloseEvent& event )
{ {
applyPlotSettings(); applyPlotSettings();
EndModal( 0 );
// Put an wxID_OK event through the dialog infrastrucutre
event.SetId( wxID_OK );
event.Skip();
} }
@ -703,7 +708,7 @@ void DIALOG_PLOT::applyPlotSettings()
selectedLayers.set( m_layerList[i] ); selectedLayers.set( m_layerList[i] );
} }
// Get a list of copper layers that aren't being used by inverting enabled layers. // Get a list of copper layers that aren't being used by inverting enabled layers.
LSET disabledCopperLayers = LSET::AllCuMask() & ~m_board->GetEnabledLayers(); LSET disabledCopperLayers = LSET::AllCuMask() & ~m_parent->GetBoard()->GetEnabledLayers();
// Enable all of the disabled copper layers. // Enable all of the disabled copper layers.
// If someone enables more copper layers they will be selected by default. // If someone enables more copper layers they will be selected by default.
selectedLayers = selectedLayers | disabledCopperLayers; selectedLayers = selectedLayers | disabledCopperLayers;
@ -750,6 +755,8 @@ void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event )
void DIALOG_PLOT::Plot( wxCommandEvent& event ) void DIALOG_PLOT::Plot( wxCommandEvent& event )
{ {
BOARD* board = m_parent->GetBoard();
applyPlotSettings(); applyPlotSettings();
// If no layer selected, we have nothing plotted. // If no layer selected, we have nothing plotted.
@ -827,7 +834,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
DisplayInfoMessage( this, DisplayInfoMessage( this,
_( "Warning: Scale option set to a very large value" ) ); _( "Warning: Scale option set to a very large value" ) );
GERBER_JOBFILE_WRITER jobfile_writer( m_board, &reporter ); GERBER_JOBFILE_WRITER jobfile_writer( board, &reporter );
// Save the current plot options in the board // Save the current plot options in the board
m_parent->SetPlotSettings( m_plotOpts ); m_parent->SetPlotSettings( m_plotOpts );
@ -844,7 +851,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
// If plot options become accessible to the layers setup dialog // If plot options become accessible to the layers setup dialog
// please move this functionality there! // please move this functionality there!
// This skips a copper layer if it is actually disabled on the board. // This skips a copper layer if it is actually disabled on the board.
if( ( LSET::AllCuMask() & ~m_board->GetEnabledLayers() )[layer] ) if( ( LSET::AllCuMask() & ~board->GetEnabledLayers() )[layer] )
continue; continue;
// Pick the basename from the board file // Pick the basename from the board file
@ -855,7 +862,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
if( m_plotOpts.GetFormat() == PLOT_FORMAT_GERBER && m_useGerberExtensions->GetValue() ) if( m_plotOpts.GetFormat() == PLOT_FORMAT_GERBER && m_useGerberExtensions->GetValue() )
file_ext = GetGerberProtelExtension( layer ); file_ext = GetGerberProtelExtension( layer );
BuildPlotFileName( &fn, outputDir.GetPath(), m_board->GetLayerName( layer ), file_ext ); BuildPlotFileName( &fn, outputDir.GetPath(), board->GetLayerName( layer ), file_ext );
wxString fullname = fn.GetFullName(); wxString fullname = fn.GetFullName();
jobfile_writer.AddGbrFile( layer, fullname ); jobfile_writer.AddGbrFile( layer, fullname );

View File

@ -40,7 +40,6 @@ public:
private: private:
PCB_EDIT_FRAME* m_parent; PCB_EDIT_FRAME* m_parent;
BOARD* m_board;
wxConfigBase* m_config; wxConfigBase* m_config;
LSEQ m_layerList; // List to hold CheckListBox layer numbers LSEQ m_layerList; // List to hold CheckListBox layer numbers
double m_XScaleAdjust; // X scale factor adjust to compensate double m_XScaleAdjust; // X scale factor adjust to compensate

View File

@ -360,6 +360,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), pointSize ); m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), pointSize );
m_drc = new DRC( this ); // these 2 objects point to each other m_drc = new DRC( this ); // these 2 objects point to each other
m_plotDialog = nullptr;
wxIcon icon; wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
@ -542,6 +543,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
PCB_EDIT_FRAME::~PCB_EDIT_FRAME() PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
{ {
delete m_drc; delete m_drc;
delete m_plotDialog;
} }
@ -1199,9 +1201,10 @@ void PCB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event )
{ {
DIALOG_PLOT dlg( this ); if( !m_plotDialog )
m_plotDialog = new DIALOG_PLOT( this );
dlg.ShowModal(); m_plotDialog->Show( true );
} }

View File

@ -47,6 +47,7 @@ class PCB_TARGET;
class DIMENSION; class DIMENSION;
class EDGE_MODULE; class EDGE_MODULE;
class DRC; class DRC;
class DIALOG_PLOT;
class ZONE_CONTAINER; class ZONE_CONTAINER;
class DRAWSEGMENT; class DRAWSEGMENT;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
@ -90,6 +91,8 @@ protected:
DRC* m_drc; ///< the DRC controller, see drc.cpp DRC* m_drc; ///< the DRC controller, see drc.cpp
DIALOG_PLOT* m_plotDialog;
PARAM_CFG_ARRAY m_configParams; ///< List of Pcbnew configuration settings. PARAM_CFG_ARRAY m_configParams; ///< List of Pcbnew configuration settings.
wxString m_lastNetListRead; ///< Last net list read with relative path. wxString m_lastNetListRead; ///< Last net list read with relative path.