diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index 3dba9c6fac..0ae9c39e4c 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -95,7 +95,7 @@ static const wxChar CoroutineStackSize[] = wxT( "CoroutineStackSize" ); * This isn't exhaustive, but it covers most common types that might be * used in the advance config */ -wxString dumpParamCfg( const PARAM_CFG_BASE& aParam ) +wxString dumpParamCfg( const PARAM_CFG& aParam ) { wxString s = aParam.m_Ident + ": "; @@ -132,15 +132,15 @@ wxString dumpParamCfg( const PARAM_CFG_BASE& aParam ) /** * Dump the configs in the given array to trace. */ -static void dumpCfg( const PARAM_CFG_ARRAY& aArray ) +static void dumpCfg( const std::vector& aArray ) { // only dump if we need to if( !wxLog::IsAllowedTraceMask( AdvancedConfigMask ) ) return; - for( const auto& param : aArray ) + for( const PARAM_CFG* param : aArray ) { - wxLogTrace( AdvancedConfigMask, dumpParamCfg( param ) ); + wxLogTrace( AdvancedConfigMask, dumpParamCfg( *param ) ); } } @@ -198,27 +198,20 @@ void ADVANCED_CFG::loadFromConfigFile() void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) { - PARAM_CFG_ARRAY configParams; + std::vector configParams; - try - { - configParams.push_back( - new PARAM_CFG_BOOL( true, AC_KEYS::UsePadProperty, &m_EnableUsePadProperty, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::UsePadProperty, + &m_EnableUsePadProperty, false ) ); - configParams.push_back( - new PARAM_CFG_BOOL( true, AC_KEYS::UsePinFunction, &m_EnableUsePinFunction, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::UsePinFunction, + &m_EnableUsePinFunction, false ) ); - configParams.push_back( - new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity, &m_realTimeConnectivity, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity, + &m_realTimeConnectivity, false ) ); - configParams.push_back( - new PARAM_CFG_INT( true, AC_KEYS::CoroutineStackSize, &m_coroutineStackSize, - AC_STACK::default_stack, AC_STACK::min_stack, AC_STACK::max_stack ) ); - } - catch( boost::bad_pointer& ) - { - // Out of memory? Ship's going down anyway.... - } + configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::CoroutineStackSize, + &m_coroutineStackSize, AC_STACK::default_stack, + AC_STACK::min_stack, AC_STACK::max_stack ) ); wxConfigLoadSetups( &aCfg, configParams ); diff --git a/common/config_params.cpp b/common/config_params.cpp index 0d9ed403c3..f079c797f6 100644 --- a/common/config_params.cpp +++ b/common/config_params.cpp @@ -34,85 +34,85 @@ #include // for wxString, operator!=, operator== -void wxConfigLoadParams( wxConfigBase* aCfg, - const PARAM_CFG_ARRAY& aList, const wxString& aGroup ) +void wxConfigLoadParams( wxConfigBase* aCfg, const std::vector& aList, + const wxString& aGroup ) { wxASSERT( aCfg ); - for( const PARAM_CFG_BASE& param : aList ) + for( PARAM_CFG* param : aList ) { - if( !!param.m_Group ) - aCfg->SetPath( param.m_Group ); + if( !!param->m_Group ) + aCfg->SetPath( param->m_Group ); else aCfg->SetPath( aGroup ); - if( param.m_Setup ) + if( param->m_Setup ) continue; - param.ReadParam( aCfg ); + param->ReadParam( aCfg ); } } -void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ) +void wxConfigLoadSetups( wxConfigBase* aCfg, const std::vector& aList ) { wxASSERT( aCfg ); - for( const PARAM_CFG_BASE& param : aList ) + for( PARAM_CFG* param : aList ) { - if( !param.m_Setup ) + if( !param->m_Setup ) continue; - param.ReadParam( aCfg ); + param->ReadParam( aCfg ); } } -void wxConfigSaveParams( wxConfigBase* aCfg, - const PARAM_CFG_ARRAY& aList, const wxString& aGroup ) +void wxConfigSaveParams( wxConfigBase* aCfg, const std::vector& aList, + const wxString& aGroup ) { wxASSERT( aCfg ); - for( const PARAM_CFG_BASE& param : aList ) + for( PARAM_CFG* param : aList ) { - if( !!param.m_Group ) - aCfg->SetPath( param.m_Group ); + if( !!param->m_Group ) + aCfg->SetPath( param->m_Group ); else aCfg->SetPath( aGroup ); - if( param.m_Setup ) + if( param->m_Setup ) continue; - if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data + if( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data { - if( !!param.m_Ident ) - aCfg->DeleteGroup( param.m_Ident ); + if( !!param->m_Ident ) + aCfg->DeleteGroup( param->m_Ident ); } else { - param.SaveParam( aCfg ); + param->SaveParam( aCfg ); } } } -void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ) +void wxConfigSaveSetups( wxConfigBase* aCfg, const std::vector& aList ) { wxASSERT( aCfg ); - for( const PARAM_CFG_BASE& param : aList ) + for( PARAM_CFG* param : aList ) { - if( !param.m_Setup ) + if( !param->m_Setup ) continue; - if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data + if( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data { - if( !!param.m_Ident ) - aCfg->DeleteGroup( param.m_Ident ); + if( !!param->m_Ident ) + aCfg->DeleteGroup( param->m_Ident ); } else { - param.SaveParam( aCfg ); + param->SaveParam( aCfg ); } } } @@ -130,8 +130,8 @@ void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double } -PARAM_CFG_BASE::PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type, - const wxChar* group, const wxString& legacy ) +PARAM_CFG::PARAM_CFG( const wxString& ident, const paramcfg_id type, + const wxChar* group, const wxString& legacy ) { m_Ident = ident; m_Type = type; @@ -144,7 +144,7 @@ PARAM_CFG_BASE::PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type, PARAM_CFG_INT::PARAM_CFG_INT( const wxString& ident, int* ptparam, int default_val, int min, int max, const wxChar* group, const wxString& legacy ) : - PARAM_CFG_BASE( ident, PARAM_INT, group, legacy ) + PARAM_CFG( ident, PARAM_INT, group, legacy ) { m_Pt_param = ptparam; m_Default = default_val; @@ -155,7 +155,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( const wxString& ident, int* ptparam, int default_v PARAM_CFG_INT::PARAM_CFG_INT( bool setup, const wxString& ident, int* ptparam, int default_val, int min, int max, const wxChar* group, const wxString& legacy ) : - PARAM_CFG_BASE( ident, PARAM_INT, group, legacy ) + PARAM_CFG( ident, PARAM_INT, group, legacy ) { m_Pt_param = ptparam; m_Default = default_val; @@ -247,7 +247,7 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, COLOR4D* ptparam, COLOR4D default_val, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) + PARAM_CFG( ident, PARAM_SETCOLOR, group ) { m_Pt_param = ptparam; m_Default = default_val; @@ -259,7 +259,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, COLOR4D* ptparam, COLOR4D default_val, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) + PARAM_CFG( ident, PARAM_SETCOLOR, group ) { m_Pt_param = ptparam; m_Default = default_val; @@ -314,7 +314,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam, double default_val, double min, double max, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_DOUBLE, group ) + PARAM_CFG( ident, PARAM_DOUBLE, group ) { m_Pt_param = ptparam; m_Default = default_val; @@ -330,7 +330,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup, double min, double max, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_DOUBLE, group ) + PARAM_CFG( ident, PARAM_DOUBLE, group ) { m_Pt_param = ptparam; m_Default = default_val; @@ -370,7 +370,7 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxString& ident, bool* ptparam, int default_val, const wxChar* group, const wxString& legacy ) : - PARAM_CFG_BASE( ident, PARAM_BOOL, group, legacy ) + PARAM_CFG( ident, PARAM_BOOL, group, legacy ) { m_Pt_param = ptparam; m_Default = default_val ? true : false; @@ -379,7 +379,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxString& ident, bool* ptparam, int defaul PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam, int default_val, const wxChar* group, const wxString& legacy ) : - PARAM_CFG_BASE( ident, PARAM_BOOL, group, legacy ) + PARAM_CFG( ident, PARAM_BOOL, group, legacy ) { m_Pt_param = ptparam; m_Default = default_val ? true : false; @@ -412,7 +412,7 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) const PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_WXSTRING, group ) + PARAM_CFG( ident, PARAM_WXSTRING, group ) { m_Pt_param = ptparam; } @@ -420,7 +420,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxString& ident, wxString* ptparam, const wxString& default_val, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_WXSTRING, group ) + PARAM_CFG( ident, PARAM_WXSTRING, group ) { m_Pt_param = ptparam; m_Setup = Insetup; @@ -449,7 +449,7 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) const PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_FILENAME, group ) + PARAM_CFG( ident, PARAM_FILENAME, group ) { m_Pt_param = ptparam; } @@ -486,7 +486,7 @@ void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig ) const PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident, wxArrayString* ptparam, const wxChar* group ) : - PARAM_CFG_BASE( ident, PARAM_LIBNAME_LIST, group ) + PARAM_CFG( ident, PARAM_LIBNAME_LIST, group ) { m_Pt_param = ptparam; } diff --git a/common/project.cpp b/common/project.cpp index d071e51964..ca2b0ddc39 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -321,7 +321,7 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName, - const PARAM_CFG_ARRAY& aParams, const wxString& aFileName ) + const std::vector& aParams, const wxString& aFileName ) { std::unique_ptr cfg( configCreate( aSList, aGroupName, aFileName ) ); @@ -356,7 +356,8 @@ void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aGroupName, - const PARAM_CFG_ARRAY& aParams, const wxString& aForeignProjectFileName ) + const std::vector& aParams, + const wxString& aForeignProjectFileName ) { std::unique_ptr cfg( configCreate( aSList, aGroupName, aForeignProjectFileName ) ); diff --git a/common/settings.cpp b/common/settings.cpp index 8b64b82e47..637e7d90a1 100644 --- a/common/settings.cpp +++ b/common/settings.cpp @@ -25,26 +25,26 @@ void SETTINGS::Load( wxConfigBase *aConfig ) { - for( const PARAM_CFG_BASE& param : m_params ) + for( PARAM_CFG* param : m_params ) { - if( !!param.m_Group ) - aConfig->SetPath( param.m_Group ); + if( !!param->m_Group ) + aConfig->SetPath( param->m_Group ); else aConfig->SetPath( wxT("") ); - param.ReadParam( aConfig ); + param->ReadParam( aConfig ); } } void SETTINGS::Save( wxConfigBase *aConfig ) { - for( PARAM_CFG_BASE& param : m_params ) + for( PARAM_CFG* param : m_params ) { - if( !!param.m_Group ) - aConfig->SetPath( param.m_Group ); + if( !!param->m_Group ) + aConfig->SetPath( param->m_Group ); else aConfig->SetPath( wxT("") ); - param.SaveParam( aConfig ); + param->SaveParam( aConfig ); } } diff --git a/cvpcb/cfg.cpp b/cvpcb/cfg.cpp index fd83b8051b..9c9fbe11a4 100644 --- a/cvpcb/cfg.cpp +++ b/cvpcb/cfg.cpp @@ -33,12 +33,12 @@ #include -PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters() +std::vector& CVPCB_MAINFRAME::GetProjectFileParameters() { if( !m_projectFileParams.empty() ) return m_projectFileParams; - m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUP_PCB_LIBS, PARAM_COMMAND_ERASE ) ); + m_projectFileParams.push_back( new PARAM_CFG( GROUP_PCB_LIBS, PARAM_COMMAND_ERASE ) ); m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "EquName" ), &m_EquFilesNames, GROUP_CVP_EQU ) ); diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index 69e8eb94dc..fe4a6491d2 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -81,12 +81,13 @@ public: FOOTPRINT_LIST* m_FootprintsList; protected: - bool m_modified; - bool m_skipComponentSelect; // true to skip OnSelectComponent event - // (in automatic selection/deletion of associations) - PARAM_CFG_ARRAY m_projectFileParams; + bool m_modified; + bool m_skipComponentSelect; // skip component selection event during + // automatic selection/deletion of + // associations + std::vector m_projectFileParams; - bool m_initialized; + bool m_initialized; CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ); @@ -334,9 +335,9 @@ public: * at compile time requiring global variable definitions. *

