Even more open-coded dialog state-saving cleanup.

This commit is contained in:
Jeff Young 2025-08-11 12:51:20 +01:00
parent cd325198c1
commit 6947b3b233
10 changed files with 104 additions and 209 deletions

View File

@ -78,9 +78,8 @@ static const wxString pageFmts[] =
// to be recognized in code // to be recognized in code
}; };
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, EMBEDDED_FILES* aEmbeddedFiles,
EMBEDDED_FILES* aEmbeddedFiles, double aIuPerMils, double aIuPerMils, const VECTOR2D& aMaxUserSizeMils ) :
const VECTOR2D& aMaxUserSizeMils ) :
DIALOG_PAGES_SETTINGS_BASE( aParent ), DIALOG_PAGES_SETTINGS_BASE( aParent ),
m_parent( aParent ), m_parent( aParent ),
m_screen( m_parent->GetScreen() ), m_screen( m_parent->GetScreen() ),
@ -479,9 +478,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
BASE_SCREEN::m_DrawingSheetFileName = fileName; BASE_SCREEN::m_DrawingSheetFileName = fileName;
if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( fullFileName, &msg ) ) if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( fullFileName, &msg ) )
{
DisplayErrorMessage( this, wxString::Format( _( "Error loading drawing sheet '%s'." ), fullFileName ), msg ); DisplayErrorMessage( this, wxString::Format( _( "Error loading drawing sheet '%s'." ), fullFileName ), msg );
}
m_localPrjConfigChanged = true; m_localPrjConfigChanged = true;
@ -506,36 +503,21 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
else else
{ {
// search for longest common string first, e.g. A4 before A // search for longest common string first, e.g. A4 before A
if( paperType.Contains( PAGE_INFO::USLetter ) ) if( paperType.Contains( PAGE_INFO::USLetter ) ) success = m_pageInfo.SetType( PAGE_INFO::USLetter );
success = m_pageInfo.SetType( PAGE_INFO::USLetter ); else if( paperType.Contains( PAGE_INFO::USLegal ) ) success = m_pageInfo.SetType( PAGE_INFO::USLegal );
else if( paperType.Contains( PAGE_INFO::USLegal ) ) else if( paperType.Contains( PAGE_INFO::USLedger ) ) success = m_pageInfo.SetType( PAGE_INFO::USLedger );
success = m_pageInfo.SetType( PAGE_INFO::USLegal ); else if( paperType.Contains( PAGE_INFO::GERBER ) ) success = m_pageInfo.SetType( PAGE_INFO::GERBER );
else if( paperType.Contains( PAGE_INFO::USLedger ) ) else if( paperType.Contains( PAGE_INFO::A5 ) ) success = m_pageInfo.SetType( PAGE_INFO::A5 );
success = m_pageInfo.SetType( PAGE_INFO::USLedger ); else if( paperType.Contains( PAGE_INFO::A4 ) ) success = m_pageInfo.SetType( PAGE_INFO::A4 );
else if( paperType.Contains( PAGE_INFO::GERBER ) ) else if( paperType.Contains( PAGE_INFO::A3 ) ) success = m_pageInfo.SetType( PAGE_INFO::A3 );
success = m_pageInfo.SetType( PAGE_INFO::GERBER ); else if( paperType.Contains( PAGE_INFO::A2 ) ) success = m_pageInfo.SetType( PAGE_INFO::A2 );
else if( paperType.Contains( PAGE_INFO::A5 ) ) else if( paperType.Contains( PAGE_INFO::A1 ) ) success = m_pageInfo.SetType( PAGE_INFO::A1 );
success = m_pageInfo.SetType( PAGE_INFO::A5 ); else if( paperType.Contains( PAGE_INFO::A0 ) ) success = m_pageInfo.SetType( PAGE_INFO::A0 );
else if( paperType.Contains( PAGE_INFO::A4 ) ) else if( paperType.Contains( PAGE_INFO::A ) ) success = m_pageInfo.SetType( PAGE_INFO::A );
success = m_pageInfo.SetType( PAGE_INFO::A4 ); else if( paperType.Contains( PAGE_INFO::B ) ) success = m_pageInfo.SetType( PAGE_INFO::B );
else if( paperType.Contains( PAGE_INFO::A3 ) ) else if( paperType.Contains( PAGE_INFO::C ) ) success = m_pageInfo.SetType( PAGE_INFO::C );
success = m_pageInfo.SetType( PAGE_INFO::A3 ); else if( paperType.Contains( PAGE_INFO::D ) ) success = m_pageInfo.SetType( PAGE_INFO::D );
else if( paperType.Contains( PAGE_INFO::A2 ) ) else if( paperType.Contains( PAGE_INFO::E ) ) success = m_pageInfo.SetType( PAGE_INFO::E );
success = m_pageInfo.SetType( PAGE_INFO::A2 );
else if( paperType.Contains( PAGE_INFO::A1 ) )
success = m_pageInfo.SetType( PAGE_INFO::A1 );
else if( paperType.Contains( PAGE_INFO::A0 ) )
success = m_pageInfo.SetType( PAGE_INFO::A0 );
else if( paperType.Contains( PAGE_INFO::A ) )
success = m_pageInfo.SetType( PAGE_INFO::A );
else if( paperType.Contains( PAGE_INFO::B ) )
success = m_pageInfo.SetType( PAGE_INFO::B );
else if( paperType.Contains( PAGE_INFO::C ) )
success = m_pageInfo.SetType( PAGE_INFO::C );
else if( paperType.Contains( PAGE_INFO::D ) )
success = m_pageInfo.SetType( PAGE_INFO::D );
else if( paperType.Contains( PAGE_INFO::E ) )
success = m_pageInfo.SetType( PAGE_INFO::E );
if( success ) if( success )
{ {
@ -800,8 +782,7 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
// Display a file picker dialog // Display a file picker dialog
FILEDLG_HOOK_EMBED_FILE customize; FILEDLG_HOOK_EMBED_FILE customize;
wxFileDialog fileDialog( this, _( "Drawing Sheet File" ), path, name, wxFileDialog fileDialog( this, _( "Drawing Sheet File" ), path, name, FILEEXT::DrawingSheetFileWildcard(),
FILEEXT::DrawingSheetFileWildcard(),
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST ); wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
if( m_embeddedFiles ) if( m_embeddedFiles )

View File

@ -33,6 +33,8 @@
static constexpr double MIN_SCALE = 0.01; static constexpr double MIN_SCALE = 0.01;
static constexpr double MAX_SCALE = 100.0; static constexpr double MAX_SCALE = 100.0;
wxPrintData* DIALOG_PRINT_GENERIC::s_printData = nullptr;
wxPageSetupDialogData* DIALOG_PRINT_GENERIC::s_pageSetupData = nullptr;
/** /**
@ -43,16 +45,15 @@ static constexpr double MAX_SCALE = 100.0;
class KI_PREVIEW_FRAME : public wxPreviewFrame class KI_PREVIEW_FRAME : public wxPreviewFrame
{ {
public: public:
KI_PREVIEW_FRAME( wxPrintPreview* aPreview, wxWindow* aParent, KI_PREVIEW_FRAME( wxPrintPreview* aPreview, wxWindow* aParent, const wxString& aTitle,
const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition, const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize ) :
const wxSize& aSize = wxDefaultSize ) : wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
{ {
} }
bool Show( bool show ) override bool Show( bool show ) override
{ {
bool ret; bool ret;
// Show or hide the window. If hiding, save current position and size. // Show or hide the window. If hiding, save current position and size.
// If showing, use previous position and size. // If showing, use previous position and size.
@ -85,16 +86,10 @@ wxPoint KI_PREVIEW_FRAME::s_pos;
wxSize KI_PREVIEW_FRAME::s_size; wxSize KI_PREVIEW_FRAME::s_size;
DIALOG_PRINT_GENERIC::DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings ) DIALOG_PRINT_GENERIC::DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings ) :
: DIALOG_PRINT_GENERIC_BASE( aParent ), DIALOG_PRINT_GENERIC_BASE( aParent ),
m_config( nullptr ), m_settings( aSettings )
m_settings( aSettings )
{ {
// Note: for the validator, min value is 0.0, to allow typing values like 0.5
// that start by 0
m_scaleValidator.SetRange( 0.0, MAX_SCALE );
m_scaleCustomText->SetValidator( m_scaleValidator );
// Show m_panelPrinters only if there are printers to list: // Show m_panelPrinters only if there are printers to list:
m_panelPrinters->Show( m_panelPrinters->AsPrintersAvailable() ); m_panelPrinters->Show( m_panelPrinters->AsPrintersAvailable() );
@ -114,22 +109,10 @@ DIALOG_PRINT_GENERIC::DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SE
} }
DIALOG_PRINT_GENERIC::~DIALOG_PRINT_GENERIC()
{
}
void DIALOG_PRINT_GENERIC::ForcePrintBorder( bool aValue ) void DIALOG_PRINT_GENERIC::ForcePrintBorder( bool aValue )
{ {
m_titleBlock->SetValue( aValue ); m_titleBlock->SetValue( aValue );
m_titleBlock->Hide(); m_titleBlock->Hide();
if( m_config )
{
m_settings->Load( m_config );
m_settings->m_titleBlock = aValue;
m_settings->Save( m_config );
}
} }
@ -138,27 +121,27 @@ void DIALOG_PRINT_GENERIC::saveSettings()
m_settings->m_scale = getScaleValue(); m_settings->m_scale = getScaleValue();
m_settings->m_titleBlock = m_titleBlock->GetValue(); m_settings->m_titleBlock = m_titleBlock->GetValue();
m_settings->m_blackWhite = m_outputMode->GetSelection(); m_settings->m_blackWhite = m_outputMode->GetSelection();
if( m_config )
m_settings->Save( m_config );
} }
double DIALOG_PRINT_GENERIC::getScaleValue() double DIALOG_PRINT_GENERIC::getScaleValue()
{ {
if( m_scale1->GetValue() ) if( m_scale1->GetValue() )
{
return 1.0; return 1.0;
}
if( m_scaleFit->GetValue() ) else if( m_scaleFit->GetValue() )
{
return 0.0; return 0.0;
}
if( m_scaleCustom->GetValue() ) else if( m_scaleCustom->GetValue() )
{ {
double scale = 1.0;; double scale = 1.0;;
if( !m_scaleCustomText->GetValue().ToDouble( &scale ) ) if( !m_scaleCustomText->GetValue().ToDouble( &scale ) )
{ {
DisplayInfoMessage( nullptr, _( "Warning: scale is not a number." ) ); DisplayInfoMessage( nullptr, _( "Warning: custom scale is not a number." ) );
setScaleValue( 1.0 );
scale = 1.0; scale = 1.0;
} }
@ -166,17 +149,15 @@ double DIALOG_PRINT_GENERIC::getScaleValue()
{ {
scale = MAX_SCALE; scale = MAX_SCALE;
setScaleValue( scale ); setScaleValue( scale );
DisplayInfoMessage( nullptr, wxString::Format( _( "Warning: scale set to a very large " DisplayInfoMessage( nullptr, wxString::Format( _( "Warning: custom scale is too large.\n"
"value.\nIt will be clamped to %f." ), "It will be clamped to %f." ), scale ) );
scale ) );
} }
else if( scale < MIN_SCALE ) else if( scale < MIN_SCALE )
{ {
scale = MIN_SCALE; scale = MIN_SCALE;
setScaleValue( scale ); setScaleValue( scale );
DisplayInfoMessage( nullptr, wxString::Format( _( "Warning: scale set to a very small " DisplayInfoMessage( nullptr, wxString::Format( _( "Warning: custom scale is too small.\n"
"value.\nIt will be clamped to %f." ), "It will be clamped to %f." ), scale ) );
scale ) );
} }
return scale; return scale;
@ -218,9 +199,6 @@ bool DIALOG_PRINT_GENERIC::TransferDataToWindow()
if( !wxDialog::TransferDataToWindow() ) if( !wxDialog::TransferDataToWindow() )
return false; return false;
if( m_config )
m_settings->Load( m_config );
setScaleValue( m_settings->m_scale ); setScaleValue( m_settings->m_scale );
m_titleBlock->SetValue( m_settings->m_titleBlock ); m_titleBlock->SetValue( m_settings->m_titleBlock );
m_outputMode->SetSelection( m_settings->m_blackWhite ? 1 : 0 ); m_outputMode->SetSelection( m_settings->m_blackWhite ? 1 : 0 );
@ -234,7 +212,7 @@ void DIALOG_PRINT_GENERIC::onPageSetup( wxCommandEvent& event )
wxPageSetupDialog pageSetupDialog( this, s_pageSetupData ); wxPageSetupDialog pageSetupDialog( this, s_pageSetupData );
pageSetupDialog.ShowModal(); pageSetupDialog.ShowModal();
(*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData(); (*s_printData ) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData(); (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
} }
@ -255,12 +233,11 @@ void DIALOG_PRINT_GENERIC::onPrintPreview( wxCommandEvent& event )
if( m_panelPrinters ) if( m_panelPrinters )
selectedPrinterName = m_panelPrinters->GetSelectedPrinterName(); selectedPrinterName = m_panelPrinters->GetSelectedPrinterName();
s_PrintData->SetPrinterName( selectedPrinterName ); s_printData->SetPrinterName( selectedPrinterName );
// Pass two printout objects: for preview, and possible printing. // Pass two printout objects: for preview, and possible printing.
wxString title = _( "Print Preview" ); wxString title = _( "Print Preview" );
wxPrintPreview* preview = wxPrintPreview* preview = new wxPrintPreview( createPrintout( title ), createPrintout( title ), s_printData );
new wxPrintPreview( createPrintout( title ), createPrintout( title ), s_PrintData );
preview->SetZoom( 100 ); preview->SetZoom( 100 );
@ -313,9 +290,9 @@ void DIALOG_PRINT_GENERIC::onPrintButtonClick( wxCommandEvent& event )
if( m_panelPrinters ) if( m_panelPrinters )
selectedPrinterName = m_panelPrinters->GetSelectedPrinterName(); selectedPrinterName = m_panelPrinters->GetSelectedPrinterName();
s_PrintData->SetPrinterName( selectedPrinterName ); s_printData->SetPrinterName( selectedPrinterName );
wxPrintDialogData printDialogData( *s_PrintData ); wxPrintDialogData printDialogData( *s_printData );
printDialogData.SetMaxPage( m_settings->m_pageCount ); printDialogData.SetMaxPage( m_settings->m_pageCount );
wxPrinter printer( &printDialogData ); wxPrinter printer( &printDialogData );
@ -331,7 +308,7 @@ void DIALOG_PRINT_GENERIC::onPrintButtonClick( wxCommandEvent& event )
} }
else else
{ {
*s_PrintData = printer.GetPrintDialogData().GetPrintData(); *s_printData = printer.GetPrintDialogData().GetPrintData();
} }
} }
@ -364,38 +341,39 @@ void DIALOG_PRINT_GENERIC::onSetCustomScale( wxCommandEvent& event )
void DIALOG_PRINT_GENERIC::initPrintData() void DIALOG_PRINT_GENERIC::initPrintData()
{ {
if( !s_PrintData ) // First print if( !s_printData ) // First print
{ {
s_PrintData = new wxPrintData(); s_printData = new wxPrintData();
if( !s_PrintData->Ok() ) if( !s_printData->Ok() )
DisplayError( this, _( "An error occurred initializing the printer information." ) ); DisplayError( this, _( "An error occurred initializing the printer information." ) );
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH; s_printData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
} }
if( !s_pageSetupData ) if( !s_pageSetupData )
{ {
const PAGE_INFO& pageInfo = m_settings->m_pageInfo; const PAGE_INFO& pageInfo = m_settings->m_pageInfo;
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData ); s_pageSetupData = new wxPageSetupDialogData( *s_printData );
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() ); s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
if( pageInfo.IsCustom() ) if( pageInfo.IsCustom() )
{ {
if( pageInfo.IsPortrait() ) if( pageInfo.IsPortrait() )
{
s_pageSetupData->SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ), s_pageSetupData->SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ),
EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ) ) ); EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ) ) );
}
else else
{
s_pageSetupData->SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ), s_pageSetupData->SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ),
EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ) ) ); EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ) ) );
}
} }
*s_PrintData = s_pageSetupData->GetPrintData(); *s_printData = s_pageSetupData->GetPrintData();
} }
} }
wxPrintData* DIALOG_PRINT_GENERIC::s_PrintData = nullptr;
wxPageSetupDialogData* DIALOG_PRINT_GENERIC::s_pageSetupData = nullptr;

View File

@ -85,8 +85,6 @@ DIALOG_PRINT_GENERIC_BASE::DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindow
bSizerScaleCustom->Add( m_scaleCustom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); bSizerScaleCustom->Add( m_scaleCustom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_scaleCustomText = new wxTextCtrl( bScaleSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_scaleCustomText = new wxTextCtrl( bScaleSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_scaleCustomText->SetToolTip( _("Set X scale adjust for exact scale plotting") );
bSizerScaleCustom->Add( m_scaleCustomText, 1, wxEXPAND|wxRIGHT, 5 ); bSizerScaleCustom->Add( m_scaleCustomText, 1, wxEXPAND|wxRIGHT, 5 );

View File

@ -674,7 +674,7 @@
<property name="style"></property> <property name="style"></property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip">Set X scale adjust for exact scale plotting</property> <property name="tooltip"></property>
<property name="validator_data_type"></property> <property name="validator_data_type"></property>
<property name="validator_style"></property> <property name="validator_style"></property>
<property name="validator_type">wxDefaultValidator</property> <property name="validator_type">wxDefaultValidator</property>

View File

@ -140,7 +140,7 @@ void DIALOG_MAP_GERBER_LAYERS_TO_PCB::initDialog()
flexColumnBoxSizer = m_flexRightColumnBoxSizer; flexColumnBoxSizer = m_flexRightColumnBoxSizer;
// Provide a text string to identify the Gerber layer // Provide a text string to identify the Gerber layer
msg.Printf( _( "Layer %d" ), m_buttonTable[ii] + 1 ); msg.Printf( _( "Layer %d:" ), m_buttonTable[ii] + 1 );
label = new wxStaticText( this, wxID_STATIC, msg ); label = new wxStaticText( this, wxID_STATIC, msg );
flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
@ -151,9 +151,9 @@ void DIALOG_MAP_GERBER_LAYERS_TO_PCB::initDialog()
flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
// Provide a button for this layer (which will invoke a child dialog box) // Provide a button for this layer (which will invoke a child dialog box)
item_ID = ID_BUTTON_0 + ii; item_ID = ID_BUTTON_0 + ii;
wxButton * Button = new wxButton( this, item_ID, wxT( "..." ), wxDefaultPosition, wxButton * Button = new wxButton( this, item_ID, wxT( "..." ), wxDefaultPosition, wxDefaultSize,
wxDefaultSize, wxBU_EXACTFIT ); wxBU_EXACTFIT );
flexColumnBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL ); flexColumnBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL );

View File

@ -31,11 +31,8 @@ DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE::DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE( wxWi
m_bSizerLayerList->Add( 0, 0, 0, wxRIGHT|wxLEFT, 10 ); m_bSizerLayerList->Add( 0, 0, 0, wxRIGHT|wxLEFT, 10 );
m_flexLeftColumnBoxSizer = new wxFlexGridSizer( 4, 0, 0 ); m_flexLeftColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 0 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 1 ); m_flexLeftColumnBoxSizer->AddGrowableCol( 1 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 2 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 3 );
m_flexLeftColumnBoxSizer->SetFlexibleDirection( wxBOTH ); m_flexLeftColumnBoxSizer->SetFlexibleDirection( wxBOTH );
m_flexLeftColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_flexLeftColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -45,11 +42,8 @@ DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE::DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE( wxWi
m_staticlineSep = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); m_staticlineSep = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
m_bSizerLayerList->Add( m_staticlineSep, 0, wxEXPAND | wxALL, 5 ); m_bSizerLayerList->Add( m_staticlineSep, 0, wxEXPAND | wxALL, 5 );
m_flexRightColumnBoxSizer = new wxFlexGridSizer( 4, 0, 0 ); m_flexRightColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
m_flexRightColumnBoxSizer->AddGrowableCol( 0 );
m_flexRightColumnBoxSizer->AddGrowableCol( 1 ); m_flexRightColumnBoxSizer->AddGrowableCol( 1 );
m_flexRightColumnBoxSizer->AddGrowableCol( 2 );
m_flexRightColumnBoxSizer->AddGrowableCol( 3 );
m_flexRightColumnBoxSizer->SetFlexibleDirection( wxBOTH ); m_flexRightColumnBoxSizer->SetFlexibleDirection( wxBOTH );
m_flexRightColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_flexRightColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -60,7 +54,7 @@ DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE::DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE( wxWi
bSizerLayerSelection->Add( m_bSizerLayerList, 1, wxEXPAND, 5 ); bSizerLayerSelection->Add( m_bSizerLayerList, 1, wxEXPAND, 5 );
sbUpperSizer->Add( bSizerLayerSelection, 1, wxEXPAND, 5 ); sbUpperSizer->Add( bSizerLayerSelection, 1, wxEXPAND|wxRIGHT, 5 );
wxBoxSizer* bRightSizer; wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL ); bRightSizer = new wxBoxSizer( wxVERTICAL );
@ -113,7 +107,7 @@ DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE::DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE( wxWi
bRightSizer->Add( bSizerButtons, 0, wxEXPAND, 5 ); bRightSizer->Add( bSizerButtons, 0, wxEXPAND, 5 );
sbUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); sbUpperSizer->Add( bRightSizer, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerMain->Add( sbUpperSizer, 1, wxEXPAND|wxALL, 5 ); bSizerMain->Add( sbUpperSizer, 1, wxEXPAND|wxALL, 5 );

View File

@ -75,7 +75,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="true"> <object class="sizeritem" expanded="true">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND|wxRIGHT</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="true"> <object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -170,7 +170,7 @@
<object class="wxFlexGridSizer" expanded="true"> <object class="wxFlexGridSizer" expanded="true">
<property name="cols">4</property> <property name="cols">4</property>
<property name="flexible_direction">wxBOTH</property> <property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,1,2,3</property> <property name="growablecols">1</property>
<property name="growablerows"></property> <property name="growablerows"></property>
<property name="hgap">0</property> <property name="hgap">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -247,7 +247,7 @@
<object class="wxFlexGridSizer" expanded="true"> <object class="wxFlexGridSizer" expanded="true">
<property name="cols">4</property> <property name="cols">4</property>
<property name="flexible_direction">wxBOTH</property> <property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,1,2,3</property> <property name="growablecols">1</property>
<property name="growablerows"></property> <property name="growablerows"></property>
<property name="hgap">0</property> <property name="hgap">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -264,7 +264,7 @@
</object> </object>
<object class="sizeritem" expanded="true"> <object class="sizeritem" expanded="true">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property> <property name="flag">wxRIGHT|wxLEFT|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="true"> <object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property> <property name="minimum_size"></property>

View File

@ -45,7 +45,7 @@ class DIALOG_PRINT_GERBVIEW : public DIALOG_PRINT_GENERIC
{ {
public: public:
DIALOG_PRINT_GERBVIEW( GERBVIEW_FRAME* aParent, BOARD_PRINTOUT_SETTINGS* aSettings ); DIALOG_PRINT_GERBVIEW( GERBVIEW_FRAME* aParent, BOARD_PRINTOUT_SETTINGS* aSettings );
~DIALOG_PRINT_GERBVIEW() {}; ~DIALOG_PRINT_GERBVIEW() = default;
private: private:
BOARD_PRINTOUT_SETTINGS* settings() const BOARD_PRINTOUT_SETTINGS* settings() const
@ -68,9 +68,6 @@ private:
///< Check whether a layer is enabled in a listbox ///< Check whether a layer is enabled in a listbox
bool isLayerEnabled( unsigned int aLayer ) const; bool isLayerEnabled( unsigned int aLayer ) const;
///< Enable/disable layer in a listbox
void enableLayer( unsigned int aLayer, bool aValue );
///< Update layerset basing on the selected layers ///< Update layerset basing on the selected layers
int setLayerSetFromList(); int setLayerSetFromList();
@ -78,8 +75,8 @@ private:
wxPrintout* createPrintout( const wxString& aTitle ) override wxPrintout* createPrintout( const wxString& aTitle ) override
{ {
return new GERBVIEW_PRINTOUT( m_parent->GetGerberLayout(), *settings(), return new GERBVIEW_PRINTOUT( m_parent->GetGerberLayout(), *settings(), m_parent->GetCanvas()->GetView(),
m_parent->GetCanvas()->GetView(), aTitle ); aTitle );
} }
GERBVIEW_FRAME* m_parent; GERBVIEW_FRAME* m_parent;
@ -101,13 +98,10 @@ private:
}; };
DIALOG_PRINT_GERBVIEW::DIALOG_PRINT_GERBVIEW( GERBVIEW_FRAME* aParent, DIALOG_PRINT_GERBVIEW::DIALOG_PRINT_GERBVIEW( GERBVIEW_FRAME* aParent, BOARD_PRINTOUT_SETTINGS* aSettings ) :
BOARD_PRINTOUT_SETTINGS* aSettings ) : DIALOG_PRINT_GENERIC( aParent, aSettings ),
DIALOG_PRINT_GENERIC( aParent, aSettings ), m_parent( aParent )
m_parent( aParent )
{ {
m_config = Kiface().KifaceSettings();
createExtraOptions(); createExtraOptions();
createLeftPanel(); createLeftPanel();
} }
@ -168,8 +162,7 @@ void DIALOG_PRINT_GERBVIEW::createExtraOptions()
// Print mirrored // Print mirrored
m_checkboxMirror = new wxCheckBox( box, wxID_ANY, _( "Print mirrored" ) ); m_checkboxMirror = new wxCheckBox( box, wxID_ANY, _( "Print mirrored" ) );
optionsSizer->Add( m_checkboxMirror, wxGBPosition( rows, 0 ), wxGBSpan( 1, cols ), optionsSizer->Add( m_checkboxMirror, wxGBPosition( rows, 0 ), wxGBSpan( 1, cols ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBOTTOM | wxRIGHT | wxLEFT, 5 );
} }
@ -188,17 +181,13 @@ void DIALOG_PRINT_GERBVIEW::createLeftPanel()
} }
// Select/Unselect all buttons // Select/Unselect all buttons
m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Select all" ) );
_( "Select all" ) ); m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Deselect all" ) );
m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY,
_( "Deselect all" ) );
m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_PRINT_GERBVIEW::onSelectAllClick ), wxCommandEventHandler( DIALOG_PRINT_GERBVIEW::onSelectAllClick ), nullptr, this );
nullptr, this );
m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_PRINT_GERBVIEW::onDeselectAllClick ), wxCommandEventHandler( DIALOG_PRINT_GERBVIEW::onDeselectAllClick ), nullptr, this );
nullptr, this );
wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL );
buttonSizer->Add( m_buttonSelectAll, 1, wxALL, 5 ); buttonSizer->Add( m_buttonSelectAll, 1, wxALL, 5 );
@ -214,15 +203,15 @@ void DIALOG_PRINT_GERBVIEW::createLeftPanel()
void DIALOG_PRINT_GERBVIEW::onSelectAllClick( wxCommandEvent& event ) void DIALOG_PRINT_GERBVIEW::onSelectAllClick( wxCommandEvent& event )
{ {
for( unsigned int i = 0; i < LAYER_LIST_COUNT; ++i ) for( wxCheckListBox* checkbox : m_layerLists )
setListBoxValue( m_layerLists[i], true ); setListBoxValue( checkbox, true );
} }
void DIALOG_PRINT_GERBVIEW::onDeselectAllClick( wxCommandEvent& event ) void DIALOG_PRINT_GERBVIEW::onDeselectAllClick( wxCommandEvent& event )
{ {
for( unsigned int i = 0; i < LAYER_LIST_COUNT; ++i ) for( wxCheckListBox* checkbox : m_layerLists )
setListBoxValue( m_layerLists[i], false ); setListBoxValue( checkbox, false );
} }
@ -250,24 +239,6 @@ bool DIALOG_PRINT_GERBVIEW::isLayerEnabled( unsigned int aLayer ) const
} }
void DIALOG_PRINT_GERBVIEW::enableLayer( unsigned int aLayer, bool aValue )
{
auto layerMapIt = m_layerToItemMap.find( aLayer );
if( layerMapIt == m_layerToItemMap.end() )
return;
unsigned int itemNr = layerMapIt->second;
unsigned int listIdx = itemNr / LAYER_PER_LIST;
unsigned int itemIdx = itemNr % LAYER_PER_LIST;
wxCHECK( listIdx < LAYER_LIST_COUNT, /* void */ );
wxCheckListBox* listBox = m_layerLists[listIdx];
if( itemIdx < listBox->GetCount() )
listBox->Check( itemIdx, aValue );
}
int DIALOG_PRINT_GERBVIEW::setLayerSetFromList() int DIALOG_PRINT_GERBVIEW::setLayerSetFromList()
{ {
settings()->m_LayerSet = LSET(); settings()->m_LayerSet = LSET();

View File

@ -35,7 +35,7 @@ class DIALOG_PRINT_GENERIC : public DIALOG_PRINT_GENERIC_BASE
{ {
public: public:
DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings ); DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings );
virtual ~DIALOG_PRINT_GENERIC(); virtual ~DIALOG_PRINT_GENERIC() = default;
/** /**
* Set 'print border and title block' to a requested value and hides the * Set 'print border and title block' to a requested value and hides the
@ -99,14 +99,10 @@ private:
void initPrintData(); void initPrintData();
protected: protected:
APP_SETTINGS_BASE* m_config;
PRINTOUT_SETTINGS* m_settings; PRINTOUT_SETTINGS* m_settings;
private: private:
wxFloatingPointValidator<double> m_scaleValidator; static wxPrintData* s_printData;
static wxPrintData* s_PrintData;
static wxPageSetupDialogData* s_pageSetupData; static wxPageSetupDialogData* s_pageSetupData;
}; };

View File

@ -98,13 +98,10 @@ private:
}; };
DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent, DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent, PCBNEW_PRINTOUT_SETTINGS* aSettings ) :
PCBNEW_PRINTOUT_SETTINGS* aSettings ) : DIALOG_PRINT_GENERIC( aParent, aSettings ),
DIALOG_PRINT_GENERIC( aParent, aSettings ), m_parent( aParent )
m_parent( aParent )
{ {
m_config = Kiface().KifaceSettings();
createExtraOptions(); createExtraOptions();
createLeftPanel(); createLeftPanel();
@ -198,8 +195,7 @@ bool DIALOG_PRINT_PCBNEW::TransferDataToWindow()
m_drillMarksChoice->SetSelection( (int)settings()->m_DrillMarks ); m_drillMarksChoice->SetSelection( (int)settings()->m_DrillMarks );
// Print all layers one one page or separately // Print all layers one one page or separately
m_checkboxPagePerLayer->SetValue( settings()->m_Pagination m_checkboxPagePerLayer->SetValue( settings()->m_Pagination == PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE );
== PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE );
onPagePerLayerClicked( dummy ); onPagePerLayerClicked( dummy );
// Update the dialog layout when layers are added // Update the dialog layout when layers are added
@ -215,22 +211,16 @@ void DIALOG_PRINT_PCBNEW::createExtraOptions()
wxStaticBox* box = getOptionsBox(); wxStaticBox* box = getOptionsBox();
int rows = optionsSizer->GetEffectiveRowsCount(); int rows = optionsSizer->GetEffectiveRowsCount();
m_checkAsItems = new wxCheckBox( box, wxID_ANY, _( "Print according to objects tab of " m_checkAsItems = new wxCheckBox( box, wxID_ANY, _( "Print according to objects tab of appearance manager" ) );
"appearance manager" ) ); optionsSizer->Add( m_checkAsItems, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ), wxLEFT|wxRIGHT|wxBOTTOM, 5 );
optionsSizer->Add( m_checkAsItems, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ),
wxLEFT|wxRIGHT|wxBOTTOM, 5 );
m_checkBackground = new wxCheckBox( box, wxID_ANY, _( "Print background color" ) ); m_checkBackground = new wxCheckBox( box, wxID_ANY, _( "Print background color" ) );
optionsSizer->Add( m_checkBackground, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ), optionsSizer->Add( m_checkBackground, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ), wxLEFT|wxRIGHT|wxBOTTOM, 5 );
wxLEFT|wxRIGHT|wxBOTTOM, 5 );
m_checkUseTheme = new wxCheckBox( box, wxID_ANY, _( "Use a different color theme for " m_checkUseTheme = new wxCheckBox( box, wxID_ANY, _( "Use a different color theme for printing:" ) );
"printing:" ) ); optionsSizer->Add( m_checkUseTheme, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ), wxLEFT|wxRIGHT, 5 );
optionsSizer->Add( m_checkUseTheme, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ),
wxLEFT|wxRIGHT, 5 );
m_checkUseTheme->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, m_checkUseTheme->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &DIALOG_PRINT_PCBNEW::onUseThemeClicked, this );
&DIALOG_PRINT_PCBNEW::onUseThemeClicked, this );
wxArrayString choices; wxArrayString choices;
m_colorTheme = new wxChoice( box, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices, 0 ); m_colorTheme = new wxChoice( box, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices, 0 );
@ -263,16 +253,12 @@ void DIALOG_PRINT_PCBNEW::createExtraOptions()
// Pagination // Pagination
m_checkboxPagePerLayer = new wxCheckBox( box, wxID_ANY, _( "Print one page per layer" ) ); m_checkboxPagePerLayer = new wxCheckBox( box, wxID_ANY, _( "Print one page per layer" ) );
m_checkboxPagePerLayer->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, m_checkboxPagePerLayer->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &DIALOG_PRINT_PCBNEW::onPagePerLayerClicked, this );
&DIALOG_PRINT_PCBNEW::onPagePerLayerClicked, this );
m_checkboxEdgesOnAllPages = new wxCheckBox( box, wxID_ANY, m_checkboxEdgesOnAllPages = new wxCheckBox( box, wxID_ANY, _( "Print board edges on all pages" ) );
_( "Print board edges on all pages" ) );
optionsSizer->Add( m_checkboxPagePerLayer, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ), optionsSizer->Add( m_checkboxPagePerLayer, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ), wxLEFT|wxRIGHT, 5 );
wxLEFT|wxRIGHT, 5 ); optionsSizer->Add( m_checkboxEdgesOnAllPages, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ), wxLEFT, 28 );
optionsSizer->Add( m_checkboxEdgesOnAllPages, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ),
wxLEFT, 28 );
} }
@ -289,20 +275,11 @@ void DIALOG_PRINT_PCBNEW::createLeftPanel()
getMainSizer()->Insert( 0, sbLayersSizer, 1, wxEXPAND | wxALL, 5 ); getMainSizer()->Insert( 0, sbLayersSizer, 1, wxEXPAND | wxALL, 5 );
m_popMenu = new wxMenu(); m_popMenu = new wxMenu();
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_FAB_LAYERS, m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_FAB_LAYERS, _( "Select Fab Layers" ) ) );
_( "Select Fab Layers" ), wxEmptyString ) ); m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_COPPER_LAYERS, _( "Select all Copper Layers" ) ) );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_DESELECT_COPPER_LAYERS, _( "Deselect all Copper Layers" ) ) );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_COPPER_LAYERS, m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_ALL_LAYERS, _( "Select all Layers" ) ) );
_( "Select all Copper Layers" ), wxEmptyString ) ); m_popMenu->Append( new wxMenuItem( m_popMenu, ID_DESELECT_ALL_LAYERS, _( "Deselect all Layers" ) ) );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_DESELECT_COPPER_LAYERS,
_( "Deselect all Copper Layers" ), wxEmptyString ) );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_ALL_LAYERS,
_( "Select all Layers" ), wxEmptyString ) );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_DESELECT_ALL_LAYERS,
_( "Deselect all Layers" ), wxEmptyString ) );
this->Bind( wxEVT_RIGHT_DOWN, this->Bind( wxEVT_RIGHT_DOWN,
[&]( wxMouseEvent& aEvent ) [&]( wxMouseEvent& aEvent )