diff --git a/common/class_layer_box_selector.cpp b/common/class_layer_box_selector.cpp index c7ffce1c8b..9bfdd84ac4 100644 --- a/common/class_layer_box_selector.cpp +++ b/common/class_layer_box_selector.cpp @@ -25,7 +25,7 @@ bool LAYER_SELECTOR::SetLayersHotkeys( bool value ) } -void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_ID aLayer ) +void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer ) { wxMemoryDC bmpDC; wxBrush brush; @@ -120,7 +120,7 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly() for( LAYER_NUM i = 0; i < elements; ++i ) { wxBitmap layerbmp( 14, 14 ); - SetBitmapLayer( layerbmp, ToLAYER_ID( i ) ); + SetBitmapLayer( layerbmp, i ); } } diff --git a/common/lset.cpp b/common/lset.cpp index 06ca945268..d76dcb1c5f 100644 --- a/common/lset.cpp +++ b/common/lset.cpp @@ -37,24 +37,34 @@ LSET::LSET( const LAYER_ID* aArray, unsigned aCount ) } -LSET::LSET( size_t aIdCount, ... ) +LSET::LSET( unsigned aIdCount, LAYER_ID aFirst, ... ) { - va_list ap; + // The constructor, without the mandatory aFirst argument, could have been confused + // by the compiler with the LSET( LAYER_ID ). With aFirst, that ambiguity is not + // present. Therefore aIdCount must always be >=1. + wxASSERT_MSG( aIdCount > 0, wxT( "aIdCount must be >= 1" ) ); - va_start( ap, aIdCount ); + set( aFirst ); - for( size_t i=0; i BASE_SEQ; * * * for( LSEQ cu_stack = aSet.CuStack(); cu_stack; ++cu_stack ) + * { * layer_id = *cu_stack; + * : + * things to do with layer_id; + * } * * */ @@ -198,13 +202,24 @@ class LSET : public BASE_SET { public: + // The constructor flavors are carefully chosen to prevent LSET( int ) from compiling. + // That excludes "LSET s = 0;" and excludes "LSET s = -1;", etc. + // LSET s = 0; needs to be removed from the code, this accomplishes that. + // Remember LSET( LAYER_ID(0) ) sets bit 0, so "LSET s = 0;" is illegal + // to prevent that surprize. Therefore LSET's constructor suite is significantly + // different than the base class from which it is derived. + + // Other member functions (non-constructor functions) are identical to the base + // class's and therefore are re-used from the base class. + /** * Constructor LSET() * creates an empty (cleared) set. */ LSET() : - BASE_SET() - {} + BASE_SET() // all bits are set to zero in BASE_SET() + { + } LSET( const BASE_SET& aOther ) : BASE_SET( aOther ) @@ -214,12 +229,11 @@ public: /** * Constructor LSET( LAYER_ID ) * takes a LAYER_ID and sets that bit. This makes the following code into - * a bug typically: + * a bug: * * LSET s = 0; * - * since that will call this constructor and set bit zero, probably not what was - * intended. Use + * Instead use: * * * LSET s; @@ -239,12 +253,16 @@ public: LSET( const LAYER_ID* aArray, unsigned aCount ); /** - * Constructor LSET( int, ...) - * takes a variable number of LAYER_IDs in the argument list to construct - * the set. Typically used only in static construction. + * Constructor LSET( unsigned, LAYER_ID, ...) + * takes one or more LAYER_IDs in the argument list to construct + * the set. Typically only used in static construction. + * * @param aIdCount is the number of LAYER_IDs which follow. + * @param aFirst is the first included in @a aIdCount and must always be present, and can + * be followed by any number of additional LAYER_IDs so long as @a aIdCount accurately + * reflects the count. */ - LSET( size_t aIdCount, ... ); + LSET( unsigned aIdCount, LAYER_ID aFirst, ... ); // args chosen to prevent LSET( int ) from compiling /** * Function Name diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 908de4f4b4..d95bdfc64c 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -607,7 +607,7 @@ public: * @return the selected layer id */ LAYER_ID SelectLayer( LAYER_ID aDefaultLayer, - LSET aNotAllowedLayersMask = 0, + LSET aNotAllowedLayersMask = LSET(), wxPoint aDlgPosition = wxDefaultPosition ); /* Display a list of two copper layers to choose a pair of copper layers diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 4b10040241..621c1ad477 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -363,7 +363,6 @@ public: int GetSubRatsnest() const { return m_SubRatsnest; } void SetSubRatsnest( int aSubRatsnest ) { m_SubRatsnest = aSubRatsnest; } - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); bool IsOnLayer( LAYER_ID aLayer ) const diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index a6685e3d6b..b39505a713 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -268,7 +268,8 @@ void DIALOG_COPPER_ZONE::initDialog() imageList->Add( makeLayerBitmap( layerColor ) ); - int itemIndex = m_LayerSelectionCtrl->InsertItem( 0, msg, layer ); + int itemIndex = m_LayerSelectionCtrl->InsertItem( + m_LayerSelectionCtrl->GetItemCount(), msg, layer ); if( m_settings.m_CurrentZone_Layer == layer ) m_LayerSelectionCtrl->Select( itemIndex ); diff --git a/pcbnew/dialogs/dialog_layers_setup.cpp b/pcbnew/dialogs/dialog_layers_setup.cpp index 5b57412ee5..74f20e6500 100644 --- a/pcbnew/dialogs/dialog_layers_setup.cpp +++ b/pcbnew/dialogs/dialog_layers_setup.cpp @@ -80,6 +80,7 @@ static LSEQ dlg_layers() F_Mask, F_Cu, + In1_Cu, In2_Cu, In3_Cu, In4_Cu, @@ -360,14 +361,19 @@ DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( wxTopLevelWindow* aParent, BOARD* aBoa void DIALOG_LAYERS_SETUP::showCopperChoice( int copperCount ) { - static const int copperCounts[] = { 2,4,6,8,10,12,14,16 }; + if( copperCount > MAX_CU_LAYERS ) + copperCount = MAX_CU_LAYERS; - for( unsigned i = 0; iSetSelection(i); + int idx = lyrCnt/2 - 1; + m_CopperLayersChoice->SetSelection(idx); break; } } diff --git a/pcbnew/dialogs/dialog_layers_setup_base.cpp b/pcbnew/dialogs/dialog_layers_setup_base.cpp index f0e5978dba..c67da1bc62 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.cpp +++ b/pcbnew/dialogs/dialog_layers_setup_base.cpp @@ -42,7 +42,7 @@ DIALOG_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID m_staticTextCopperLayers->Wrap( -1 ); bCopperLayersSizer->Add( m_staticTextCopperLayers, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - wxString m_CopperLayersChoiceChoices[] = { _("2"), _("4"), _("6"), _("8"), _("10"), _("12"), _("14"), _("16"), _("18"), _("20"), _("22"), _("24"), _("26"), _("27"), _("28"), _("30"), _("32") }; + wxString m_CopperLayersChoiceChoices[] = { _("2"), _("4"), _("6"), _("8"), _("10"), _("12"), _("14"), _("16"), _("18"), _("20"), _("22"), _("24"), _("26"), _("28"), _("30"), _("32") }; int m_CopperLayersChoiceNChoices = sizeof( m_CopperLayersChoiceChoices ) / sizeof( wxString ); m_CopperLayersChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_CopperLayersChoiceNChoices, m_CopperLayersChoiceChoices, 0 ); m_CopperLayersChoice->SetSelection( 3 ); diff --git a/pcbnew/dialogs/dialog_layers_setup_base.fbp b/pcbnew/dialogs/dialog_layers_setup_base.fbp index 6fc6a4d396..4769253a1d 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.fbp +++ b/pcbnew/dialogs/dialog_layers_setup_base.fbp @@ -394,7 +394,7 @@ 1 0 - "2" "4" "6" "8" "10" "12" "14" "16" "18" "20" "22" "24" "26" "27" "28" "30" "32" + "2" "4" "6" "8" "10" "12" "14" "16" "18" "20" "22" "24" "26" "28" "30" "32" 1 1 diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 06fe19edcf..e16280b904 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -67,7 +67,7 @@ void PCB_PARSER::init() std::string untranslated = TO_UTF8( wxString( LSET::Name( LAYER_ID( layer ) ) ) ); m_layerIndices[ untranslated ] = LAYER_ID( layer ); - m_layerMasks[ untranslated ] = LSET( layer ); + m_layerMasks[ untranslated ] = LSET( LAYER_ID( layer ) ); } m_layerMasks[ "*.Cu" ] = LSET::AllCuMask(); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index e6c4b9c5e5..8e95ba46a2 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -366,9 +366,12 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() &DisplayOpt.DisplayZonesMode, 0, 0, 2 ) ); // layer colors: + wxASSERT( DIM( cds.m_LayersColors ) == LAYER_ID_COUNT ); for( int i = 0; i