* - * @return A reference to a PARAM_CFG_ARRAY contain the project settings for CvPcb. + * @return reference to a std::vector contain the project settings for CvPcb. */ - PARAM_CFG_ARRAY& GetProjectFileParameters( void ); + std::vector& GetProjectFileParameters( void ); /** * Function SendMessageToEESCHEMA diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 548a23c78f..ab76ebada0 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -428,7 +428,7 @@ void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave, { wxString pro = aProject->GetProjectFullName(); - PARAM_CFG_ARRAY ca; + std::vector ca; try { diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index d49209e3c3..b20f9bb023 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -377,7 +377,7 @@ void CONNECTION_GRAPH::Reset() } -void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList, bool aUnconditional ) +void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnconditional ) { PROF_COUNTER recalc_time; PROF_COUNTER update_items; @@ -385,7 +385,7 @@ void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList, bool aUncondition if( aUnconditional ) Reset(); - for( const auto& sheet : aSheetList ) + for( const SCH_SHEET_PATH& sheet : aSheetList ) { std::vector items; @@ -434,7 +434,7 @@ void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList, bool aUncondition void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet, - std::vector aItemList ) + const std::vector& aItemList ) { std::unordered_map< wxPoint, std::vector > connection_map; @@ -446,18 +446,18 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet, if( item->Type() == SCH_SHEET_T ) { - for( auto& pin : static_cast( item )->GetPins() ) + for( SCH_SHEET_PIN* pin : static_cast( item )->GetPins() ) { - if( !pin.Connection( aSheet ) ) + if( !pin->Connection( aSheet ) ) { - pin.InitializeConnection( aSheet ); + pin->InitializeConnection( aSheet ); } - pin.ConnectedItems().clear(); - pin.Connection( aSheet )->Reset(); + pin->ConnectedItems().clear(); + pin->Connection( aSheet )->Reset(); - connection_map[ pin.GetTextPos() ].push_back( &pin ); - m_items.insert( &pin ); + connection_map[ pin->GetTextPos() ].push_back( pin ); + m_items.insert( pin ); } } else if( item->Type() == SCH_COMPONENT_T ) diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index 75dfde3206..43072cffdb 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -225,7 +225,7 @@ public: * @param aSheetList is the list of possibly modified sheets * @param aUnconditional is true if an unconditional full recalculation should be done */ - void Recalculate( SCH_SHEET_LIST aSheetList, bool aUnconditional = false ); + void Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnconditional = false ); /** * Returns a bus alias pointer for the given name if it exists (from cache) @@ -330,7 +330,7 @@ private: * @param aItemList is a list of items to consider */ void updateItemConnectivity( SCH_SHEET_PATH aSheet, - std::vector aItemList ); + const std::vector& aItemList ); /** * Generates the connection graph (after all item connectivity has been updated) diff --git a/eeschema/dialogs/panel_eeschema_settings.cpp b/eeschema/dialogs/panel_eeschema_settings.cpp index abf13c4103..7b25509858 100644 --- a/eeschema/dialogs/panel_eeschema_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_settings.cpp @@ -68,7 +68,7 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataFromWindow() m_frame->SetUserUnits( m_choiceUnits->GetSelection() == 0 ? EDA_UNITS::INCHES : EDA_UNITS::MILLIMETRES ); - int textSize = ValueFromString( EDA_UNITS::INCHES, m_textSizeCtrl->GetValue(), true ); + int textSize = (int) ValueFromString( EDA_UNITS::INCHES, m_textSizeCtrl->GetValue(), true ); if( textSize != GetDefaultTextSize() ) { @@ -77,8 +77,8 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataFromWindow() } m_frame->SetRepeatStep( - wxPoint( ValueFromString( EDA_UNITS::INCHES, m_hPitchCtrl->GetValue(), true ), - ValueFromString( EDA_UNITS::INCHES, m_vPitchCtrl->GetValue(), true ) ) ); + wxPoint( (int) ValueFromString( EDA_UNITS::INCHES, m_hPitchCtrl->GetValue(), true ), + (int) ValueFromString( EDA_UNITS::INCHES, m_vPitchCtrl->GetValue(), true ) ) ); m_frame->SetRepeatDeltaLabel( m_spinRepeatLabel->GetValue() ); m_frame->SetForceHVLines( m_checkHVOrientation->GetValue() ); diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 6a978eb02a..6586d9cc52 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -184,9 +184,9 @@ void SetLayerColor( COLOR4D aColor, SCH_LAYER_ID aLayer ) } -static PARAM_CFG_ARRAY& cfg_params() +static std::vector& cfg_params() { - static PARAM_CFG_ARRAY ca; + static std::vector ca; if( !ca.size() ) { diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index acb994c304..dd756a9570 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -181,60 +181,55 @@ void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, } -PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters() +std::vector& SCH_EDIT_FRAME::GetProjectFileParameters() { if( !m_projectFileParams.empty() ) return m_projectFileParams; - try - { - m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ), - &BASE_SCREEN::m_PageLayoutDescrFileName ) ); + std::vector& params = m_projectFileParams; - m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PlotDirectoryName" ), - &m_plotDirectoryName ) ); + params.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ), + &BASE_SCREEN::m_PageLayoutDescrFileName ) ); - m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ), - LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) ); - m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ), - LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); + params.push_back( new PARAM_CFG_FILENAME( wxT( "PlotDirectoryName" ), + &m_plotDirectoryName ) ); - m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetFmtName" ), - &m_netListFormat) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "SpiceAjustPassiveValues" ), - &m_spiceAjustPassiveValues, false ) ); + params.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ), + LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) ); + params.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ), + LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); - m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "LabSize" ), - &s_defaultTextSize, DEFAULT_SIZE_TEXT, 5, 1000 ) ); + params.push_back( new PARAM_CFG_WXSTRING( wxT( "NetFmtName" ), + &m_netListFormat) ); + params.push_back( new PARAM_CFG_BOOL( wxT( "SpiceAjustPassiveValues" ), + &m_spiceAjustPassiveValues, false ) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_WriteFile" ), - &m_ercSettings.write_erc_file, false ) ); + params.push_back( new PARAM_CFG_INT( wxT( "LabSize" ), + &s_defaultTextSize, DEFAULT_SIZE_TEXT, 5, 1000 ) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_TestSimilarLabels" ), - &m_ercSettings.check_similar_labels, true ) ); + params.push_back( new PARAM_CFG_BOOL( wxT( "ERC_WriteFile" ), + &m_ercSettings.write_erc_file, false ) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckUniqueGlobalLabels" ), - &m_ercSettings.check_unique_global_labels, true ) ); + params.push_back( new PARAM_CFG_BOOL( wxT( "ERC_TestSimilarLabels" ), + &m_ercSettings.check_similar_labels, true ) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusDriverConflicts" ), - &m_ercSettings.check_bus_driver_conflicts, true ) ); + params.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckUniqueGlobalLabels" ), + &m_ercSettings.check_unique_global_labels, true ) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusEntryConflicts" ), - &m_ercSettings.check_bus_entry_conflicts, true ) ); + params.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusDriverConflicts" ), + &m_ercSettings.check_bus_driver_conflicts, true ) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusToBusConflicts" ), - &m_ercSettings.check_bus_to_bus_conflicts, true ) ); + params.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusEntryConflicts" ), + &m_ercSettings.check_bus_entry_conflicts, true ) ); - m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusToNetConflicts" ), - &m_ercSettings.check_bus_to_net_conflicts, true ) ); - } - catch( boost::bad_pointer& ) - { - // Out of memory? Ship's going down anyway.... - } + params.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusToBusConflicts" ), + &m_ercSettings.check_bus_to_bus_conflicts, true ) ); - return m_projectFileParams; + params.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusToNetConflicts" ), + &m_ercSettings.check_bus_to_net_conflicts, true ) ); + + return params; } @@ -345,36 +340,30 @@ static const wxChar selectionThickness[] = wxT( "SelectionThickness" ); ///@} -PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings() +std::vector& SCH_EDIT_FRAME::GetConfigurationSettings() { if( !m_configSettings.empty() ) return m_configSettings; - try - { - m_configSettings.push_back( new PARAM_CFG_BOOL( true, ShowPageLimitsEntry, - &m_showPageLimits, true ) ); - m_configSettings.push_back( new PARAM_CFG_INT( - true, UnitsEntry, (int*) &m_userUnits, (int) EDA_UNITS::MILLIMETRES ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, ShowPageLimitsEntry, + &m_showPageLimits, true ) ); + m_configSettings.push_back( new PARAM_CFG_INT( true, UnitsEntry, + (int*) &m_userUnits, + (int) EDA_UNITS::MILLIMETRES ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, PrintMonochromeEntry, - &m_printMonochrome, true ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, PrintSheetRefEntry, - &m_printSheetReference, true ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, PrintMonochromeEntry, + &m_printMonochrome, true ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, PrintSheetRefEntry, + &m_printSheetReference, true ) ); - m_configSettings.push_back( new PARAM_CFG_INT( true, RepeatLabelIncrementEntry, - &m_repeatDeltaLabel, DEFAULT_REPEAT_LABEL_INC, - -10, +10 ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, ShowIllegalSymboLibDialog, - &m_showIllegalSymbolLibDialog, true ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, showSheetFileNameCaseSensitivityDlg, - &m_showSheetFileNameCaseSensitivityDlg, - true ) ); - } - catch( boost::bad_pointer& ) - { - // Out of memory? Ship's going down anyway.... - } + m_configSettings.push_back( new PARAM_CFG_INT( true, RepeatLabelIncrementEntry, + &m_repeatDeltaLabel, DEFAULT_REPEAT_LABEL_INC, + -10, +10 ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, ShowIllegalSymboLibDialog, + &m_showIllegalSymbolLibDialog, true ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, showSheetFileNameCaseSensitivityDlg, + &m_showSheetFileNameCaseSensitivityDlg, + true ) ); return m_configSettings; } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 779d43ca16..a6ae83e9f9 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -122,8 +122,8 @@ class SCH_EDIT_FRAME : public SCH_BASE_FRAME private: wxString m_SelectedNetName; - PARAM_CFG_ARRAY m_projectFileParams; - PARAM_CFG_ARRAY m_configSettings; + std::vector m_projectFileParams; + std::vector m_configSettings; ERC_SETTINGS m_ercSettings; wxPageSetupDialogData m_pageSetupData; bool m_printMonochrome; ///< Print monochrome instead of grey scale. @@ -149,29 +149,23 @@ private: DIALOG_SCH_FIND* m_findReplaceDialog; STATUS_TEXT_POPUP* m_findReplaceStatusPopup; - /// Flag to indicate show hidden pins. - bool m_showAllPins; + bool m_showAllPins; // show hidden pins + bool m_selectPinSelectSymbol; // select parent when clicking on pin - /// Flag to indicate the pin selection (on a left click) select the paren symbol. - bool m_selectPinSelectSymbol; - - /// The name of the destination directory to use when generating plot files. - wxString m_plotDirectoryName; - - /// The name of the format to use when generating a net list. - wxString m_netListFormat; + wxString m_plotDirectoryName; + wxString m_netListFormat; /// Use netcodes (net number) as net names when generating spice net lists. - bool m_spiceAjustPassiveValues; + bool m_spiceAjustPassiveValues; /* these are PROJECT specific, not schematic editor specific - wxString m_userLibraryPath; - wxArrayString m_componentLibFiles; + wxString m_userLibraryPath; + wxArrayString m_componentLibFiles; */ - static PINSHEETLABEL_SHAPE m_lastSheetPinType; ///< Last sheet pin type. - static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size. - static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position. + static PINSHEETLABEL_SHAPE m_lastSheetPinType; ///< Last sheet pin type. + static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size. + static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position. protected: /** @@ -258,7 +252,7 @@ public: * Populate the project file parameter array specific to Eeschema if it hasn't * already been populated and return a reference to the array to the caller. */ - PARAM_CFG_ARRAY& GetProjectFileParameters(); + std::vector& GetProjectFileParameters(); /** * Save changes to the project settings to the project (.pro) file. @@ -313,7 +307,7 @@ public: * setting that need to be loaded at run time, this is the place to define it. *

