diff --git a/pcbnew/class_pcb_layer_box_selector.cpp b/pcbnew/class_pcb_layer_box_selector.cpp index 7de31f47a8..ee02ba604a 100644 --- a/pcbnew/class_pcb_layer_box_selector.cpp +++ b/pcbnew/class_pcb_layer_box_selector.cpp @@ -7,9 +7,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2012 Jean-Pierre Charras + * Copyright (C) 1992-2015 Jean-Pierre Charras * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -84,17 +84,25 @@ void PCB_LAYER_BOX_SELECTOR::Resync() const int BM_SIZE = 14; - LSET show = getEnabledLayers() & ~m_layerMaskDisable; + LSET show = LSET::AllLayersMask() & ~m_layerMaskDisable; + LSET activated = getEnabledLayers() & ~m_layerMaskDisable; + wxString layerstatus; for( LSEQ seq = show.UIOrder(); seq; ++seq ) { LAYER_ID layerid = *seq; - wxBitmap layerbmp( BM_SIZE, BM_SIZE ); + if( !m_showNotEnabledBrdlayers && !activated[layerid] ) + continue; + else if( !activated[layerid] ) + layerstatus = wxT( " " ) + _( "(not activated)" ); + else + layerstatus.Empty(); + wxBitmap layerbmp( BM_SIZE, BM_SIZE ); SetBitmapLayer( layerbmp, layerid ); - wxString layername = GetLayerName( layerid ); + wxString layername = GetLayerName( layerid ) + layerstatus; if( m_layerhotkeys && m_hotkeys ) { @@ -107,9 +115,7 @@ void PCB_LAYER_BOX_SELECTOR::Resync() Append( layername, layerbmp, (void*)(intptr_t) layerid ); int w, h; - dc.GetTextExtent ( layername, &w, &h ); - minwidth = std::max( minwidth, w ); } diff --git a/pcbnew/class_pcb_layer_box_selector.h b/pcbnew/class_pcb_layer_box_selector.h index 559633c711..196c891efd 100644 --- a/pcbnew/class_pcb_layer_box_selector.h +++ b/pcbnew/class_pcb_layer_box_selector.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 2012-2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or @@ -36,7 +36,10 @@ class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR { PCB_BASE_FRAME* m_boardFrame; - LSET m_layerMaskDisable; // A mask to remove some layers from layer list + LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers + // from layer list + bool m_showNotEnabledBrdlayers; // true to list all allowed layers + // (with not activated layers flagged) public: // Hotkey Info @@ -44,7 +47,7 @@ public: public: // If you are thinking the constructor is a bit curious, - // just remember it is used by automaticallty generated by wxFormBuilder files, + // just remember it is used by automatically generated by wxFormBuilder files, // and it should mimic the wxBitmapComboBox constructor. // Therefore, value, style are not yet used, // but they are here for compatibility @@ -57,6 +60,7 @@ public: { m_boardFrame = NULL; m_hotkeys = NULL; + m_showNotEnabledBrdlayers = false; } // Accessors @@ -67,13 +71,21 @@ public: void SetBoardFrame( PCB_BASE_FRAME* aFrame ) { m_boardFrame = aFrame; }; // SetLayerSet allows disableing some layers, which are not - // shown in list; + // shown in list void SetLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; } // Reload the Layers names and bitmaps // Virtual function void Resync(); + // Allow (or not) the layers not activated for the current board to be shown + // in layer selector. Not actavated layers are flagged + // ( "(not activated)" added to the layer name ) + void ShowNonActivatedLayers( bool aShow ) + { + m_showNotEnabledBrdlayers = aShow; + } + private: // Returns a color index from the layer id // Virtual function diff --git a/pcbnew/dialogs/dialog_edit_module_text.cpp b/pcbnew/dialogs/dialog_edit_module_text.cpp index 18b65d8aa5..aa73c9fcfb 100644 --- a/pcbnew/dialogs/dialog_edit_module_text.cpp +++ b/pcbnew/dialogs/dialog_edit_module_text.cpp @@ -6,10 +6,10 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Jean-Pierre Charras + * Copyright (C) 2015 Jean-Pierre Charras * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2008-2013 Wayne Stambaugh - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,6 +43,7 @@ #include #include +#include #include @@ -162,6 +163,11 @@ void DialogEditModuleText::initDlg( ) m_Show->SetSelection( 1 ); // Configure the layers list selector + if( !m_parent->GetBoard()->IsLayerEnabled( m_currentText->GetLayer() ) ) + // Footprints are built outside the current board, so items cann be + // on a not activated layer, therefore show it if happens. + m_LayerSelectionCtrl->ShowNonActivatedLayers( true ); + m_LayerSelectionCtrl->SetLayersHotkeys( false ); m_LayerSelectionCtrl->SetLayerSet( forbiddenLayers ); m_LayerSelectionCtrl->SetBoardFrame( m_parent ); diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 043dc10776..618807a7b7 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -6,9 +6,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -134,6 +134,11 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, AddUnitSymbol( *m_staticTextPosY ); // Configure the layers list selector + if( !m_Parent->GetBoard()->IsLayerEnabled( aDimension->GetLayer() ) ) + // Should not happens, because one acnnot select a board item on a + // not activated layer, but ... + m_SelLayerBox->ShowNonActivatedLayers( true ); + m_SelLayerBox->SetLayersHotkeys( false ); m_SelLayerBox->SetLayerSet( LSET::AllCuMask().set( Edge_Cuts ) ); m_SelLayerBox->SetBoardFrame( m_Parent ); @@ -160,6 +165,15 @@ void DIALOG_DIMENSION_EDITOR::OnCancelClick( wxCommandEvent& event ) void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) { + LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ); + + if( !m_Parent->GetBoard()->IsLayerEnabled( newlayer ) ) + { + wxMessageBox( _( "the layer currently selected is not enabled for this board\n" + "You cannot use it" ) ); + return; + } + #ifndef USE_WX_OVERLAY if( m_DC ) // Delete old text. { @@ -208,7 +222,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false ); - CurrentDimension->SetLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); + CurrentDimension->SetLayer( newlayer ); #ifndef USE_WX_OVERLAY if( m_DC ) // Display new text {