From 5fd7064f760cebdd1cf6a8d38df661f04638599d Mon Sep 17 00:00:00 2001 From: Peter Montgomery Date: Wed, 22 Jul 2020 02:03:43 +0000 Subject: [PATCH] Add Gerber filename to 'Select Layer:' dialog The 'Select Layer:' dialog pops up directly over the dialog with the loaded Gerbers and hides all Gerber file names. This is just an aid so users remember exactly which Gerber layer they're working on without having to move the dialog. Fixes https://gitlab.com/kicad/code/kicad/-/issues/4893 --- gerbview/dialogs/dialog_select_one_pcb_layer.cpp | 16 +++++++++------- gerbview/gerbview_frame.h | 3 ++- gerbview/select_layers_to_pcb.cpp | 8 +++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp index 4c43437272..5827476d91 100644 --- a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp +++ b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp @@ -55,7 +55,8 @@ private: public: // Constructor and destructor - SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount ); + SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount, + wxString aGerberName ); ~SELECT_LAYER_DIALOG() { }; private: @@ -88,9 +89,10 @@ END_EVENT_TABLE() * different radiobutton is clicked on) prior to then clicking on the "Deselect" * button provided within the "Layer selection:" dialog box). */ -int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount ) +int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, wxString aGerberName ) { - SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this, aDefaultLayer, aCopperLayerCount ); + SELECT_LAYER_DIALOG* frame = + new SELECT_LAYER_DIALOG( this, aDefaultLayer, aCopperLayerCount, aGerberName ); int layer = frame->ShowModal(); frame->Destroy(); @@ -104,10 +106,10 @@ int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount ) * radiobuttons, in which case they are positioned (in a vertical line) * to the right of that radiobox. */ -SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer, - int aCopperLayerCount ) : - DIALOG_SHIM( parent, -1, _( "Select Layer:" ), wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) +SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( + GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount, wxString aGerberName ) + : DIALOG_SHIM( parent, -1, wxString::Format( _( "Select Layer: %s" ), aGerberName ), + wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { wxButton* button; int ii; diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index ec5fa426e9..78c9ace630 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -116,6 +116,7 @@ public: /** Install the dialog box for layer selection * @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer) * @param aCopperLayerCount = number of copper layers + * @param aGerberName = Name of Gerber file to select KiCad layer for * @return new layer value (NB_PCB_LAYERS when "(Deselect)" radiobutton selected), * or -1 if canceled * @@ -127,7 +128,7 @@ public: * different radiobutton is clicked on) prior to then clicking on the "Deselect" * button provided within the "Layer selection:" dialog box). */ - int SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount ); + int SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, wxString aGerberName ); /** * @return the color of the grid diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp index dc71aafd2e..a340d15179 100644 --- a/gerbview/select_layers_to_pcb.cpp +++ b/gerbview/select_layers_to_pcb.cpp @@ -362,7 +362,13 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event ) if( jj != UNSELECTED_LAYER && jj != UNDEFINED_LAYER && !IsValidLayer( jj ) ) jj = B_Cu; // (Defaults to "Copper" layer.) - jj = m_Parent->SelectPCBLayer( jj, m_exportBoardCopperLayersCount ); + // Get file name of Gerber loaded on this layer + wxFileName fn( m_Parent->GetGerberLayout()->GetImagesList()->GetGbrImage( ii )->m_FileName ); + // Surround it with quotes to make it stand out on the dialog title bar + wxString layerName = "\"" + fn.GetFullName() + "\""; + + // Display dialog to let user select a layer for the Gerber + jj = m_Parent->SelectPCBLayer( jj, m_exportBoardCopperLayersCount, layerName ); if( jj != UNSELECTED_LAYER && jj != UNDEFINED_LAYER && !IsValidLayer( jj ) ) return;