*/ - PARAM_CFG_ARRAY& GetConfigurationSettings(); + std::vector& GetConfigurationSettings(); void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override; diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index 544bdf3f88..60cf64fbec 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -99,8 +99,8 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool doClone ) { SCH_SHEET* sheet = (SCH_SHEET*) newItem; - for( SCH_SHEET_PIN& pin : sheet->GetPins() ) - pin.ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED ); + for( SCH_SHEET_PIN* pin : sheet->GetPins() ) + pin->ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED ); } return newItem; diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 8d82145981..4626dbc894 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -1011,6 +1011,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) } else // Sheet pin. { + // Use a unique_ptr so that we clean up in the case of a throw std::unique_ptr< SCH_SHEET_PIN > sheetPin( new SCH_SHEET_PIN( sheet.get() ) ); sheetPin->SetNumber( fieldId ); @@ -2162,14 +2163,14 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) m_out->Print( 0, "F1 %s %d\n", EscapedUTF8( aSheet->GetFileName() ).c_str(), Iu2Mils( aSheet->GetFileNameSize() ) ); - for( const SCH_SHEET_PIN& pin : aSheet->GetPins() ) + for( const SCH_SHEET_PIN* pin : aSheet->GetPins() ) { int type, side; - if( pin.GetText().IsEmpty() ) + if( pin->GetText().IsEmpty() ) break; - switch( pin.GetEdge() ) + switch( pin->GetEdge() ) { default: case SHEET_LEFT_SIDE: side = 'L'; break; @@ -2178,7 +2179,7 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) case SHEET_BOTTOM_SIDE: side = 'B'; break; } - switch( pin.GetShape() ) + switch( pin->GetShape() ) { case PINSHEETLABEL_SHAPE::PS_INPUT: type = 'I'; @@ -2198,11 +2199,11 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) break; } - m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin.GetNumber(), - EscapedUTF8( pin.GetText() ).c_str(), // supplies wrapping quotes - type, side, Iu2Mils( pin.GetPosition().x ), - Iu2Mils( pin.GetPosition().y ), - Iu2Mils( pin.GetTextWidth() ) ); + m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin->GetNumber(), + EscapedUTF8( pin->GetText() ).c_str(), // supplies wrapping quotes + type, side, Iu2Mils( pin->GetPosition().x ), + Iu2Mils( pin->GetPosition().y ), + Iu2Mils( pin->GetTextWidth() ) ); } m_out->Print( 0, "$EndSheet\n" ); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index f7e33b3aea..e8f3c395b3 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -1522,20 +1522,20 @@ void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer ) if( aLayer == LAYER_HIERLABEL || drawingShadows ) { - for( auto& sheetPin : aSheet->GetPins() ) + for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() ) { - if( drawingShadows && !aSheet->IsSelected() && !sheetPin.IsSelected() ) + if( drawingShadows && !aSheet->IsSelected() && !sheetPin->IsSelected() ) continue; if( drawingShadows && !GetSelectionDrawChildItems() && aSheet->IsSelected() ) break; int width = aSheet->GetPenSize(); - wxPoint initial_pos = sheetPin.GetTextPos(); + wxPoint initial_pos = sheetPin->GetTextPos(); wxPoint offset_pos = initial_pos; // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2 - switch( sheetPin.GetEdge() ) + switch( sheetPin->GetEdge() ) { case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break; case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break; @@ -1544,10 +1544,10 @@ void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer ) default: break; } - sheetPin.SetTextPos( offset_pos ); - draw( static_cast( &sheetPin ), aLayer ); + sheetPin->SetTextPos( offset_pos ); + draw( static_cast( sheetPin ), aLayer ); m_gal->DrawLine( offset_pos, initial_pos ); - sheetPin.SetTextPos( initial_pos ); + sheetPin->SetTextPos( initial_pos ); } } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index dc66c3f0b3..6c346f7475 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -72,10 +72,12 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : m_screen = aSheet.m_screen; m_name = aSheet.m_name; m_fileName = aSheet.m_fileName; - m_pins = aSheet.m_pins; - for( size_t i = 0; i < m_pins.size(); i++ ) - m_pins[i].SetParent( this ); + for( SCH_SHEET_PIN* pin : aSheet.m_pins ) + { + m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) ); + m_pins.back()->SetParent( this ); + } if( m_screen ) m_screen->IncRefCount(); @@ -93,6 +95,10 @@ SCH_SHEET::~SCH_SHEET() if( m_screen->GetRefCount() == 0 ) delete m_screen; } + + // We own our pins; delete them + for( SCH_SHEET_PIN* pin : m_pins ) + delete pin; } @@ -161,17 +167,12 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem ) std::swap( m_fileNameSize, sheet->m_fileNameSize ); m_pins.swap( sheet->m_pins ); - // Ensure sheet labels have their .m_Parent member pointing really on their - // parent, after swapping. - for( SCH_SHEET_PIN& sheetPin : m_pins ) - { - sheetPin.SetParent( this ); - } + // Update parent pointers after swapping. + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->SetParent( this ); - for( SCH_SHEET_PIN& sheetPin : sheet->m_pins ) - { - sheetPin.SetParent( sheet ); - } + for( SCH_SHEET_PIN* sheetPin : sheet->m_pins ) + sheetPin->SetParent( sheet ); } @@ -190,9 +191,7 @@ void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin ) wxASSERT( aSheetPin != NULL ); wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T ); - SCH_SHEET_PINS::iterator i; - - for( i = m_pins.begin(); i < m_pins.end(); ++i ) + for( auto i = m_pins.begin(); i < m_pins.end(); ++i ) { if( *i == aSheetPin ) { @@ -209,9 +208,9 @@ void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin ) bool SCH_SHEET::HasPin( const wxString& aName ) { - for( const SCH_SHEET_PIN& pin : m_pins ) + for( SCH_SHEET_PIN* pin : m_pins ) { - if( pin.GetText().CmpNoCase( aName ) == 0 ) + if( pin->GetText().CmpNoCase( aName ) == 0 ) return true; } @@ -224,9 +223,9 @@ bool SCH_SHEET::IsVerticalOrientation() const int leftRight = 0; int topBottom = 0; - for( const SCH_SHEET_PIN& pin : m_pins ) + for( SCH_SHEET_PIN* pin : m_pins ) { - switch( pin.GetEdge() ) + switch( pin->GetEdge() ) { case SHEET_LEFT_SIDE: leftRight++; break; case SHEET_RIGHT_SIDE: leftRight++; break; @@ -242,13 +241,13 @@ bool SCH_SHEET::IsVerticalOrientation() const bool SCH_SHEET::HasUndefinedPins() { - for( const SCH_SHEET_PIN& pin : m_pins ) + for( SCH_SHEET_PIN* pin : m_pins ) { /* Search the schematic for a hierarchical label corresponding to this sheet label. */ const SCH_HIERLABEL* HLabel = nullptr; for( auto aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) ) { - if( !pin.GetText().CmpNoCase( static_cast( aItem )->GetText() ) ) + if( !pin->GetText().CmpNoCase( static_cast( aItem )->GetText() ) ) { HLabel = static_cast( aItem ); break; @@ -269,8 +268,8 @@ int SCH_SHEET::GetMinWidth() const for( size_t i = 0; i < m_pins.size(); i++ ) { - int edge = m_pins[i].GetEdge(); - EDA_RECT pinRect = m_pins[i].GetBoundingBox(); + int edge = m_pins[i]->GetEdge(); + EDA_RECT pinRect = m_pins[i]->GetBoundingBox(); wxASSERT( edge != SHEET_UNDEFINED_SIDE ); @@ -287,12 +286,12 @@ int SCH_SHEET::GetMinWidth() const for( size_t j = 0; j < m_pins.size(); j++ ) { // Check for pin directly across from the current pin. - if( (i == j) || (m_pins[i].GetPosition().y != m_pins[j].GetPosition().y) ) + if( (i == j) || (m_pins[i]->GetPosition().y != m_pins[j]->GetPosition().y) ) continue; - if( width < pinRect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth() ) + if( width < pinRect.GetWidth() + m_pins[j]->GetBoundingBox().GetWidth() ) { - width = pinRect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth(); + width = pinRect.GetWidth() + m_pins[j]->GetBoundingBox().GetWidth(); break; } } @@ -309,8 +308,8 @@ int SCH_SHEET::GetMinHeight() const for( size_t i = 0; i < m_pins.size(); i++ ) { - int edge = m_pins[i].GetEdge(); - EDA_RECT pinRect = m_pins[i].GetBoundingBox(); + int edge = m_pins[i]->GetEdge(); + EDA_RECT pinRect = m_pins[i]->GetBoundingBox(); // Make sure pin is on top or bottom side of sheet. if( edge == SHEET_RIGHT_SIDE || edge == SHEET_LEFT_SIDE ) @@ -326,12 +325,12 @@ int SCH_SHEET::GetMinHeight() const for( size_t j = 0; j < m_pins.size(); j++ ) { // Check for pin directly above or below the current pin. - if( (i == j) || (m_pins[i].GetPosition().x != m_pins[j].GetPosition().x) ) + if( (i == j) || (m_pins[i]->GetPosition().x != m_pins[j]->GetPosition().x) ) continue; - if( height < pinRect.GetHeight() + m_pins[j].GetBoundingBox().GetHeight() ) + if( height < pinRect.GetHeight() + m_pins[j]->GetBoundingBox().GetHeight() ) { - height = pinRect.GetHeight() + m_pins[j].GetBoundingBox().GetHeight(); + height = pinRect.GetHeight() + m_pins[j]->GetBoundingBox().GetHeight(); break; } } @@ -344,16 +343,16 @@ int SCH_SHEET::GetMinHeight() const void SCH_SHEET::CleanupSheet() { - SCH_SHEET_PINS::iterator i = m_pins.begin(); + auto i = m_pins.begin(); while( i != m_pins.end() ) { /* Search the schematic for a hierarchical label corresponding to this sheet label. */ const SCH_HIERLABEL* HLabel = NULL; - for( auto aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) ) + for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) ) { - if( !i->GetText().CmpNoCase( static_cast( aItem )->GetText() ) ) + if( (*i)->GetText().CmpNoCase( static_cast( aItem )->GetText() ) == 0 ) { HLabel = static_cast( aItem ); break; @@ -370,10 +369,10 @@ void SCH_SHEET::CleanupSheet() SCH_SHEET_PIN* SCH_SHEET::GetPin( const wxPoint& aPosition ) { - for( SCH_SHEET_PIN& pin : m_pins ) + for( SCH_SHEET_PIN* pin : m_pins ) { - if( pin.HitTest( aPosition ) ) - return &pin; + if( pin->HitTest( aPosition ) ) + return pin; } return NULL; @@ -470,8 +469,8 @@ void SCH_SHEET::Print( wxDC* aDC, const wxPoint& aOffset ) textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, textWidth, false, false ); /* Draw text : SheetLabel */ - for( SCH_SHEET_PIN& sheetPin : m_pins ) - sheetPin.Print( aDC, aOffset ); + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->Print( aDC, aOffset ); } @@ -650,10 +649,8 @@ void SCH_SHEET::Rotate(wxPoint aPosition) m_size.y = -m_size.y; } - for( SCH_SHEET_PIN& sheetPin : m_pins ) - { - sheetPin.Rotate( aPosition ); - } + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->Rotate( aPosition ); } @@ -662,10 +659,8 @@ void SCH_SHEET::MirrorX( int aXaxis_position ) MIRROR( m_pos.y, aXaxis_position ); m_pos.y -= m_size.y; - for( SCH_SHEET_PIN& sheetPin : m_pins ) - { - sheetPin.MirrorX( aXaxis_position ); - } + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->MirrorX( aXaxis_position ); } @@ -674,10 +669,8 @@ void SCH_SHEET::MirrorY( int aYaxis_position ) MIRROR( m_pos.x, aYaxis_position ); m_pos.x -= m_size.x; - for( SCH_SHEET_PIN& label : m_pins ) - { - label.MirrorY( aYaxis_position ); - } + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->MirrorY( aYaxis_position ); } void SCH_SHEET::SetPosition( const wxPoint& aPosition ) @@ -697,10 +690,8 @@ void SCH_SHEET::Resize( const wxSize& aSize ) m_size = aSize; /* Move the sheet labels according to the new sheet size. */ - for( SCH_SHEET_PIN& label : m_pins ) - { - label.ConstrainOnEdge( label.GetPosition() ); - } + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->ConstrainOnEdge( sheetPin->GetPosition() ); } @@ -734,9 +725,9 @@ void SCH_SHEET::renumberPins() { int id = 2; - for( SCH_SHEET_PIN& pin : m_pins ) + for( SCH_SHEET_PIN* pin : m_pins ) { - pin.SetNumber( id ); + pin->SetNumber( id ); id++; } } @@ -744,14 +735,12 @@ void SCH_SHEET::renumberPins() void SCH_SHEET::GetEndPoints( std::vector & aItemList ) { - for( unsigned ii = 0; ii < GetPins().size(); ii++ ) + for( SCH_SHEET_PIN* sheetPin : m_pins ) { - SCH_SHEET_PIN &pinsheet = GetPins()[ii]; - - wxCHECK2_MSG( pinsheet.Type() == SCH_SHEET_PIN_T, continue, + wxCHECK2_MSG( sheetPin->Type() == SCH_SHEET_PIN_T, continue, wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) ); - pinsheet.GetEndPoints( aItemList ); + sheetPin->GetEndPoints( aItemList ); } } @@ -760,8 +749,8 @@ bool SCH_SHEET::UpdateDanglingState( std::vector& aItemList ) { bool changed = false; - for( SCH_SHEET_PIN& pinsheet : GetPins() ) - changed |= pinsheet.UpdateDanglingState( aItemList ); + for( SCH_SHEET_PIN* sheetPin : m_pins ) + changed |= sheetPin->UpdateDanglingState( aItemList ); return changed; } @@ -769,8 +758,8 @@ bool SCH_SHEET::UpdateDanglingState( std::vector& aItemList ) void SCH_SHEET::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { - for( size_t i = 0; i < GetPins().size(); i++ ) - aPoints.push_back( GetPins()[i].GetPosition() ); + for( SCH_SHEET_PIN* sheetPin : m_pins ) + aPoints.push_back( sheetPin->GetPosition() ); } @@ -790,9 +779,9 @@ SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KICA if( stype == SCH_LOCATE_ANY_T || stype == SCH_SHEET_PIN_T ) { // Test the sheet labels. - for( size_t i = 0; i < m_pins.size(); i++ ) + for( SCH_SHEET_PIN* sheetPin : m_pins ) { - if( SEARCH_RESULT::QUIT == aInspector( &m_pins[i], this ) ) + if( SEARCH_RESULT::QUIT == aInspector( sheetPin, this ) ) return SEARCH_RESULT::QUIT; } } @@ -843,20 +832,20 @@ void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH sheetPath = *aSheetPath; sheetPath.push_back( this ); - for( size_t i = 0; i < m_pins.size(); i++ ) + for( SCH_SHEET_PIN* sheetPin : m_pins ) { NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPathInclude = sheetPath; item->m_SheetPath = *aSheetPath; - item->m_Comp = &m_pins[i]; + item->m_Comp = sheetPin; item->m_Link = this; item->m_Type = NET_SHEETLABEL; - item->m_Label = m_pins[i].GetText(); - item->m_Start = item->m_End = m_pins[i].GetPosition(); + item->m_Label = sheetPin->GetText(); + item->m_Start = item->m_End = sheetPin->GetPosition(); aNetListItems.push_back( item ); SCH_CONNECTION conn; - if( conn.IsBusLabel( m_pins[i].GetText() ) ) + if( conn.IsBusLabel( sheetPin->GetText() ) ) item->ConvertBusToNetListItems( aNetListItems ); } } @@ -933,14 +922,12 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) aPlotter->SetColor( GetLayerColor( GetLayer() ) ); /* Draw texts : SheetLabel */ - for( size_t i = 0; i < m_pins.size(); i++ ) - { - m_pins[i].Plot( aPlotter ); - } + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->Plot( aPlotter ); } -SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem ) +SCH_SHEET& SCH_SHEET::operator=( const SCH_ITEM& aItem ) { wxLogDebug( wxT( "Sheet assignment operator." ) ); @@ -959,13 +946,11 @@ SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem ) m_name = sheet->m_name; m_sheetNameSize = sheet->m_sheetNameSize; m_fileNameSize = sheet->m_fileNameSize; - m_pins = sheet->m_pins; - // Ensure sheet labels have their #m_Parent member pointing really on their - // parent, after assigning. - for( SCH_SHEET_PIN& sheetPin : m_pins ) + for( SCH_SHEET_PIN* pin : sheet->m_pins ) { - sheetPin.SetParent( this ); + m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) ); + m_pins.back()->SetParent( this ); } } @@ -984,10 +969,8 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const << TO_UTF8( m_name ) << '"' << ">\n"; // show all the pins, and check the linked list integrity - for( const SCH_SHEET_PIN& label : m_pins ) - { - label.Show( nestLevel + 1, os ); - } + for( SCH_SHEET_PIN* sheetPin : m_pins ) + sheetPin->Show( nestLevel + 1, os ); NestedSpace( nestLevel, os ) << "\n" << std::flush; } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 784cfe35a2..7d79bcf1d0 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -200,9 +200,6 @@ public: }; -typedef boost::ptr_vector SCH_SHEET_PINS; - - /** * Sheet symbol placed in a schematic, and is the entry point for a sub schematic. */ @@ -215,7 +212,7 @@ class SCH_SHEET : public SCH_ITEM SCH_SCREEN* m_screen; /// The list of sheet connection points. - SCH_SHEET_PINS m_pins; + std::vector m_pins; /// The file name is also in the #SCH_SCREEN object associated with the sheet. It is /// also needed here for loading after reading the sheet description from file. @@ -332,11 +329,11 @@ public: */ void AddPin( SCH_SHEET_PIN* aSheetPin ); - SCH_SHEET_PINS& GetPins() { return m_pins; } + std::vector& GetPins() { return m_pins; } - SCH_SHEET_PINS& GetPins() const + std::vector& GetPins() const { - return const_cast< SCH_SHEET_PINS& >( m_pins ); + return const_cast< std::vector& >( m_pins ); } /** @@ -479,10 +476,8 @@ public: { m_pos += aMoveVector; - for( SCH_SHEET_PIN& pin : m_pins ) - { - pin.Move( aMoveVector ); - } + for( SCH_SHEET_PIN* pin : m_pins ) + pin->Move( aMoveVector ); } void MirrorY( int aYaxis_position ) override; @@ -536,7 +531,7 @@ public: void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override; - SCH_ITEM& operator=( const SCH_ITEM& aSheet ); + SCH_SHEET& operator=( const SCH_ITEM& aSheet ); void ViewGetLayers( int aLayers[], int& aCount ) const override; diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 25e1425365..95501c8a8e 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -532,11 +532,11 @@ void EE_POINT_EDITOR::updateItem() const sheet->SetSize( wxSize( botRight.x - topLeft.x, botRight.y - topLeft.y ) ); // Keep sheet pins attached to edges: - for( SCH_SHEET_PIN& pin : sheet->GetPins() ) + for( SCH_SHEET_PIN* pin : sheet->GetPins() ) { - wxPoint pos = pin.GetPosition(); + wxPoint pos = pin->GetPosition(); - switch( pin.GetEdge() ) + switch( pin->GetEdge() ) { case SHEET_LEFT_SIDE: pos.x = topLeft.x; break; case SHEET_RIGHT_SIDE: pos.x = topRight.x; break; @@ -545,7 +545,7 @@ void EE_POINT_EDITOR::updateItem() const case SHEET_UNDEFINED_SIDE: break; } - pin.SetPosition( pos ); + pin->SetPosition( pos ); } break; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index c491a2c69c..d7df16a5fa 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -718,8 +718,8 @@ bool EE_SELECTION_TOOL::selectMultiple() { int layer = pair.second; - for( SCH_SHEET_PIN& pin : sheet->GetPins() ) - sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( &pin, layer ) ); + for( SCH_SHEET_PIN* pin : sheet->GetPins() ) + sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) ); } } @@ -1223,14 +1223,14 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGr } else if( itemType == SCH_SHEET_T ) { - SCH_SHEET_PINS& pins = static_cast( aItem )->GetPins(); + std::vector& pins = static_cast( aItem )->GetPins(); - for( SCH_SHEET_PIN& pin : pins ) + for( SCH_SHEET_PIN* pin : pins ) { if( aMode == SELECTED ) - pin.SetSelected(); + pin->SetSelected(); else if( aMode == BRIGHTENED ) - pin.SetBrightened(); + pin->SetBrightened(); } } @@ -1280,14 +1280,14 @@ void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* a } else if( itemType == SCH_SHEET_T ) { - SCH_SHEET_PINS& pins = static_cast( aItem )->GetPins(); + std::vector& pins = static_cast( aItem )->GetPins(); - for( SCH_SHEET_PIN& pin : pins ) + for( SCH_SHEET_PIN* pin : pins ) { if( aMode == SELECTED ) - pin.ClearSelected(); + pin->ClearSelected(); else if( aMode == BRIGHTENED ) - pin.ClearBrightened(); + pin->ClearBrightened(); } } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 220c787312..50e6f98db0 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -738,20 +738,20 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent ) } else if( item->Type() == SCH_SHEET_T ) { - for( SCH_SHEET_PIN& pin : static_cast( item )->GetPins() ) + for( SCH_SHEET_PIN* pin : static_cast( item )->GetPins() ) { - auto pin_conn = pin.Connection( *g_CurrentSheet ); - bool redrawPin = pin.IsBrightened(); + auto pin_conn = pin->Connection( *g_CurrentSheet ); + bool redrawPin = pin->IsBrightened(); if( pin_conn && pin_conn->Name() == selectedNetName ) - pin.SetBrightened(); + pin->SetBrightened(); else - pin.ClearBrightened(); + pin->ClearBrightened(); - redrawPin |= pin.IsBrightened(); + redrawPin |= pin->IsBrightened(); if( redrawPin ) - itemsToRedraw.push_back( &pin ); + itemsToRedraw.push_back( pin ); } } diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 4f941a6447..dd3fe2f0a3 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -387,12 +387,10 @@ const SCH_SHEET_PIN* SCH_LINE_WIRE_BUS_TOOL::getSheetPin( const wxPoint& aPositi { auto sheet = static_cast( item ); - for( const SCH_SHEET_PIN& pin : sheet->GetPins() ) + for( SCH_SHEET_PIN* pin : sheet->GetPins() ) { - if( pin.GetPosition() == aPosition ) - { - return &pin; - } + if( pin->GetPosition() == aPosition ) + return pin; } } diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index 10b6a140a1..6c123153d0 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -47,38 +47,32 @@ void GERBVIEW_FRAME::InstallPreferences( PAGED_DIALOG* aParent, } -PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings() +std::vector& GERBVIEW_FRAME::GetConfigurationSettings() { if( !m_configSettings.empty() ) return m_configSettings; - try - { - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "DrawModeOption" ), - &m_displayMode, 2, 0, 2 ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( - true, wxT( "DCodeColorEx" ), - &g_ColorsSettings.m_LayersColors[LAYER_DCODES], WHITE ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( - true, wxT( "NegativeObjectsColorEx" ), - &g_ColorsSettings.m_LayersColors[LAYER_NEGATIVE_OBJECTS], DARKGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( - true, wxT( "GridColorEx" ), - &g_ColorsSettings.m_LayersColors[LAYER_GERBVIEW_GRID], DARKGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( - true, wxT( "WorksheetColorEx" ), - &g_ColorsSettings.m_LayersColors[ LAYER_WORKSHEET], DARKRED ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( - true, wxT( "BackgroundColorEx" ), - &g_ColorsSettings.m_LayersColors[LAYER_PCB_BACKGROUND], BLACK ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( - true, wxT( "DisplayPolarCoordinates" ), - &m_PolarCoords, false ) ); - } - catch( boost::bad_pointer& ) - { - // Out of memory? Ship's going down anyway.... - } + m_configSettings.push_back( new PARAM_CFG_INT( + true, wxT( "DrawModeOption" ), + &m_displayMode, 2, 0, 2 ) ); + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( + true, wxT( "DCodeColorEx" ), + &g_ColorsSettings.m_LayersColors[LAYER_DCODES], WHITE ) ); + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( + true, wxT( "NegativeObjectsColorEx" ), + &g_ColorsSettings.m_LayersColors[LAYER_NEGATIVE_OBJECTS], DARKGRAY ) ); + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( + true, wxT( "GridColorEx" ), + &g_ColorsSettings.m_LayersColors[LAYER_GERBVIEW_GRID], DARKGRAY ) ); + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( + true, wxT( "WorksheetColorEx" ), + &g_ColorsSettings.m_LayersColors[ LAYER_WORKSHEET], DARKRED ) ); + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( + true, wxT( "BackgroundColorEx" ), + &g_ColorsSettings.m_LayersColors[LAYER_PCB_BACKGROUND], BLACK ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( + true, wxT( "DisplayPolarCoordinates" ), + &m_PolarCoords, false ) ); // Default colors for layers 0 to 31 static const COLOR4D color_default[] = { diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 514180bf3b..c43be063ea 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -170,10 +170,9 @@ public: COLORS_DESIGN_SETTINGS* m_colorsSettings; private: - // list of PARAM_CFG_xxx to read/write parameters saved in config - PARAM_CFG_ARRAY m_configSettings; + std::vector m_configSettings; - int m_displayMode; // Gerber images ("layers" in Gerbview) can be drawn: + int m_displayMode; // Gerber images ("layers" in Gerbview) can be drawn: // - in fast mode (write mode) but if there are negative // items only the last image is correctly drawn (no // problem to see only one image or when no negative items) @@ -420,7 +419,7 @@ public: * GerbView source code (mainly in dialogs). If you need to define a configuration * setting that need to be loaded at run time, this is the place to define it. */ - PARAM_CFG_ARRAY& GetConfigurationSettings( void ); + std::vector& GetConfigurationSettings( void ); void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override; diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 189897e9ba..682115250c 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -828,7 +828,7 @@ public: * allow reading or writing of configuration file information directly into * this object. */ - void AppendConfigs( BOARD* aBoard, PARAM_CFG_ARRAY* aResult ); + void AppendConfigs( BOARD* aBoard, std::vector* aResult ); inline int GetBoardThickness() const { return m_boardThickness; } inline void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; } diff --git a/include/colors_design_settings.h b/include/colors_design_settings.h index 8f49ce68ad..8a93e47f15 100644 --- a/include/colors_design_settings.h +++ b/include/colors_design_settings.h @@ -39,7 +39,7 @@ class wxConfigBase; class wxString; #include -class PARAM_CFG_ARRAY; +class PARAM_CFG; /** * COLORS_DESIGN_SETTINGS diff --git a/include/config_params.h b/include/config_params.h index 0c2c33044d..c141d2217a 100644 --- a/include/config_params.h +++ b/include/config_params.h @@ -88,7 +88,7 @@ enum paramcfg_id { /** - * PARAM_CFG_BASE + * PARAM_CFG * is a base class which establishes the interface functions ReadParam and SaveParam, * which are implemented by a number of derived classes, and these function's * doxygen comments are inherited also. @@ -96,7 +96,7 @@ enum paramcfg_id { * See kicad.odt or kicad.pdf, chapter 2 : * "Installation and configuration/Initialization of the default config". */ -class PARAM_CFG_BASE +class PARAM_CFG { public: wxString m_Ident; ///< Keyword in config data @@ -109,9 +109,9 @@ public: wxString m_Ident_legacy; public: - PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type, const wxChar* group = NULL, - const wxString& legacy_ident = wxEmptyString ); - virtual ~PARAM_CFG_BASE() {} + PARAM_CFG( const wxString& ident, const paramcfg_id type, const wxChar* group = NULL, + const wxString& legacy_ident = wxEmptyString ); + virtual ~PARAM_CFG() {} /** * Function ReadParam @@ -133,7 +133,7 @@ public: * Configuration parameter - Integer Class * */ -class PARAM_CFG_INT : public PARAM_CFG_BASE +class PARAM_CFG_INT : public PARAM_CFG { public: int* m_Pt_param; ///< Pointer to the parameter value @@ -190,7 +190,7 @@ public: * Configuration parameter - SetColor Class * */ -class PARAM_CFG_SETCOLOR : public PARAM_CFG_BASE +class PARAM_CFG_SETCOLOR : public PARAM_CFG { public: COLOR4D* m_Pt_param; ///< Pointer to the parameter value @@ -211,7 +211,7 @@ public: * Configuration parameter - Double Precision Class * */ -class PARAM_CFG_DOUBLE : public PARAM_CFG_BASE +class PARAM_CFG_DOUBLE : public PARAM_CFG { public: double* m_Pt_param; ///< Pointer to the parameter value @@ -235,7 +235,7 @@ public: * Configuration parameter - Boolean Class * */ -class PARAM_CFG_BOOL : public PARAM_CFG_BASE +class PARAM_CFG_BOOL : public PARAM_CFG { public: bool* m_Pt_param; ///< Pointer to the parameter value @@ -258,7 +258,7 @@ public: * Configuration parameter - wxString Class * */ -class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE +class PARAM_CFG_WXSTRING : public PARAM_CFG { public: wxString* m_Pt_param; ///< Pointer to the parameter value @@ -284,7 +284,7 @@ public: * and replace "/" by "\" under Windows. * Used to store paths and filenames in config files */ -class PARAM_CFG_FILENAME : public PARAM_CFG_BASE +class PARAM_CFG_FILENAME : public PARAM_CFG { public: wxString* m_Pt_param; ///< Pointer to the parameter value @@ -297,7 +297,7 @@ public: }; -class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG_BASE +class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG { public: wxArrayString* m_Pt_param; ///< Pointer to the parameter value @@ -312,68 +312,52 @@ public: }; -/** A list of parameters type */ -//typedef boost::ptr_vector PARAM_CFG_ARRAY; -class PARAM_CFG_ARRAY : public boost::ptr_vector -{ -}; - - /** * Function wxConfigSaveSetups - * writes @a aList of PARAM_CFG_ARRAY elements to save configuration values - * to @a aCfg. Only elements with m_Setup set true will be saved, hence the - * function name. + * writes @a aList of PARAM_CFG to save configuration values to @a aCfg. + * Only elements with m_Setup set true will be saved, hence the function name. * * @param aCfg where to save * @param aList holds some configuration parameters, not all of which will * necessarily be saved. */ -void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ); +void wxConfigSaveSetups( wxConfigBase* aCfg, const std::vector& aList ); /** * Function wxConfigSaveParams - * writes @a aList of PARAM_CFG_ARRAY elements to save configuration values - * to @a aCfg. Only elements with m_Setup set false will be saved, hence the - * function name. + * writes @a aList of PARAM_CFG to save configuration values to @a aCfg. + * Only elements with m_Setup set false will be saved, hence the function name. * * @param aCfg where to save - * @param aList holds some configuration parameters, not all of which will - * necessarily be saved. - * @param aGroup indicates in which group the value should be saved, - * unless the PARAM_CFG_ARRAY element provides its own group, in which case it will - * take precedence. aGroup may be empty. + * @param aList holds some configuration parameters, not all of which will necessarily be saved. + * @param aGroup indicates in which group the value should be saved, unless the PARAM_CFG provides + * its own group, in which case it will take precedence. aGroup may be empty. */ -void wxConfigSaveParams( wxConfigBase* aCfg, - const PARAM_CFG_ARRAY& aList, const wxString& aGroup ); +void wxConfigSaveParams( wxConfigBase* aCfg, const std::vector& aList, + const wxString& aGroup ); /** * Function wxConfigLoadSetups - * uses @a aList of PARAM_CFG_ARRAY elements to load configuration values - * from @a aCfg. Only elements whose m_Setup field is true will be loaded. + * uses @a aList of PARAM_CFG to load configuration values from @a aCfg. + * Only elements whose m_Setup field is true will be loaded. * * @param aCfg where to load from. - * @param aList holds some configuration parameters, not all of which will - * necessarily be loaded. + * @param aList holds some configuration parameters, not all of which will necessarily be loaded. */ -void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ); +void wxConfigLoadSetups( wxConfigBase* aCfg, const std::vector& aList ); /** * Function wxConfigLoadParams - * uses @a aList of PARAM_CFG_ARRAY elements to load configuration values - * from @a aCfg. Only elements whose m_Setup field is false will be loaded. + * uses @a aList of PARAM_CFG to load configuration values from @a aCfg. + * Only elements whose m_Setup field is false will be loaded. * * @param aCfg where to load from. - * - * @param aList holds some configuration parameters, not all of which will - * necessarily be loaded. - * - * @param aGroup indicates in which group the value should be saved, - * unless the PARAM_CFG_ARRAY element provides its own group, in which case it will - * take precedence. aGroup may be empty. + * @param aList holds some configuration parameters, not all of which will necessarily be loaded. + * @param aGroup indicates in which group the value should be saved, unless the PARAM_CFG provides + * its own group, in which case it will take precedence. aGroup may be empty. */ -void wxConfigLoadParams( wxConfigBase* aCfg, - const PARAM_CFG_ARRAY& aList, const wxString& aGroup ); +void wxConfigLoadParams( wxConfigBase* aCfg, const std::vector& aList, + const wxString& aGroup ); #endif // CONFIG_PARAMS_H_ diff --git a/include/core/settings.h b/include/core/settings.h index 01a786fec1..6bc5c2f47d 100644 --- a/include/core/settings.h +++ b/include/core/settings.h @@ -118,8 +118,8 @@ class SETTINGS return aEntryName; } - wxString m_prefix; - PARAM_CFG_ARRAY m_params; + wxString m_prefix; + std::vector m_params; }; diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 5ea45d113b..fb3537f36f 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -64,7 +64,7 @@ class EDA_RECT; class EDA_DRAW_PANEL_GAL; class EDA_MSG_PANEL; class BASE_SCREEN; -class PARAM_CFG_BASE; +class PARAM_CFG; class PAGE_INFO; class PLOTTER; class TITLE_BLOCK; diff --git a/include/project.h b/include/project.h index ee17ff00dc..67533c285f 100644 --- a/include/project.h +++ b/include/project.h @@ -38,7 +38,7 @@ class wxConfigBase; -class PARAM_CFG_ARRAY; +class PARAM_CFG; class FP_LIB_TABLE; class PART_LIBS; class SEARCH_STACK; @@ -130,14 +130,15 @@ public: * * @param aSList a SEARCH_STACK * @param aGroupName is the name of the group inside the config which contains parameters - * @param aParams is a ptr vector of PARAM_CFG_BASE derivatives. + * @param aParams is a ptr vector of PARAM_CFG derivatives. * Saved parameters are the subset in this array having the .m_Setup member * set to false. * @param aFileName is where to save the *.pro file and if NULL means use this PROJECT's * @a m_project_name. */ VTBL_ENTRY void ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName, - const PARAM_CFG_ARRAY& aParams, const wxString& aFileName = wxEmptyString ); + const std::vector& aParams, + const wxString& aFileName = wxEmptyString ); /** * Function ConfigLoad @@ -151,14 +152,15 @@ public: * * @param aSearchS a SEARCH_STACK where a kicad.pro template file may be found. * @param aGroupName - * @param aParams is ptr vector of PARAM_CFG_BASE derivatives. + * @param aParams is ptr vector of PARAM_CFG derivatives. * @param aForeignConfigFileName when NULL means load the *.pro filename given * in this PROJECT's @a m_project_name field, otherwise load the provided filename. * * @return bool - true if loaded OK. */ VTBL_ENTRY bool ConfigLoad( const SEARCH_STACK& aSearchS, const wxString& aGroupName, - const PARAM_CFG_ARRAY& aParams, const wxString& aForeignConfigFileName = wxEmptyString ); + const std::vector& aParams, + const wxString& aForeignConfigFileName = wxEmptyString ); /// Retain a number of project specific wxStrings, enumerated here: enum RSTRING_T diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 246b33d1e4..6b134895f5 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -60,7 +60,7 @@ // for new projects #define GeneralGroupName wxT( "/general" ) -PARAM_CFG_ARRAY s_KicadManagerParams; +std::vector s_KicadManagerParams; // Menubar and toolbar event table diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index c245d2c46d..cd3c49e647 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -62,7 +62,7 @@ protected: private: // list of PARAM_CFG_xxx to read/write parameters saved in config - PARAM_CFG_ARRAY m_configSettings; + std::vector m_configSettings; public: PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ); @@ -221,7 +221,7 @@ public: * source code (mainly in dialogs). If you need to define a configuration * setting that need to be loaded at run time, this is the place to define it. */ - PARAM_CFG_ARRAY& GetConfigurationSettings() { return m_configSettings; } + std::vector& GetConfigurationSettings() { return m_configSettings; } void LoadSettings( wxConfigBase* aCfg ) override; diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 37a5fe216b..18473ef9c5 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -59,14 +59,14 @@ // NOTE: layer configuration info is stored in both the BOARD and BOARD_DESIGN_SETTINGS so one // of the two needs to read/write the config so we don't end up with order dependency issues. // -class PARAM_CFG_LAYERS : public PARAM_CFG_BASE +class PARAM_CFG_LAYERS : public PARAM_CFG { protected: BOARD* m_Pt_param; ///< Pointer to the parameter value public: PARAM_CFG_LAYERS( BOARD* ptparam, const wxChar* group = nullptr ) : - PARAM_CFG_BASE( wxEmptyString, PARAM_LAYERS, group ) + PARAM_CFG( wxEmptyString, PARAM_LAYERS, group ) { m_Pt_param = ptparam; } @@ -150,14 +150,14 @@ public: }; -class PARAM_CFG_TRACKWIDTHS : public PARAM_CFG_BASE +class PARAM_CFG_TRACKWIDTHS : public PARAM_CFG { protected: std::vector* m_Pt_param; ///< Pointer to the parameter value public: PARAM_CFG_TRACKWIDTHS( std::vector* ptparam, const wxChar* group = nullptr ) : - PARAM_CFG_BASE( wxEmptyString, PARAM_TRACKWIDTHS, group ) + PARAM_CFG( wxEmptyString, PARAM_TRACKWIDTHS, group ) { m_Pt_param = ptparam; } @@ -195,14 +195,14 @@ public: }; -class PARAM_CFG_VIADIMENSIONS : public PARAM_CFG_BASE +class PARAM_CFG_VIADIMENSIONS : public PARAM_CFG { protected: std::vector* m_Pt_param; ///< Pointer to the parameter value public: PARAM_CFG_VIADIMENSIONS( std::vector* ptparam, const wxChar* group = nullptr ) : - PARAM_CFG_BASE( wxEmptyString, PARAM_VIADIMENSIONS, group ) + PARAM_CFG( wxEmptyString, PARAM_VIADIMENSIONS, group ) { m_Pt_param = ptparam; } @@ -247,7 +247,7 @@ public: }; -class PARAM_CFG_DIFFPAIRDIMENSIONS : public PARAM_CFG_BASE +class PARAM_CFG_DIFFPAIRDIMENSIONS : public PARAM_CFG { protected: std::vector* m_Pt_param; ///< Pointer to the parameter value @@ -255,7 +255,7 @@ protected: public: PARAM_CFG_DIFFPAIRDIMENSIONS( std::vector* ptparam, const wxChar* group = nullptr ) : - PARAM_CFG_BASE( wxEmptyString, PARAM_DIFFPAIRDIMENSIONS, group ) + PARAM_CFG( wxEmptyString, PARAM_DIFFPAIRDIMENSIONS, group ) { m_Pt_param = ptparam; } @@ -306,7 +306,7 @@ public: }; -class PARAM_CFG_NETCLASSES : public PARAM_CFG_BASE +class PARAM_CFG_NETCLASSES : public PARAM_CFG { protected: NETCLASSES* m_Pt_param; ///< Pointer to the parameter value @@ -314,7 +314,7 @@ protected: public: PARAM_CFG_NETCLASSES( const wxChar* ident, NETCLASSES* ptparam, const wxChar* group = nullptr ) : - PARAM_CFG_BASE( ident, PARAM_NETCLASSES, group ) + PARAM_CFG( ident, PARAM_NETCLASSES, group ) { m_Pt_param = ptparam; } @@ -533,183 +533,176 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : // Add parameters to save in project config. // values are saved in mm -void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, PARAM_CFG_ARRAY* aResult ) +void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, std::vector* aResult ) { - try - { - aResult->push_back( new PARAM_CFG_LAYERS( aBoard ) ); + aResult->push_back( new PARAM_CFG_LAYERS( aBoard ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "AllowMicroVias" ), - &m_MicroViasAllowed, false ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "AllowMicroVias" ), + &m_MicroViasAllowed, false ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "AllowBlindVias" ), - &m_BlindBuriedViaAllowed, false ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "AllowBlindVias" ), + &m_BlindBuriedViaAllowed, false ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "RequireCourtyardDefinitions" ), - &m_RequireCourtyards, false ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "RequireCourtyardDefinitions" ), + &m_RequireCourtyards, false ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "ProhibitOverlappingCourtyards" ), - &m_ProhibitOverlappingCourtyards, true ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "ProhibitOverlappingCourtyards" ), + &m_ProhibitOverlappingCourtyards, true ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinTrackWidth" ), - &m_TrackMinWidth, - Millimeter2iu( DEFAULT_TRACKMINWIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 25.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinTrackWidth" ), + &m_TrackMinWidth, + Millimeter2iu( DEFAULT_TRACKMINWIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 25.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinViaDiameter" ), - &m_ViasMinSize, - Millimeter2iu( DEFAULT_VIASMINSIZE ), Millimeter2iu( 0.01 ), Millimeter2iu( 25.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinViaDiameter" ), + &m_ViasMinSize, + Millimeter2iu( DEFAULT_VIASMINSIZE ), Millimeter2iu( 0.01 ), Millimeter2iu( 25.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinViaDrill" ), - &m_ViasMinDrill, - Millimeter2iu( DEFAULT_VIASMINDRILL ), Millimeter2iu( 0.01 ), Millimeter2iu( 25.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinViaDrill" ), + &m_ViasMinDrill, + Millimeter2iu( DEFAULT_VIASMINDRILL ), Millimeter2iu( 0.01 ), Millimeter2iu( 25.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinMicroViaDiameter" ), - &m_MicroViasMinSize, - Millimeter2iu( DEFAULT_MICROVIASMINSIZE ), Millimeter2iu( 0.01 ), Millimeter2iu( 10.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinMicroViaDiameter" ), + &m_MicroViasMinSize, + Millimeter2iu( DEFAULT_MICROVIASMINSIZE ), Millimeter2iu( 0.01 ), Millimeter2iu( 10.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinMicroViaDrill" ), - &m_MicroViasMinDrill, - Millimeter2iu( DEFAULT_MICROVIASMINDRILL ), Millimeter2iu( 0.01 ), Millimeter2iu( 10.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinMicroViaDrill" ), + &m_MicroViasMinDrill, + Millimeter2iu( DEFAULT_MICROVIASMINDRILL ), Millimeter2iu( 0.01 ), Millimeter2iu( 10.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinHoleToHole" ), - &m_HoleToHoleMin, - Millimeter2iu( DEFAULT_HOLETOHOLEMIN ), Millimeter2iu( 0.0 ), Millimeter2iu( 10.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "MinHoleToHole" ), + &m_HoleToHoleMin, + Millimeter2iu( DEFAULT_HOLETOHOLEMIN ), Millimeter2iu( 0.0 ), Millimeter2iu( 10.0 ), + nullptr, MM_PER_IU ) ); - // Note: a clearance of -0.01 is a flag indicating we should use the legacy (pre-6.0) method - // based on the edge cut thicknesses. - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperEdgeClearance" ), - &m_CopperEdgeClearance, - Millimeter2iu( LEGACY_COPPEREDGECLEARANCE ), Millimeter2iu( -0.01 ), Millimeter2iu( 25.0 ), - nullptr, MM_PER_IU ) ); + // Note: a clearance of -0.01 is a flag indicating we should use the legacy (pre-6.0) method + // based on the edge cut thicknesses. + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperEdgeClearance" ), + &m_CopperEdgeClearance, + Millimeter2iu( LEGACY_COPPEREDGECLEARANCE ), Millimeter2iu( -0.01 ), Millimeter2iu( 25.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_TRACKWIDTHS( &m_TrackWidthList ) ); - aResult->push_back( new PARAM_CFG_VIADIMENSIONS( &m_ViasDimensionsList ) ); - aResult->push_back( new PARAM_CFG_DIFFPAIRDIMENSIONS( &m_DiffPairDimensionsList ) ); + aResult->push_back( new PARAM_CFG_TRACKWIDTHS( &m_TrackWidthList ) ); + aResult->push_back( new PARAM_CFG_VIADIMENSIONS( &m_ViasDimensionsList ) ); + aResult->push_back( new PARAM_CFG_DIFFPAIRDIMENSIONS( &m_DiffPairDimensionsList ) ); - aResult->push_back( new PARAM_CFG_NETCLASSES( wxT( "Netclasses" ), &m_NetClasses ) ); + aResult->push_back( new PARAM_CFG_NETCLASSES( wxT( "Netclasses" ), &m_NetClasses ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkLineWidth" ), - &m_LineThickness[ LAYER_CLASS_SILK ], - Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), - nullptr, MM_PER_IU, wxT( "ModuleOutlineThickness" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkLineWidth" ), + &m_LineThickness[ LAYER_CLASS_SILK ], + Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), + nullptr, MM_PER_IU, wxT( "ModuleOutlineThickness" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkTextSizeV" ), - &m_TextSize[ LAYER_CLASS_SILK ].y, - Millimeter2iu( DEFAULT_SILK_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, - nullptr, MM_PER_IU, wxT( "ModuleTextSizeV" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkTextSizeV" ), + &m_TextSize[ LAYER_CLASS_SILK ].y, + Millimeter2iu( DEFAULT_SILK_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, + nullptr, MM_PER_IU, wxT( "ModuleTextSizeV" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkTextSizeH" ), - &m_TextSize[ LAYER_CLASS_SILK ].x, - Millimeter2iu( DEFAULT_SILK_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, - nullptr, MM_PER_IU, wxT( "ModuleTextSizeH" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkTextSizeH" ), + &m_TextSize[ LAYER_CLASS_SILK ].x, + Millimeter2iu( DEFAULT_SILK_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, + nullptr, MM_PER_IU, wxT( "ModuleTextSizeH" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkTextSizeThickness" ), - &m_TextThickness[ LAYER_CLASS_SILK ], - Millimeter2iu( DEFAULT_SILK_TEXT_WIDTH ), 1, TEXTS_MAX_WIDTH, - nullptr, MM_PER_IU, wxT( "ModuleTextSizeThickness" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SilkTextSizeThickness" ), + &m_TextThickness[ LAYER_CLASS_SILK ], + Millimeter2iu( DEFAULT_SILK_TEXT_WIDTH ), 1, TEXTS_MAX_WIDTH, + nullptr, MM_PER_IU, wxT( "ModuleTextSizeThickness" ) ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "SilkTextItalic" ), - &m_TextItalic[ LAYER_CLASS_SILK ], false ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "SilkTextItalic" ), + &m_TextItalic[ LAYER_CLASS_SILK ], false ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "SilkTextUpright" ), - &m_TextUpright[ LAYER_CLASS_SILK ], true ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "SilkTextUpright" ), + &m_TextUpright[ LAYER_CLASS_SILK ], true ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperLineWidth" ), - &m_LineThickness[ LAYER_CLASS_COPPER ], - Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), - nullptr, MM_PER_IU, wxT( "DrawSegmentWidth" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperLineWidth" ), + &m_LineThickness[ LAYER_CLASS_COPPER ], + Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), + nullptr, MM_PER_IU, wxT( "DrawSegmentWidth" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperTextSizeV" ), - &m_TextSize[ LAYER_CLASS_COPPER ].y, - Millimeter2iu( DEFAULT_COPPER_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, - nullptr, MM_PER_IU, wxT( "PcbTextSizeV" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperTextSizeV" ), + &m_TextSize[ LAYER_CLASS_COPPER ].y, + Millimeter2iu( DEFAULT_COPPER_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, + nullptr, MM_PER_IU, wxT( "PcbTextSizeV" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperTextSizeH" ), - &m_TextSize[ LAYER_CLASS_COPPER ].x, - Millimeter2iu( DEFAULT_COPPER_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, - nullptr, MM_PER_IU, wxT( "PcbTextSizeH" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperTextSizeH" ), + &m_TextSize[ LAYER_CLASS_COPPER ].x, + Millimeter2iu( DEFAULT_COPPER_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, + nullptr, MM_PER_IU, wxT( "PcbTextSizeH" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperTextThickness" ), - &m_TextThickness[ LAYER_CLASS_COPPER ], - Millimeter2iu( DEFAULT_COPPER_TEXT_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), - nullptr, MM_PER_IU, wxT( "PcbTextThickness" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CopperTextThickness" ), + &m_TextThickness[ LAYER_CLASS_COPPER ], + Millimeter2iu( DEFAULT_COPPER_TEXT_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), + nullptr, MM_PER_IU, wxT( "PcbTextThickness" ) ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "CopperTextItalic" ), - &m_TextItalic[ LAYER_CLASS_COPPER ], false ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "CopperTextItalic" ), + &m_TextItalic[ LAYER_CLASS_COPPER ], false ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "CopperTextUpright" ), - &m_TextUpright[ LAYER_CLASS_COPPER ], true ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "CopperTextUpright" ), + &m_TextUpright[ LAYER_CLASS_COPPER ], true ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "EdgeCutLineWidth" ), - &m_LineThickness[ LAYER_CLASS_EDGES ], - Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), - nullptr, MM_PER_IU, wxT( "BoardOutlineThickness" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "EdgeCutLineWidth" ), + &m_LineThickness[ LAYER_CLASS_EDGES ], + Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), + nullptr, MM_PER_IU, wxT( "BoardOutlineThickness" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CourtyardLineWidth" ), - &m_LineThickness[ LAYER_CLASS_COURTYARD ], - Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "CourtyardLineWidth" ), + &m_LineThickness[ LAYER_CLASS_COURTYARD ], + Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersLineWidth" ), - &m_LineThickness[ LAYER_CLASS_OTHERS ], - Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), - nullptr, MM_PER_IU, wxT( "ModuleOutlineThickness" ) ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersLineWidth" ), + &m_LineThickness[ LAYER_CLASS_OTHERS ], + Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ), Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), + nullptr, MM_PER_IU, wxT( "ModuleOutlineThickness" ) ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersTextSizeV" ), - &m_TextSize[ LAYER_CLASS_OTHERS ].x, - Millimeter2iu( DEFAULT_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersTextSizeV" ), + &m_TextSize[ LAYER_CLASS_OTHERS ].x, + Millimeter2iu( DEFAULT_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersTextSizeH" ), - &m_TextSize[ LAYER_CLASS_OTHERS ].y, - Millimeter2iu( DEFAULT_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersTextSizeH" ), + &m_TextSize[ LAYER_CLASS_OTHERS ].y, + Millimeter2iu( DEFAULT_TEXT_SIZE ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersTextSizeThickness" ), - &m_TextThickness[ LAYER_CLASS_OTHERS ], - Millimeter2iu( DEFAULT_TEXT_WIDTH ), 1, TEXTS_MAX_WIDTH, - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "OthersTextSizeThickness" ), + &m_TextThickness[ LAYER_CLASS_OTHERS ], + Millimeter2iu( DEFAULT_TEXT_WIDTH ), 1, TEXTS_MAX_WIDTH, + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "OthersTextItalic" ), - &m_TextItalic[ LAYER_CLASS_OTHERS ], false ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "OthersTextItalic" ), + &m_TextItalic[ LAYER_CLASS_OTHERS ], false ) ); - aResult->push_back( new PARAM_CFG_BOOL( wxT( "OthersTextUpright" ), - &m_TextUpright[ LAYER_CLASS_OTHERS ], true ) ); + aResult->push_back( new PARAM_CFG_BOOL( wxT( "OthersTextUpright" ), + &m_TextUpright[ LAYER_CLASS_OTHERS ], true ) ); - aResult->push_back( new PARAM_CFG_INT( wxT( "DimensionUnits" ), - &m_DimensionUnits, 0, 0, 2 ) ); - aResult->push_back( new PARAM_CFG_INT( wxT( "DimensionPrecision" ), - &m_DimensionPrecision, 1, 0, 2 ) ); + aResult->push_back( new PARAM_CFG_INT( wxT( "DimensionUnits" ), + &m_DimensionUnits, 0, 0, 2 ) ); + aResult->push_back( new PARAM_CFG_INT( wxT( "DimensionPrecision" ), + &m_DimensionPrecision, 1, 0, 2 ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderMaskClearance" ), - &m_SolderMaskMargin, - Millimeter2iu( DEFAULT_SOLDERMASK_CLEARANCE ), Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderMaskClearance" ), + &m_SolderMaskMargin, + Millimeter2iu( DEFAULT_SOLDERMASK_CLEARANCE ), Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderMaskMinWidth" ), - &m_SolderMaskMinWidth, - Millimeter2iu( DEFAULT_SOLDERMASK_MIN_WIDTH ), 0, Millimeter2iu( 1.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderMaskMinWidth" ), + &m_SolderMaskMinWidth, + Millimeter2iu( DEFAULT_SOLDERMASK_MIN_WIDTH ), 0, Millimeter2iu( 1.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderPasteClearance" ), - &m_SolderPasteMargin, - Millimeter2iu( DEFAULT_SOLDERPASTE_CLEARANCE ), Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ), - nullptr, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderPasteClearance" ), + &m_SolderPasteMargin, + Millimeter2iu( DEFAULT_SOLDERPASTE_CLEARANCE ), Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ), + nullptr, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_DOUBLE( wxT( "SolderPasteRatio" ), - &m_SolderPasteMarginRatio, - DEFAULT_SOLDERPASTE_RATIO, -0.5, 1.0 ) ); - } - catch( boost::bad_pointer& ) - { - // Out of memory? Ship's going down anyway.... - } + aResult->push_back( new PARAM_CFG_DOUBLE( wxT( "SolderPasteRatio" ), + &m_SolderPasteMarginRatio, + DEFAULT_SOLDERPASTE_RATIO, -0.5, 1.0 ) ); } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 1a45a2ebb7..60129ab239 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -535,41 +535,34 @@ void D_PAD::MirrorXPrimitives( int aX ) } -void D_PAD::AppendConfigs( PARAM_CFG_ARRAY* aResult ) +void D_PAD::AppendConfigs( std::vector* aResult ) { // Parameters stored in config are only significant parameters // for a template. // So not all parameters are stored, just few. - try - { - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrill" ), - &m_Drill.x, - Millimeter2iu( 0.6 ), - Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ), - NULL, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrill" ), + &m_Drill.x, + Millimeter2iu( 0.6 ), + Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ), + NULL, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrillOvalY" ), - &m_Drill.y, - Millimeter2iu( 0.6 ), - Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ), - NULL, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrillOvalY" ), + &m_Drill.y, + Millimeter2iu( 0.6 ), + Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ), + NULL, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeH" ), - &m_Size.x, - Millimeter2iu( 1.4 ), - Millimeter2iu( 0.1 ), Millimeter2iu( 20.0 ), - NULL, MM_PER_IU ) ); + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeH" ), + &m_Size.x, + Millimeter2iu( 1.4 ), + Millimeter2iu( 0.1 ), Millimeter2iu( 20.0 ), + NULL, MM_PER_IU ) ); - aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeV" ), - &m_Size.y, - Millimeter2iu( 1.4 ), - Millimeter2iu( 0.1 ), Millimeter2iu( 20.0 ), - NULL, MM_PER_IU ) ); - } - catch( boost::bad_pointer& ) - { - // Out of memory? Ship's going down anyway.... - } + aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeV" ), + &m_Size.y, + Millimeter2iu( 1.4 ), + Millimeter2iu( 0.1 ), Millimeter2iu( 20.0 ), + NULL, MM_PER_IU ) ); } diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 4f50762b8e..82b55ca9e8 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -33,13 +33,13 @@ #include "zones.h" #include #include -#include // PARAM_CFG_ARRAY #include #include #include #include class DRAWSEGMENT; +class PARAM_CFG; enum CUST_PAD_SHAPE_IN_ZONE { @@ -799,7 +799,7 @@ public: * allow reading or writing of configuration file information directly into * this object. */ - void AppendConfigs( PARAM_CFG_ARRAY* aResult ); + void AppendConfigs( std::vector* aResult ); EDA_ITEM* Clone() const override; diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index c89e56d2c7..1c5d2dba6c 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -95,7 +95,7 @@ void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event ) cfg->SetPath( wxCONFIG_PATH_SEPARATOR ); BOARD* dummyBoard = new BOARD(); - PARAM_CFG_ARRAY designSettingsConfig; + std::vector designSettingsConfig; dummyBoard->GetDesignSettings().AppendConfigs( dummyBoard, &designSettingsConfig ); wxConfigLoadParams( cfg, designSettingsConfig, GROUP_PCB ); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 70cb5223b9..3720d4bc27 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -92,7 +92,7 @@ public: * * @return - Reference to the list of applications settings. */ - PARAM_CFG_ARRAY& GetConfigurationSettings(); + std::vector& GetConfigurationSettings(); void OnCloseWindow( wxCloseEvent& Event ) override; void CloseModuleEditor( wxCommandEvent& Event ); @@ -352,7 +352,7 @@ protected: FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ); PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer - PARAM_CFG_ARRAY m_configParams; // List of footprint editor configuration parameters. + std::vector m_configParams; // List of footprint editor configuration parameters. /** * Make sure the footprint info list is loaded (with a progress dialog) and then initialize diff --git a/pcbnew/footprint_editor_options.cpp b/pcbnew/footprint_editor_options.cpp index 3bf8008952..f55bc18126 100644 --- a/pcbnew/footprint_editor_options.cpp +++ b/pcbnew/footprint_editor_options.cpp @@ -31,7 +31,7 @@ #include -PARAM_CFG_ARRAY& FOOTPRINT_EDIT_FRAME::GetConfigurationSettings() +std::vector& FOOTPRINT_EDIT_FRAME::GetConfigurationSettings() { auto& displ_opts = m_DisplayOptions; BOARD_DESIGN_SETTINGS& settings = GetDesignSettings(); @@ -41,17 +41,17 @@ PARAM_CFG_ARRAY& FOOTPRINT_EDIT_FRAME::GetConfigurationSettings() // Display options: m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorDisplayPolarCoords" ), - &m_PolarCoords, false ) ); + &m_PolarCoords, false ) ); m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorPadDisplayMode" ), - &displ_opts.m_DisplayPadFill, true ) ); + &displ_opts.m_DisplayPadFill, true ) ); m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorGraphicLinesDisplayMode" ), - &displ_opts.m_DisplayModEdgeFill, FILLED ) ); + &displ_opts.m_DisplayModEdgeFill, FILLED ) ); m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ), - &displ_opts.m_DisplayModTextFill, FILLED ) ); + &displ_opts.m_DisplayModTextFill, FILLED ) ); m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ), - &displ_opts.m_DisplayModTextFill, FILLED ) ); + &displ_opts.m_DisplayModTextFill, FILLED ) ); m_configParams.push_back( new PARAM_CFG_WXSTRING( true, wxT( "FpEditorTextsRefDefaultText" ), - &settings.m_RefDefaultText, wxT( "REF**" ) ) ); + &settings.m_RefDefaultText, wxT( "REF**" ) ) ); // design settings m_configParams.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorSilkLineWidth" ), diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index dbd95098a7..8629005106 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -99,13 +99,13 @@ class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME friend class PCB_LAYER_WIDGET; /// The auxiliary right vertical tool bar used to access the microwave tools. - ACTION_TOOLBAR* m_microWaveToolBar; + ACTION_TOOLBAR* m_microWaveToolBar; protected: - PARAM_CFG_ARRAY m_configParams; // List of Pcbnew configuration settings. - PARAM_CFG_ARRAY m_projectFileParams; + std::vector m_configParams; // List of Pcbnew configuration settings. + std::vector m_projectFileParams; - wxString m_lastPath[ LAST_PATH_SIZE ]; + wxString m_lastPath[ LAST_PATH_SIZE ]; /** @@ -407,10 +407,10 @@ public: * to define local variables. The old method of statically building the array * at compile time requiring global variable definitions by design. *

