diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/create_scene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/create_scene.cpp index 9fa0565309..e291ffc8d6 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/create_scene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/create_scene.cpp @@ -958,7 +958,10 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe } // Init initial lights - m_lights.Clear(); + for( LIGHT* light : m_lights ) + delete light; + + m_lights.clear(); auto IsColorZero = []( const SFVEC3F& aSource ) @@ -972,19 +975,23 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe m_cameraLight->SetCastShadows( false ); if( !IsColorZero( m_boardAdapter.m_RtCameraLightColor ) ) - m_lights.Add( m_cameraLight ); + m_lights.push_back( m_cameraLight ); const SFVEC3F& boardCenter = m_boardAdapter.GetBBox().GetCenter(); if( !IsColorZero( m_boardAdapter.m_RtLightColorTop ) ) - m_lights.Add( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y, - +RANGE_SCALE_3D * 2.0f ), - m_boardAdapter.m_RtLightColorTop ) ); + { + m_lights.push_back( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y, + +RANGE_SCALE_3D * 2.0f ), + m_boardAdapter.m_RtLightColorTop ) ); + } if( !IsColorZero( m_boardAdapter.m_RtLightColorBottom ) ) - m_lights.Add( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y, - -RANGE_SCALE_3D * 2.0f ), - m_boardAdapter.m_RtLightColorBottom ) ); + { + m_lights.push_back( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y, + -RANGE_SCALE_3D * 2.0f ), + m_boardAdapter.m_RtLightColorBottom ) ); + } wxASSERT( m_boardAdapter.m_RtLightColor.size() == m_boardAdapter.m_RtLightSphericalCoords.size() ); @@ -995,7 +1002,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe { const SFVEC2F sc = m_boardAdapter.m_RtLightSphericalCoords[i]; - m_lights.Add( new DIRECTIONAL_LIGHT( + m_lights.push_back( new DIRECTIONAL_LIGHT( SphericalToCartesian( glm::pi() * sc.x, glm::pi() * sc.y ), m_boardAdapter.m_RtLightColor[i] ) ); } @@ -1003,20 +1010,13 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe } // Create an accelerator - if( m_accelerator ) - { - delete m_accelerator; - } - - m_accelerator = 0; - + delete m_accelerator; m_accelerator = new BVH_PBRT( m_objectContainer, 8, SPLITMETHOD::MIDDLE ); if( aStatusReporter ) { // Calculation time in seconds - const double calculation_time = - (double) ( GetRunningMicroSecs() - stats_startReloadTime ) / 1e6; + double calculation_time = (double) GetRunningMicroSecs() - stats_startReloadTime / 1e6; aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) ); } @@ -1051,9 +1051,12 @@ void RENDER_3D_RAYTRACE::insertHole( const PCB_VIA* aVia ) if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_CopperColor ) ); + else if( aVia->GetViaType() == VIATYPE::MICROVIA ) + objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( LAYER_VIA_MICROVIA ) ) ); + else if( aVia->GetViaType() == VIATYPE::BLIND_BURIED ) + objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( LAYER_VIA_BBLIND ) ) ); else - objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( - LAYER_VIAS + static_cast( aVia->GetViaType() ) ) ) ); + objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( LAYER_VIAS ) ) ); m_objectContainer.Add( objPtr ); } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/light.h b/3d-viewer/3d_rendering/3d_render_raytracing/light.h index abf8b29fb1..7d1e33ff10 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/light.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/light.h @@ -147,56 +147,4 @@ private: }; -typedef std::list LIST_LIGHT; - - -/** - * A container for light sources. - * - * @todo Do we really need this object? Wouldn't it be cleaner to just use std::list directly? - */ -class LIGHT_SOURCES -{ -public: - LIGHT_SOURCES() {} - - ~LIGHT_SOURCES() { Clear(); } - - /** - * Remove all lights from the container. - */ - void Clear() - { - if( !m_lights.empty() ) - { - for( LIST_LIGHT::iterator ii = m_lights.begin(); ii != m_lights.end(); ++ii ) - { - delete *ii; - *ii = nullptr; - } - - m_lights.clear(); - } - } - - /** - * Add a light source to the container. - */ - void Add( LIGHT* aLight ) - { - if( aLight ) - m_lights.push_back( aLight ); - } - - /** - * Get light list of this container. - * - * @return a list of lights - */ - const LIST_LIGHT& GetList() const { return m_lights; } - -private: - LIST_LIGHT m_lights; ///< list of lights -}; - #endif // _LIGHT_H_ diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.cpp index 2fb4ee7e5c..05e762c122 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.cpp @@ -1567,8 +1567,6 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay, const SFVEC3F diffuseColorObj = aHitInfo.pHitObject->GetDiffuseColor( aHitInfo ); - const LIST_LIGHT& lightList = m_lights.GetList(); - #if USE_EXPERIMENTAL_SOFT_SHADOWS const bool is_aa_enabled = m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) && (!m_isPreview); @@ -1578,10 +1576,8 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay, unsigned int nr_lights_that_can_cast_shadows = 0; - for( LIST_LIGHT::const_iterator ii = lightList.begin(); ii != lightList.end(); ++ii ) + for( const LIGHT* light : m_lights ) { - const LIGHT* light = (LIGHT *)*ii; - SFVEC3F vectorToLight; SFVEC3F colorOfLight; float distToLight; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.h b/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.h index e94c38dfb3..29ea0015a4 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/render_3d_raytrace.h @@ -161,7 +161,7 @@ private: POST_SHADER_SSAO m_postShaderSsao; - LIGHT_SOURCES m_lights; + std::list m_lights; DIRECTIONAL_LIGHT* m_cameraLight; diff --git a/eeschema/bom_plugins.h b/eeschema/bom_plugins.h index 485e61e4bf..ed1eeea16b 100644 --- a/eeschema/bom_plugins.h +++ b/eeschema/bom_plugins.h @@ -45,8 +45,6 @@ extern const wxChar BOM_TRACE[]; class BOM_GENERATOR_HANDLER { public: - typedef std::unique_ptr PTR; - /** * @param aFile is path to the plugin file. */ diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 261ede5bd7..ac96b3df2f 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -55,7 +55,7 @@ wxString s_bomHelpInfo = // BOM "plugins" are not actually plugins. They are external tools // (scripts or executables) called by this dialog. -typedef std::vector BOM_GENERATOR_ARRAY; +typedef std::vector< std::unique_ptr > BOM_GENERATOR_ARRAY; // The main dialog frame to run scripts to build bom diff --git a/eeschema/dialogs/dialog_sim_settings.cpp b/eeschema/dialogs/dialog_sim_settings.cpp index 6bd970f401..6e8b7a4c7b 100644 --- a/eeschema/dialogs/dialog_sim_settings.cpp +++ b/eeschema/dialogs/dialog_sim_settings.cpp @@ -223,7 +223,7 @@ bool DIALOG_SIM_SETTINGS::TransferDataFromWindow() } else if( page == m_pgNoise ) // Noise analysis { - const NETLIST_EXPORTER_PSPICE::NET_INDEX_MAP& netMap = m_exporter->GetNetIndexMap(); + const std::map& netMap = m_exporter->GetNetIndexMap(); if( empty( m_noiseMeas ) || empty( m_noiseSrc ) || empty( m_noisePointsNumber ) || empty( m_noiseFreqStart ) || empty( m_noiseFreqStop ) ) diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index dbe677d41a..6179669d77 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -269,11 +269,9 @@ wxString NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_FIELD aField, SCH_S bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl ) { - const wxString delimiters( "{:,; }" ); - - SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); - // Set of reference names, to check for duplication - std::set refNames; + const wxString delimiters( "{:,; }" ); + SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); + std::set refNames; // Set of reference names, to check for duplication m_netMap.clear(); m_netMap["GND"] = 0; // 0 is reserved for "GND" @@ -330,7 +328,7 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl ) // Store pin information for( const PIN_INFO& pin : m_sortedSymbolPinList ) { - // Create net mapping + // Create net mapping spiceItem.m_pins.push_back( pin.netName ); pinNames.Add( pin.num ); @@ -458,7 +456,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) // Mark directive as started or continued in case it is a multi-line one directiveStarted = line.StartsWith( '.' ) - || ( directiveStarted && line.StartsWith( '+' ) ); + || ( directiveStarted && line.StartsWith( '+' ) ); } } } @@ -468,9 +466,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) void NETLIST_EXPORTER_PSPICE::writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const { for( const wxString& dir : m_directives ) - { aFormatter->Print( 0, "%s\n", TO_UTF8( dir ) ); - } } diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.h b/eeschema/netlist_exporters/netlist_exporter_pspice.h index 80d81042ff..36e18106de 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.h +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.h @@ -71,27 +71,16 @@ enum SPICE_PRIMITIVE { */ struct SPICE_ITEM { - ///< Schematic symbol represented by this SPICE_ITEM. - SCH_SYMBOL* m_parent; - ///< Spice primitive type (@see SPICE_PRIMITIVE). - wxChar m_primitive; - - ///< Library model (for semiconductors and subcircuits), component value (for passive - ///< components) or voltage/current (for sources). - wxString m_model; - - ///< - wxString m_refName; - - ///< Flag to indicate whether the symbol should be used in simulation. - bool m_enabled; - - ///< Array containing Standard Pin Name - std::vector m_pins; - - ///< Numeric indices into m_SortedSymbolPinList - std::vector m_pinSequence; + SCH_SYMBOL* m_parent; ///< Schematic symbol represented by this SPICE_ITEM. + wxChar m_primitive; ///< Spice primitive type (@see SPICE_PRIMITIVE). + wxString m_model; ///< Library model (for semiconductors and subcircuits), + ///< component value (for passive components) or + ///< voltage/current (for sources). + wxString m_refName; + bool m_enabled; ///< Whether the symbol should be used in simulation. + std::vector m_pins; ///< Array containing Standard Pin Name + std::vector m_pinSequence; ///< Numeric indices into m_SortedSymbolPinList }; @@ -110,15 +99,10 @@ public: { } - typedef std::list SPICE_ITEM_LIST; - - ///< Net name to circuit node number mapping - typedef std::map NET_INDEX_MAP; - /** * Return list of items representing schematic components in the Spice world. */ - const SPICE_ITEM_LIST& GetSpiceItems() const + const std::list& GetSpiceItems() const { return m_spiceItems; } @@ -153,15 +137,13 @@ public: /** * Replace illegal spice net name characters with an underscore. - * - * @param aNetName is the net name to modify. */ static void ReplaceForbiddenChars( wxString& aNetName ); /** * Return a map of circuit nodes to net names. */ - const NET_INDEX_MAP& GetNetIndexMap() const + const std::map& GetNetIndexMap() const { return m_netMap; } @@ -226,20 +208,12 @@ protected: virtual void writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const; private: - ///< Spice simulation title found in the processed schematic sheet - wxString m_title; - ///< Spice directives found in the processed schematic sheet - std::vector m_directives; - - ///< Libraries used by the simulated circuit - std::set m_libraries; - - ///< Map circuit nodes to net names - NET_INDEX_MAP m_netMap; - - ///< List of items representing schematic components in the Spice world - SPICE_ITEM_LIST m_spiceItems; + wxString m_title; ///< Spice simulation title found in the schematic sheet + std::vector m_directives; ///< Spice directives found in the schematic sheet + std::set m_libraries; ///< Spice libraries used by the simulated circuit + std::map m_netMap; ///< Map spice nodes to net codes + std::list m_spiceItems; ///< Items representing schematic symbols in Spice world // Component fields that are processed during netlist export & simulation static const std::vector m_spiceFields; diff --git a/eeschema/pin_numbers.cpp b/eeschema/pin_numbers.cpp index b609f7d3a7..ecb505a06b 100644 --- a/eeschema/pin_numbers.cpp +++ b/eeschema/pin_numbers.cpp @@ -108,7 +108,7 @@ wxString PIN_NUMBERS::GetSummary() const } -int PIN_NUMBERS::Compare( const PinNumber& lhs, const PinNumber& rhs ) +int PIN_NUMBERS::Compare( const wxString& lhs, const wxString& rhs ) { wxString::size_type cursor1 = 0; wxString::size_type cursor2 = 0; diff --git a/eeschema/symbol_editor/symbol_library_manager.cpp b/eeschema/symbol_editor/symbol_library_manager.cpp index c763a0ebff..8d6137ff65 100644 --- a/eeschema/symbol_editor/symbol_library_manager.cpp +++ b/eeschema/symbol_editor/symbol_library_manager.cpp @@ -913,8 +913,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::CreateBuffer( LIB_SYMBOL* aCopy, SCH_SC } -bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer( - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf, LIB_SYMBOL* aCopy ) +bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer( std::shared_ptr aSymbolBuf, + LIB_SYMBOL* aCopy ) { wxCHECK( aCopy && aSymbolBuf, false ); @@ -929,8 +929,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer( } -bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer( - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf ) +bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer( std::shared_ptr aSymbolBuf ) { auto symbolBufIt = std::find( m_symbols.begin(), m_symbols.end(), aSymbolBuf ); wxCHECK( symbolBufIt != m_symbols.end(), false ); @@ -952,8 +951,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer( } -bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable ) +bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr aSymbolBuf, + SYMBOL_LIB_TABLE* aLibTable ) { wxCHECK( aSymbolBuf, false ); LIB_SYMBOL* libSymbol = aSymbolBuf->GetSymbol(); @@ -1000,8 +999,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( result = aLibTable->SaveSymbol( m_libName, newCachedSymbol ); wxCHECK( result == SYMBOL_LIB_TABLE::SAVE_OK, false ); - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR originalBufferedParent = - GetBuffer( bufferedParent->GetName() ); + auto originalBufferedParent = GetBuffer( bufferedParent->GetName() ); wxCHECK( originalBufferedParent, false ); originalSymbol = new LIB_SYMBOL( *libSymbol ); originalSymbol->SetParent( originalBufferedParent->GetSymbol() ); @@ -1026,7 +1024,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( for( auto entry : derivedSymbols ) { - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR symbol = GetBuffer( entry ); + std::shared_ptr symbol = GetBuffer( entry ); LIB_SYMBOL* derivedSymbol = new LIB_SYMBOL( *symbol->GetSymbol() ); derivedSymbol->SetParent( parentSymbol ); result = aLibTable->SaveSymbol( m_libName, derivedSymbol ); @@ -1040,8 +1038,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } -bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf, const wxString& aFileName, +bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr aSymbolBuf, + const wxString& aFileName, SCH_PLUGIN* aPlugin, bool aBuffer ) { wxCHECK( aSymbolBuf, false ); @@ -1129,8 +1127,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( return false; } - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR originalBufferedParent = - GetBuffer( bufferedParent->GetName() ); + auto originalBufferedParent = GetBuffer( bufferedParent->GetName() ); wxCHECK( originalBufferedParent, false ); originalSymbol = new LIB_SYMBOL( *libSymbol ); originalSymbol->SetParent( originalBufferedParent->GetSymbol() ); @@ -1178,7 +1175,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( // Save the derived symbols. for( auto entry : derivedSymbols ) { - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR symbol = GetBuffer( entry ); + std::shared_ptr symbol = GetBuffer( entry ); LIB_SYMBOL* derivedSymbol = new LIB_SYMBOL( *symbol->GetSymbol() ); derivedSymbol->SetParent( parentSymbol ); @@ -1202,7 +1199,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } -SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR +std::shared_ptr SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetBuffer( const wxString& aAlias ) const { for( auto entry : m_symbols ) @@ -1211,7 +1208,7 @@ SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetBuffer( const wxString& aAlias ) const return entry; } - return SYMBOL_BUFFER::PTR( nullptr ); + return std::shared_ptr( nullptr ); } @@ -1270,13 +1267,12 @@ size_t SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetDerivedSymbolNames( const wxString } -int SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::removeChildSymbols( - SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf ) +int SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::removeChildSymbols( std::shared_ptr aSymbolBuf ) { wxCHECK( aSymbolBuf && aSymbolBuf->GetSymbol()->IsRoot(), 0 ); int cnt = 0; - std::deque< SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR >::iterator it = m_symbols.begin(); + std::deque< std::shared_ptr >::iterator it = m_symbols.begin(); while( it != m_symbols.end() ) { diff --git a/eeschema/symbol_editor/symbol_library_manager.h b/eeschema/symbol_editor/symbol_library_manager.h index 65a5aa2cae..c97f8aa95e 100644 --- a/eeschema/symbol_editor/symbol_library_manager.h +++ b/eeschema/symbol_editor/symbol_library_manager.h @@ -300,9 +300,6 @@ private: return ret; } - typedef std::shared_ptr PTR; - typedef std::weak_ptr WEAK_PTR; - private: std::unique_ptr m_screen; @@ -325,7 +322,7 @@ private: if( !m_deleted.empty() ) return true; - for( const auto& symbolBuf : m_symbols ) + for( const std::shared_ptr& symbolBuf : m_symbols ) { if( symbolBuf->IsModified() ) return true; @@ -343,9 +340,9 @@ private: bool CreateBuffer( LIB_SYMBOL* aCopy, SCH_SCREEN* aScreen ); ///< Update the buffered symbol with the contents of \a aCopy. - bool UpdateBuffer( SYMBOL_BUFFER::PTR aSymbolBuf, LIB_SYMBOL* aCopy ); + bool UpdateBuffer( std::shared_ptr aSymbolBuf, LIB_SYMBOL* aCopy ); - bool DeleteBuffer( SYMBOL_BUFFER::PTR aSymbolBuf ); + bool DeleteBuffer( std::shared_ptr aSymbolBuf ); void ClearDeletedBuffer() { @@ -354,18 +351,18 @@ private: ///< Save stored modifications to Symbol Lib Table. It may result in saving the symbol ///< to disk as well, depending on the row properties. - bool SaveBuffer( SYMBOL_BUFFER::PTR aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable ); + bool SaveBuffer( std::shared_ptr aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable ); ///< Save stored modifications using a plugin. aBuffer decides whether the changes ///< should be cached or stored directly to the disk (for SCH_LEGACY_PLUGIN). - bool SaveBuffer( SYMBOL_BUFFER::PTR aSymbolBuf, const wxString& aFileName, + bool SaveBuffer( std::shared_ptr aSymbolBuf, const wxString& aFileName, SCH_PLUGIN* aPlugin, bool aBuffer ); ///< Return a symbol buffer with LIB_SYMBOL holding a symbolicular alias - SYMBOL_BUFFER::PTR GetBuffer( const wxString& aAlias ) const; + std::shared_ptr GetBuffer( const wxString& aAlias ) const; ///< Return all buffered symbols - const std::deque& GetBuffers() const { return m_symbols; } + const std::deque< std::shared_ptr >& GetBuffers() const { return m_symbols; } /** * Check to see any symbols in the buffer are derived from a parent named \a aParentName. @@ -400,14 +397,14 @@ private: * @param aParent is the #SYMBOL_BUFFER to check against. * @return the count of #SYMBOL_BUFFER objects removed from the library. */ - int removeChildSymbols( SYMBOL_BUFFER::PTR aSymbolBuf ); + int removeChildSymbols( std::shared_ptr aSymbolBuf ); - std::deque m_symbols; + std::deque< std::shared_ptr > m_symbols; ///< Buffer for deleted symbols until library is saved. - std::deque m_deleted; - const wxString m_libName; // Buffered library name - int m_hash; + std::deque< std::shared_ptr > m_deleted; + const wxString m_libName; // Buffered library name + int m_hash; }; /** diff --git a/eeschema/symbol_library.h b/eeschema/symbol_library.h index 53abf8c1db..699c31bedf 100644 --- a/eeschema/symbol_library.h +++ b/eeschema/symbol_library.h @@ -183,7 +183,6 @@ struct LibSymbolMapSort /// Symbol map used by symbol library object. typedef std::map< wxString, LIB_SYMBOL*, LibSymbolMapSort > LIB_SYMBOL_MAP; -typedef std::vector< LIB_SYMBOL* > LIB_SYMBOLS; typedef boost::ptr_vector< SYMBOL_LIB > SYMBOL_LIBS_BASE; diff --git a/pcbnew/drc/drc_length_report.h b/pcbnew/drc/drc_length_report.h index ee89580144..0269f52264 100644 --- a/pcbnew/drc/drc_length_report.h +++ b/pcbnew/drc/drc_length_report.h @@ -27,23 +27,21 @@ class DRC_RULE; class DRC_LENGTH_REPORT { public: - typedef std::set CITEMS; - struct ENTRY { - int netcode; - wxString netname; - BOARD_CONNECTED_ITEM* fromItem; - BOARD_CONNECTED_ITEM* toItem; - DRC_RULE* matchingRule; - wxString from; - wxString to; - CITEMS items; - int viaCount; - int totalRoute; - int totalVia; - int totalPadToDie; - int total; + int netcode; + wxString netname; + BOARD_CONNECTED_ITEM* fromItem; + BOARD_CONNECTED_ITEM* toItem; + DRC_RULE* matchingRule; + wxString from; + wxString to; + std::set items; + int viaCount; + int totalRoute; + int totalVia; + int totalPadToDie; + int total; }; DRC_LENGTH_REPORT() diff --git a/pcbnew/drc/drc_test_provider_matched_length.cpp b/pcbnew/drc/drc_test_provider_matched_length.cpp index cd325f74fd..81639ebda7 100644 --- a/pcbnew/drc/drc_test_provider_matched_length.cpp +++ b/pcbnew/drc/drc_test_provider_matched_length.cpp @@ -79,13 +79,11 @@ private: bool runInternal( bool aDelayReportMode = false ); - using LENGTH_ENTRY = DRC_LENGTH_REPORT::ENTRY; - typedef std::set CITEMS; - typedef std::vector LENGTH_ENTRIES; + using CONNECTION = DRC_LENGTH_REPORT::ENTRY; - void checkLengthViolations( DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& aMatchedConnections ); - void checkSkewViolations( DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& aMatchedConnections ); - void checkViaCountViolations( DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& aMatchedConnections ); + void checkLengths( DRC_CONSTRAINT& aConstraint, std::vector& aMatchedConnections ); + void checkSkews( DRC_CONSTRAINT& aConstraint, std::vector& aMatchedConnections ); + void checkViaCounts( DRC_CONSTRAINT& aConstraint, std::vector& aMatchedConnections ); BOARD* m_board; DRC_LENGTH_REPORT m_report; @@ -98,10 +96,10 @@ static int computeViaThruLength( PCB_VIA *aVia, const std::set& aMatchedConnections ) { - for( const DRC_LENGTH_REPORT::ENTRY& ent : matchedConnections ) + for( const DRC_LENGTH_REPORT::ENTRY& ent : aMatchedConnections ) { bool minViolation = false; bool maxViolation = false; @@ -150,17 +148,17 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations( DRC_CONSTRAINT& aC } } -void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations( DRC_CONSTRAINT& aConstraint, - LENGTH_ENTRIES& matchedConnections ) +void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews( DRC_CONSTRAINT& aConstraint, + std::vector& aMatchedConnections ) { int avgLength = 0; - for( const DRC_LENGTH_REPORT::ENTRY& ent : matchedConnections ) + for( const DRC_LENGTH_REPORT::ENTRY& ent : aMatchedConnections ) avgLength += ent.total; - avgLength /= matchedConnections.size(); + avgLength /= aMatchedConnections.size(); - for( const auto& ent : matchedConnections ) + for( const auto& ent : aMatchedConnections ) { int skew = ent.total - avgLength; if( aConstraint.GetValue().HasMax() && abs( skew ) > aConstraint.GetValue().Max() ) @@ -187,10 +185,10 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations( DRC_CONSTRAINT& aCon } -void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCountViolations( DRC_CONSTRAINT& aConstraint, - LENGTH_ENTRIES& matchedConnections ) +void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCounts( DRC_CONSTRAINT& aConstraint, + std::vector& aMatchedConnections ) { - for( const auto& ent : matchedConnections ) + for( const auto& ent : aMatchedConnections ) { if( aConstraint.GetValue().HasMax() && ent.viaCount > aConstraint.GetValue().Max() ) { @@ -231,7 +229,7 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode ) return false; } - std::map itemSets; + std::map > itemSets; auto evaluateLengthConstraints = [&]( BOARD_ITEM *item ) -> bool @@ -265,11 +263,11 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode ) forEachGeometryItem( { PCB_TRACE_T, PCB_VIA_T, PCB_ARC_T }, LSET::AllCuMask(), evaluateLengthConstraints ); - std::map matches; + std::map > matches; for( auto it : itemSets ) { - std::map netMap; + std::map > netMap; for( auto citem : it.second ) netMap[ citem->GetNetCode() ].insert( citem ); @@ -277,7 +275,7 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode ) for( auto nitem : netMap ) { - LENGTH_ENTRY ent; + CONNECTION ent; ent.items = nitem.second; ent.netcode = nitem.first; ent.netname = m_board->GetNetInfo().GetNetItem( ent.netcode )->GetNetname(); @@ -340,7 +338,7 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode ) auto& matchedConnections = it.second; std::sort( matchedConnections.begin(), matchedConnections.end(), - [] ( const LENGTH_ENTRY&a, const LENGTH_ENTRY&b ) -> int + [] ( const CONNECTION&a, const CONNECTION&b ) -> int { return a.netname < b.netname; } ); @@ -369,17 +367,17 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode ) OPT lengthConstraint = rule->FindConstraint( LENGTH_CONSTRAINT ); if( lengthConstraint ) - checkLengthViolations( *lengthConstraint, matchedConnections ); + checkLengths( *lengthConstraint, matchedConnections ); OPT skewConstraint = rule->FindConstraint( SKEW_CONSTRAINT ); if( skewConstraint ) - checkSkewViolations( *skewConstraint, matchedConnections ); + checkSkews( *skewConstraint, matchedConnections ); OPT viaCountConstraint = rule->FindConstraint( VIA_COUNT_CONSTRAINT ); if( viaCountConstraint ) - checkViaCountViolations( *viaCountConstraint, matchedConnections ); + checkViaCounts( *viaCountConstraint, matchedConnections ); } reportRuleStatistics(); diff --git a/pcbnew/plugins/kicad/kicad_plugin.cpp b/pcbnew/plugins/kicad/kicad_plugin.cpp index 64ab8deed4..73ace7fe3b 100644 --- a/pcbnew/plugins/kicad/kicad_plugin.cpp +++ b/pcbnew/plugins/kicad/kicad_plugin.cpp @@ -2198,7 +2198,7 @@ void PCB_IO::format( const ZONE* aZone, int aNestLevel ) const } // Save the filling segments list - const auto& segs = aZone->FillSegments( layer ); + const std::vector& segs = aZone->FillSegments( layer ); if( segs.size() ) { @@ -2206,11 +2206,11 @@ void PCB_IO::format( const ZONE* aZone, int aNestLevel ) const m_out->Print( aNestLevel + 2, "(layer %s)\n", TO_UTF8( BOARD::GetStandardLayerName( layer ) ) ); - for( ZONE_SEGMENT_FILL::const_iterator it = segs.begin(); it != segs.end(); ++it ) + for( const SEG& seg : segs ) { m_out->Print( aNestLevel + 2, "(pts (xy %s) (xy %s))\n", - FormatInternalUnits( wxPoint( it->A ) ).c_str(), - FormatInternalUnits( wxPoint( it->B ) ).c_str() ); + FormatInternalUnits( wxPoint( seg.A ) ).c_str(), + FormatInternalUnits( wxPoint( seg.B ) ).c_str() ); } m_out->Print( aNestLevel + 1, ")\n" ); diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 2b1f39af67..4c389a1e17 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -5255,7 +5255,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) case T_fill_segments: { - ZONE_SEGMENT_FILL segs; + std::vector segs; for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 27b270c8bf..3b407d0931 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -196,7 +196,7 @@ bool ZONE::UnFill() pair.second.RemoveAllContours(); } - for( std::pair& pair : m_FillSegmList ) + for( std::pair >& pair : m_FillSegmList ) { change |= !pair.second.empty(); pair.second.clear(); @@ -678,7 +678,7 @@ void ZONE::Move( const wxPoint& offset ) for( std::pair& pair : m_FilledPolysList ) pair.second.Move( offset ); - for( std::pair& pair : m_FillSegmList ) + for( std::pair >& pair : m_FillSegmList ) { for( SEG& seg : pair.second ) { @@ -715,7 +715,7 @@ void ZONE::Rotate( const wxPoint& aCentre, double aAngle ) for( std::pair& pair : m_FilledPolysList ) pair.second.Rotate( aAngle, VECTOR2I( aCentre ) ); - for( std::pair& pair : m_FillSegmList ) + for( std::pair >& pair : m_FillSegmList ) { for( SEG& seg : pair.second ) { @@ -752,7 +752,7 @@ void ZONE::Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight ) for( std::pair& pair : m_FilledPolysList ) pair.second.Mirror( aMirrorLeftRight, !aMirrorLeftRight, VECTOR2I( aMirrorRef ) ); - for( std::pair& pair : m_FillSegmList ) + for( std::pair >& pair : m_FillSegmList ) { for( SEG& seg : pair.second ) { diff --git a/pcbnew/zone.h b/pcbnew/zone.h index a2548ff0a7..7dacde5c82 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -43,7 +43,6 @@ class BOARD; class ZONE; class MSG_PANEL_ITEM; -typedef std::vector ZONE_SEGMENT_FILL; /** * Handle a list of polygons defining a copper zone. @@ -306,13 +305,13 @@ public: int GetLocalFlags() const { return m_localFlgs; } void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; } - ZONE_SEGMENT_FILL& FillSegments( PCB_LAYER_ID aLayer ) + std::vector& FillSegments( PCB_LAYER_ID aLayer ) { wxASSERT( m_FillSegmList.count( aLayer ) ); return m_FillSegmList.at( aLayer ); } - const ZONE_SEGMENT_FILL& FillSegments( PCB_LAYER_ID aLayer ) const + const std::vector& FillSegments( PCB_LAYER_ID aLayer ) const { wxASSERT( m_FillSegmList.count( aLayer ) ); return m_FillSegmList.at( aLayer ); @@ -711,7 +710,7 @@ public: void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon ); - void SetFillSegments( PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL& aSegments ) + void SetFillSegments( PCB_LAYER_ID aLayer, const std::vector& aSegments ) { m_FillSegmList[aLayer] = aSegments; } @@ -905,7 +904,7 @@ protected: * Segments used to fill the zone (#m_FillMode ==1 ), when fill zone by segment is used. * In this case the segments have #m_ZoneMinThickness width. */ - std::map m_FillSegmList; + std::map > m_FillSegmList; /* set of filled polygons used to draw a zone as a filled area. * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole