From 6f49b57f9bdfc3627e2b3987101b972f5957b9e2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 29 Jul 2022 22:02:35 +0100 Subject: [PATCH] Cleanup & performance enhancements. --- 3d-viewer/3d_canvas/create_layer_items.cpp | 14 ++-- 3d-viewer/3d_canvas/eda_3d_canvas.cpp | 6 +- 3d-viewer/3d_rendering/opengl/3d_model.cpp | 52 +++++++------- .../3d_rendering/opengl/create_scene.cpp | 6 +- .../3d_rendering/raytracing/create_scene.cpp | 8 +-- .../raytracing/shapes2D/triangle_2d.cpp | 2 +- common/bitmap_base.cpp | 4 +- common/dialog_shim.cpp | 13 ++-- common/dialogs/panel_color_settings.cpp | 4 +- common/drawing_sheet/ds_draw_item.cpp | 2 +- common/eda_draw_frame.cpp | 2 +- common/env_paths.cpp | 8 ++- common/env_vars.cpp | 2 +- common/grid_tricks.cpp | 4 +- common/origin_viewitem.cpp | 2 +- common/project.cpp | 8 +-- common/settings/settings_manager.cpp | 2 +- common/tool/action_manager.cpp | 2 +- common/tool/action_menu.cpp | 2 +- common/tool/selection.cpp | 6 +- common/tool/tool_manager.cpp | 4 +- cvpcb/tools/cvpcb_association_tool.cpp | 21 +++--- eeschema/connection_graph.cpp | 6 +- eeschema/cross-probing.cpp | 2 +- eeschema/dialogs/dialog_symbol_remap.cpp | 2 +- eeschema/files-io.cpp | 2 +- .../netlist_exporter_orcadpcb2.cpp | 9 +-- .../netlist_exporter_xml.cpp | 2 +- eeschema/project_rescue.cpp | 4 +- .../kicad/sch_sexpr_lib_plugin_cache.cpp | 8 +-- eeschema/sch_plugins/sch_lib_plugin_cache.cpp | 8 ++- eeschema/sch_screen.cpp | 8 +-- eeschema/sch_sheet.cpp | 4 +- eeschema/sch_sheet_path.cpp | 2 +- eeschema/sch_view.cpp | 2 +- pcbnew/tools/board_editor_control.cpp | 2 - pcbnew/tools/board_reannotate_tool.cpp | 4 +- pcbnew/tools/convert_tool.cpp | 7 +- pcbnew/tools/drawing_stackup_table_tool.cpp | 69 +++++++++---------- pcbnew/tools/drawing_tool.cpp | 3 +- pcbnew/tools/drawing_tool.h | 8 +-- pcbnew/tools/edit_tool.cpp | 1 - pcbnew/tools/pad_tool.cpp | 4 +- pcbnew/tools/pcb_control.cpp | 36 ++++------ 44 files changed, 170 insertions(+), 197 deletions(-) diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index dfa75412fb..2e2d943a0e 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -58,7 +58,7 @@ void BOARD_ADAPTER::destroyLayers() { if( !m_layers_poly.empty() ) { - for( auto& poly : m_layers_poly ) + for( std::pair& poly : m_layers_poly ) delete poly.second; m_layers_poly.clear(); @@ -72,7 +72,7 @@ void BOARD_ADAPTER::destroyLayers() if( !m_layerHoleIdPolys.empty() ) { - for( auto& poly : m_layerHoleIdPolys ) + for( std::pair& poly : m_layerHoleIdPolys ) delete poly.second; m_layerHoleIdPolys.clear(); @@ -80,7 +80,7 @@ void BOARD_ADAPTER::destroyLayers() if( !m_layerHoleOdPolys.empty() ) { - for( auto& poly : m_layerHoleOdPolys ) + for( std::pair& poly : m_layerHoleOdPolys ) delete poly.second; m_layerHoleOdPolys.clear(); @@ -88,7 +88,7 @@ void BOARD_ADAPTER::destroyLayers() if( !m_layerMap.empty() ) { - for( auto& poly : m_layerMap ) + for( std::pair& poly : m_layerMap ) delete poly.second; m_layerMap.clear(); @@ -102,7 +102,7 @@ void BOARD_ADAPTER::destroyLayers() if( !m_layerHoleMap.empty() ) { - for( auto& poly : m_layerHoleMap ) + for( std::pair& poly : m_layerHoleMap ) delete poly.second; m_layerHoleMap.clear(); @@ -726,9 +726,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) auto layerPolyContainer = m_layers_poly.find( layer ); if( layerContainer != m_layerMap.end() ) - { addSolidAreasShapes( zone, layerContainer->second, layer ); - } if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL @@ -1087,7 +1085,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( !m_layerHoleMap.empty() ) { - for( auto& hole : m_layerHoleMap ) + for( std::pair& hole : m_layerHoleMap ) hole.second->BuildBVH(); } diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp index 11433e5ffe..2513453e7a 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp @@ -126,7 +126,11 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList, wxASSERT( m_3d_render_raytracing != nullptr ); wxASSERT( m_3d_render_opengl != nullptr ); - auto busy_indicator_factory = []() { return std::make_unique(); }; + auto busy_indicator_factory = + []() + { + return std::make_unique(); + }; m_3d_render_raytracing->SetBusyIndicatorFactory( busy_indicator_factory ); m_3d_render_opengl->SetBusyIndicatorFactory( busy_indicator_factory ); diff --git a/3d-viewer/3d_rendering/opengl/3d_model.cpp b/3d-viewer/3d_rendering/opengl/3d_model.cpp index a9a3f1a0c0..729a1a0772 100644 --- a/3d-viewer/3d_rendering/opengl/3d_model.cpp +++ b/3d-viewer/3d_rendering/opengl/3d_model.cpp @@ -149,24 +149,25 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode ) for( unsigned int mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i ) { - const auto& mesh = a3DModel.m_Meshes[mesh_i]; + const SMESH& mesh = a3DModel.m_Meshes[mesh_i]; // silently ignore meshes that have invalid material references or invalid geometry. if( mesh.m_MaterialIdx >= m_materials.size() - || mesh.m_Positions == nullptr - || mesh.m_FaceIdx == nullptr - || mesh.m_Normals == nullptr - || mesh.m_FaceIdxSize == 0 - || mesh.m_VertexSize == 0 ) - continue; + || mesh.m_Positions == nullptr + || mesh.m_FaceIdx == nullptr + || mesh.m_Normals == nullptr + || mesh.m_FaceIdxSize == 0 + || mesh.m_VertexSize == 0 ) + { + continue; + } - auto& mesh_group = mesh_groups[mesh.m_MaterialIdx]; - auto& material = m_materials[mesh.m_MaterialIdx]; + MESH_GROUP& mesh_group = mesh_groups[mesh.m_MaterialIdx]; + MATERIAL& material = m_materials[mesh.m_MaterialIdx]; - if( material.IsTransparent() - && m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY ) + if( material.IsTransparent() && m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY ) m_have_transparent_meshes = true; - else + else m_have_opaque_meshes = true; const unsigned int vtx_offset = mesh_group.m_vertices.size(); @@ -180,15 +181,14 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode ) { m_meshes_bbox[mesh_i].Union( mesh.m_Positions[vtx_i] ); - auto& vtx_out = mesh_group.m_vertices[vtx_offset + vtx_i]; + VERTEX& vtx_out = mesh_group.m_vertices[vtx_offset + vtx_i]; vtx_out.m_pos = mesh.m_Positions[vtx_i]; vtx_out.m_nrm = glm::clamp( glm::vec4( mesh.m_Normals[vtx_i], 1.0f ) * 127.0f, -127.0f, 127.0f ); - vtx_out.m_tex_uv = mesh.m_Texcoords != nullptr - ? mesh.m_Texcoords[vtx_i] - : glm::vec2 (0); + vtx_out.m_tex_uv = mesh.m_Texcoords != nullptr ? mesh.m_Texcoords[vtx_i] + : glm::vec2 (0); if( mesh.m_Color != nullptr ) { @@ -299,7 +299,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode ) unsigned int total_vertex_count = 0; unsigned int total_index_count = 0; - for( auto& mg : mesh_groups ) + for( const MESH_GROUP& mg : mesh_groups ) { total_vertex_count += mg.m_vertices.size(); total_index_count += mg.m_indices.size(); @@ -327,8 +327,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode ) // temporary index buffer which will contain either GLushort or GLuint // type indices. allocate with a bit of meadow at the end. - auto tmp_idx = std::make_unique( - ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) ); + auto tmp_idx = std::make_unique( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) ); unsigned int prev_vtx_count = 0; unsigned int idx_offset = 0; @@ -336,23 +335,22 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode ) for( unsigned int mg_i = 0; mg_i < mesh_groups.size (); ++mg_i ) { - auto& mg = mesh_groups[mg_i]; - auto& mat = m_materials[mg_i]; + MESH_GROUP& mg = mesh_groups[mg_i]; + MATERIAL& mat = m_materials[mg_i]; + uintptr_t tmp_idx_ptr = reinterpret_cast( tmp_idx.get() ); if( m_index_buffer_type == GL_UNSIGNED_SHORT ) { - auto idx_out = reinterpret_cast( - reinterpret_cast( tmp_idx.get() ) + idx_offset ); + GLushort* idx_out = reinterpret_cast( tmp_idx_ptr + idx_offset ); - for( auto idx : mg.m_indices ) + for( GLuint idx : mg.m_indices ) *idx_out++ = static_cast( idx + prev_vtx_count ); } else if( m_index_buffer_type == GL_UNSIGNED_INT ) { - auto idx_out = reinterpret_cast( - reinterpret_cast( tmp_idx.get() ) + idx_offset ); + GLuint* idx_out = reinterpret_cast( tmp_idx_ptr + idx_offset ); - for( auto idx : mg.m_indices ) + for( GLuint idx : mg.m_indices ) *idx_out++ = static_cast( idx + prev_vtx_count ); } diff --git a/3d-viewer/3d_rendering/opengl/create_scene.cpp b/3d-viewer/3d_rendering/opengl/create_scene.cpp index d2bd22d044..8d6a28860d 100644 --- a/3d-viewer/3d_rendering/opengl/create_scene.cpp +++ b/3d-viewer/3d_rendering/opengl/create_scene.cpp @@ -531,7 +531,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo float layer_z_bot = 0.0f; float layer_z_top = 0.0f; - for( const auto ii : outerMapHoles ) + for( const std::pair& ii : outerMapHoles ) { const PCB_LAYER_ID layer_id = ii.first; const SHAPE_POLY_SET* poly = ii.second; @@ -543,7 +543,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo layer_z_top, layer_z_bot, false ); } - for( const auto ii : innerMapHoles ) + for( const std::pair& ii : innerMapHoles ) { const PCB_LAYER_ID layer_id = ii.first; const SHAPE_POLY_SET* poly = ii.second; @@ -565,7 +565,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap(); - for( const auto ii : m_boardAdapter.GetLayerMap() ) + for( const std::pair& ii : m_boardAdapter.GetLayerMap() ) { const PCB_LAYER_ID layer_id = ii.first; diff --git a/3d-viewer/3d_rendering/raytracing/create_scene.cpp b/3d-viewer/3d_rendering/raytracing/create_scene.cpp index 90a7559b65..a10dae8fa9 100644 --- a/3d-viewer/3d_rendering/raytracing/create_scene.cpp +++ b/3d-viewer/3d_rendering/raytracing/create_scene.cpp @@ -556,9 +556,9 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe aStatusReporter->Report( _( "Load Raytracing: layers" ) ); // Add layers maps (except B_Mask and F_Mask) - for( auto entry : m_boardAdapter.GetLayerMap() ) + for( const std::pair& entry : m_boardAdapter.GetLayerMap() ) { - PCB_LAYER_ID layer_id = entry.first; + const PCB_LAYER_ID layer_id = entry.first; const BVH_CONTAINER_2D* container2d = entry.second; // Only process layers that exist @@ -677,9 +677,9 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe { const MATERIAL* materialLayer = &m_materials.m_SolderMask; - for( auto entry : m_boardAdapter.GetLayerMap() ) + for( const std::pair& entry : m_boardAdapter.GetLayerMap() ) { - PCB_LAYER_ID layer_id = entry.first; + const PCB_LAYER_ID layer_id = entry.first; const BVH_CONTAINER_2D* container2d = entry.second; // Only process layers that exist diff --git a/3d-viewer/3d_rendering/raytracing/shapes2D/triangle_2d.cpp b/3d-viewer/3d_rendering/raytracing/shapes2D/triangle_2d.cpp index 688712c563..712a58351e 100644 --- a/3d-viewer/3d_rendering/raytracing/shapes2D/triangle_2d.cpp +++ b/3d-viewer/3d_rendering/raytracing/shapes2D/triangle_2d.cpp @@ -130,7 +130,7 @@ void ConvertPolygonToTriangles( const SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BA for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ ) { - auto triPoly = aPolyList.TriangulatedPolygon( j ); + const SHAPE_POLY_SET::TRIANGULATED_POLYGON* triPoly = aPolyList.TriangulatedPolygon( j ); for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ ) { diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp index 19dd5d134e..707c3f09e6 100644 --- a/common/bitmap_base.cpp +++ b/common/bitmap_base.cpp @@ -77,12 +77,10 @@ void BITMAP_BASE::ImportData( BITMAP_BASE* aItem ) bool BITMAP_BASE::ReadImageFile( wxInputStream& aInStream ) { - auto new_image = std::make_unique(); + std::unique_ptr new_image = std::make_unique(); if( !new_image->LoadFile( aInStream ) ) - { return false; - } delete m_image; m_image = new_image.release(); diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 8543c9270c..983a722523 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -595,12 +595,13 @@ void DIALOG_SHIM::OnCharHook( wxKeyEvent& aEvt ) int currentIdx = -1; int delta = aEvt.ShiftDown() ? -1 : 1; - auto advance = [&]( int& idx ) - { - // Wrap-around modulus - int size = m_tabOrder.size(); - idx = ( ( idx + delta ) % size + size ) % size; - }; + auto advance = + [&]( int& idx ) + { + // Wrap-around modulus + int size = m_tabOrder.size(); + idx = ( ( idx + delta ) % size + size ) % size; + }; for( size_t i = 0; i < m_tabOrder.size(); ++i ) { diff --git a/common/dialogs/panel_color_settings.cpp b/common/dialogs/panel_color_settings.cpp index 93541577a0..756141807f 100644 --- a/common/dialogs/panel_color_settings.cpp +++ b/common/dialogs/panel_color_settings.cpp @@ -149,7 +149,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event ) newSettings->SetName( themeName ); newSettings->SetReadOnly( false ); - for( auto layer : m_validLayers ) + for( int layer : m_validLayers ) newSettings->SetColor( layer, m_currentSettings->GetColor( layer ) ); newSettings->SaveToFile( settingsMgr.GetPathForSettingsFile( newSettings ) ); @@ -367,7 +367,7 @@ bool PANEL_COLOR_SETTINGS::saveCurrentTheme( bool aValidate ) selected->SetOverrideSchItemColors( m_optOverrideColors->GetValue() ); - for( auto layer : m_validLayers ) + for( int layer : m_validLayers ) selected->SetColor( layer, m_currentSettings->GetColor( layer ) ); settingsMgr.SaveColorSettings( selected, m_colorNamespace ); diff --git a/common/drawing_sheet/ds_draw_item.cpp b/common/drawing_sheet/ds_draw_item.cpp index c2094f76ed..5357402b43 100644 --- a/common/drawing_sheet/ds_draw_item.cpp +++ b/common/drawing_sheet/ds_draw_item.cpp @@ -538,7 +538,7 @@ void DS_DRAW_ITEM_LIST::Print( const RENDER_SETTINGS* aSettings ) second_items.push_back( item ); } - for( auto item : second_items ) + for( DS_DRAW_ITEM_BASE* item : second_items ) item->PrintWsItem( aSettings ); } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 3d9553702c..4e2f894210 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -175,7 +175,7 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME() { delete m_socketServer; - for( auto socket : m_sockets ) + for( wxSocketBase* socket : m_sockets ) { socket->Shutdown(); socket->Destroy(); diff --git a/common/env_paths.cpp b/common/env_paths.cpp index 48846b4fd2..b223015e52 100644 --- a/common/env_paths.cpp +++ b/common/env_paths.cpp @@ -79,12 +79,14 @@ wxString NormalizePath( const wxFileName& aFilePath, const ENV_VAR_MAP* aEnvVars if( aEnvVars ) { - for( auto& entry : *aEnvVars ) + for( const std::pair& entry : *aEnvVars ) { // Don't bother normalizing paths that don't exist or the user cannot read. if( !wxFileName::DirExists( entry.second.GetValue() ) - || !wxFileName::IsDirReadable( entry.second.GetValue() ) ) + || !wxFileName::IsDirReadable( entry.second.GetValue() ) ) + { continue; + } envPath.SetPath( entry.second.GetValue() ); @@ -177,7 +179,7 @@ wxString ResolveFile( const wxString& aFileName, const ENV_VAR_MAP* aEnvVars, if( aEnvVars ) { - for( auto& entry : *aEnvVars ) + for( const std::pair& entry : *aEnvVars ) { wxFileName fn( createFilePath( entry.second.GetValue(), aFileName ) ); diff --git a/common/env_vars.cpp b/common/env_vars.cpp index cc6d502a9c..6baf386a75 100644 --- a/common/env_vars.cpp +++ b/common/env_vars.cpp @@ -47,7 +47,7 @@ static const ENV_VAR::ENV_VAR_LIST predefinedEnvVars = { bool ENV_VAR::IsEnvVarImmutable( const wxString& aEnvVar ) { - for( const auto& s : predefinedEnvVars ) + for( const wxString& s : predefinedEnvVars ) { if( s == aEnvVar ) return true; diff --git a/common/grid_tricks.cpp b/common/grid_tricks.cpp index d5709dbace..c883ddee55 100644 --- a/common/grid_tricks.cpp +++ b/common/grid_tricks.cpp @@ -70,8 +70,8 @@ GRID_TRICKS::GRID_TRICKS( WX_GRID* aGrid ): bool GRID_TRICKS::toggleCell( int aRow, int aCol, bool aPreserveSelection ) { - auto renderer = m_grid->GetCellRenderer( aRow, aCol ); - bool isCheckbox = ( dynamic_cast( renderer ) != nullptr ); + wxGridCellRenderer* renderer = m_grid->GetCellRenderer( aRow, aCol ); + bool isCheckbox = ( dynamic_cast( renderer ) ); renderer->DecRef(); if( isCheckbox ) diff --git a/common/origin_viewitem.cpp b/common/origin_viewitem.cpp index a29ef009b3..898e60daa4 100644 --- a/common/origin_viewitem.cpp +++ b/common/origin_viewitem.cpp @@ -69,7 +69,7 @@ const BOX2I ORIGIN_VIEWITEM::ViewBBox() const void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const { - auto gal = aView->GetGAL(); + GAL* gal = aView->GetGAL(); // Nothing to do if the target shouldn't be drawn at 0,0 and that's where the target is. if( !m_drawAtZero && ( m_position.x == 0 ) && ( m_position.y == 0 ) ) diff --git a/common/project.cpp b/common/project.cpp index c546f6cba5..6e49f79a5b 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -198,7 +198,7 @@ const wxString PROJECT::GetSheetName( const KIID& aSheetID ) { if( m_sheetNames.empty() ) { - for( auto pair : GetProjectFile().GetSheets() ) + for( const std::pair& pair : GetProjectFile().GetSheets() ) m_sheetNames[pair.first] = pair.second; } @@ -214,13 +214,9 @@ void PROJECT::SetRString( RSTRING_T aIndex, const wxString& aString ) unsigned ndx = unsigned( aIndex ); if( ndx < arrayDim( m_rstrings ) ) - { m_rstrings[ndx] = aString; - } else - { wxASSERT( 0 ); // bad index - } } @@ -247,9 +243,7 @@ PROJECT::_ELEM* PROJECT::GetElem( ELEM_T aIndex ) { // This is virtual, so implement it out of line if( unsigned( aIndex ) < arrayDim( m_elems ) ) - { return m_elems[aIndex]; - } return nullptr; } diff --git a/common/settings/settings_manager.cpp b/common/settings/settings_manager.cpp index 1f9d6b490a..23eee502a4 100644 --- a/common/settings/settings_manager.cpp +++ b/common/settings/settings_manager.cpp @@ -617,7 +617,7 @@ bool SETTINGS_MANAGER::GetPreviousVersionPaths( std::vector* aPaths ) std::set checkedPaths; - for( auto base_path : base_paths ) + for( const wxFileName& base_path : base_paths ) { if( checkedPaths.count( base_path.GetFullPath() ) ) continue; diff --git a/common/tool/action_manager.cpp b/common/tool/action_manager.cpp index 27171d35e9..a56449c465 100644 --- a/common/tool/action_manager.cpp +++ b/common/tool/action_manager.cpp @@ -202,7 +202,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const } else if( !global.empty() ) { - for( auto act : global ) + for( const TOOL_ACTION* act : global ) { bool runAction = true; diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp index 91f46d5a2e..eedc825086 100644 --- a/common/tool/action_menu.cpp +++ b/common/tool/action_menu.cpp @@ -60,7 +60,7 @@ ACTION_MENU::ACTION_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) : ACTION_MENU::~ACTION_MENU() { // Set parent to NULL to prevent submenus from unregistering from a nonexistent object - for( auto menu : m_submenus ) + for( ACTION_MENU* menu : m_submenus ) menu->SetParent( nullptr ); ACTION_MENU* parent = dynamic_cast( GetParent() ); diff --git a/common/tool/selection.cpp b/common/tool/selection.cpp index 61d3b345b6..c72558c33f 100644 --- a/common/tool/selection.cpp +++ b/common/tool/selection.cpp @@ -122,7 +122,7 @@ EDA_RECT SELECTION::GetBoundingBox() const bool SELECTION::HasType( KICAD_T aType ) const { - for( auto item : m_items ) + for( const EDA_ITEM* item : m_items ) { if( item->Type() == aType ) return true; @@ -136,7 +136,7 @@ size_t SELECTION::CountType( KICAD_T aType ) const { size_t count = 0; - for( EDA_ITEM* item : m_items ) + for( const EDA_ITEM* item : m_items ) { if( item->Type() == aType ) count++; @@ -150,7 +150,7 @@ const std::vector SELECTION::updateDrawList() const { std::vector items; - for( auto item : m_items ) + for( EDA_ITEM* item : m_items ) items.push_back( item ); return items; diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 241535249c..a44060a1c9 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -871,7 +871,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent ) m_menuCursor = m_viewControls->GetCursorPosition(); // Save all tools cursor settings, as they will be overridden - for( auto idState : m_toolIdIndex ) + for( const std::pair& idState : m_toolIdIndex ) { TOOL_STATE* s = idState.second; const auto& vc = s->vcSettings; @@ -916,7 +916,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent ) m_menuOwner = -1; // Restore cursor settings - for( auto const& cursorSetting : m_cursorSettings ) + for( const std::pair>& cursorSetting : m_cursorSettings ) { auto it = m_toolIdIndex.find( cursorSetting.first ); wxASSERT( it != m_toolIdIndex.end() ); diff --git a/cvpcb/tools/cvpcb_association_tool.cpp b/cvpcb/tools/cvpcb_association_tool.cpp index 7dceb4acfc..28e1ef678e 100644 --- a/cvpcb/tools/cvpcb_association_tool.cpp +++ b/cvpcb/tools/cvpcb_association_tool.cpp @@ -158,7 +158,8 @@ int CVPCB_ASSOCIATION_TOOL::PasteAssoc( const TOOL_EVENT& aEvent ) // Assign the fpid to the selections bool firstAssoc = true; - for( auto i : idx ) + + for( unsigned int i : idx ) { m_frame->AssociateFootprint( CVPCB_ASSOCIATION( i, fpid ), firstAssoc ); firstAssoc = false; @@ -210,10 +211,9 @@ int CVPCB_ASSOCIATION_TOOL::Associate( const TOOL_EVENT& aEvent ) } // Get all the components that are selected and associate them with the current footprint - std::vector sel = m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS ); - bool firstAssoc = true; - for( auto i : sel ) + + for( unsigned int i : m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS ) ) { CVPCB_ASSOCIATION newfp( i, fpid ); m_frame->AssociateFootprint( newfp, firstAssoc ); @@ -237,12 +237,10 @@ int CVPCB_ASSOCIATION_TOOL::AutoAssociate( const TOOL_EVENT& aEvent ) int CVPCB_ASSOCIATION_TOOL::DeleteAssoc( const TOOL_EVENT& aEvent ) { - // Get all the components that are selected - std::vector sel = m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS ); - - // Delete the association + // Delete all the selected components' associations bool firstAssoc = true; - for( auto i : sel ) + + for( unsigned int i : m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS ) ) { m_frame->AssociateFootprint( CVPCB_ASSOCIATION( i, LIB_ID() ), firstAssoc ); firstAssoc = false; @@ -258,11 +256,10 @@ int CVPCB_ASSOCIATION_TOOL::DeleteAll( const TOOL_EVENT& aEvent ) { // Remove all selections to avoid issues when setting the fpids m_frame->SetSelectedComponent( -1, true ); - std::vector idx = - m_frame->GetComponentIndices( CVPCB_MAINFRAME::ALL_COMPONENTS ); bool firstAssoc = true; - for( auto i : idx ) + + for( unsigned int i : m_frame->GetComponentIndices( CVPCB_MAINFRAME::ALL_COMPONENTS ) ) { m_frame->AssociateFootprint( CVPCB_ASSOCIATION( i, LIB_ID() ), firstAssoc ); firstAssoc = false; diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 2498671d0a..b919e8ca1b 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -832,7 +832,7 @@ void CONNECTION_GRAPH::resolveAllDrivers() return 0; // Special processing for some items - for( auto item : subgraph->m_items ) + for( SCH_ITEM* item : subgraph->m_items ) { switch( item->Type() ) { @@ -1237,7 +1237,7 @@ void CONNECTION_GRAPH::processSubGraphs() wxString test_name = member->Name( true ); - for( auto candidate : candidate_subgraphs ) + for( CONNECTION_SUBGRAPH* candidate : candidate_subgraphs ) { if( candidate->m_absorbed ) continue; @@ -2425,7 +2425,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSu SCH_ITEM* label = nullptr; SCH_ITEM* port = nullptr; - for( auto item : aSubgraph->m_items ) + for( SCH_ITEM* item : aSubgraph->m_items ) { switch( item->Type() ) { diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index e91acfe0b0..f0cb57f03b 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -60,7 +60,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wx { SCH_SCREEN* screen = sheet.LastScreen(); - for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) ) + for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) ) { SCH_SYMBOL* candidate = static_cast( item ); diff --git a/eeschema/dialogs/dialog_symbol_remap.cpp b/eeschema/dialogs/dialog_symbol_remap.cpp index 63db8e360a..fc22b944cd 100644 --- a/eeschema/dialogs/dialog_symbol_remap.cpp +++ b/eeschema/dialogs/dialog_symbol_remap.cpp @@ -251,7 +251,7 @@ void DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable( REPORTER& aReporter ) for( screen = schematic.GetFirst(); screen; screen = schematic.GetNext() ) { - for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) ) + for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) ) { symbol = dynamic_cast( item ); diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index b741312444..cf9e281f1c 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -990,7 +990,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs ) updateFileType = true; tmpFn.SetExt( KiCadSchematicFileExtension ); - for( auto item : screen->Items().OfType( SCH_SHEET_T ) ) + for( EDA_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) ) { SCH_SHEET* sheet = static_cast( item ); wxFileName sheetFileName = sheet->GetFileName(); diff --git a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp index b53022be4a..06913de8b2 100644 --- a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp @@ -69,7 +69,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, SCH_SHEET_PATH sheet = sheetList[i]; // Process symbol attributes - for( auto item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) ) + for( EDA_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) ) { SCH_SYMBOL* symbol = findNextSymbol( item, &sheet ); @@ -79,9 +79,10 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, CreatePinList( symbol, &sheet, true ); if( symbol->GetLibSymbolRef() - && symbol->GetLibSymbolRef()->GetFPFilters().GetCount() != 0 ) - cmpList.push_back( SCH_REFERENCE( symbol, symbol->GetLibSymbolRef().get(), - sheet ) ); + && symbol->GetLibSymbolRef()->GetFPFilters().GetCount() != 0 ) + { + cmpList.push_back( SCH_REFERENCE( symbol, symbol->GetLibSymbolRef().get(), sheet ) ); + } footprint = symbol->GetFootprint( &sheet, true ); footprint.Replace( wxT( " " ), wxT( "_" ) ); diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index b021a62a7a..5374f620d6 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -535,7 +535,7 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts() m_libraries.clear(); - for( auto lcomp : m_libParts ) + for( LIB_SYMBOL* lcomp : m_libParts ) { wxString libNickname = lcomp->GetLibId().GetLibNickname();; diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 53deb1e22f..62f942df03 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -68,7 +68,7 @@ static void getSymbols( SCHEMATIC* aSchematic, std::vector& aSymbol // Get the full list for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() ) { - for( auto aItem : screen->Items().OfType( SCH_SYMBOL_T ) ) + for( EDA_ITEM* aItem : screen->Items().OfType( SCH_SYMBOL_T ) ) aSymbols.push_back( static_cast( aItem ) ); } @@ -685,7 +685,7 @@ void LEGACY_RESCUER::OpenRescueLibrary() rescueLib->GetSymbols( symbols ); - for( auto symbol : symbols ) + for( LIB_SYMBOL* symbol : symbols ) { // The LIB_SYMBOL copy constructor flattens derived symbols (formerly known as aliases). m_rescue_lib->AddSymbol( new LIB_SYMBOL( *symbol, m_rescue_lib.get() ) ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp index c03f223f13..1f42547ae9 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp @@ -93,7 +93,7 @@ void SCH_SEXPR_PLUGIN_CACHE::Save( const std::optional& aOpt ) formatter->Print( 0, "(kicad_symbol_lib (version %d) (generator kicad_symbol_editor)\n", SEXPR_SYMBOL_LIB_FILE_VERSION ); - for( auto parent : m_symbols ) + for( const std::pair& parent : m_symbols ) { // Save the root symbol first so alias can inherit from them. if( parent.second->IsRoot() ) @@ -101,7 +101,7 @@ void SCH_SEXPR_PLUGIN_CACHE::Save( const std::optional& aOpt ) SaveSymbol( parent.second, *formatter.get(), 1 ); // Save all of the aliases associated with the current root symbol. - for( auto alias : m_symbols ) + for( const std::pair& alias : m_symbols ) { if( !alias.second->IsAlias() ) continue; @@ -218,7 +218,7 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& a return a.m_unit < b.m_unit; } ); - for( auto unit : units ) + for( const LIB_SYMBOL_UNIT& unit : units ) { // Add quotes and escape chars like ") to the UTF8 unitName string name = aFormatter.Quotes( unitName ); @@ -298,7 +298,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFOR { wxString tmp; - for( auto filter : fpFilters ) + for( const wxString& filter : fpFilters ) { // Spaces are not handled in fp filter names so escape spaces if any wxString curr_filter = EscapeString( filter, ESCAPE_CONTEXT::CTX_NO_SPACE ); diff --git a/eeschema/sch_plugins/sch_lib_plugin_cache.cpp b/eeschema/sch_plugins/sch_lib_plugin_cache.cpp index 812de32afd..1e97697c53 100644 --- a/eeschema/sch_plugins/sch_lib_plugin_cache.cpp +++ b/eeschema/sch_plugins/sch_lib_plugin_cache.cpp @@ -111,7 +111,7 @@ LIB_SYMBOL* SCH_LIB_PLUGIN_CACHE::removeSymbol( LIB_SYMBOL* aSymbol ) // the root symbol and make it the new root. if( aSymbol->IsRoot() ) { - for( auto entry : m_symbols ) + for( const std::pair& entry : m_symbols ) { if( entry.second->IsAlias() && entry.second->GetParent().lock() == aSymbol->SharedPtr() ) @@ -139,11 +139,13 @@ LIB_SYMBOL* SCH_LIB_PLUGIN_CACHE::removeSymbol( LIB_SYMBOL* aSymbol ) } // Reparent the remaining aliases. - for( auto entry : m_symbols ) + for( const std::pair& entry : m_symbols ) { if( entry.second->IsAlias() - && entry.second->GetParent().lock() == aSymbol->SharedPtr() ) + && entry.second->GetParent().lock() == aSymbol->SharedPtr() ) + { entry.second->SetParent( firstChild ); + } } } } diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index e1bddd99bf..9e4a4c45c9 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -100,7 +100,7 @@ SCHEMATIC* SCH_SCREEN::Schematic() const void SCH_SCREEN::clearLibSymbols() { - for( auto libSymbol : m_libSymbols ) + for( const std::pair& libSymbol : m_libSymbols ) delete libSymbol.second; m_libSymbols.clear(); @@ -529,9 +529,9 @@ TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& a case SCH_SYMBOL_T: { - auto symbol = static_cast( item ); - auto pins = symbol->GetPins( aSheet ); - for( auto pin : pins ) + SCH_SYMBOL* symbol = static_cast( item ); + + for( SCH_PIN* pin : symbol->GetPins( aSheet ) ) { if( pin->GetPosition() == aPosition ) { diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 82f0549873..ee6dddded2 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -723,14 +723,12 @@ bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList ) if( m_screen == aScreen ) return true; - for( auto item : m_screen->Items().OfType( SCH_SHEET_T ) ) + for( EDA_ITEM* item : m_screen->Items().OfType( SCH_SHEET_T ) ) { SCH_SHEET* sheet = static_cast( item ); if( sheet->LocatePathOfScreen( aScreen, aList ) ) - { return true; - } } aList->pop_back(); diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 2668700727..6b70b11c65 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -154,7 +154,7 @@ void SCH_SHEET_PATH::Rehash() { m_current_hash = 0; - for( auto sheet : m_sheets ) + for( SCH_SHEET* sheet : m_sheets ) boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() ); } diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index b575c43478..844dd3661f 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -179,7 +179,7 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol ) void SCH_VIEW::ClearHiddenFlags() { - for( auto item : *m_allItems ) + for( VIEW_ITEM* item : *m_allItems ) Hide( item, false ); } diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 3b008cf6b3..a95a7406c1 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include // LAST_PATH_TYPE #include @@ -96,7 +95,6 @@ public: Add( PCB_ACTIONS::drawSimilarZone ); } - protected: ACTION_MENU* create() const override { diff --git a/pcbnew/tools/board_reannotate_tool.cpp b/pcbnew/tools/board_reannotate_tool.cpp index 33887e32dc..772be73fcc 100644 --- a/pcbnew/tools/board_reannotate_tool.cpp +++ b/pcbnew/tools/board_reannotate_tool.cpp @@ -73,13 +73,13 @@ int BOARD_REANNOTATE_TOOL::ReannotateDuplicatesInSelection() } int BOARD_REANNOTATE_TOOL::ReannotateDuplicates( const PCB_SELECTION& aSelectionToReannotate, - const std::vector& aAdditionalFootprints ) + const std::vector& aAdditionalFootprints ) { if( aSelectionToReannotate.Empty() ) return 0; // 1. Build list of designators on the board & the additional footprints - FOOTPRINTS fpOnBoard = m_frame->GetBoard()->Footprints(); + FOOTPRINTS fpOnBoard = m_frame->GetBoard()->Footprints(); std::multimap usedDesignatorsMap; for( EDA_ITEM* item : aAdditionalFootprints ) diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index fcddf58319..07e58a5e63 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -691,7 +691,6 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent ) FOOTPRINT_EDIT_FRAME* fpEditor = dynamic_cast( m_frame ); FOOTPRINT* footprint = nullptr; PCB_LAYER_ID targetLayer = m_frame->GetActiveLayer(); - PCB_LAYER_ID copperLayer = F_Cu; BOARD_ITEM_CONTAINER* parent = frame->GetModel(); if( fpEditor ) @@ -738,12 +737,10 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent ) { if( !IsCopperLayer( targetLayer ) ) { - copperLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() ); + targetLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() ); - if( copperLayer == UNDEFINED_LAYER ) // User canceled + if( targetLayer == UNDEFINED_LAYER ) // User canceled return true; - - targetLayer = copperLayer; } } diff --git a/pcbnew/tools/drawing_stackup_table_tool.cpp b/pcbnew/tools/drawing_stackup_table_tool.cpp index a94241da58..7e4caff650 100644 --- a/pcbnew/tools/drawing_stackup_table_tool.cpp +++ b/pcbnew/tools/drawing_stackup_table_tool.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014-2017 CERN - * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,12 +27,8 @@ #include #include #include -#include -#include -#include #include #include -#include #include #include #include @@ -48,9 +44,8 @@ using SCOPED_DRAW_MODE = SCOPED_SET_RESET; static std::vector initTextTable( std::vector> aContent, - wxPoint origin, PCB_LAYER_ID aLayer, - wxPoint* aTableSize, - bool aDrawFrame = true ) + VECTOR2I origin, PCB_LAYER_ID aLayer, + VECTOR2I* aTableSize, bool aDrawFrame = true ) { int i; int j; @@ -58,7 +53,7 @@ static std::vector initTextTable( std::vector& col : aContent ) nbRows = std::max( nbRows, static_cast( col.size() ) ); // Limit the number of cells @@ -176,8 +171,8 @@ static std::vector initTextTable( std::vector& col : aContent ) { @@ -190,7 +185,6 @@ static std::vector initTextTable( std::vector= nbRows ) break; @@ -208,17 +202,18 @@ static std::vector initTextTable( std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& aOrigin, +std::vector DRAWING_TOOL::DrawSpecificationStackup( const VECTOR2I& aOrigin, PCB_LAYER_ID aLayer, bool aDrawNow, - wxPoint* tableSize ) + VECTOR2I* tableSize ) { BOARD_COMMIT commit( m_frame ); + FOOTPRINT* footprint = static_cast( m_frame->GetModel() ); + std::vector> texts; // Style : Header - std::unique_ptr headStyle = - std::make_unique( static_cast( m_frame->GetModel() ) ); + std::unique_ptr headStyle = std::make_unique( footprint ); headStyle->SetLayer( Eco1_User ); headStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); headStyle->SetTextThickness( Millimeter2iu( 0.3 ) ); @@ -229,8 +224,7 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); // Style : data - std::unique_ptr dataStyle = - std::make_unique( static_cast( m_frame->GetModel() ) ); + std::unique_ptr dataStyle = std::make_unique( footprint ); dataStyle->SetLayer( Eco1_User ); dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); dataStyle->SetTextThickness( Millimeter2iu( 0.1 ) ); @@ -317,7 +311,9 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& t->SetText( ly_name ); } else + { t->SetText( stackup_item->GetLayerName() ); + } colLayer.push_back( t ); @@ -371,17 +367,17 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& } -std::vector DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& aOrigin, +std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& aOrigin, PCB_LAYER_ID aLayer, bool aDrawNow, - wxPoint* tableSize ) + VECTOR2I* tableSize ) { BOARD_COMMIT commit( m_frame ); std::vector objects; BOARD_DESIGN_SETTINGS& settings = m_frame->GetBoard()->GetDesignSettings(); BOARD_STACKUP& stackup = settings.GetStackupDescriptor(); - wxPoint cursorPos = aOrigin; + VECTOR2I cursorPos = aOrigin; // Style : Section header std::unique_ptr headStyle = @@ -530,7 +526,7 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& texts.push_back( colbreak ); texts.push_back( colLabel2 ); texts.push_back( colData2 ); - wxPoint tableSize2 = wxPoint(); + VECTOR2I tableSize2; std::vector table = initTextTable( texts, cursorPos, Eco1_User, &tableSize2, false ); @@ -701,20 +697,16 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent, int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent ) { - wxPoint tableSize = wxPoint(); + VECTOR2I tableSize; - LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() ); - layerSet = static_cast( layerSet.set( Edge_Cuts ).set( Margin ) ); - layerSet = static_cast( layerSet.reset( F_Fab ).reset( B_Fab ) ); + LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() ); + layerSet = static_cast( layerSet.set( Edge_Cuts ).set( Margin ) ); + layerSet = static_cast( layerSet.reset( F_Fab ).reset( B_Fab ) ); - PCB_LAYER_ID layer = m_frame->GetActiveLayer(); - PCB_LAYER_ID savedLayer = layer; + PCB_LAYER_ID layer = m_frame->GetActiveLayer(); if( ( layerSet & LSET( layer ) ).count() ) // if layer is a forbidden layer - { m_frame->SetActiveLayer( Cmts_User ); - layer = Cmts_User; - } std::vector table = DrawBoardCharacteristics( wxPoint( 0, 0 ), m_frame->GetActiveLayer(), false, @@ -766,7 +758,7 @@ int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent ) items.push_back( static_cast( group ) ); if( InteractivePlaceWithPreview( aEvent, items, preview, &layerSet ) == -1 ) - m_frame->SetActiveLayer( savedLayer ); + m_frame->SetActiveLayer( layer ); else m_frame->SetActiveLayer( table.front()->GetLayer() ); @@ -776,11 +768,11 @@ int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent ) int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent ) { - wxPoint tableSize = wxPoint(); + VECTOR2I tableSize; - LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() ); - layerSet = static_cast( layerSet.set( Edge_Cuts ).set( Margin ) ); - layerSet = static_cast( layerSet.reset( F_Fab ).reset( B_Fab ) ); + LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() ); + layerSet = static_cast( layerSet.set( Edge_Cuts ).set( Margin ) ); + layerSet = static_cast( layerSet.reset( F_Fab ).reset( B_Fab ) ); PCB_LAYER_ID layer = m_frame->GetActiveLayer(); PCB_LAYER_ID savedLayer = layer; @@ -791,8 +783,9 @@ int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent ) layer = Cmts_User; } - std::vector table = DrawSpecificationStackup( - wxPoint( 0, 0 ), m_frame->GetActiveLayer(), false, &tableSize ); + std::vector table = DrawSpecificationStackup( VECTOR2I( 0, 0 ), + m_frame->GetActiveLayer(), false, + &tableSize ); std::vector preview; std::vector items; diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index c30d176333..1034834323 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -285,8 +285,7 @@ void DRAWING_TOOL::UpdateStatusBar() const else constrained = mgr.GetAppSettings()->m_Use45Limit; - m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" ) - : wxT( "" ) ); + m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" ) : wxT( "" ) ); } } diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index edd9837dc6..c75e507a4b 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -86,13 +86,13 @@ public: /** */ - std::vector DrawBoardCharacteristics( const wxPoint& origin, PCB_LAYER_ID aLayer, - bool aDrawNow, wxPoint* tablesize ); + std::vector DrawBoardCharacteristics( const VECTOR2I& origin, PCB_LAYER_ID aLayer, + bool aDrawNow, VECTOR2I* tablesize ); /** */ - std::vector DrawSpecificationStackup( const wxPoint& origin, PCB_LAYER_ID aLayer, - bool aDrawNow, wxPoint* tablesize ); + std::vector DrawSpecificationStackup( const VECTOR2I& origin, PCB_LAYER_ID aLayer, + bool aDrawNow, VECTOR2I* tablesize ); /** */ diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index d1977789b2..338713995a 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index a140e911c8..6cfffb7129 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -594,8 +594,8 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent ) if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() ) { msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ), - KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey() ) );} - + KeyNameFromKeyCode( PCB_ACTIONS::recombinePad.GetHotKey() ) ); + } else { msg.Printf( _( "Pad Edit Mode. Press %s to exit." ), diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 05a6511cd8..f9d2377f28 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -33,7 +33,6 @@ #include #include #include <3d_viewer/eda_3d_viewer_frame.h> -#include #include #include #include @@ -57,8 +56,6 @@ #include #include #include -#include -#include #include #include #include @@ -171,7 +168,7 @@ int PCB_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent ) for( PCB_TRACK* track : board()->Tracks() ) { - if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T ) + if( track->Type() == PCB_VIA_T ) view()->Update( track, KIGFX::REPAINT ); } @@ -587,11 +584,9 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); if( m_isFootprintEditor ) - collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, - (wxPoint) aPos, guide ); + collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide ); else - collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, - (wxPoint) aPos, guide ); + collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide ); // Remove unselectable items for( int i = collector.GetCount() - 1; i >= 0; --i ) @@ -607,7 +602,6 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) if( m_pickerItem != item ) { - if( m_pickerItem ) selectionTool->UnbrightenItem( m_pickerItem ); @@ -714,12 +708,12 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) ) return 0; - PASTE_MODE pasteMode = PASTE_MODE::KEEP_ANNOTATIONS; + PASTE_MODE mode = PASTE_MODE::KEEP_ANNOTATIONS; const wxString defaultRef = wxT( "REF**" ); if( aEvent.IsAction( &ACTIONS::pasteSpecial ) ) { - DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode, defaultRef ); + DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef ); if( dlg.ShowModal() == wxID_CANCEL ) return 0; @@ -803,18 +797,17 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) delete clipBoard; - placeBoardItems( pastedItems, true, true, - pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS ); + placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS ); } else { - if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS ) + if( mode == PASTE_MODE::REMOVE_ANNOTATIONS ) { for( FOOTPRINT* clipFootprint : clipBoard->Footprints() ) clipFootprint->SetReference( defaultRef ); } - placeBoardItems( clipBoard, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS ); + placeBoardItems( clipBoard, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS ); m_frame->GetBoard()->BuildConnectivity(); m_frame->Compile_Ratsnest( true ); @@ -835,14 +828,14 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) } else { - if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS ) + if( mode == PASTE_MODE::REMOVE_ANNOTATIONS ) clipFootprint->SetReference( defaultRef ); clipFootprint->SetParent( board() ); pastedItems.push_back( clipFootprint ); } - placeBoardItems( pastedItems, true, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS ); + placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS ); break; } @@ -1260,11 +1253,12 @@ int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) if( overlap.count() > 0 && ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) ) { - constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, - overlap.CuStack().front() ); + PCB_LAYER_ID layer = overlap.CuStack().front(); - std::shared_ptr a_shape( a_conn->GetEffectiveShape( overlap.CuStack().front() ) ); - std::shared_ptr b_shape( b_conn->GetEffectiveShape( overlap.CuStack().front() ) ); + constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer ); + + std::shared_ptr a_shape( a_conn->GetEffectiveShape( layer ) ); + std::shared_ptr b_shape( b_conn->GetEffectiveShape( layer ) ); int actual_clearance = a_shape->GetClearance( b_shape.get() );