- * @return PARAM_CFG_ARRAY - it is only good until SetBoard() is called, so - * don't keep it around past that event. + * @return std::vector - it is only good until SetBoard() is called, so + * don't keep it around past that event. */ - PARAM_CFG_ARRAY& GetProjectFileParameters(); + std::vector& GetProjectFileParameters(); /** * Function SaveProjectSettings @@ -442,7 +442,7 @@ public: * * @return - Reference to the list of applications settings. */ - PARAM_CFG_ARRAY& GetConfigurationSettings(); + std::vector& GetConfigurationSettings(); void LoadSettings( wxConfigBase* aCfg ) override; diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 18460f3e9f..784c769ad9 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -113,7 +113,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) } -PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() +std::vector& PCB_EDIT_FRAME::GetProjectFileParameters() { m_projectFileParams.clear(); @@ -147,7 +147,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() } -PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() +std::vector& PCB_EDIT_FRAME::GetConfigurationSettings() { PCB_DISPLAY_OPTIONS& displ_opts = m_DisplayOptions; diff --git a/qa/eeschema/test_sch_sheet.cpp b/qa/eeschema/test_sch_sheet.cpp index 9eebb3415f..1b5b97e6e2 100644 --- a/qa/eeschema/test_sch_sheet.cpp +++ b/qa/eeschema/test_sch_sheet.cpp @@ -109,9 +109,8 @@ BOOST_AUTO_TEST_CASE( AddPins ) BOOST_CHECK_EQUAL( m_sheet.GetPin( pinPos ), &pinRef ); // check the actual list can be retrieved - // this should be const... - SCH_SHEET_PINS& pins = m_sheet.GetPins(); - BOOST_CHECK_EQUAL( &pins[0], &pinRef ); + std::vector& pins = m_sheet.GetPins(); + BOOST_CHECK_EQUAL( pins[0], &pinRef ); // catch the bad call CHECK_WX_ASSERT( m_sheet.RemovePin( nullptr ) ); @@ -131,22 +130,20 @@ BOOST_AUTO_TEST_CASE( PinRenumbering ) { for( int i = 0; i < 5; ++i ) { - auto pin = std::make_unique( &m_sheet, wxPoint{ i, i }, "name" ); + SCH_SHEET_PIN* pin = new SCH_SHEET_PIN( &m_sheet, wxPoint{ i, i }, "name" ); // set the pins to have the same number going in pin->SetNumber( 2 ); - m_sheet.AddPin( pin.release() ); + m_sheet.AddPin( pin ); } - SCH_SHEET_PINS& pins = m_sheet.GetPins(); + std::vector& pins = m_sheet.GetPins(); std::vector numbers; - for( const auto& pin : pins ) - { - numbers.push_back( pin.GetNumber() ); - } + for( SCH_SHEET_PIN* pin : pins ) + numbers.push_back( pin->GetNumber() ); // and now...they are all unique BOOST_CHECK_PREDICATE( KI_TEST::CollectionHasNoDuplicates, ( numbers ) ); @@ -180,12 +177,9 @@ BOOST_AUTO_TEST_CASE( EndconnectionPoints ) // Insert the pins into the sheet for( const auto& pin : pin_defs ) - { - m_sheet.AddPin( - std::make_unique( &m_sheet, pin.m_pos, pin.m_pin_name ).release() ); - } + m_sheet.AddPin( new SCH_SHEET_PIN( &m_sheet, pin.m_pos, pin.m_pin_name ) ); - SCH_SHEET_PINS& pins = m_sheet.GetPins(); + std::vector& pins = m_sheet.GetPins(); // make sure the pins made it in BOOST_CHECK_EQUAL( pins.size(), pin_defs.size() ); @@ -195,17 +189,17 @@ BOOST_AUTO_TEST_CASE( EndconnectionPoints ) std::vector expectedDangling; // Construct expected from the pin, not defs, as we need the pin address - for( auto& pin : pins ) + for( SCH_SHEET_PIN* pin : pins ) { - expectedDangling.emplace_back( - DANGLING_END_T::SHEET_LABEL_END, &pin, pin.GetPosition(), &pin ); + expectedDangling.emplace_back( DANGLING_END_T::SHEET_LABEL_END, pin, + pin->GetPosition(), pin ); } std::vector dangling; m_sheet.GetEndPoints( dangling ); - BOOST_CHECK_EQUAL_COLLECTIONS( dangling.begin(), dangling.end(), expectedDangling.begin(), - expectedDangling.end() ); + BOOST_CHECK_EQUAL_COLLECTIONS( dangling.begin(), dangling.end(), + expectedDangling.begin(), expectedDangling.end() ); } // And check the connection getter @@ -222,7 +216,7 @@ BOOST_AUTO_TEST_CASE( EndconnectionPoints ) m_sheet.GetConnectionPoints( connections ); BOOST_CHECK_EQUAL_COLLECTIONS( connections.begin(), connections.end(), - expectedConnections.begin(), expectedConnections.end() ); + expectedConnections.begin(), expectedConnections.end() ); } }