From da20e80de67d0d6c0e2b390b2e76125e074f7308 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 21 Feb 2013 21:53:50 +0100 Subject: [PATCH] Pcbnew: plot Dialog: add a popup menu (try mouse right click in plot dialog) to selected/unselect groups of layers to plot. All: For new zoom centering option: use Shift+Ctrl key instead of Alt key to select the new zoom centering, because Alt key has a special function under Windows. 2 very minor other changes. --- common/build_version.cpp | 4 +- common/drawpanel.cpp | 3 +- pcbnew/dialogs/dialog_plot.cpp | 68 ++++++++++++++++++++++-- pcbnew/dialogs/dialog_plot.h | 4 +- pcbnew/dialogs/dialog_plot_base.cpp | 36 +++++++++++++ pcbnew/dialogs/dialog_plot_base.fbp | 82 ++++++++++++++++++++++++++++- pcbnew/dialogs/dialog_plot_base.h | 19 ++++++- version.txt | 4 -- 8 files changed, 207 insertions(+), 13 deletions(-) delete mode 100644 version.txt diff --git a/common/build_version.cpp b/common/build_version.cpp index 78b55b228f..9a1f5d3c46 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -7,9 +7,9 @@ #ifndef KICAD_BUILD_VERSION #if defined KICAD_GOST -# define KICAD_BUILD_VERSION "(2012-nov-02 GOST)" +# define KICAD_BUILD_VERSION "(2013-feb-21 GOST)" #else -# define KICAD_BUILD_VERSION "(2012-nov-02)" +# define KICAD_BUILD_VERSION "(2013-feb-21)" #endif #endif diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 93d2076af3..47c2996935 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -877,7 +877,8 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event ) cmd.SetId( ID_PAN_UP ); else if( event.ControlDown() && !event.ShiftDown() ) cmd.SetId( ID_PAN_LEFT ); - else if( event.AltDown() || m_enableZoomNoCenter) + else if( (event.ControlDown() && event.ShiftDown() ) + || m_enableZoomNoCenter) cmd.SetId( ID_OFFCENTER_ZOOM_IN ); else cmd.SetId( ID_POPUP_ZOOM_IN ); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 0a0d2cd9ae..636f7eae8a 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -159,7 +159,7 @@ void DIALOG_PLOT::Init_Dialog() if( !m_board->IsLayerEnabled( layer ) ) continue; - layerList.push_back( layer ); + m_layerList.push_back( layer ); checkIndex = m_layerCheckListBox->Append( m_board->GetLayerName( layer ) ); if( m_plotOpts.GetLayerSelection() & ( 1 << layer ) ) @@ -223,6 +223,68 @@ void DIALOG_PLOT::OnClose( wxCloseEvent& event ) EndModal( 0 ); } +// A helper function to show a popup menu, when the dialog is right clicked. +void DIALOG_PLOT::OnRightClick( wxMouseEvent& event ) +{ + PopupMenu( m_popMenu ); +} + +// Select or deselect groups of layers in the layers list: +#include +void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) +{ + unsigned int i; + + switch( event.GetId() ) + { + case ID_LAYER_FAB: // Select layers usually neede d to build a board + for( i = 0; i < m_layerList.size(); i++ ) + { + long layermask = 1 << m_layerList[ i ]; + if( ( layermask & + ( ALL_CU_LAYERS | SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT | + SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT | + SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT ) ) + != 0 ) + m_layerCheckListBox->Check( i, true ); + else + m_layerCheckListBox->Check( i, false ); + + } + break; + + case ID_SELECT_COPPER_LAYERS: + for( i = 0; i < m_layerList.size(); i++ ) + { + if( m_layerList[i] <= LAST_COPPER_LAYER ) + m_layerCheckListBox->Check( i, true ); + + } + break; + + case ID_DESELECT_COPPER_LAYERS: + for( i = 0; i < m_layerList.size(); i++ ) + { + if( m_layerList[i] <= LAST_COPPER_LAYER ) + m_layerCheckListBox->Check( i, false ); + + } + break; + + case ID_SELECT_ALL_LAYERS: + for( i = 0; i < m_layerList.size(); i++ ) + m_layerCheckListBox->Check( i, true ); + break; + + case ID_DESELECT_ALL_LAYERS: + for( i = 0; i < m_layerList.size(); i++ ) + m_layerCheckListBox->Check( i, false ); + break; + + default: + break; + } +} void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event ) { @@ -608,10 +670,10 @@ void DIALOG_PLOT::applyPlotSettings() long selectedLayers = 0; unsigned int i; - for( i = 0; i < layerList.size(); i++ ) + for( i = 0; i < m_layerList.size(); i++ ) { if( m_layerCheckListBox->IsChecked( i ) ) - selectedLayers |= (1 << layerList[i]); + selectedLayers |= (1 << m_layerList[i]); } tempOptions.SetLayerSelection( selectedLayers ); diff --git a/pcbnew/dialogs/dialog_plot.h b/pcbnew/dialogs/dialog_plot.h index 45ceb61ce3..d9edce8ca4 100644 --- a/pcbnew/dialogs/dialog_plot.h +++ b/pcbnew/dialogs/dialog_plot.h @@ -43,7 +43,7 @@ private: BOARD* m_board; BOARD_DESIGN_SETTINGS m_brdSettings; wxConfig* m_config; - std::vector layerList; // List to hold CheckListBox layer numbers + std::vector m_layerList; // List to hold CheckListBox layer numbers double m_XScaleAdjust; // X scale factor adjust to compensate // plotter X scaling error double m_YScaleAdjust; // X scale factor adjust to compensate @@ -63,6 +63,8 @@ private: void OnQuit( wxCommandEvent& event ); void OnClose( wxCloseEvent& event ); void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ); + void OnRightClick( wxMouseEvent& event ); + void OnPopUpLayers( wxCommandEvent& event ); void SetPlotFormat( wxCommandEvent& event ); void OnSetScaleOpt( wxCommandEvent& event ); void applyPlotSettings(); diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp index 6170fac7bd..3081a970ee 100644 --- a/pcbnew/dialogs/dialog_plot_base.cpp +++ b/pcbnew/dialogs/dialog_plot_base.cpp @@ -375,18 +375,47 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr this->SetSizer( m_MainSizer ); this->Layout(); m_MainSizer->Fit( this ); + m_popMenu = new wxMenu(); + wxMenuItem* m_menuItem1; + m_menuItem1 = new wxMenuItem( m_popMenu, ID_LAYER_FAB, wxString( _("Select fab layers") ) , wxEmptyString, wxITEM_NORMAL ); + m_popMenu->Append( m_menuItem1 ); + + wxMenuItem* m_menuItem2; + m_menuItem2 = new wxMenuItem( m_popMenu, ID_SELECT_COPPER_LAYERS, wxString( _("Select all copper layers") ) , wxEmptyString, wxITEM_NORMAL ); + m_popMenu->Append( m_menuItem2 ); + + wxMenuItem* m_menuItem3; + m_menuItem3 = new wxMenuItem( m_popMenu, ID_DESELECT_COPPER_LAYERS, wxString( _("Deselect all copper layers") ) , wxEmptyString, wxITEM_NORMAL ); + m_popMenu->Append( m_menuItem3 ); + + wxMenuItem* m_menuItem4; + m_menuItem4 = new wxMenuItem( m_popMenu, ID_SELECT_ALL_LAYERS, wxString( _("Select all layers") ) , wxEmptyString, wxITEM_NORMAL ); + m_popMenu->Append( m_menuItem4 ); + + wxMenuItem* m_menuItem5; + m_menuItem5 = new wxMenuItem( m_popMenu, ID_DESELECT_ALL_LAYERS, wxString( _("Deselect all layers") ) , wxEmptyString, wxITEM_NORMAL ); + m_popMenu->Append( m_menuItem5 ); + + this->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( DIALOG_PLOT_BASE::DIALOG_PLOT_BASEOnContextMenu ), NULL, this ); + this->Centre( wxBOTH ); // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_BASE::OnClose ) ); this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PLOT_BASE::OnInitDialog ) ); + this->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( DIALOG_PLOT_BASE::OnRightClick ) ); m_plotFormatOpt->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::SetPlotFormat ), NULL, this ); 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_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 ); + this->Connect( m_menuItem1->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Connect( m_menuItem2->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Connect( m_menuItem3->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Connect( m_menuItem4->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Connect( m_menuItem5->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); } DIALOG_PLOT_BASE::~DIALOG_PLOT_BASE() @@ -394,11 +423,18 @@ DIALOG_PLOT_BASE::~DIALOG_PLOT_BASE() // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_BASE::OnClose ) ); this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PLOT_BASE::OnInitDialog ) ); + this->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( DIALOG_PLOT_BASE::OnRightClick ) ); m_plotFormatOpt->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::SetPlotFormat ), NULL, this ); 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_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 ); + this->Disconnect( ID_LAYER_FAB, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Disconnect( ID_SELECT_COPPER_LAYERS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Disconnect( ID_DESELECT_COPPER_LAYERS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Disconnect( ID_SELECT_ALL_LAYERS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + this->Disconnect( ID_DESELECT_ALL_LAYERS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); + delete m_popMenu; } diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp index 051ba1573d..906456e4bf 100644 --- a/pcbnew/dialogs/dialog_plot_base.fbp +++ b/pcbnew/dialogs/dialog_plot_base.fbp @@ -81,7 +81,7 @@ - + OnRightClick @@ -4404,6 +4404,86 @@ + + MyMenu + m_popMenu + protected + + + 0 + 1 + + ID_LAYER_FAB + wxITEM_NORMAL + Select fab layers + m_menuItem1 + none + + + OnPopUpLayers + + + + + 0 + 1 + + ID_SELECT_COPPER_LAYERS + wxITEM_NORMAL + Select all copper layers + m_menuItem2 + none + + + OnPopUpLayers + + + + + 0 + 1 + + ID_DESELECT_COPPER_LAYERS + wxITEM_NORMAL + Deselect all copper layers + m_menuItem3 + none + + + OnPopUpLayers + + + + + 0 + 1 + + ID_SELECT_ALL_LAYERS + wxITEM_NORMAL + Select all layers + m_menuItem4 + none + + + OnPopUpLayers + + + + + 0 + 1 + + ID_DESELECT_ALL_LAYERS + wxITEM_NORMAL + Deselect all layers + m_menuItem5 + none + + + OnPopUpLayers + + + diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h index 6c96a1e614..8875fd1adb 100644 --- a/pcbnew/dialogs/dialog_plot_base.h +++ b/pcbnew/dialogs/dialog_plot_base.h @@ -25,6 +25,10 @@ #include #include #include +#include +#include +#include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -42,7 +46,12 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM ID_ALLOW_PRINT_PAD_ON_SILKSCREEN = 1000, ID_PRINT_REF, ID_MIROR_OPT, - ID_CREATE_DRILL_FILE + ID_CREATE_DRILL_FILE, + ID_LAYER_FAB, + ID_SELECT_COPPER_LAYERS, + ID_DESELECT_COPPER_LAYERS, + ID_SELECT_ALL_LAYERS, + ID_DESELECT_ALL_LAYERS }; wxBoxSizer* m_MainSizer; @@ -97,22 +106,30 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM wxButton* m_plotButton; wxButton* m_buttonDrill; wxButton* m_buttonQuit; + wxMenu* m_popMenu; // Virtual event handlers, overide them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); } + virtual void OnRightClick( wxMouseEvent& event ) { event.Skip(); } virtual void SetPlotFormat( wxCommandEvent& event ) { event.Skip(); } virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnSetScaleOpt( wxCommandEvent& event ) { event.Skip(); } virtual void Plot( wxCommandEvent& event ) { event.Skip(); } virtual void CreateDrillFile( wxCommandEvent& event ) { event.Skip(); } virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); } + virtual void OnPopUpLayers( wxCommandEvent& event ) { event.Skip(); } public: DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_PLOT_BASE(); + + void DIALOG_PLOT_BASEOnContextMenu( wxMouseEvent &event ) + { + this->PopupMenu( m_popMenu, event.GetPosition() ); + } }; diff --git a/version.txt b/version.txt deleted file mode 100644 index de376a24c7..0000000000 --- a/version.txt +++ /dev/null @@ -1,4 +0,0 @@ -release version: -2011 nov 30 -files (.zip,.tgz): -kicad-2011-11-30