From c087883d386293d6fe3baae32cd8b64a57e43ab0 Mon Sep 17 00:00:00 2001 From: Marco Mattila Date: Wed, 16 Feb 2011 00:54:23 +0200 Subject: [PATCH] Move layers into a wxCheckListBox in pcbnew plot dialog. --- pcbnew/dialogs/dialog_plot_base.cpp | 32 ++----- pcbnew/dialogs/dialog_plot_base.fbp | 135 +++------------------------- pcbnew/dialogs/dialog_plot_base.h | 6 +- pcbnew/pcbplot.cpp | 64 ++++++------- 4 files changed, 46 insertions(+), 191 deletions(-) diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp index 647a411219..a2e17b5b2f 100644 --- a/pcbnew/dialogs/dialog_plot_base.cpp +++ b/pcbnew/dialogs/dialog_plot_base.cpp @@ -26,13 +26,13 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_staticText121 = new wxStaticText( this, wxID_ANY, _("Plot format:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText121->Wrap( -1 ); - bSizer27->Add( m_staticText121, 0, wxALL, 5 ); + bSizer27->Add( m_staticText121, 0, wxTOP, 5 ); wxString m_plotFormatOptChoices[] = { _("HPGL"), _("Gerber"), _("Postscript"), _("Postscript A4"), _("DXF") }; int m_plotFormatOptNChoices = sizeof( m_plotFormatOptChoices ) / sizeof( wxString ); m_plotFormatOpt = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_plotFormatOptNChoices, m_plotFormatOptChoices, 0 ); m_plotFormatOpt->SetSelection( 0 ); - bSizer27->Add( m_plotFormatOpt, 0, wxALL, 5 ); + bSizer27->Add( m_plotFormatOpt, 0, 0, 5 ); bSizer26->Add( bSizer27, 0, wxEXPAND, 5 ); @@ -41,7 +41,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_staticTextDir = new wxStaticText( this, wxID_ANY, _("Output directory:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextDir->Wrap( -1 ); - bSizer28->Add( m_staticTextDir, 0, wxALL|wxEXPAND, 5 ); + bSizer28->Add( m_staticTextDir, 0, wxEXPAND|wxLEFT|wxTOP, 5 ); wxBoxSizer* bSizer29; bSizer29 = new wxBoxSizer( wxHORIZONTAL ); @@ -63,18 +63,9 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr wxBoxSizer* bUpperSizer; bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); - wxStaticBoxSizer* sbLayersSizer; - sbLayersSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Layers") ), wxHORIZONTAL ); + m_LayersSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Layers") ), wxHORIZONTAL ); - m_CopperLayersBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Copper Layers") ), wxVERTICAL ); - - sbLayersSizer->Add( m_CopperLayersBoxSizer, 1, wxALL, 5 ); - - m_TechnicalLayersBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Technical Layers") ), wxVERTICAL ); - - sbLayersSizer->Add( m_TechnicalLayersBoxSizer, 1, wxALL, 5 ); - - bUpperSizer->Add( sbLayersSizer, 1, wxALL, 3 ); + bUpperSizer->Add( m_LayersSizer, 1, wxALL, 3 ); m_PlotOptionsSizer = new wxBoxSizer( wxVERTICAL ); @@ -135,7 +126,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr int m_drillShapeOptNChoices = sizeof( m_drillShapeOptChoices ) / sizeof( wxString ); m_drillShapeOpt = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_drillShapeOptNChoices, m_drillShapeOptChoices, 0 ); m_drillShapeOpt->SetSelection( 0 ); - bSizer15->Add( m_drillShapeOpt, 0, wxEXPAND, 5 ); + bSizer15->Add( m_drillShapeOpt, 0, wxEXPAND|wxLEFT, 5 ); m_staticText12 = new wxStaticText( this, wxID_ANY, _("Scaling:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText12->Wrap( -1 ); @@ -145,7 +136,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr int m_scaleOptNChoices = sizeof( m_scaleOptChoices ) / sizeof( wxString ); m_scaleOpt = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_scaleOptNChoices, m_scaleOptChoices, 0 ); m_scaleOpt->SetSelection( 0 ); - bSizer15->Add( m_scaleOpt, 0, wxEXPAND, 5 ); + bSizer15->Add( m_scaleOpt, 0, wxEXPAND|wxLEFT, 5 ); m_staticText13 = new wxStaticText( this, wxID_ANY, _("Plot mode:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText13->Wrap( -1 ); @@ -155,7 +146,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr int m_plotModeOptNChoices = sizeof( m_plotModeOptChoices ) / sizeof( wxString ); m_plotModeOpt = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_plotModeOptNChoices, m_plotModeOptChoices, 0 ); m_plotModeOpt->SetSelection( 0 ); - bSizer15->Add( m_plotModeOpt, 0, wxEXPAND, 5 ); + bSizer15->Add( m_plotModeOpt, 0, wxEXPAND|wxLEFT, 5 ); m_textDefaultPenSize = new wxStaticText( this, wxID_ANY, _("Default linewidth"), wxDefaultPosition, wxDefaultSize, 0 ); m_textDefaultPenSize->Wrap( -1 ); @@ -166,7 +157,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_linesWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_linesWidth->SetToolTip( _("Line width for, e.g., sheet references.") ); - bSizer15->Add( m_linesWidth, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizer15->Add( m_linesWidth, 0, wxBOTTOM|wxEXPAND|wxLEFT, 5 ); bSizer14->Add( bSizer15, 1, wxALL, 3 ); @@ -316,9 +307,6 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_plotButton->SetDefault(); bSizer191->Add( m_plotButton, 0, wxALL, 5 ); - m_buttonSaveOpt = new wxButton( this, ID_SAVE_OPT_PLOT, _("Apply Settings"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer191->Add( m_buttonSaveOpt, 0, wxALL, 5 ); - m_buttonDrill = new wxButton( this, ID_CREATE_DRILL_FILE, _("Generate Drill File"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer191->Add( m_buttonDrill, 0, wxALL, 5 ); @@ -340,7 +328,6 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_scaleOpt->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnSetScaleOpt ), NULL, this ); m_plotButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); - m_buttonSaveOpt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::applyPlotSettings ), NULL, this ); m_buttonDrill->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::CreateDrillFile ), NULL, this ); m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnQuit ), NULL, this ); } @@ -354,7 +341,6 @@ DIALOG_PLOT_BASE::~DIALOG_PLOT_BASE() m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_scaleOpt->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnSetScaleOpt ), NULL, this ); m_plotButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); - m_buttonSaveOpt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::applyPlotSettings ), NULL, this ); m_buttonDrill->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::CreateDrillFile ), NULL, this ); m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnQuit ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp index 258550ac69..de210387c1 100644 --- a/pcbnew/dialogs/dialog_plot_base.fbp +++ b/pcbnew/dialogs/dialog_plot_base.fbp @@ -142,7 +142,7 @@ none 5 - wxALL + wxTOP 0 1 @@ -226,7 +226,7 @@ 5 - wxALL + 0 1 @@ -321,7 +321,7 @@ none 5 - wxALL|wxEXPAND + wxEXPAND|wxLEFT|wxTOP 0 1 @@ -600,46 +600,18 @@ bUpperSizer wxHORIZONTAL none - + 3 wxALL 1 - + wxID_ANY Layers - sbLayersSizer + m_LayersSizer wxHORIZONTAL - none + protected - - 5 - wxALL - 1 - - wxID_ANY - Copper Layers - - m_CopperLayersBoxSizer - wxVERTICAL - protected - - - - - 5 - wxALL - 1 - - wxID_ANY - Technical Layers - - m_TechnicalLayersBoxSizer - wxVERTICAL - protected - - - @@ -1467,7 +1439,7 @@ 5 - wxEXPAND + wxEXPAND|wxLEFT 0 1 @@ -1635,7 +1607,7 @@ 5 - wxEXPAND + wxEXPAND|wxLEFT 0 1 @@ -1803,7 +1775,7 @@ 5 - wxEXPAND + wxEXPAND|wxLEFT 0 1 @@ -1971,7 +1943,7 @@ 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT 0 1 @@ -3760,91 +3732,6 @@ - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_SAVE_OPT_PLOT - Apply Settings - - 0 - - 0 - - 1 - m_buttonSaveOpt - 1 - - - protected - 1 - - - Resizable - - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - applyPlotSettings - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxALL diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h index d923366f1f..0c8176b878 100644 --- a/pcbnew/dialogs/dialog_plot_base.h +++ b/pcbnew/dialogs/dialog_plot_base.h @@ -39,7 +39,6 @@ class DIALOG_PLOT_BASE : public wxDialog ID_ALLOW_PRINT_PAD_ON_SILKSCREEN = 1000, ID_PRINT_REF, ID_MIROR_OPT, - ID_SAVE_OPT_PLOT, ID_CREATE_DRILL_FILE, }; @@ -49,8 +48,7 @@ class DIALOG_PLOT_BASE : public wxDialog wxStaticText* m_staticTextDir; wxTextCtrl* m_outputDirectoryName; wxButton* m_browseButton; - wxStaticBoxSizer* m_CopperLayersBoxSizer; - wxStaticBoxSizer* m_TechnicalLayersBoxSizer; + wxStaticBoxSizer* m_LayersSizer; wxBoxSizer* m_PlotOptionsSizer; wxCheckBox* m_plotSheetRef; wxCheckBox* m_plotPads_on_Silkscreen; @@ -90,7 +88,6 @@ class DIALOG_PLOT_BASE : public wxDialog wxTextCtrl* m_messagesBox; wxButton* m_plotButton; - wxButton* m_buttonSaveOpt; wxButton* m_buttonDrill; wxButton* m_buttonQuit; @@ -101,7 +98,6 @@ class DIALOG_PLOT_BASE : public wxDialog virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnSetScaleOpt( wxCommandEvent& event ) { event.Skip(); } virtual void Plot( wxCommandEvent& event ) { event.Skip(); } - virtual void applyPlotSettings( wxCommandEvent& event ) { event.Skip(); } virtual void CreateDrillFile( wxCommandEvent& event ) { event.Skip(); } virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index f695cd361b..da7ac30f2f 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -57,7 +57,8 @@ class DIALOG_PLOT : public DIALOG_PLOT_BASE public: WinEDA_PcbFrame* m_Parent; wxConfig* m_Config; - wxCheckBox* m_BoxSelectLayer[LAYER_COUNT]; // wxCheckBox list to select/deselec layers to plot + std::vector layerList; // List to hold CheckListBox layer numbers + wxCheckListBox* layerCheckListBox; double m_XScaleAdjust; double m_YScaleAdjust; @@ -102,7 +103,7 @@ private: void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ); void SetPlotFormat( wxCommandEvent& event ); void OnSetScaleOpt( wxCommandEvent& event ); - void applyPlotSettings( wxCommandEvent& event ); + void applyPlotSettings(); void CreateDrillFile( wxCommandEvent& event ); }; @@ -115,6 +116,10 @@ DIALOG_PLOT::DIALOG_PLOT( WinEDA_PcbFrame* parent ) : m_Parent = parent; m_Config = wxGetApp().m_EDA_Config; + layerCheckListBox = new wxCheckListBox( this, wxID_ANY ); + + m_LayersSizer->Add( layerCheckListBox, 0, wxGROW | wxALL, 1 ); + Init_Dialog(); GetSizer()->Fit( this ); @@ -169,40 +174,24 @@ void DIALOG_PLOT::Init_Dialog() m_plotPSNegativeOpt->SetValue( g_PcbPlotOptions.m_PlotPSNegative ); - // Create layer list. - int layer; - for( layer = 0; layer < NB_LAYERS; ++layer ) - { - if( !board->IsLayerEnabled( layer ) ) - m_BoxSelectLayer[layer] = NULL; - else - m_BoxSelectLayer[layer] = - new wxCheckBox( this, -1, board->GetLayerName( layer ) ); - } - - // Add wxCheckBoxes in layers lists dialog // List layers in same order than in setup layers dialog // (Front or Top to Back or Bottom) DECLARE_LAYERS_ORDER_LIST( layersOrder ); - int layer_idx; - for( layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx ) + int layerIndex, checkIndex, layer; + for( layerIndex = 0; layerIndex < NB_LAYERS; layerIndex++ ) { - layer = layersOrder[layer_idx]; + layer = layersOrder[layerIndex]; wxASSERT( layer < NB_LAYERS ); - if( m_BoxSelectLayer[layer] == NULL ) + if( !board->IsLayerEnabled( layer ) ) continue; - if( layer < NB_COPPER_LAYERS ) - m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer], - 0, wxGROW | wxALL, 1 ); - else - m_TechnicalLayersBoxSizer->Add( m_BoxSelectLayer[layer], - 0, wxGROW | wxALL, 1 ); + layerList.push_back( layer ); + checkIndex = layerCheckListBox->Append( board->GetLayerName( layer ) ); if( g_PcbPlotOptions.GetLayerSelection() & ( 1 << layer ) ) - m_BoxSelectLayer[layer]->SetValue( true ); + layerCheckListBox->Check( checkIndex ); } // Option for using proper Gerber extensions @@ -269,6 +258,7 @@ void DIALOG_PLOT::OnQuit( wxCommandEvent& event ) void DIALOG_PLOT::OnClose( wxCloseEvent& event ) { + applyPlotSettings(); EndModal( 0 ); } @@ -438,7 +428,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) } -void DIALOG_PLOT::applyPlotSettings( wxCommandEvent& event ) +void DIALOG_PLOT::applyPlotSettings() { PCB_PLOT_PARAMS tempOptions; @@ -549,14 +539,11 @@ void DIALOG_PLOT::applyPlotSettings( wxCommandEvent& event ) tempOptions.m_PlotFormat = m_plotFormatOpt->GetSelection(); long selectedLayers = 0; - long mask = 1; - int layer; - for( layer = 0; layer < NB_LAYERS; layer++, mask <<= 1 ) + unsigned int i; + for( i = 0; i < layerList.size(); i++ ) { - if( m_BoxSelectLayer[layer] == NULL ) - continue; - if( m_BoxSelectLayer[layer]->GetValue() ) - selectedLayers |= mask; + if( layerCheckListBox->IsChecked( i ) ) + selectedLayers |= (1 << layerList[i]); } tempOptions.SetLayerSelection( selectedLayers ); @@ -584,7 +571,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) BOARD* board = m_Parent->GetBoard(); - applyPlotSettings( event ); + applyPlotSettings(); // Create output directory if it does not exist wxFileName outputDir = wxFileName::DirName( m_outputDirectoryName->GetValue() ); @@ -680,14 +667,13 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) ); - long mask = 1; - for( layer = 0; layer < NB_LAYERS; layer++, mask <<= 1 ) + unsigned int i; + for( i = 0; i < layerList.size(); i++ ) { - if( m_BoxSelectLayer[layer] == NULL ) - continue; bool success = false; - if( m_BoxSelectLayer[layer]->GetValue() ) + if( layerCheckListBox->IsChecked( i ) ) { + layer = layerList[i]; fn = m_Parent->GetScreen()->GetFileName(); fn.SetPath( outputDir.GetPath() );