From e2aa7be4b33688f5a88bd8e50bd357ad87ad3e1f Mon Sep 17 00:00:00 2001 From: Dominik Wernberger Date: Sat, 6 Mar 2021 10:27:41 +0100 Subject: [PATCH] Added a lot of consts and refactored a few lines --- .../3d_rendering/legacy/create_scene.cpp | 85 ++++---- common/bitmap_base.cpp | 2 +- common/eda_text.cpp | 12 +- common/filename_resolver.cpp | 23 +-- common/gal/opengl/opengl_gal.cpp | 4 +- common/rc_item.cpp | 6 +- common/tool/tool_manager.cpp | 24 +-- common/undo_redo_container.cpp | 4 +- common/widgets/mathplot.cpp | 175 ++++++++-------- cvpcb/cvpcb_mainframe.cpp | 4 +- cvpcb/cvpcb_mainframe.h | 4 +- eeschema/component_references_lister.cpp | 14 +- .../dialogs/dialog_edit_components_libid.cpp | 6 +- eeschema/erc_settings.cpp | 16 +- eeschema/erc_settings.h | 10 +- eeschema/lib_arc.cpp | 2 +- eeschema/lib_arc.h | 2 +- eeschema/lib_bezier.cpp | 2 +- eeschema/lib_bezier.h | 2 +- eeschema/lib_circle.cpp | 2 +- eeschema/lib_circle.h | 2 +- eeschema/lib_field.cpp | 4 +- eeschema/lib_field.h | 4 +- eeschema/lib_item.h | 2 +- eeschema/lib_pin.cpp | 14 +- eeschema/lib_pin.h | 8 +- eeschema/lib_polyline.cpp | 2 +- eeschema/lib_polyline.h | 2 +- eeschema/lib_rectangle.cpp | 2 +- eeschema/lib_rectangle.h | 2 +- eeschema/lib_symbol.cpp | 20 +- eeschema/lib_symbol.h | 20 +- eeschema/lib_text.cpp | 2 +- eeschema/lib_text.h | 2 +- eeschema/sch_bitmap.cpp | 2 +- eeschema/sch_bitmap.h | 2 +- eeschema/sch_bus_entry.cpp | 6 +- eeschema/sch_bus_entry.h | 2 +- eeschema/sch_edit_frame.cpp | 4 +- eeschema/sch_edit_frame.h | 6 +- eeschema/sch_field.cpp | 2 +- eeschema/sch_field.h | 2 +- eeschema/sch_item.cpp | 2 +- eeschema/sch_item.h | 6 +- eeschema/sch_junction.cpp | 2 +- eeschema/sch_junction.h | 2 +- eeschema/sch_line.cpp | 2 +- eeschema/sch_line.h | 2 +- eeschema/sch_marker.h | 3 +- eeschema/sch_no_connect.cpp | 2 +- eeschema/sch_no_connect.h | 2 +- .../sch_plugins/legacy/sch_legacy_plugin.cpp | 6 +- eeschema/sch_reference_list.h | 14 +- eeschema/sch_rtree.h | 8 +- eeschema/sch_screen.cpp | 44 ++-- eeschema/sch_screen.h | 35 ++-- eeschema/sch_sheet.cpp | 2 +- eeschema/sch_sheet.h | 4 +- eeschema/sch_sheet_path.cpp | 8 +- eeschema/sch_sheet_path.h | 8 +- eeschema/sch_sheet_pin.cpp | 21 +- eeschema/sch_symbol.cpp | 2 +- eeschema/sch_symbol.h | 2 +- eeschema/sch_text.cpp | 23 ++- eeschema/sch_text.h | 12 +- include/bitmap_base.h | 2 +- include/board_item.h | 4 +- include/eda_draw_frame.h | 2 +- include/filename_resolver.h | 12 +- include/footprint_info.h | 5 +- include/hashtables.h | 6 +- include/multivector.h | 2 +- include/pcb_base_frame.h | 2 +- include/rc_item.h | 6 +- include/tool/tool_manager.h | 28 +-- include/widgets/mathplot.h | 194 +++++++++--------- libs/kimath/include/geometry/shape_poly_set.h | 22 +- libs/kimath/src/geometry/shape_compound.cpp | 2 +- libs/kimath/src/geometry/shape_poly_set.cpp | 6 +- pcb_calculator/params_read_write.cpp | 4 +- pcb_calculator/pcb_calculator_frame.h | 4 +- pcb_calculator/transline_ident.h | 6 +- pcbnew/board.cpp | 38 ++-- pcbnew/board.h | 26 +-- ...board_items_to_polygon_shape_transform.cpp | 34 +-- pcbnew/cleanup_item.h | 4 +- pcbnew/connectivity/from_to_cache.cpp | 8 +- pcbnew/dialogs/dialog_board_statistics.cpp | 18 +- pcbnew/dimension.cpp | 4 +- pcbnew/dimension.h | 8 +- pcbnew/drc/drc_results_provider.h | 8 +- pcbnew/drc/drc_rtree.h | 6 +- pcbnew/footprint.cpp | 4 +- pcbnew/pcb_base_frame.cpp | 2 +- pcbnew/pcb_painter.cpp | 34 +-- pcbnew/pcbplot.cpp | 10 +- pcbnew/pcbplot.h | 40 ++-- pcbnew/plot_board_layers.cpp | 26 +-- pcbnew/plot_brditems_plotter.cpp | 54 ++--- pcbnew/tools/edit_tool.cpp | 2 +- pcbnew/tools/zone_create_helper.cpp | 2 +- pcbnew/tools/zone_create_helper.h | 4 +- 102 files changed, 673 insertions(+), 689 deletions(-) diff --git a/3d-viewer/3d_rendering/legacy/create_scene.cpp b/3d-viewer/3d_rendering/legacy/create_scene.cpp index 695a3bbf1a..90639b9392 100644 --- a/3d-viewer/3d_rendering/legacy/create_scene.cpp +++ b/3d-viewer/3d_rendering/legacy/create_scene.cpp @@ -168,7 +168,7 @@ void RENDER_3D_LEGACY::addObjectTriangles( const ROUND_SEGMENT_2D* aSeg, const SFVEC2F& rightStart = aSeg->GetRightStar(); const SFVEC2F& rightEnd = aSeg->GetRightEnd(); const SFVEC2F& rightDir = aSeg->GetRightDir(); - const float radius = aSeg->GetRadius(); + const float radius = aSeg->GetRadius(); const SFVEC2F& start = aSeg->GetStart(); const SFVEC2F& end = aSeg->GetEnd(); @@ -176,7 +176,7 @@ void RENDER_3D_LEGACY::addObjectTriangles( const ROUND_SEGMENT_2D* aSeg, const float texture_factor = ( 12.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f; const float texture_factorF = ( 6.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f; - const float radius_of_the_square = sqrtf( aSeg->GetRadiusSquared() * 2.0f ); + const float radius_of_the_square = sqrtf( aSeg->GetRadiusSquared() * 2.0f ); const float radius_triangle_factor = ( radius_of_the_square - radius ) / radius; const SFVEC2F factorS = SFVEC2F( -rightDir.y * radius * radius_triangle_factor, @@ -255,11 +255,9 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generateHoles( const LIST_OBJECT2D& aListH new TRIANGLE_DISPLAY_LIST( aListHolesObject2d.size() * 2 ); // Convert the list of objects(filled circles) to triangle layer structure - for( LIST_OBJECT2D::const_iterator itemOnLayer = aListHolesObject2d.begin(); - itemOnLayer != aListHolesObject2d.end(); - ++itemOnLayer ) + for( const OBJECT_2D* itemOnLayer : aListHolesObject2d ) { - const OBJECT_2D* object2d_A = static_cast( *itemOnLayer ); + const OBJECT_2D* object2d_A = itemOnLayer; wxASSERT( ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::FILLED_CIRCLE ) || ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::ROUNDSEG ) ); @@ -327,37 +325,35 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generateLayerList( const BVH_CONTAINER_2D* m_triangles.push_back( layerTriangles ); // Load the 2D (X,Y axis) component of shapes - for( LIST_OBJECT2D::const_iterator itemOnLayer = listObject2d.begin(); - itemOnLayer != listObject2d.end(); - ++itemOnLayer ) + for( const OBJECT_2D* itemOnLayer : listObject2d ) { - const OBJECT_2D* object2d_A = static_cast( *itemOnLayer ); + const OBJECT_2D* object2d_A = itemOnLayer; switch( object2d_A->GetObjectType() ) { case OBJECT_2D_TYPE::FILLED_CIRCLE: - addObjectTriangles( (const FILLED_CIRCLE_2D *)object2d_A, layerTriangles, - layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d_A ), + layerTriangles, layer_z_top, layer_z_bot ); break; case OBJECT_2D_TYPE::POLYGON4PT: - addObjectTriangles( (const POLYGON_4PT_2D*)object2d_A, layerTriangles, - layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d_A ), + layerTriangles, layer_z_top, layer_z_bot ); break; case OBJECT_2D_TYPE::RING: - addObjectTriangles( (const RING_2D*)object2d_A, layerTriangles, layer_z_top, - layer_z_bot ); + addObjectTriangles( static_cast( object2d_A ), + layerTriangles, layer_z_top, layer_z_bot ); break; case OBJECT_2D_TYPE::TRIANGLE: - addObjectTriangles( (const TRIANGLE_2D*)object2d_A, layerTriangles, layer_z_top, - layer_z_bot ); + addObjectTriangles( static_cast( object2d_A ), + layerTriangles, layer_z_top, layer_z_bot ); break; case OBJECT_2D_TYPE::ROUNDSEG: - addObjectTriangles( (const ROUND_SEGMENT_2D*) object2d_A, layerTriangles, - layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d_A ), + layerTriangles, layer_z_top, layer_z_bot ); break; default: @@ -366,7 +362,7 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generateLayerList( const BVH_CONTAINER_2D* } } - if( aPolyList &&aPolyList->OutlineCount() > 0 ) + if( aPolyList && aPolyList->OutlineCount() > 0 ) { layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top, m_boardAdapter.BiuTo3dUnits(), false, aThroughHoles ); @@ -401,15 +397,13 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::createBoard( const SHAPE_POLY_SET& aBoardP new TRIANGLE_DISPLAY_LIST( listBoardObject2d.size() ); // Convert the list of objects(triangles) to triangle layer structure - for( LIST_OBJECT2D::const_iterator itemOnLayer = listBoardObject2d.begin(); - itemOnLayer != listBoardObject2d.end(); - ++itemOnLayer ) + for( const OBJECT_2D* itemOnLayer : listBoardObject2d ) { - const OBJECT_2D* object2d_A = static_cast( *itemOnLayer ); + const OBJECT_2D* object2d_A = itemOnLayer; wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE ); - const TRIANGLE_2D* tri = (const TRIANGLE_2D *)object2d_A; + const TRIANGLE_2D* tri = static_cast( object2d_A ); const SFVEC2F& v1 = tri->GetP1(); const SFVEC2F& v2 = tri->GetP2(); @@ -520,10 +514,10 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo float layer_z_bot = 0.0f; float layer_z_top = 0.0f; - for( MAP_POLY::const_iterator ii = outerMapHoles.begin(); ii != outerMapHoles.end(); ++ii ) + for( const auto ii : outerMapHoles ) { - PCB_LAYER_ID layer_id = static_cast(ii->first); - const SHAPE_POLY_SET* poly = static_cast( ii->second ); + const PCB_LAYER_ID layer_id = ii.first; + const SHAPE_POLY_SET* poly = ii.second; const BVH_CONTAINER_2D* container = map_holes.at( layer_id ); getLayerZPos( layer_id, layer_z_top, layer_z_bot ); @@ -532,10 +526,10 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo layer_z_top, layer_z_bot, false ); } - for( MAP_POLY::const_iterator ii = innerMapHoles.begin(); ii != innerMapHoles.end(); ++ii ) + for( const auto ii : innerMapHoles ) { - PCB_LAYER_ID layer_id = static_cast( ii->first ); - const SHAPE_POLY_SET* poly = static_cast( ii->second ); + const PCB_LAYER_ID layer_id = ii.first; + const SHAPE_POLY_SET* poly = ii.second; const BVH_CONTAINER_2D* container = map_holes.at( layer_id ); getLayerZPos( layer_id, layer_z_top, layer_z_bot ); @@ -554,16 +548,14 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap(); - for( MAP_CONTAINER_2D_BASE::const_iterator ii = m_boardAdapter.GetLayerMap().begin(); - ii != m_boardAdapter.GetLayerMap().end(); - ++ii ) + for( const auto ii : m_boardAdapter.GetLayerMap() ) { - PCB_LAYER_ID layer_id = static_cast( ii->first ); + const PCB_LAYER_ID layer_id = ii.first; if( !m_boardAdapter.Is3dLayerEnabled( layer_id ) ) continue; - const BVH_CONTAINER_2D* container2d = static_cast( ii->second ); + const BVH_CONTAINER_2D* container2d = ii.second; SHAPE_POLY_SET polyListSubtracted; SHAPE_POLY_SET* aPolyList = nullptr; @@ -601,7 +593,6 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ), SHAPE_POLY_SET::PM_FAST ); } - } } @@ -730,7 +721,7 @@ void RENDER_3D_LEGACY::generateCylinder( const SFVEC2F& aCenter, float aInnerRad void RENDER_3D_LEGACY::generateViasAndPads() { - if( m_boardAdapter.GetViaCount() ) + if( m_boardAdapter.GetViaCount() > 0 ) { const unsigned int reserve_nr_triangles_estimation = m_boardAdapter.GetCircleSegmentCount( @@ -743,11 +734,11 @@ void RENDER_3D_LEGACY::generateViasAndPads() // Insert plated vertical holes inside the board // Insert vias holes (vertical cylinders) - for( auto track : m_boardAdapter.GetBoard()->Tracks() ) + for( const TRACK* track : m_boardAdapter.GetBoard()->Tracks() ) { if( track->Type() == PCB_VIA_T ) { - const VIA* via = static_cast(track); + const VIA* via = static_cast( track ); const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits(); const float thickness = m_boardAdapter.GetCopperThickness(); @@ -789,7 +780,7 @@ void RENDER_3D_LEGACY::generateViasAndPads() // Insert pads holes (vertical cylinders) for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() ) { - for( PAD* pad : footprint->Pads() ) + for( const PAD* pad : footprint->Pads() ) { if( pad->GetAttribute() != PAD_ATTRIB_NPTH ) { @@ -835,15 +826,13 @@ void RENDER_3D_LEGACY::generateViasAndPads() new TRIANGLE_DISPLAY_LIST( listHolesObject2d.size() ); // Convert the list of objects(triangles) to triangle layer structure - for( LIST_OBJECT2D::const_iterator itemOnLayer = listHolesObject2d.begin(); - itemOnLayer != listHolesObject2d.end(); - ++itemOnLayer ) + for( const OBJECT_2D* itemOnLayer : listHolesObject2d ) { - const OBJECT_2D* object2d_A = static_cast( *itemOnLayer ); + const OBJECT_2D* object2d_A = itemOnLayer; wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE ); - const TRIANGLE_2D* tri = (const TRIANGLE_2D *)object2d_A; + const TRIANGLE_2D* tri = static_cast( object2d_A ); const SFVEC2F& v1 = tri->GetP1(); const SFVEC2F& v2 = tri->GetP2(); @@ -880,7 +869,7 @@ void RENDER_3D_LEGACY::load3dModels( REPORTER* aStatusReporter ) } // Go for all footprints - for( FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() ) + for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() ) { for( const FP_3DMODEL& model : footprint->Models() ) { diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp index 2210d63e86..717fd51017 100644 --- a/common/bitmap_base.cpp +++ b/common/bitmap_base.cpp @@ -340,7 +340,7 @@ void BITMAP_BASE::Rotate( bool aRotateCCW ) void BITMAP_BASE::PlotImage( PLOTTER* aPlotter, const wxPoint& aPos, COLOR4D aDefaultColor, - int aDefaultPensize ) + int aDefaultPensize ) const { if( m_image == NULL ) return; diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 622ab66f64..7745bdc03f 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -70,7 +70,7 @@ EDA_TEXT_HJUSTIFY_T EDA_TEXT::MapHorizJustify( int aHorizJustify ) if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT ) return GR_TEXT_HJUSTIFY_LEFT; - return (EDA_TEXT_HJUSTIFY_T) aHorizJustify; + return static_cast( aHorizJustify ); } @@ -84,13 +84,13 @@ EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify( int aVertJustify ) if( aVertJustify < GR_TEXT_VJUSTIFY_TOP ) return GR_TEXT_VJUSTIFY_TOP; - return (EDA_TEXT_VJUSTIFY_T) aVertJustify; + return static_cast( aVertJustify ); } EDA_TEXT::EDA_TEXT( const wxString& text ) : m_text( text ), - m_e( 1<& aPathList ) +bool FILENAME_RESOLVER::UpdatePathList( const std::vector< SEARCH_PATH >& aPathList ) { wxUniChar envMarker( '$' ); while( !m_paths.empty() && envMarker != *m_paths.back().m_Alias.rbegin() ) m_paths.pop_back(); - size_t nI = aPathList.size(); - - for( size_t i = 0; i < nI; ++i ) - addPath( aPathList[i] ); + for( const SEARCH_PATH& path : aPathList ) + addPath( path ); return writePathList(); } @@ -471,7 +469,6 @@ bool FILENAME_RESOLVER::addPath( const SEARCH_PATH& aPath ) #endif } - wxString pname = path.GetPath(); std::list< SEARCH_PATH >::iterator sPL = m_paths.begin(); std::list< SEARCH_PATH >::iterator ePL = m_paths.end(); @@ -822,14 +819,14 @@ wxString FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName ) -const std::list< SEARCH_PATH >* FILENAME_RESOLVER::GetPaths() +const std::list< SEARCH_PATH >* FILENAME_RESOLVER::GetPaths() const { return &m_paths; } bool FILENAME_RESOLVER::SplitAlias( const wxString& aFileName, - wxString& anAlias, wxString& aRelPath ) + wxString& anAlias, wxString& aRelPath ) const { anAlias.clear(); aRelPath.clear(); @@ -839,7 +836,7 @@ bool FILENAME_RESOLVER::SplitAlias( const wxString& aFileName, size_t tagpos = aFileName.find( wxT( ":" ), 1 ); - if( wxString::npos == tagpos || 1 == tagpos ) + if( wxString::npos == tagpos || 1 == tagpos ) return false; if( tagpos + 1 >= aFileName.length() ) @@ -947,7 +944,7 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& } -bool FILENAME_RESOLVER::ValidateFileName( const wxString& aFileName, bool& hasAlias ) +bool FILENAME_RESOLVER::ValidateFileName( const wxString& aFileName, bool& hasAlias ) const { // Rules: // 1. The generic form of an aliased 3D relative path is: @@ -1005,7 +1002,7 @@ bool FILENAME_RESOLVER::ValidateFileName( const wxString& aFileName, bool& hasAl } -bool FILENAME_RESOLVER::GetKicadPaths( std::list< wxString >& paths ) +bool FILENAME_RESOLVER::GetKicadPaths( std::list< wxString >& paths ) const { paths.clear(); diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 33d3ed7b3e..f833ae7769 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -111,8 +111,8 @@ private: GL_BITMAP_CACHE::~GL_BITMAP_CACHE() { - for( auto b = m_bitmaps.begin(); b != m_bitmaps.end(); ++b ) - glDeleteTextures( 1, &b->second.id ); + for( auto& bitmap : m_bitmaps ) + glDeleteTextures( 1, &bitmap.second.id ); } diff --git a/common/rc_item.cpp b/common/rc_item.cpp index fb777a36e5..4ab406ad15 100644 --- a/common/rc_item.cpp +++ b/common/rc_item.cpp @@ -412,7 +412,7 @@ bool RC_TREE_MODEL::GetAttr( wxDataViewItem const& aItem, } -void RC_TREE_MODEL::ValueChanged( RC_TREE_NODE* aNode ) +void RC_TREE_MODEL::ValueChanged( const RC_TREE_NODE* aNode ) { if( aNode->m_Type == RC_TREE_NODE::MAIN_ITEM || aNode->m_Type == RC_TREE_NODE::AUX_ITEM ) { @@ -423,7 +423,7 @@ void RC_TREE_MODEL::ValueChanged( RC_TREE_NODE* aNode ) { wxDataViewModel::ValueChanged( ToItem( aNode ), 0 ); - for( RC_TREE_NODE* child : aNode->m_Children ) + for( const RC_TREE_NODE* child : aNode->m_Children ) wxDataViewModel::ValueChanged( ToItem( child ), 0 ); } } @@ -437,7 +437,7 @@ void RC_TREE_MODEL::DeleteCurrentItem( bool aDeep ) void RC_TREE_MODEL::DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, bool aDeep ) { - RC_TREE_NODE* current_node = ToNode( m_view->GetCurrentItem() ); + RC_TREE_NODE* current_node = ToNode( m_view->GetCurrentItem() ); const std::shared_ptr current_item = current_node ? current_node->m_RcItem : nullptr; /// Keep a vector of elements to free after wxWidgets is definitely done accessing them diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 2cfa07fe35..8ab846ab2c 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -293,7 +293,7 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* a } -VECTOR2D TOOL_MANAGER::GetMousePosition() +VECTOR2D TOOL_MANAGER::GetMousePosition() const { if( m_viewControls ) return m_viewControls->GetMousePosition(); @@ -302,7 +302,7 @@ VECTOR2D TOOL_MANAGER::GetMousePosition() } -VECTOR2D TOOL_MANAGER::GetCursorPosition() +VECTOR2D TOOL_MANAGER::GetCursorPosition() const { if( m_viewControls ) return m_viewControls->GetCursorPosition(); @@ -361,13 +361,13 @@ void TOOL_MANAGER::PrimeTool( const VECTOR2D& aPosition ) } -const std::map& TOOL_MANAGER::GetActions() +const std::map& TOOL_MANAGER::GetActions() const { return m_actionMgr->GetActions(); } -int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) +int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const { return m_actionMgr->GetHotKey( aAction ); } @@ -475,7 +475,7 @@ void TOOL_MANAGER::ShutdownTool( TOOL_BASE* aTool ) if( isActive( aTool ) ) { - auto it = std::find( m_activeTools.begin(), m_activeTools.end(), id ); + TOOL_MANAGER::ID_LIST::iterator it = std::find( m_activeTools.begin(), m_activeTools.end(), id ); TOOL_STATE* st = m_toolIdIndex[*it]; @@ -644,7 +644,7 @@ TOOL_EVENT* TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool, const TOOL_EVENT_LIST& } -bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent ) +bool TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) { bool handled = false; @@ -676,7 +676,7 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent ) if( st && st->cofunc && st->pendingWait && st->waitEvents.Matches( aEvent ) ) { if( !aEvent.FirstResponder() ) - const_cast( &aEvent )->SetFirstResponder( st->theTool ); + aEvent.SetFirstResponder( st->theTool ); // got matching event? clear wait list and wake up the coroutine st->wakeupEvent = aEvent; @@ -711,7 +711,7 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent ) ++it; } - for( auto& state : m_toolState ) + for( const auto& state : m_toolState ) { TOOL_STATE* st = state.second; bool finished = false; @@ -720,14 +720,14 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent ) // Go() method that match the event. if( !st->transitions.empty() ) { - for( TRANSITION& tr : st->transitions ) + for( const TRANSITION& tr : st->transitions ) { if( tr.first.Matches( aEvent ) ) { auto func_copy = tr.second; if( !aEvent.FirstResponder() ) - const_cast( &aEvent )->SetFirstResponder( st->theTool ); + aEvent.SetFirstResponder( st->theTool ); // if there is already a context, then push it on the stack // and transfer the previous view control settings to the new context @@ -1040,7 +1040,7 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView, } -bool TOOL_MANAGER::isActive( TOOL_BASE* aTool ) +bool TOOL_MANAGER::isActive( TOOL_BASE* aTool ) const { if( !isRegistered( aTool ) ) return false; @@ -1090,7 +1090,7 @@ void TOOL_MANAGER::saveViewControls( TOOL_STATE* aState ) } -void TOOL_MANAGER::applyViewControls( TOOL_STATE* aState ) +void TOOL_MANAGER::applyViewControls( const TOOL_STATE* aState ) { m_viewControls->ApplySettings( aState->vcSettings ); } diff --git a/common/undo_redo_container.cpp b/common/undo_redo_container.cpp index 8cdfa4bdd0..5b36a6fa1b 100644 --- a/common/undo_redo_container.cpp +++ b/common/undo_redo_container.cpp @@ -89,9 +89,9 @@ ITEM_PICKER PICKED_ITEMS_LIST::PopItem() bool PICKED_ITEMS_LIST::ContainsItem( const EDA_ITEM* aItem ) const { - for( size_t i = 0; i < m_ItemsList.size(); i++ ) + for( const ITEM_PICKER& picker : m_ItemsList ) { - if( m_ItemsList[ i ].GetItem() == aItem ) + if( picker.GetItem() == aItem ) return true; } diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index e5ba6872ae..89121c0049 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -80,7 +80,7 @@ mpLayer::mpLayer() : m_type( mpLAYER_UNDEF ) } -wxBitmap mpLayer::GetColourSquare( int side ) +wxBitmap mpLayer::GetColourSquare( int side ) const { wxBitmap square( side, side, -1 ); wxColour filler = m_pen.GetColour(); @@ -193,13 +193,13 @@ void mpInfoLayer::Plot( wxDC& dc, mpWindow& w ) } -wxPoint mpInfoLayer::GetPosition() +wxPoint mpInfoLayer::GetPosition() const { return m_dim.GetPosition(); } -wxSize mpInfoLayer::GetSize() +wxSize mpInfoLayer::GetSize() const { return m_dim.GetSize(); } @@ -963,11 +963,11 @@ mpScaleBase::mpScaleBase() } #if 0 -int mpScaleBase::getLabelDecimalDigits( int maxDigits ) +int mpScaleBase::getLabelDecimalDigits( int maxDigits ) const { int m = 0; - for( auto l : m_tickLabels ) + for( const TickLabel& l : m_tickLabels ) { int k = countDecimalDigits( l.pos ); m = std::max( k, m ); @@ -975,9 +975,7 @@ int mpScaleBase::getLabelDecimalDigits( int maxDigits ) return std::min( m, maxDigits ); } - - -#endif +#endif // 0 void mpScaleBase::computeLabelExtents( wxDC& dc, mpWindow& w ) { @@ -1069,9 +1067,8 @@ double mpScaleX::getLabelPos( int n ) { return 0; // return m_labeledTicks[n]; } +#endif // 0 - -#endif void mpScaleY::getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) { wxCoord minYpx = m_drawOutsideMargins ? 0 : w.GetMarginTop(); @@ -2035,7 +2032,7 @@ void mpWindow::Fit( double xMin, double xMax, double yMin, double yMax, yMin -= yExtra; yMax += yExtra; - if( printSizeX!=NULL && printSizeY!=NULL ) + if( printSizeX != NULL && printSizeY != NULL ) { // Printer: m_scrX = *printSizeX; @@ -2052,8 +2049,8 @@ void mpWindow::Fit( double xMin, double xMax, double yMin, double yMax, Ax = xMax - xMin; Ay = yMax - yMin; - m_scaleX = (Ax!=0) ? (m_scrX - m_marginLeft - m_marginRight) / Ax : 1; // m_scaleX = (Ax!=0) ? m_scrX/Ax : 1; - m_scaleY = (Ay!=0) ? (m_scrY - m_marginTop - m_marginBottom) / Ay : 1; // m_scaleY = (Ay!=0) ? m_scrY/Ay : 1; + m_scaleX = (Ax != 0) ? (m_scrX - m_marginLeft - m_marginRight) / Ax : 1; // m_scaleX = (Ax != 0) ? m_scrX / Ax : 1; + m_scaleY = (Ay != 0) ? (m_scrY - m_marginTop - m_marginBottom) / Ay : 1; // m_scaleY = (Ay != 0) ? m_scrY / Ay : 1; if( m_lockaspect ) { @@ -2076,7 +2073,7 @@ void mpWindow::Fit( double xMin, double xMax, double yMin, double yMax, // It is VERY IMPORTANT to DO NOT call Refresh if we are drawing to the printer!! // Otherwise, the DC dimensions will be those of the window instead of the printer device - if( printSizeX==NULL || printSizeY==NULL ) + if( printSizeX == NULL || printSizeY == NULL ) UpdateAll(); } @@ -2495,7 +2492,7 @@ void mpWindow::OnPaint( wxPaintEvent& WXUNUSED( event ) ) // J.L.Blanco @ Aug 2007: Added double buffer support if( m_enableDoubleBuffer ) { - if( m_last_lx!=m_scrX || m_last_ly!=m_scrY ) + if( m_last_lx != m_scrX || m_last_ly != m_scrY ) { if( m_buff_bmp ) delete m_buff_bmp; @@ -2921,7 +2918,7 @@ void mpWindow::OnScrollBottom( wxScrollWinEvent& event ) void mpWindow::SetScaleX( double scaleX ) { - if( scaleX!=0 ) + if( scaleX != 0 ) m_scaleX = scaleX; UpdateAll(); @@ -2930,25 +2927,21 @@ void mpWindow::SetScaleX( double scaleX ) // New methods implemented by Davide Rondini -unsigned int mpWindow::CountLayers() +unsigned int mpWindow::CountLayers() const { - // wxNode *node = m_layers.GetFirst(); unsigned int layerNo = 0; - for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ ) // while(node) + for( const mpLayer* layer : m_layers ) { - if( (*li)->HasBBox() ) + if( layer->HasBBox() ) layerNo++; - - // node = node->GetNext(); } - ; return layerNo; } -mpLayer* mpWindow::GetLayer( int position ) +mpLayer* mpWindow::GetLayer( int position ) const { if( ( position >= (int) m_layers.size() ) || position < 0 ) return NULL; @@ -2957,18 +2950,17 @@ mpLayer* mpWindow::GetLayer( int position ) } -mpLayer* mpWindow::GetLayerByName( const wxString& name ) +const mpLayer* mpWindow::GetLayerByName( const wxString& name ) const { - for( wxLayerList::iterator it = m_layers.begin(); it!=m_layers.end(); it++ ) - if( !(*it)->GetName().Cmp( name ) ) - return *it; - + for( const mpLayer* layer : m_layers ) + if( !layer->GetName().Cmp( name ) ) + return layer; return NULL; // Not found } -void mpWindow::GetBoundingBox( double* bbox ) +void mpWindow::GetBoundingBox( double* bbox ) const { bbox[0] = m_minX; bbox[1] = m_maxX; @@ -3016,10 +3008,8 @@ bool mpWindow::SaveScreenshot( const wxString& filename, wxBitmapType type, } // Draw all the layers: - wxLayerList::iterator li; - - for( li = m_layers.begin(); li != m_layers.end(); li++ ) - (*li)->Plot( screenDC, *this ); + for( mpLayer* layer : m_layers ) + layer->Plot( screenDC, *this ); if( imageSize != wxDefaultSize ) { @@ -3037,22 +3027,20 @@ bool mpWindow::SaveScreenshot( const wxString& filename, wxBitmapType type, void mpWindow::SetMargins( int top, int right, int bottom, int left ) { - m_marginTop = top; - m_marginRight = right; - m_marginBottom = bottom; - m_marginLeft = left; + m_marginTop = top; + m_marginRight = right; + m_marginBottom = bottom; + m_marginLeft = left; } mpInfoLayer* mpWindow::IsInsideInfoLayer( wxPoint& point ) { - wxLayerList::iterator li; - - for( li = m_layers.begin(); li != m_layers.end(); li++ ) + for( mpLayer* layer : m_layers ) { - if( (*li)->IsInfo() ) + if( layer->IsInfo() ) { - mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li); + mpInfoLayer* tmpLyr = static_cast( layer ); if( tmpLyr->Inside( point ) ) { @@ -3077,11 +3065,11 @@ void mpWindow::SetLayerVisible( const wxString& name, bool viewable ) } -bool mpWindow::IsLayerVisible( const wxString& name ) +bool mpWindow::IsLayerVisible( const wxString& name ) const { - mpLayer* lx = GetLayerByName( name ); + const mpLayer* lx = GetLayerByName( name ); - return (lx) ? lx->IsVisible() : false; + return lx ? lx->IsVisible() : false; } @@ -3097,7 +3085,7 @@ void mpWindow::SetLayerVisible( const unsigned int position, bool viewable ) } -bool mpWindow::IsLayerVisible( const unsigned int position ) +bool mpWindow::IsLayerVisible( unsigned int position ) const { mpLayer* lx = GetLayer( position ); @@ -3114,23 +3102,22 @@ void mpWindow::SetColourTheme( const wxColour& bgColour, m_bgColour = bgColour; m_fgColour = drawColour; m_axColour = axesColour; - // cycle between layers to set colours and properties to them - wxLayerList::iterator li; - for( li = m_layers.begin(); li != m_layers.end(); li++ ) + // Cycle between layers to set colours and properties to them + for( mpLayer* layer : m_layers ) { - if( (*li)->GetLayerType() == mpLAYER_AXIS ) + if( layer->GetLayerType() == mpLAYER_AXIS ) { - wxPen axisPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width + wxPen axisPen = layer->GetPen(); // Get the old pen to modify only colour, not style or width axisPen.SetColour( axesColour ); - (*li)->SetPen( axisPen ); + layer->SetPen( axisPen ); } - if( (*li)->GetLayerType() == mpLAYER_INFO ) + if( layer->GetLayerType() == mpLAYER_INFO ) { - wxPen infoPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width + wxPen infoPen = layer->GetPen(); // Get the old pen to modify only colour, not style or width infoPen.SetColour( drawColour ); - (*li)->SetPen( infoPen ); + layer->SetPen( infoPen ); } } } @@ -3203,31 +3190,31 @@ mpFXYVector::mpFXYVector( const wxString& name, int flags ) : mpFXY( name, flags } -double mpScaleX::TransformToPlot( double x ) +double mpScaleX::TransformToPlot( double x ) const { return (x + m_offset) * m_scale; } -double mpScaleX::TransformFromPlot( double xplot ) +double mpScaleX::TransformFromPlot( double xplot ) const { return xplot / m_scale - m_offset; } -double mpScaleY::TransformToPlot( double x ) +double mpScaleY::TransformToPlot( double x ) const { return (x + m_offset) * m_scale; } -double mpScaleY::TransformFromPlot( double xplot ) +double mpScaleY::TransformFromPlot( double xplot ) const { return xplot / m_scale - m_offset; } -double mpScaleXLog::TransformToPlot( double x ) +double mpScaleXLog::TransformToPlot( double x ) const { double xlogmin = log10( m_minV ); double xlogmax = log10( m_maxV ); @@ -3236,7 +3223,7 @@ double mpScaleXLog::TransformToPlot( double x ) } -double mpScaleXLog::TransformFromPlot( double xplot ) +double mpScaleXLog::TransformFromPlot( double xplot ) const { double xlogmin = log10( m_minV ); double xlogmax = log10( m_maxV ); @@ -3253,14 +3240,14 @@ mpFSemiLogXVector::mpFSemiLogXVector( wxString name, int flags ) : IMPLEMENT_DYNAMIC_CLASS( mpFSemiLogXVector, mpFXYVector ) -#endif +#endif // 0 void mpFXYVector::Rewind() { m_index = 0; } -size_t mpFXYVector::GetCount() +size_t mpFXYVector::GetCount() const { return m_xs.size(); } @@ -3299,31 +3286,29 @@ void mpFXYVector::SetData( const std::vector& xs, const std::vector0 ) + if( xs.size() > 0 ) { m_minX = xs[0]; m_maxX = xs[0]; m_minY = ys[0]; m_maxY = ys[0]; - std::vector::const_iterator it; - - for( it = xs.begin(); it!=xs.end(); it++ ) + for( const double x : xs ) { - if( *itm_maxX ) - m_maxX = *it; + if( x > m_maxX ) + m_maxX = x; } - for( it = ys.begin(); it!=ys.end(); it++ ) + for( const double y : ys ) { - if( *itm_maxY ) - m_maxY = *it; + if( y > m_maxY ) + m_maxY = y; } } else @@ -3490,7 +3475,7 @@ void mpMovableObject::TranslatePoint( double x, double y, double& out_x, double& void mpMovableObject::ShapeUpdated() { // Just in case... - if( m_shape_xs.size()!=m_shape_ys.size() ) + if( m_shape_xs.size() != m_shape_ys.size() ) { } else @@ -3569,7 +3554,7 @@ void mpMovableObject::Plot( wxDC& dc, mpWindow& w ) wxCoord cx0 = 0, cy0 = 0; bool first = true; - while( itX!=m_trans_shape_xs.end() ) + while( itX != m_trans_shape_xs.end() ) { wxCoord cx = w.x2p( *(itX++) ); wxCoord cy = w.y2p( *(itY++) ); @@ -3644,13 +3629,13 @@ void mpCovarianceEllipse::RecalculateShape() m_shape_ys.clear(); // Preliminary checks: - if( m_quantiles<0 ) + if( m_quantiles < 0 ) return; - if( m_cov_00<0 ) + if( m_cov_00 < 0 ) return; - if( m_cov_11<0 ) + if( m_cov_11 < 0 ) return; m_shape_xs.resize( m_segments, 0 ); @@ -3659,11 +3644,11 @@ void mpCovarianceEllipse::RecalculateShape() // Compute the two eigenvalues of the covariance: // ------------------------------------------------- double b = -m_cov_00 - m_cov_11; - double c = m_cov_00 * m_cov_11 - m_cov_01 * m_cov_01; + double c = m_cov_00 * m_cov_11 - m_cov_01 * m_cov_01; double D = b * b - 4 * c; - if( D<0 ) + if( D < 0 ) return; double eigenVal0 = 0.5 * ( -b + sqrt( D ) ); @@ -3674,7 +3659,7 @@ void mpCovarianceEllipse::RecalculateShape() double eigenVec0_x, eigenVec0_y; double eigenVec1_x, eigenVec1_y; - if( fabs( eigenVal0 - m_cov_00 )>1e-6 ) + if( fabs( eigenVal0 - m_cov_00 ) > 1e-6 ) { double k1x = m_cov_01 / ( eigenVal0 - m_cov_00 ); eigenVec0_y = 1; @@ -3687,7 +3672,7 @@ void mpCovarianceEllipse::RecalculateShape() eigenVec0_y = eigenVec0_x * k1y; } - if( fabs( eigenVal1 - m_cov_00 )>1e-6 ) + if( fabs( eigenVal1 - m_cov_00 ) > 1e-6 ) { double k2x = m_cov_01 / ( eigenVal1 - m_cov_00 ); eigenVec1_y = 1; @@ -3726,7 +3711,7 @@ void mpCovarianceEllipse::RecalculateShape() double Aang = 6.283185308 / (m_segments - 1); int i; - for( i = 0, ang = 0; i& points_xs, const std::vector& points_ys, bool closedShape ) { - if( points_xs.size()==points_ys.size() ) + if( points_xs.size() == points_ys.size() ) { m_shape_xs = points_xs; m_shape_ys = points_ys; - if( closedShape && points_xs.size() ) + if( closedShape && !points_xs.empty() ) { m_shape_xs.push_back( points_xs[0] ); m_shape_ys.push_back( points_ys[0] ); @@ -3825,16 +3810,16 @@ void mpBitmapLayer::Plot( wxDC& dc, mpWindow& w ) // The actual drawn rectangle (dx0,dy0)-(dx1,dy1) is (x0,y0)-(x1,y1) clipped: wxCoord dx0 = x0, dx1 = x1, dy0 = y0, dy1 = y1; - if( dx0<0 ) + if( dx0 < 0 ) dx0 = -borderMarginX; - if( dy0<0 ) + if( dy0 < 0 ) dy0 = -borderMarginY; - if( dx1>w.GetScrX() ) + if( dx1 > w.GetScrX() ) dx1 = w.GetScrX() + borderMarginX; - if( dy1>w.GetScrY() ) + if( dy1 > w.GetScrY() ) dy1 = w.GetScrY() + borderMarginY; // For convenience, compute the width/height of the rectangle to be actually drawn: @@ -3861,10 +3846,10 @@ void mpBitmapLayer::Plot( wxDC& dc, mpWindow& w ) wxRect r( wxRect( offset_x, offset_y, b_width, b_height ) ); // Just for the case.... - if( r.x<0 ) + if( r.x < 0 ) r.x = 0; - if( r.y<0 ) + if( r.y < 0 ) r.y = 0; if( r.width>m_bitmap.GetWidth() ) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index dff52ad6ac..28728de46f 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -1058,7 +1058,7 @@ wxWindow* CVPCB_MAINFRAME::GetToolCanvas() const } -CVPCB_MAINFRAME::CONTROL_TYPE CVPCB_MAINFRAME::GetFocusedControl() +CVPCB_MAINFRAME::CONTROL_TYPE CVPCB_MAINFRAME::GetFocusedControl() const { if( m_libListBox->HasFocus() ) return CVPCB_MAINFRAME::CONTROL_LIBRARY; @@ -1071,7 +1071,7 @@ CVPCB_MAINFRAME::CONTROL_TYPE CVPCB_MAINFRAME::GetFocusedControl() } -wxControl* CVPCB_MAINFRAME::GetFocusedControlObject() +wxControl* CVPCB_MAINFRAME::GetFocusedControlObject() const { if( m_libListBox->HasFocus() ) return m_libListBox; diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index a8a0967acb..743a042581 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -156,14 +156,14 @@ public: * * @return the contorl that currently has focus */ - CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl(); + CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const; /** * Get a pointer to the currently focused control * * @return the control that currently has focus */ - wxControl* GetFocusedControlObject(); + wxControl* GetFocusedControlObject() const; /** * Set the focus to a specific control. diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index bec31f87ee..c33f2149c3 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -142,11 +142,9 @@ bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1, } -int SCH_REFERENCE_LIST::FindUnit( size_t aIndex, int aUnit ) +int SCH_REFERENCE_LIST::FindUnit( size_t aIndex, int aUnit ) const { - int NumRef; - - NumRef = flatList[aIndex].m_numRef; + int NumRef = flatList[aIndex].m_numRef; for( size_t ii = 0; ii < flatList.size(); ii++ ) { @@ -188,11 +186,11 @@ int SCH_REFERENCE_LIST::FindRef( const wxString& aRef ) const } -void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId ) +void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId ) const { aIdList.clear(); - for( SCH_REFERENCE& ref : flatList ) + for( const SCH_REFERENCE& ref : flatList ) { if( flatList[aIndex].CompareRef( ref ) == 0 && ref.m_numRef >= aMinRefId ) aIdList.push_back( ref.m_numRef ); @@ -210,11 +208,11 @@ void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList, } -int SCH_REFERENCE_LIST::GetLastReference( int aIndex, int aMinValue ) +int SCH_REFERENCE_LIST::GetLastReference( int aIndex, int aMinValue ) const { int lastNumber = aMinValue; - for( SCH_REFERENCE& ref : flatList ) + for( const SCH_REFERENCE& ref : flatList ) { // search only for the current reference prefix: if( flatList[aIndex].CompareRef( ref ) != 0 ) diff --git a/eeschema/dialogs/dialog_edit_components_libid.cpp b/eeschema/dialogs/dialog_edit_components_libid.cpp index f63afbdd94..b9a662c266 100644 --- a/eeschema/dialogs/dialog_edit_components_libid.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid.cpp @@ -112,12 +112,8 @@ GRIDCELL_AUTOWRAP_STRINGRENDERER::GetTextLines(wxGrid& grid, return logicalLines; wxArrayString physicalLines; - for ( wxArrayString::const_iterator it = logicalLines.begin(); - it != logicalLines.end(); - ++it ) + for ( const wxString& line : logicalLines ) { - const wxString& line = *it; - if ( dc.GetTextExtent(line).x > maxWidth ) { // Line does not fit, break it up. diff --git a/eeschema/erc_settings.cpp b/eeschema/erc_settings.cpp index c2819def08..b3a9275a56 100644 --- a/eeschema/erc_settings.cpp +++ b/eeschema/erc_settings.cpp @@ -266,7 +266,7 @@ void ERC_SETTINGS::ResetPinMap() } -void SHEETLIST_ERC_ITEMS_PROVIDER::visitMarkers( std::function aVisitor ) +void SHEETLIST_ERC_ITEMS_PROVIDER::visitMarkers( std::function aVisitor ) const { SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); @@ -279,16 +279,16 @@ void SHEETLIST_ERC_ITEMS_PROVIDER::visitMarkers( std::functionItems().OfType( SCH_MARKER_T ) ) + for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) ) { - SCH_MARKER* marker = static_cast( aItem ); + SCH_MARKER* marker = static_cast( item ); if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC ) continue; // Don't show non-specific markers more than once if( !firstTime && - !static_cast( marker->GetRCItem().get() )->IsSheetSpecific() ) + !static_cast( marker->GetRCItem().get() )->IsSheetSpecific() ) { continue; } @@ -323,14 +323,14 @@ void SHEETLIST_ERC_ITEMS_PROVIDER::SetSeverities( int aSeverities ) } -int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount( int aSeverity ) +int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount( int aSeverity ) const { if( aSeverity < 0 ) return m_filteredMarkers.size(); int count = 0; - ERC_SETTINGS& settings = m_schematic->ErcSettings(); + const ERC_SETTINGS& settings = m_schematic->ErcSettings(); visitMarkers( [&]( SCH_MARKER* aMarker ) @@ -350,7 +350,7 @@ int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount( int aSeverity ) } -std::shared_ptr SHEETLIST_ERC_ITEMS_PROVIDER::GetERCItem( int aIndex ) +std::shared_ptr SHEETLIST_ERC_ITEMS_PROVIDER::GetERCItem( int aIndex ) const { SCH_MARKER* marker = m_filteredMarkers[ aIndex ]; @@ -358,7 +358,7 @@ std::shared_ptr SHEETLIST_ERC_ITEMS_PROVIDER::GetERCItem( int aIndex ) } -std::shared_ptr SHEETLIST_ERC_ITEMS_PROVIDER::GetItem( int aIndex ) +std::shared_ptr SHEETLIST_ERC_ITEMS_PROVIDER::GetItem( int aIndex ) const { return GetERCItem( aIndex ); } diff --git a/eeschema/erc_settings.h b/eeschema/erc_settings.h index 05d8b1cca3..988aaa3054 100644 --- a/eeschema/erc_settings.h +++ b/eeschema/erc_settings.h @@ -194,11 +194,11 @@ public: void SetSeverities( int aSeverities ) override; - int GetCount( int aSeverity = -1 ) override; + int GetCount( int aSeverity = -1 ) const override; - std::shared_ptr GetItem( int aIndex ) override; + std::shared_ptr GetItem( int aIndex ) const override; - std::shared_ptr GetERCItem( int aIndex ); + std::shared_ptr GetERCItem( int aIndex ) const; void DeleteItem( int aIndex, bool aDeep ) override; @@ -206,8 +206,8 @@ public: private: - void visitMarkers( std::function aVisitor ); + void visitMarkers( std::function aVisitor ) const; }; -#endif +#endif // _ERC_SETTINGS_H diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index a06fdb465c..903593c9c4 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -251,7 +251,7 @@ void LIB_ARC::Rotate( const wxPoint& aCenter, bool aRotateCCW ) void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != NULL ); diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index 2042526c9a..e5f5e29017 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -94,7 +94,7 @@ public: void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; int GetWidth() const override { return m_Width; } void SetWidth( int aWidth ) override { m_Width = aWidth; } diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 844769cc7d..56150859a1 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -160,7 +160,7 @@ void LIB_BEZIER::Rotate( const wxPoint& aCenter, bool aRotateCCW ) void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != NULL ); diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index bb1f5a569b..28e0748119 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -81,7 +81,7 @@ public: void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; int GetWidth() const override { return m_Width; } void SetWidth( int aWidth ) override { m_Width = aWidth; } diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index db372a6709..e4e2a4a9a4 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -163,7 +163,7 @@ void LIB_CIRCLE::Rotate( const wxPoint& aCenter, bool aRotateCCW ) void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + aOffset; diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index 5de4dc9cce..45ecc3f147 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -79,7 +79,7 @@ public: void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; int GetWidth() const override { return m_Width; } void SetWidth( int aWidth ) override { m_Width = aWidth; } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index f80d11dc7d..57f9860b41 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -256,7 +256,7 @@ void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW ) void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { if( GetText().IsEmpty() ) return; @@ -350,7 +350,7 @@ void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const } -SCH_LAYER_ID LIB_FIELD::GetDefaultLayer() +SCH_LAYER_ID LIB_FIELD::GetDefaultLayer() const { switch( m_id ) { diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 281e3ca09a..bc626e1dae 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -169,7 +169,7 @@ public: */ wxString GetFullText( int unit = 1 ) const; - SCH_LAYER_ID GetDefaultLayer(); + SCH_LAYER_ID GetDefaultLayer() const; void BeginEdit( const wxPoint aStartPoint ) override; @@ -184,7 +184,7 @@ public: void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; int GetWidth() const override { return GetTextThickness(); } void SetWidth( int aWidth ) override { SetTextThickness( aWidth ); } diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index 61b6d53902..789870e377 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -245,7 +245,7 @@ public: * @param aTransform The plot transform. */ virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) = 0; + const TRANSFORM& aTransform ) const = 0; virtual int GetWidth() const = 0; virtual void SetWidth( int aWidth ) = 0; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 41e4838e84..025f2dd618 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -510,7 +510,7 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, wxPo } -void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ) +void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ) const { int MapX1, MapY1, x1, y1; COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_PIN ); @@ -639,8 +639,8 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie } -void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, wxPoint& aPinPos, int aPinOrient, int aTextInside, - bool aDrawPinNum, bool aDrawPinName ) +void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinOrient, int aTextInside, + bool aDrawPinNum, bool aDrawPinName ) const { if( m_name.IsEmpty() || m_name == wxT( "~" ) ) aDrawPinName = false; @@ -657,11 +657,11 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, wxPoint& aPinPos, int aPinOrient, int namePenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, false ), aPlotter->RenderSettings()->GetDefaultPenWidth() ); - int numPenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, false ), + int numPenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, false ), aPlotter->RenderSettings()->GetDefaultPenWidth() ); int name_offset = Mils2iu( PIN_TEXT_MARGIN ) + namePenWidth; - int num_offset = Mils2iu( PIN_TEXT_MARGIN ) + numPenWidth; + int num_offset = Mils2iu( PIN_TEXT_MARGIN ) + numPenWidth; /* Get the num and name colors */ COLOR4D nameColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_PINNAM ); @@ -978,9 +978,9 @@ void LIB_PIN::Rotate( const wxPoint& aCenter, bool aRotateCCW ) void LIB_PIN::Plot( PLOTTER* aPlotter, const wxPoint& aPffset, bool aFill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { - if( ! IsVisible() ) + if( !IsVisible() ) return; int orient = PinDrawOrient( aTransform ); diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 1382b8fec5..39b9deb475 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -246,10 +246,10 @@ public: * If TextInside then the text is been put inside (moving from x1, y1 in * the opposite direction to x2,y2), otherwise all is drawn outside. */ - void PlotPinTexts( PLOTTER *aPlotter, wxPoint& aPinPos, int aPinOrient, - int aTextInside, bool aDrawPinNum, bool aDrawPinName ); + void PlotPinTexts( PLOTTER *aPlotter, const wxPoint& aPinPos, int aPinOrient, + int aTextInside, bool aDrawPinNum, bool aDrawPinName ) const; - void PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ); + void PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ) const; void Offset( const wxPoint& aOffset ) override; @@ -263,7 +263,7 @@ public: void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aPffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; // Get/SetWidth() not used for pins. Use GetPenWidth() for drawing. int GetWidth() const override { return 1; } diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index d11efd702b..e7ced924b2 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -119,7 +119,7 @@ void LIB_POLYLINE::Rotate( const wxPoint& aCenter, bool aRotateCCW ) void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != NULL ); diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 8b549a54f6..08abbeca15 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -97,7 +97,7 @@ public: void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; int GetWidth() const override { return m_Width; } void SetWidth( int aWidth ) override { m_Width = aWidth; } diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 7be72bd160..60805507a3 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -122,7 +122,7 @@ void LIB_RECTANGLE::Rotate( const wxPoint& aCenter, bool aRotateCCW ) void LIB_RECTANGLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != NULL ); diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 23c1d660e8..23b0875886 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -80,7 +80,7 @@ public: void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; int GetWidth() const override { return m_Width; } void SetWidth( int aWidth ) override { m_Width = aWidth; } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 0dbf15065c..d4fe0e25e3 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -544,7 +544,7 @@ void LIB_PART::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != NULL ); @@ -553,7 +553,7 @@ void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& // draw background for filled items using background option // Solid lines will be drawn after the background - for( LIB_ITEM& item : m_drawings ) + for( const LIB_ITEM& item : m_drawings ) { // Lib Fields are not plotted here, because this plot function // is used to plot schematic items, which have they own fields @@ -572,7 +572,7 @@ void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& // Not filled items and filled shapes are now plotted // Items that have BG fills only get re-stroked to ensure the edges are in the foreground - for( LIB_ITEM& item : m_drawings ) + for( const LIB_ITEM& item : m_drawings ) { if( item.Type() == LIB_FIELD_T ) continue; @@ -692,7 +692,7 @@ LIB_ITEM* LIB_PART::GetNextDrawItem( const LIB_ITEM* aItem, KICAD_T aType ) } -void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert ) +void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert ) const { /* Notes: * when aUnit == 0: no unit filtering @@ -700,7 +700,7 @@ void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert ) * when m_unit == 0, the body item is common to units * when m_convert == 0, the body item is common to shapes */ - for( LIB_ITEM& item : m_drawings[ LIB_PIN_T ] ) + for( const LIB_ITEM& item : m_drawings[ LIB_PIN_T ] ) { // Unit filtering: if( aUnit && item.m_unit && ( item.m_unit != aUnit ) ) @@ -715,7 +715,7 @@ void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert ) } -LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert ) +LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert ) const { LIB_PINS pinList; @@ -733,20 +733,20 @@ LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert ) } -bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames, - bool aTestType, bool aTestOrientation, bool aTestLength ) +bool LIB_PART::PinsConflictWith( const LIB_PART& aOtherPart, bool aTestNums, bool aTestNames, + bool aTestType, bool aTestOrientation, bool aTestLength ) const { LIB_PINS thisPinList; GetPins( thisPinList, /* aUnit */ 0, /* aConvert */ 0 ); - for( LIB_PIN* eachThisPin : thisPinList ) + for( const LIB_PIN* eachThisPin : thisPinList ) { wxASSERT( eachThisPin ); LIB_PINS otherPinList; aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aConvert */ 0 ); bool foundMatch = false; - for( LIB_PIN* eachOtherPin : otherPinList ) + for( const LIB_PIN* eachOtherPin : otherPinList ) { wxASSERT( eachOtherPin ); diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index f79bd61e5a..cbfd6ee3e0 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -100,7 +100,7 @@ public: virtual ~LIB_PART(); ///< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared - PART_SPTR SharedPtr() { return m_me; } + PART_SPTR SharedPtr() const { return m_me; } /** * Create a copy of a LIB_PART and assigns unique KIIDs to the copy and its children. @@ -169,7 +169,7 @@ public: const wxString GetLibraryName() const; - PART_LIB* GetLib() { return m_library; } + PART_LIB* GetLib() const { return m_library; } void SetLib( PART_LIB* aLibrary ) { m_library = aLibrary; } timestamp_t GetLastModDate() const { return m_lastModDate; } @@ -311,7 +311,7 @@ public: * @param aTransform - Component plot transform matrix. */ void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset, - const TRANSFORM& aTransform ); + const TRANSFORM& aTransform ) const; /** * Plot Lib Fields only of the part to plotter. @@ -381,7 +381,7 @@ public: * @param aConvert - Convert number of pin to add to list. Set to 0 to * get pins from any convert of part. */ - void GetPins( LIB_PINS& aList, int aUnit = 0, int aConvert = 0 ); + void GetPins( LIB_PINS& aList, int aUnit = 0, int aConvert = 0 ) const; /** * Return pin object with the requested pin \a aNumber. @@ -393,7 +393,7 @@ public: * no alternate body style is required. * @return The pin object if found. Otherwise NULL. */ - LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 ); + LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 ) const; /** * Return true if this part's pins do not match another part's pins. This @@ -407,8 +407,8 @@ public: * @param aTestOrientation - Whether two pins at the same point must have the same orientation. * @param aTestLength - Whether two pins at the same point must have the same length. */ - bool PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames, - bool aTestType, bool aTestOrientation, bool aTestLength ); + bool PinsConflictWith( const LIB_PART& aOtherPart, bool aTestNums, bool aTestNames, + bool aTestType, bool aTestOrientation, bool aTestLength ) const; /** * Move the part \a aOffset. @@ -552,7 +552,7 @@ public: * @param aOffset - The offset in mils. */ void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; } - int GetPinNameOffset() { return m_pinNameOffset; } + int GetPinNameOffset() const { return m_pinNameOffset; } /** * Set or clear the pin name visibility flag. @@ -560,7 +560,7 @@ public: * @param aShow - True to make the part pin names visible. */ void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; } - bool ShowPinNames() { return m_showPinNames; } + bool ShowPinNames() const { return m_showPinNames; } /** * Set or clear the pin number visibility flag. @@ -568,7 +568,7 @@ public: * @param aShow - True to make the part pin numbers visible. */ void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; } - bool ShowPinNumbers() { return m_showPinNumbers; } + bool ShowPinNumbers() const { return m_showPinNumbers; } /** * Set or clear the include in schematic bill of materials flag. diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 3a5f9e0741..334b00e47c 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -263,7 +263,7 @@ void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW ) void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const TRANSFORM& aTransform ) + const TRANSFORM& aTransform ) const { wxASSERT( plotter != NULL ); diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index f58a264f08..78de186bfa 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -103,7 +103,7 @@ public: void NormalizeJustification( bool inverse ); void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, - const TRANSFORM& aTransform ) override; + const TRANSFORM& aTransform ) const override; int GetWidth() const override { return GetTextThickness(); } void SetWidth( int aWidth ) override { SetTextThickness( aWidth ); } diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 53c50ae13e..2fb03fce63 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -183,7 +183,7 @@ bool SCH_BITMAP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy } -void SCH_BITMAP::Plot( PLOTTER* aPlotter ) +void SCH_BITMAP::Plot( PLOTTER* aPlotter ) const { m_image->PlotImage( aPlotter, m_pos, aPlotter->RenderSettings()->GetLayerColor( GetLayer() ), aPlotter->RenderSettings()->GetDefaultPenWidth() ); diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 88ca44d86a..cfe482d71d 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -143,7 +143,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 91708e269e..e0d68075b8 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -292,7 +292,7 @@ bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector& aI bool has_wire[2] = { false }; bool has_bus[2] = { false }; - for( DANGLING_END_ITEM& each_item : aItemList ) + for( const DANGLING_END_ITEM& each_item : aItemList ) { if( each_item.GetItem() == this ) continue; @@ -351,7 +351,7 @@ bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector& aIt // when the end position is found. wxPoint seg_start; - for( DANGLING_END_ITEM& each_item : aItemList ) + for( const DANGLING_END_ITEM& each_item : aItemList ) { if( each_item.GetItem() == this ) continue; @@ -435,7 +435,7 @@ bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aA } -void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) +void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) const { auto* settings = static_cast( aPlotter->RenderSettings() ); diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index cf8dd4f146..f0609f80c1 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -104,7 +104,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 7f88ababc3..c9d6928daf 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -462,7 +462,7 @@ void SCH_EDIT_FRAME::setupUIConditions() } -void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem ) +void SCH_EDIT_FRAME::SaveCopyForRepeatItem( const SCH_ITEM* aItem ) { // we cannot store a pointer to an item in the display list here since // that item may be deleted, such as part of a line concatenation or other. @@ -479,7 +479,7 @@ void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem ) } -EDA_ITEM* SCH_EDIT_FRAME::GetItem( const KIID& aId ) +EDA_ITEM* SCH_EDIT_FRAME::GetItem( const KIID& aId ) const { return Schematic().GetSheets().GetItem( aId ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 778feabf1e..dcd21a3a5a 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -816,16 +816,16 @@ public: /** * Clone \a aItem and owns that clone in this container. */ - void SaveCopyForRepeatItem( SCH_ITEM* aItem ); + void SaveCopyForRepeatItem( const SCH_ITEM* aItem ); /** * Return the item which is to be repeated with the insert key. * * Such object is owned by this container, and must be cloned. */ - SCH_ITEM* GetRepeatItem() const { return m_item_to_repeat; } + SCH_ITEM* GetRepeatItem() const { return m_item_to_repeat; } - EDA_ITEM* GetItem( const KIID& aId ) override; + EDA_ITEM* GetItem( const KIID& aId ) const override; /** * Performs an undo of the last edit WITHOUT logging a corresponding redo. Used to cancel diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 907b813216..916e638040 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -608,7 +608,7 @@ bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) } -void SCH_FIELD::Plot( PLOTTER* aPlotter ) +void SCH_FIELD::Plot( PLOTTER* aPlotter ) const { RENDER_SETTINGS* settings = aPlotter->RenderSettings(); COLOR4D color = settings->GetLayerColor( GetLayer() ); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 4c5a639923..d9093b0189 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -201,7 +201,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index 1d23d94d29..38d89e4824 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -215,7 +215,7 @@ bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const } -void SCH_ITEM::Plot( PLOTTER* aPlotter ) +void SCH_ITEM::Plot( PLOTTER* aPlotter ) const { wxFAIL_MSG( wxT( "Plot() method not implemented for class " ) + GetClass() ); } diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index e452e53bef..df15864fc1 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -117,7 +117,7 @@ public: m_parent = aParent; } - bool operator==( const DANGLING_END_ITEM& aB ) + bool operator==( const DANGLING_END_ITEM& aB ) const { return GetItem() == aB.GetItem() && GetPosition() == aB.GetPosition() @@ -125,7 +125,7 @@ public: && GetParent() == aB.GetParent(); } - bool operator!=( const DANGLING_END_ITEM& aB ) + bool operator!=( const DANGLING_END_ITEM& aB ) const { return GetItem() != aB.GetItem() || GetPosition() != aB.GetPosition() @@ -485,7 +485,7 @@ public: * * @param aPlotter A pointer to a #PLOTTER object. */ - virtual void Plot( PLOTTER* aPlotter ); + virtual void Plot( PLOTTER* aPlotter ) const; virtual bool operator <( const SCH_ITEM& aItem ) const; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 69fa10a134..a4a1b1237b 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -221,7 +221,7 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const } -void SCH_JUNCTION::Plot( PLOTTER* aPlotter ) +void SCH_JUNCTION::Plot( PLOTTER* aPlotter ) const { auto* settings = static_cast( aPlotter->RenderSettings() ); COLOR4D color = GetJunctionColor(); diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 22f8cc95db..a4e879aadb 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -109,7 +109,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 66f43cc873..019107a249 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -826,7 +826,7 @@ bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const } -void SCH_LINE::Plot( PLOTTER* aPlotter ) +void SCH_LINE::Plot( PLOTTER* aPlotter ) const { auto* settings = static_cast( aPlotter->RenderSettings() ); int penWidth; diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index ccaf40dead..f87354c7fc 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -240,7 +240,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index a5ca2b0a15..bb39dc6bea 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -60,12 +60,11 @@ public: void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override; - void Plot( PLOTTER* aPlotter ) override + void Plot( PLOTTER* /* aPlotter */ ) const override { // SCH_MARKERs should not be plotted. However, SCH_ITEM will fail an // assertion if we do not confirm this by locally implementing a no-op // Plot(). - (void) aPlotter; } EDA_RECT const GetBoundingBox() const override; diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index c25b6973ce..9997ee1a91 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -170,7 +170,7 @@ bool SCH_NO_CONNECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur } -void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter ) +void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter ) const { int delta = GetSize() / 2; int pX = m_pos.x; diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index 55ecbf88bb..b751b832f3 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -109,7 +109,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index c6c9e410ff..691e1d3f49 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -2411,11 +2411,9 @@ SCH_LEGACY_PLUGIN_CACHE::SCH_LEGACY_PLUGIN_CACHE( const wxString& aFullPathAndFi SCH_LEGACY_PLUGIN_CACHE::~SCH_LEGACY_PLUGIN_CACHE() { - std::vector< LIB_PART* > rootParts; - // When the cache is destroyed, all of the alias objects on the heap should be deleted. - for( LIB_PART_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); ++it ) - delete it->second; + for( auto& symbol : m_symbols ) + delete symbol.second; m_symbols.clear(); } diff --git a/eeschema/sch_reference_list.h b/eeschema/sch_reference_list.h index 109d8b86e6..d38618b340 100644 --- a/eeschema/sch_reference_list.h +++ b/eeschema/sch_reference_list.h @@ -209,6 +209,11 @@ public: return flatList[ aIndex ]; } + const SCH_REFERENCE& operator[]( int aIndex ) const + { + return flatList[ aIndex ]; + } + void Clear() { flatList.clear(); @@ -217,8 +222,9 @@ public: unsigned GetCount() const { return flatList.size(); } SCH_REFERENCE& GetItem( int aIdx ) { return flatList[aIdx]; } + const SCH_REFERENCE& GetItem( int aIdx ) const { return flatList[aIdx]; } - void AddItem( SCH_REFERENCE& aItem ) { flatList.push_back( aItem ); } + void AddItem( const SCH_REFERENCE& aItem ) { flatList.push_back( aItem ); } /** * Remove an item from the list of references. @@ -393,7 +399,7 @@ public: * @param aUnit = the given unit number to search * @return index in aSymbolsList if found or -1 if not found */ - int FindUnit( size_t aIndex, int aUnit ); + int FindUnit( size_t aIndex, int aUnit ) const; /** * Search the list for a symbol with the given KIID path. @@ -411,7 +417,7 @@ public: * @param aIdList = the buffer to fill * @param aMinRefId = the min id value to store. all values < aMinRefId are ignored */ - void GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId ); + void GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId ) const; /** * Return the last used (greatest) reference number in the reference list for the prefix @@ -420,7 +426,7 @@ public: * @param aIndex The index of the reference item used for the search pattern. * @param aMinValue The minimum value for the current search. */ - int GetLastReference( int aIndex, int aMinValue ); + int GetLastReference( int aIndex, int aMinValue ) const; #if defined(DEBUG) void Show( const char* aPrefix = "" ) diff --git a/eeschema/sch_rtree.h b/eeschema/sch_rtree.h index dc101abbe3..8ed8c59300 100644 --- a/eeschema/sch_rtree.h +++ b/eeschema/sch_rtree.h @@ -221,26 +221,26 @@ public: return EE_TYPE( m_tree, aType ); } - EE_TYPE Overlapping( const EDA_RECT& aRect ) + EE_TYPE Overlapping( const EDA_RECT& aRect ) const { return EE_TYPE( m_tree, SCH_LOCATE_ANY_T, aRect ); } - EE_TYPE Overlapping( const wxPoint& aPoint, int aAccuracy = 0 ) + EE_TYPE Overlapping( const wxPoint& aPoint, int aAccuracy = 0 ) const { EDA_RECT rect( aPoint, wxSize( 0, 0 ) ); rect.Inflate( aAccuracy ); return EE_TYPE( m_tree, SCH_LOCATE_ANY_T, rect ); } - EE_TYPE Overlapping( KICAD_T aType, const wxPoint& aPoint, int aAccuracy = 0 ) + EE_TYPE Overlapping( KICAD_T aType, const wxPoint& aPoint, int aAccuracy = 0 ) const { EDA_RECT rect( aPoint, wxSize( 0, 0 ) ); rect.Inflate( aAccuracy ); return EE_TYPE( m_tree, aType, rect ); } - EE_TYPE Overlapping( KICAD_T aType, const EDA_RECT& aRect ) + EE_TYPE Overlapping( KICAD_T aType, const EDA_RECT& aRect ) const { return EE_TYPE( m_tree, aType, aRect ); } diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index a21760054a..d925500ff4 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -303,19 +303,19 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem ) } -bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem ) +bool SCH_SCREEN::CheckIfOnDrawList( const SCH_ITEM* aItem ) const { return m_rtree.contains( aItem, true ); } -SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) +SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const { EDA_RECT bbox; bbox.SetOrigin( aPosition ); bbox.Inflate( aAccuracy ); - for( auto item : Items().Overlapping( aType, bbox ) ) + for( SCH_ITEM* item : Items().Overlapping( aType, bbox ) ) { if( item->HitTest( aPosition, aAccuracy ) ) return item; @@ -370,7 +370,7 @@ std::set SCH_SCREEN::MarkConnections( SCH_LINE* aSegment ) } -bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew ) +bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew ) const { enum { WIRES, BUSES } layers; @@ -381,7 +381,7 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew ) std::vector lines[ sizeof( layers ) ]; - for( SCH_ITEM* item : Items().Overlapping( aPosition ) ) + for( const SCH_ITEM* item : Items().Overlapping( aPosition ) ) { if( item->GetEditFlags() & STRUCT_DELETED ) continue; @@ -427,7 +427,7 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew ) { bool removed_overlapping = false; - for( auto line = lines[i].begin(); line < lines[i].end(); line++ ) + for( auto line = lines[i].begin(); line < lines[i].end(); ++line ) { /// A line with a midpoint should be counted as two endpoints for this calculation /// because the junction will split the line into two if there is another item @@ -437,7 +437,7 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew ) else end_count[i]++; - for( auto second_line = lines[i].end() - 1; second_line > line; second_line-- ) + for( auto second_line = lines[i].end() - 1; second_line > line; --second_line ) { if( !(*line)->IsParallel( *second_line ) ) has_nonparallel[i] = true; @@ -480,7 +480,7 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew ) } -bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) +bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) const { wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false, wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) ); @@ -790,7 +790,7 @@ void SCH_SCREEN::Print( const RENDER_SETTINGS* aSettings ) } -void SCH_SCREEN::Plot( PLOTTER* aPlotter ) +void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const { // Ensure links are up to date, even if a library was reloaded for some reason: std::vector< SCH_ITEM* > junctions; @@ -825,19 +825,19 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) // Bitmaps are drawn first to ensure they are in the background // This is particularly important for the wxPostscriptDC (used in *nix printers) as // the bitmap PS command clears the screen - for( SCH_ITEM* item : bitmaps ) + for( const SCH_ITEM* item : bitmaps ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); item->Plot( aPlotter ); } - for( SCH_ITEM* item : other ) + for( const SCH_ITEM* item : other ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); item->Plot( aPlotter ); } - for( SCH_ITEM* item : junctions ) + for( const SCH_ITEM* item : junctions ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); item->Plot( aPlotter ); @@ -853,7 +853,7 @@ void SCH_SCREEN::ClearDrawingState() LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aSymbol, - bool aEndPointOnly ) + bool aEndPointOnly ) const { SCH_COMPONENT* candidate = NULL; LIB_PIN* pin = NULL; @@ -904,7 +904,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aSymbol, } -SCH_SHEET_PIN* SCH_SCREEN::GetSheetPin( const wxPoint& aPosition ) +SCH_SHEET_PIN* SCH_SCREEN::GetSheetPin( const wxPoint& aPosition ) const { SCH_SHEET_PIN* sheetPin = nullptr; @@ -922,11 +922,11 @@ SCH_SHEET_PIN* SCH_SCREEN::GetSheetPin( const wxPoint& aPosition ) } -size_t SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) +size_t SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const { size_t count = 0; - for( SCH_ITEM* item : Items() ) + for( const SCH_ITEM* item : Items() ) { if( ( item->Type() != SCH_JUNCTION_T || aTestJunctions ) && item->IsConnected( aPos ) ) count++; @@ -964,7 +964,7 @@ void SCH_SCREEN::EnsureAlternateReferencesExist() } -void SCH_SCREEN::GetHierarchicalItems( std::vector* aItems ) +void SCH_SCREEN::GetHierarchicalItems( std::vector* aItems ) const { static KICAD_T hierarchicalTypes[] = { SCH_COMPONENT_T, SCH_SHEET_T, SCH_GLOBAL_LABEL_T, EOT }; @@ -976,7 +976,7 @@ void SCH_SCREEN::GetHierarchicalItems( std::vector* aItems ) } -void SCH_SCREEN::GetSheets( std::vector* aItems ) +void SCH_SCREEN::GetSheets( std::vector* aItems ) const { for( SCH_ITEM* item : Items().OfType( SCH_SHEET_T ) ) aItems->push_back( item ); @@ -993,7 +993,7 @@ void SCH_SCREEN::GetSheets( std::vector* aItems ) void SCH_SCREEN::TestDanglingEnds( const SCH_SHEET_PATH* aPath, - std::function* aChangedHandler ) + std::function* aChangedHandler ) const { std::vector endPoints; @@ -1012,7 +1012,7 @@ void SCH_SCREEN::TestDanglingEnds( const SCH_SHEET_PATH* aPath, SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer, - SCH_LINE_TEST_T aSearchType ) + SCH_LINE_TEST_T aSearchType ) const { // an accuracy of 0 had problems with rounding errors; use at least 1 aAccuracy = std::max( aAccuracy, 1 ); @@ -1048,7 +1048,7 @@ SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLay } -SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) +SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) const { for( SCH_ITEM* item : Items().Overlapping( aPosition, aAccuracy ) ) { @@ -1058,7 +1058,7 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: if( item->HitTest( aPosition, aAccuracy ) ) - return (SCH_TEXT*) item; + return static_cast( item ); break; diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index 5422c414b4..dff55cb636 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -162,7 +162,7 @@ public: EE_RTREE& Items() { return m_rtree; } const EE_RTREE& Items() const { return m_rtree; } - bool IsEmpty() + bool IsEmpty() const { return m_rtree.empty(); } @@ -249,7 +249,7 @@ public: * @return The item found that meets the search criteria or NULL if none found. */ SCH_ITEM* GetItem( const wxPoint& aPosition, int aAccuracy = 0, - KICAD_T aType = SCH_LOCATE_ANY_T ); + KICAD_T aType = SCH_LOCATE_ANY_T ) const; void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { }; @@ -294,7 +294,7 @@ public: * * @param aPlotter The plotter object to plot to. */ - void Plot( PLOTTER* aPlotter ); + void Plot( PLOTTER* aPlotter ) const; /** * Remove \a aItem from the schematic associated with this screen. @@ -322,7 +322,7 @@ public: */ void DeleteItem( SCH_ITEM* aItem ); - bool CheckIfOnDrawList( SCH_ITEM* st ); + bool CheckIfOnDrawList( const SCH_ITEM* aItem ) const; /** * Test all of the connectable objects in the schematic for unused connection points. @@ -330,7 +330,7 @@ public: * @param aChangedHandler an optional callback to make on each changed item */ void TestDanglingEnds( const SCH_SHEET_PATH* aPath = nullptr, - std::function* aChangedHandler = nullptr ); + std::function* aChangedHandler = nullptr ) const; /** * Return all wires and junctions connected to \a aSegment which are not connected any @@ -345,7 +345,7 @@ public: */ void ClearDrawingState(); - size_t CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ); + size_t CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const; /** * Test if a junction is required for the items at \a aPosition on the screen. @@ -362,7 +362,7 @@ public: * @param aNew Checks if a _new_ junction is needed, i.e. there isn't one already * @return True if a junction is required at \a aPosition. */ - bool IsJunctionNeeded( const wxPoint& aPosition, bool aNew = false ); + bool IsJunctionNeeded( const wxPoint& aPosition, bool aNew = false ) const; /** * Test if \a aPosition is a connection point on \a aLayer. @@ -372,7 +372,7 @@ public: * #LAYER_BUS, and #LAYER_WIRE. * @return True if \a Position is a connection point on \a aLayer. */ - bool IsTerminalPoint( const wxPoint& aPosition, int aLayer ); + bool IsTerminalPoint( const wxPoint& aPosition, int aLayer ) const; /** * Test the screen for a component pin item at \a aPosition. @@ -384,7 +384,7 @@ public: * @return The pin item if found, otherwise NULL. */ LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aSymbol = NULL, - bool aEndPointOnly = false ); + bool aEndPointOnly = false ) const; /** * Test the screen if \a aPosition is a sheet label object. @@ -392,7 +392,7 @@ public: * @param aPosition The position to test. * @return The sheet label object if found otherwise NULL. */ - SCH_SHEET_PIN* GetSheetPin( const wxPoint& aPosition ); + SCH_SHEET_PIN* GetSheetPin( const wxPoint& aPosition ) const; /** * Clear the annotation for the components in \a aSheetPath on the screen. @@ -418,14 +418,14 @@ public: * * @param aItems Hierarchical item list to fill. */ - void GetHierarchicalItems( std::vector* aItems ); + void GetHierarchicalItems( std::vector* aItems ) const; /** * Similar to Items().OfType( SCH_SHEET_T ), but return the sheets in a * deterministic order (L-R, T-B) for sheet numbering. * @param aItems */ - void GetSheets( std::vector* aItems ); + void GetSheets( std::vector* aItems ) const; /** * Return a line item located at \a aPosition. @@ -438,16 +438,16 @@ public: * found. */ SCH_LINE* GetLine( const wxPoint& aPosition, int aAccuracy = 0, int aLayer = LAYER_NOTES, - SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T ); + SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T ) const; SCH_LINE* GetWire( const wxPoint& aPosition, int aAccuracy = 0, - SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T ) + SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T ) const { return GetLine( aPosition, aAccuracy, LAYER_WIRE, aSearchType ); } SCH_LINE* GetBus( const wxPoint& aPosition, int aAccuracy = 0, - SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T ) + SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T ) const { return GetLine( aPosition, aAccuracy, LAYER_BUS, aSearchType ); } @@ -460,7 +460,7 @@ public: * @return The SCH_TEXT* of the label item found at \a aPosition or NULL if item not * found. */ - SCH_TEXT* GetLabel( const wxPoint& aPosition, int aAccuracy = 0 ); + SCH_TEXT* GetLabel( const wxPoint& aPosition, int aAccuracy = 0 ) const; /** * Fetch a list of unique #LIB_PART object pointers required to properly render each @@ -469,6 +469,7 @@ public: * @return The list of unique #LIB_PART object pointers. */ std::map& GetLibSymbols() { return m_libSymbols; } + const std::map& GetLibSymbols() const { return m_libSymbols; } /** * Add \a aLibSymbol to the the library symbol map. @@ -497,7 +498,7 @@ public: /** * Returns a list of bus aliases defined in this screen */ - std::unordered_set< std::shared_ptr > GetBusAliases() + std::unordered_set< std::shared_ptr > GetBusAliases() const { return m_aliases; } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 6ad7943137..fc8159685b 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -947,7 +947,7 @@ bool SCH_SHEET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) } -void SCH_SHEET::Plot( PLOTTER* aPlotter ) +void SCH_SHEET::Plot( PLOTTER* aPlotter ) const { wxString msg; wxPoint pos; diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index f51b165a99..6759c73f5c 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -130,7 +130,7 @@ public: * @param aPos = Position of the shape */ void CreateGraphicShape( const RENDER_SETTINGS* aSettings, - std::vector & aPoints, const wxPoint& aPos ) override; + std::vector & aPoints, const wxPoint& aPos ) const override; void SwapData( SCH_ITEM* aItem ) override; @@ -575,7 +575,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index b2fe320046..8ef0e11035 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -503,7 +503,7 @@ void SCH_SHEET_LIST::SortByPageNumbers( bool aUpdateVirtualPageNums ) } -bool SCH_SHEET_LIST::NameExists( const wxString& aSheetName ) +bool SCH_SHEET_LIST::NameExists( const wxString& aSheetName ) const { for( const SCH_SHEET_PATH& sheet : *this ) { @@ -515,7 +515,7 @@ bool SCH_SHEET_LIST::NameExists( const wxString& aSheetName ) } -bool SCH_SHEET_LIST::IsModified() +bool SCH_SHEET_LIST::IsModified() const { for( const SCH_SHEET_PATH& sheet : *this ) { @@ -537,7 +537,7 @@ void SCH_SHEET_LIST::ClearModifyStatus() } -SCH_ITEM* SCH_SHEET_LIST::GetItem( const KIID& aID, SCH_SHEET_PATH* aPathOut ) +SCH_ITEM* SCH_SHEET_LIST::GetItem( const KIID& aID, SCH_SHEET_PATH* aPathOut ) const { for( const SCH_SHEET_PATH& sheet : *this ) { @@ -738,7 +738,7 @@ bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy, } -SCH_SHEET_PATH* SCH_SHEET_LIST::FindSheetForScreen( SCH_SCREEN* aScreen ) +SCH_SHEET_PATH* SCH_SHEET_LIST::FindSheetForScreen( const SCH_SCREEN* aScreen ) { for( SCH_SHEET_PATH& sheetpath : *this ) { diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 7c7b295633..e4bffe5be5 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -368,14 +368,14 @@ public: * * @return True if the hierarchy is modified otherwise false. */ - bool IsModified(); + bool IsModified() const; void ClearModifyStatus(); /** * Fetch a SCH_ITEM by ID. Also returns the sheet the item was found on in \a aPathOut. */ - SCH_ITEM* GetItem( const KIID& aID, SCH_SHEET_PATH* aPathOut = nullptr ); + SCH_ITEM* GetItem( const KIID& aID, SCH_SHEET_PATH* aPathOut = nullptr ) const; /** * Fill an item cache for temporary use when many items need to be fetched. @@ -432,7 +432,7 @@ public: * Return a pointer to the first #SCH_SHEET_PATH object (not necessarily the only one) using * a particular screen. */ - SCH_SHEET_PATH* FindSheetForScreen( SCH_SCREEN* aScreen ); + SCH_SHEET_PATH* FindSheetForScreen( const SCH_SCREEN* aScreen ); /** * Build the list of sheets and their sheet path from \a aSheet. @@ -458,7 +458,7 @@ public: */ void SortByPageNumbers( bool aUpdateVirtualPageNums = true ); - bool NameExists( const wxString& aSheetName ); + bool NameExists( const wxString& aSheetName ) const; /** * Update all of the symbol instance information using \a aSymbolInstances. diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index acc0818ffd..c1e58dc653 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -64,7 +64,7 @@ EDA_ITEM* SCH_SHEET_PIN::Clone() const } -void SCH_SHEET_PIN::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) +void SCH_SHEET_PIN::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) { // The icon selection is handle by the virtual method CreateGraphicShape called by ::Print SCH_HIERLABEL::Print( aSettings, aOffset ); @@ -251,8 +251,8 @@ void SCH_SHEET_PIN::Rotate( wxPoint aPosition ) } -void SCH_SHEET_PIN::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, - std::vector& aPoints, const wxPoint& aPos ) +void SCH_SHEET_PIN::CreateGraphicShape( const RENDER_SETTINGS* aSettings, + std::vector& aPoints, const wxPoint& aPos ) const { /* * These are the same icon shapes as SCH_HIERLABEL but the graphic icon is slightly @@ -260,21 +260,20 @@ void SCH_SHEET_PIN::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, * for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL * for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL */ - PINSHEETLABEL_SHAPE tmp = m_shape; + PINSHEETLABEL_SHAPE shape = m_shape; - switch( m_shape ) + switch( shape ) { - case PINSHEETLABEL_SHAPE::PS_INPUT: m_shape = PINSHEETLABEL_SHAPE::PS_OUTPUT; break; - case PINSHEETLABEL_SHAPE::PS_OUTPUT: m_shape = PINSHEETLABEL_SHAPE::PS_INPUT; break; - default: break; + case PINSHEETLABEL_SHAPE::PS_INPUT: shape = PINSHEETLABEL_SHAPE::PS_OUTPUT; break; + case PINSHEETLABEL_SHAPE::PS_OUTPUT: shape = PINSHEETLABEL_SHAPE::PS_INPUT; break; + default: break; } - SCH_HIERLABEL::CreateGraphicShape( aRenderSettings, aPoints, aPos ); - m_shape = tmp; + SCH_HIERLABEL::CreateGraphicShape( aSettings, aPoints, aPos, shape ); } -void SCH_SHEET_PIN::GetEndPoints( std::vector & aItemList ) +void SCH_SHEET_PIN::GetEndPoints( std::vector& aItemList ) { DANGLING_END_ITEM item( SHEET_LABEL_END, this, GetTextPos() ); aItemList.push_back( item ); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 479e074782..1e6c42ebad 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1848,7 +1848,7 @@ bool SCH_COMPONENT::IsInNetlist() const } -void SCH_COMPONENT::Plot( PLOTTER* aPlotter ) +void SCH_COMPONENT::Plot( PLOTTER* aPlotter ) const { if( m_part ) { diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 166a95c5e1..ac87f820ac 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -683,7 +683,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index fea4c08028..4682a2fa30 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -599,7 +599,7 @@ bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) } -void SCH_TEXT::Plot( PLOTTER* aPlotter ) +void SCH_TEXT::Plot( PLOTTER* aPlotter ) const { static std::vector s_poly; @@ -1214,7 +1214,7 @@ void SCH_GLOBALLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aO m_intersheetRefsField.Print( aSettings, aOffset ); } -void SCH_GLOBALLABEL::Plot( PLOTTER* aPlotter ) +void SCH_GLOBALLABEL::Plot( PLOTTER* aPlotter ) const { SCH_TEXT::Plot( aPlotter ); @@ -1225,7 +1225,7 @@ void SCH_GLOBALLABEL::Plot( PLOTTER* aPlotter ) } void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, - std::vector& aPoints, const wxPoint& Pos ) + std::vector& aPoints, const wxPoint& Pos ) const { int margin = GetTextOffset( aRenderSettings ); int halfSize = ( GetTextHeight() / 2 ) + margin; @@ -1432,10 +1432,17 @@ void SCH_HIERLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& offs } -void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, - std::vector& aPoints, const wxPoint& Pos ) +void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings, + std::vector& aPoints, const wxPoint& aPos ) const { - int* Template = TemplateShape[static_cast( m_shape )][static_cast( m_spin_style )]; + CreateGraphicShape( aSettings, aPoints, aPos, m_shape ); +} + + +void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings, + std::vector& aPoints, const wxPoint& aPos, PINSHEETLABEL_SHAPE aShape ) const +{ + int* Template = TemplateShape[static_cast( aShape )][static_cast( m_spin_style )]; int halfSize = GetTextHeight() / 2; int imax = *Template; Template++; @@ -1445,10 +1452,10 @@ void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, for( int ii = 0; ii < imax; ii++ ) { wxPoint corner; - corner.x = ( halfSize * (*Template) ) + Pos.x; + corner.x = ( halfSize * (*Template) ) + aPos.x; Template++; - corner.y = ( halfSize * (*Template) ) + Pos.y; + corner.y = ( halfSize * (*Template) ) + aPos.y; Template++; aPoints.push_back( corner ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index e894e0d740..0d90704c58 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -254,7 +254,7 @@ public: * Mainly for derived classes (SCH_SHEET_PIN and Hierarchical labels) */ virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings, - std::vector & aPoints, const wxPoint& Pos ) + std::vector& aPoints, const wxPoint& Pos ) const { aPoints.clear(); } @@ -315,7 +315,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; EDA_ITEM* Clone() const override; @@ -416,7 +416,7 @@ public: const EDA_RECT GetBoundingBox() const override; void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, - std::vector& aPoints, const wxPoint& aPos ) override; + std::vector& aPoints, const wxPoint& aPos ) const override; void UpdateIntersheetRefProps(); void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override; @@ -437,7 +437,7 @@ public: void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override; - void Plot( PLOTTER* aPlotter ) override; + void Plot( PLOTTER* aPlotter ) const override; SCH_FIELD* GetIntersheetRefs() { return &m_intersheetRefsField; } void SetIntersheetRefs( const SCH_FIELD& aField ) { m_intersheetRefsField = aField; } @@ -490,7 +490,9 @@ public: wxPoint GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override; void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector& aPoints, - const wxPoint& Pos ) override; + const wxPoint& aPos ) const override; + void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector& aPoints, + const wxPoint& aPos, PINSHEETLABEL_SHAPE aShape ) const; const EDA_RECT GetBoundingBox() const override; diff --git a/include/bitmap_base.h b/include/bitmap_base.h index ed9759cc61..9f3195a649 100644 --- a/include/bitmap_base.h +++ b/include/bitmap_base.h @@ -231,7 +231,7 @@ public: * @param aDefaultPensize the pen size used to plot the rectangle when bitmap is not supported. */ void PlotImage( PLOTTER* aPlotter, const wxPoint& aPos, - KIGFX::COLOR4D aDefaultColor, int aDefaultPensize ); + KIGFX::COLOR4D aDefaultColor, int aDefaultPensize ) const; private: double m_scale; // The scaling factor of the bitmap diff --git a/include/board_item.h b/include/board_item.h index cf79874aaa..9a5f8ed996 100644 --- a/include/board_item.h +++ b/include/board_item.h @@ -197,7 +197,7 @@ public: } /** - * Create a copy of a of this #BOARD_ITEM. + * Create a copy of this #BOARD_ITEM. */ virtual BOARD_ITEM* Duplicate() const { @@ -406,7 +406,7 @@ public: } #if defined(DEBUG) - void Show( int , std::ostream& ) const override {} + void Show( int , std::ostream& ) const override {} #endif }; diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 579936f58d..6619014d40 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -391,7 +391,7 @@ public: /** * Fetch an item by KIID. Frame-type-specific implementation. */ - virtual EDA_ITEM* GetItem( const KIID& aId ) { return nullptr; } + virtual EDA_ITEM* GetItem( const KIID& aId ) const { return nullptr; } /** * Print the page pointed by current screen, set by the calling print function. diff --git a/include/filename_resolver.h b/include/filename_resolver.h index f171672964..3b991b1abe 100644 --- a/include/filename_resolver.h +++ b/include/filename_resolver.h @@ -75,7 +75,7 @@ public: */ bool SetProject( PROJECT* aProject, bool* flgChanged = nullptr ); - wxString GetProjectDir( void ); + wxString GetProjectDir() const; /** * Set a pointer to the application's #PGM_BASE instance used to extract the local env vars. @@ -87,7 +87,7 @@ public: * Clear the current path list and substitutes the given path list and update the path * configuration file on success. */ - bool UpdatePathList( std::vector< SEARCH_PATH >& aPathList ); + bool UpdatePathList( const std::vector< SEARCH_PATH >& aPathList ); /** * Determines the full path of the given file name. @@ -114,27 +114,27 @@ public: * * @return pointer to the internal path list. */ - const std::list< SEARCH_PATH >* GetPaths( void ); + const std::list< SEARCH_PATH >* GetPaths() const; /** * Return true if the given name contains an alias and populates the string \a anAlias * with the alias and \a aRelPath with the relative path. */ - bool SplitAlias( const wxString& aFileName, wxString& anAlias, wxString& aRelPath ); + bool SplitAlias( const wxString& aFileName, wxString& anAlias, wxString& aRelPath ) const; /** * Returns true if the given path is a valid aliased relative path. * * If the path contains an alias then hasAlias is set true. */ - bool ValidateFileName( const wxString& aFileName, bool& hasAlias ); + bool ValidateFileName( const wxString& aFileName, bool& hasAlias ) const; /** * Return a list of path environment variables local to KiCad. * * This list always includes KICAD6_3DMODEL_DIR even if it is not defined locally. */ - bool GetKicadPaths( std::list< wxString >& paths ); + bool GetKicadPaths( std::list< wxString >& paths ) const; private: /** diff --git a/include/footprint_info.h b/include/footprint_info.h index 63a2663752..65ef341571 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -132,9 +132,6 @@ public: */ friend bool operator<( const FOOTPRINT_INFO& lhs, const FOOTPRINT_INFO& rhs ); -private: - friend bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ); - protected: void ensure_loaded() { @@ -222,7 +219,7 @@ public: * @param aIdx index of the given item. * @return the aIdx item in list. */ - FOOTPRINT_INFO& GetItem( unsigned aIdx ) + FOOTPRINT_INFO& GetItem( unsigned aIdx ) const { return *m_list[aIdx]; } diff --git a/include/hashtables.h b/include/hashtables.h index a1c9b5eecb..4a31d8771b 100644 --- a/include/hashtables.h +++ b/include/hashtables.h @@ -67,7 +67,7 @@ struct fnv_1a { std::size_t hash = 2166136261u; - for( ; *it; ++it ) + for( ; *it; ++it ) { hash ^= (unsigned char) *it; hash *= 16777619; @@ -84,9 +84,9 @@ struct WXSTRING_HASH : std::unary_function { std::size_t hash = 2166136261u; - for( wxString::const_iterator it = aString.begin(); it != aString.end(); ++it ) + for( const auto& c : aString ) { - unsigned ch = static_cast( *it ); + unsigned ch = static_cast( c ); hash ^= ch; hash *= 16777619; } diff --git a/include/multivector.h b/include/multivector.h index c619d76ffa..442c54e9b0 100644 --- a/include/multivector.h +++ b/include/multivector.h @@ -239,7 +239,7 @@ public: } } - bool empty( int aType = UNDEFINED_TYPE ) + bool empty( int aType = UNDEFINED_TYPE ) const { return ( size( aType ) == 0 ); } diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 8665f2f8e6..439be8a5df 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -206,7 +206,7 @@ public: */ virtual BOARD_ITEM_CONTAINER* GetModel() const = 0; - EDA_ITEM* GetItem( const KIID& aId ) override; + EDA_ITEM* GetItem( const KIID& aId ) const override; void FocusOnItem( BOARD_ITEM* aItem ); diff --git a/include/rc_item.h b/include/rc_item.h index e55153b9f6..6660f26d91 100644 --- a/include/rc_item.h +++ b/include/rc_item.h @@ -45,12 +45,12 @@ class RC_ITEMS_PROVIDER public: virtual void SetSeverities( int aSeverities ) = 0; - virtual int GetCount( int aSeverity = -1 ) = 0; + virtual int GetCount( int aSeverity = -1 ) const = 0; /** * Retrieve a RC_ITEM by index. */ - virtual std::shared_ptr GetItem( int aIndex ) = 0; + virtual std::shared_ptr GetItem( int aIndex ) const = 0; /** * Remove (and optionally deletes) the indexed item from the list. @@ -276,7 +276,7 @@ public: unsigned int aCol, wxDataViewItemAttr& aAttr ) const override; - void ValueChanged( RC_TREE_NODE* aNode ); + void ValueChanged( const RC_TREE_NODE* aNode ); void DeleteCurrentItem( bool aDeep ); diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index 8619da5361..7303dc609d 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -176,7 +176,7 @@ public: return RunAction( aAction, aNow, (void*) NULL ); } - const std::map& GetActions(); + const std::map& GetActions() const; /** * Send a cancel event to the tool currently at the top of the tool stack. @@ -192,9 +192,9 @@ public: void PrimeTool( const VECTOR2D& aPosition ); ///< @copydoc ACTION_MANAGER::GetHotKey() - int GetHotKey( const TOOL_ACTION& aAction ); + int GetHotKey( const TOOL_ACTION& aAction ) const; - ACTION_MANAGER* GetActionManager() { return m_actionMgr; } + ACTION_MANAGER* GetActionManager() const { return m_actionMgr; } /** * Search for a tool with given ID. @@ -213,7 +213,7 @@ public: TOOL_BASE* FindTool( const std::string& aName ) const; /* - * Return the tool of given type or NULL if there is no such tool registered. + * Return the tool of given type or nullptr if there is no such tool registered. */ template T* GetTool() @@ -223,7 +223,7 @@ public: if( tool != m_toolTypes.end() ) return static_cast( tool->second ); - return NULL; + return nullptr; } /** @@ -290,8 +290,8 @@ public: KIGFX::VIEW_CONTROLS* GetViewControls() const { return m_viewControls; } - VECTOR2D GetMousePosition(); - VECTOR2D GetCursorPosition(); + VECTOR2D GetMousePosition() const; + VECTOR2D GetCursorPosition() const; EDA_ITEM* GetModel() const { return m_model; } @@ -414,7 +414,7 @@ public: /** * True while processing a context menu. */ - bool IsContextMenuActive() + bool IsContextMenuActive() const { return m_menuActive; } @@ -443,7 +443,7 @@ public: */ bool DispatchHotKey( const TOOL_EVENT& aEvent ); - VECTOR2D GetMenuCursorPos() + VECTOR2D GetMenuCursorPos() const { return m_menuCursor; } @@ -452,9 +452,9 @@ private: typedef std::pair TRANSITION; /** - * Passe an event at first to the active tools, then to all others. + * Pass an event at first to the active tools, then to all others. */ - bool dispatchInternal( const TOOL_EVENT& aEvent ); + bool dispatchInternal( TOOL_EVENT& aEvent ); /** * Check if it is a valid activation event and invokes a proper tool. @@ -509,7 +509,7 @@ private: * @param aTool is the tool to be checked. * @return True if the tool is on the active tools stack, false otherwise. */ - bool isActive( TOOL_BASE* aTool ); + bool isActive( TOOL_BASE* aTool ) const; /** * Save the #VIEW_CONTROLS settings to the tool state object. @@ -521,7 +521,7 @@ private: /** * Apply #VIEW_CONTROLS settings stored in a #TOOL_STATE object. */ - void applyViewControls( TOOL_STATE* aState ); + void applyViewControls( const TOOL_STATE* aState ); /** * Main function for event processing. @@ -586,4 +586,4 @@ private: TOOL_STATE* m_activeState; }; -#endif +#endif // __TOOL_MANAGER_H diff --git a/include/widgets/mathplot.h b/include/widgets/mathplot.h index df8f5ca650..a517e9c674 100644 --- a/include/widgets/mathplot.h +++ b/include/widgets/mathplot.h @@ -153,42 +153,42 @@ public: virtual ~mpLayer() {}; /** Check whether this layer has a bounding box. - * The default implementation returns \a TRUE. Override and return - * FALSE if your mpLayer implementation should be ignored by the calculation + * The default implementation returns \a true. Override and return + * false if your mpLayer implementation should be ignored by the calculation * of the global bounding box for all layers in a mpWindow. - * @retval TRUE Has bounding box - * @retval FALSE Has not bounding box + * @retval true Has bounding box + * @retval false Has not bounding box */ - virtual bool HasBBox() { return TRUE; } + virtual bool HasBBox() const { return true; } /** Check whether the layer is an info box. - * The default implementation returns \a FALSE. It is overrided to \a TRUE for mpInfoLayer + * The default implementation returns \a false. It is overrided to \a true for mpInfoLayer * class and its derivative. It is necessary to define mouse actions behaviour over * info boxes. * @return whether the layer is an info boxes * @sa mpInfoLayer::IsInfo */ - virtual bool IsInfo() { return false; }; + virtual bool IsInfo() const { return false; }; /** Get inclusive left border of bounding box. * @return Value */ - virtual double GetMinX() { return -1.0; } + virtual double GetMinX() const { return -1.0; } /** Get inclusive right border of bounding box. * @return Value */ - virtual double GetMaxX() { return 1.0; } + virtual double GetMaxX() const { return 1.0; } /** Get inclusive bottom border of bounding box. * @return Value */ - virtual double GetMinY() { return -1.0; } + virtual double GetMinY() const { return -1.0; } /** Get inclusive top border of bounding box. * @return Value */ - virtual double GetMaxY() { return 1.0; } + virtual double GetMaxY() const { return 1.0; } /** Plot given view of layer to the given device context. * An implementation of this function has to transform layer coordinates to @@ -246,7 +246,7 @@ public: /** Get pen set for this layer. * @return Pen */ - const wxPen& GetPen() const { return m_pen; } + const wxPen& GetPen() const { return m_pen; } /** Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points). * @sa GetContinuity @@ -288,15 +288,15 @@ public: /** Get a small square bitmap filled with the colour of the pen used in the layer. Useful to create legends or similar reference to the layers. * @param side side length in pixels * @return a wxBitmap filled with layer's colour */ - wxBitmap GetColourSquare( int side = 16 ); + wxBitmap GetColourSquare( int side = 16 ) const; /** Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value. * @return An integer indicating layer type */ - mpLayerType GetLayerType() { return m_type; }; + mpLayerType GetLayerType() const { return m_type; }; /** Checks whether the layer is visible or not. * @return \a true if visible */ - bool IsVisible() { return m_visible; }; + bool IsVisible() const { return m_visible; }; /** Sets layer visibility. * @param show visibility bool. */ @@ -354,8 +354,8 @@ public: virtual void UpdateInfo( mpWindow& w, wxEvent& event ); /** mpInfoLayer has not bounding box. @sa mpLayer::HasBBox - * @return always \a FALSE */ - virtual bool HasBBox() override { return false; } + * @return always \a false */ + virtual bool HasBBox() const override { return false; } /** Plot method. Can be overidden by derived classes. * @param dc the device content where to plot @@ -364,9 +364,9 @@ public: virtual void Plot( wxDC& dc, mpWindow& w ) override; /** Specifies that this is an Info box layer. - * @return always \a TRUE + * @return always \a true * @sa mpLayer::IsInfo */ - virtual bool IsInfo() override { return true; } + virtual bool IsInfo() const override { return true; } /** Checks whether a point is inside the info box rectangle. * @param point The point to be checked @@ -382,15 +382,15 @@ public: /** Returns the position of the upper left corner of the box (in pixels) * @return The rectangle position */ - wxPoint GetPosition(); + wxPoint GetPosition() const; /** Returns the size of the box (in pixels) * @return The rectangle size */ - wxSize GetSize(); + wxSize GetSize() const; /** Returns the current rectangle coordinates. * @return The info layer rectangle */ - const wxRect& GetRectangle() { return m_dim; }; + const wxRect& GetRectangle() const { return m_dim; }; protected: wxRect m_dim; // !< The bounding rectangle of the box. It may be resized dynamically by the Plot method. @@ -534,7 +534,7 @@ public: * @param x Argument * @return Function value */ - virtual double GetY( double x ) = 0; + virtual double GetY( double x ) const = 0; /** Layer plot handler. * This implementation will plot the function in the visible area and @@ -566,7 +566,7 @@ public: * @param y Argument * @return Function value */ - virtual double GetX( double y ) = 0; + virtual double GetX( double y ) const = 0; /** Layer plot handler. * This implementation will plot the function in the visible area and @@ -607,7 +607,7 @@ public: */ virtual bool GetNextXY( double& x, double& y ) = 0; - virtual size_t GetCount() = 0; + virtual size_t GetCount() const = 0; /** Layer plot handler. * This implementation will plot the locus in the visible area and @@ -661,7 +661,7 @@ public: * @param x Argument * @return Function value */ - virtual double GetY( double x ) = 0; + virtual double GetY( double x ) const = 0; /** Layer plot handler. * This implementation will plot the function in the visible area and @@ -697,9 +697,9 @@ public: mpScaleBase(); virtual ~mpScaleBase() {}; - virtual bool IsHorizontal() = 0; + virtual bool IsHorizontal() const = 0; - bool HasBBox() override { return FALSE; } + bool HasBBox() const override { return false; } /** Set X axis alignment. * @param align alignment (choose between mpALIGN_BORDER_BOTTOM, mpALIGN_BOTTOM, mpALIGN_CENTER, @@ -715,9 +715,9 @@ public: void SetTicks( bool enable ) { m_ticks = enable; }; /** Get X axis ticks or grid - * @return TRUE if plot is drawing axis ticks, FALSE if the grid is active. + * @return true if plot is drawing axis ticks, false if the grid is active. */ - bool GetTicks() { return m_ticks; }; + bool GetTicks() const { return m_ticks; }; // virtual double X2p( mpWindow &w, double x ) = 0; @@ -730,7 +730,7 @@ public: m_maxV = maxV; } - void GetDataRange( double& minV, double& maxV ) + void GetDataRange( double& minV, double& maxV ) const { minV = m_minV; maxV = m_maxV; @@ -772,8 +772,8 @@ public: return m_absVisibleMaxV; } - virtual double TransformToPlot( double x ) { return 0.0; }; - virtual double TransformFromPlot( double xplot ) { return 0.0; }; + virtual double TransformToPlot( double x ) const { return 0.0; }; + virtual double TransformFromPlot( double xplot ) const { return 0.0; }; struct TickLabel { @@ -794,7 +794,7 @@ protected: void updateTickLabels( wxDC& dc, mpWindow& w ); void computeLabelExtents( wxDC& dc, mpWindow& w ); - // virtual int getLabelDecimalDigits(int maxDigits); + // virtual int getLabelDecimalDigits(int maxDigits) const; virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) {}; virtual void recalculateTicks( wxDC& dc, mpWindow& w ) {}; @@ -811,17 +811,17 @@ protected: virtual const wxString formatLabel( double value, int nDigits ) { return wxT( "" ); } virtual void formatLabels() {}; - virtual double getTickPos( int n ) + virtual double getTickPos( int n ) const { return m_tickValues[n]; } - virtual double getLabelPos( int n ) + virtual double getLabelPos( int n ) const { return m_tickLabels[n].pos; } - virtual const wxString getLabel( int n ) + virtual wxString getLabel( int n ) const { return m_tickLabels[n].label; } @@ -846,14 +846,14 @@ public: /** Full constructor. * @param name Label to plot by the ruler * @param flags Set the position of the scale with respect to the window. - * @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid. + * @param ticks Select ticks or grid. Give true (default) for drawing axis ticks, false for drawing the grid. * @param type mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds. */ mpScaleXBase( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER, bool ticks = true, unsigned int type = mpX_NORMAL ); virtual ~mpScaleXBase() {}; - virtual bool IsHorizontal() override { return true; } + virtual bool IsHorizontal() const override { return true; } /** Layer plot handler. * This implementation will plot the ruler adjusted to the visible area. */ virtual void Plot( wxDC& dc, mpWindow& w ) override; @@ -873,7 +873,7 @@ public: /** Full constructor. * @param name Label to plot by the ruler * @param flags Set the position of the scale with respect to the window. - * @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid. + * @param ticks Select ticks or grid. Give true (default) for drawing axis ticks, false for drawing the grid. * @param type mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds. */ mpScaleX( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER, bool ticks = true, unsigned int type = mpX_NORMAL ); @@ -884,8 +884,8 @@ public: // virtual double X2p( mpWindow &w, double x ); // virtual double P2x( mpWindow &w, double x ); - virtual double TransformToPlot( double x ) override; - virtual double TransformFromPlot( double xplot ) override; + virtual double TransformToPlot( double x ) const override; + virtual double TransformFromPlot( double xplot ) const override; protected: virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override; @@ -901,14 +901,14 @@ public: /** Full constructor. * @param name Label to plot by the ruler * @param flags Set the position of the scale with respect to the window. - * @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid. + * @param ticks Select ticks or grid. Give true (default) for drawing axis ticks, false for drawing the grid. * @param type mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds. */ mpScaleXLog( const wxString& name = wxT("log(X)"), int flags = mpALIGN_CENTER, bool ticks = true, unsigned int type = mpX_NORMAL ); - virtual double TransformToPlot( double x ) override; - virtual double TransformFromPlot( double xplot ) override; + virtual double TransformToPlot( double x ) const override; + virtual double TransformFromPlot( double xplot ) const override; /** Layer plot handler. * This implementation will plot the ruler adjusted to the visible area. @@ -944,11 +944,11 @@ class WXDLLIMPEXP_MATHPLOT mpScaleY : public mpScaleBase public: /** @param name Label to plot by the ruler * @param flags Set position of the scale respect to the window. - * @param ticks Select ticks or grid. Give TRUE (default) for drawing axis ticks, FALSE for drawing the grid + * @param ticks Select ticks or grid. Give true (default) for drawing axis ticks, false for drawing the grid */ - mpScaleY( const wxString& name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true ); + mpScaleY( const wxString& name = wxT( "Y" ), int flags = mpALIGN_CENTER, bool ticks = true ); - virtual bool IsHorizontal() override { return false; } + virtual bool IsHorizontal() const override { return false; } /** Layer plot handler. * This implementation will plot the ruler adjusted to the visible area. @@ -956,25 +956,25 @@ public: virtual void Plot( wxDC& dc, mpWindow& w ) override; /** Check whether this layer has a bounding box. - * This implementation returns \a FALSE thus making the ruler invisible + * This implementation returns \a false thus making the ruler invisible * to the plot layer bounding box calculation by mpWindow. */ - virtual bool HasBBox() override { return FALSE; } + virtual bool HasBBox() const override { return false; } /** Set Y axis alignment. * @param align alignment (choose between mpALIGN_BORDER_LEFT, mpALIGN_LEFT, mpALIGN_CENTER, mpALIGN_RIGHT, mpALIGN_BORDER_RIGHT) */ void SetAlign( int align ) { m_flags = align; }; /** Set Y axis ticks or grid - * @param ticks TRUE to plot axis ticks, FALSE to plot grid. */ + * @param ticks true to plot axis ticks, false to plot grid. */ void SetTicks( bool ticks ) { m_ticks = ticks; }; /** Get Y axis ticks or grid - * @return TRUE if plot is drawing axis ticks, FALSE if the grid is active. */ - bool GetTicks() { return m_ticks; }; + * @return true if plot is drawing axis ticks, false if the grid is active. */ + bool GetTicks() const { return m_ticks; }; - virtual double TransformToPlot( double x ) override; - virtual double TransformFromPlot( double xplot ) override; + virtual double TransformToPlot( double x ) const override; + virtual double TransformFromPlot( double xplot ) const override; void SetMasterScale( mpScaleY* masterScale ) @@ -1063,8 +1063,8 @@ public: * @param layer Pointer to layer. The mpLayer object will get under control of mpWindow, * i.e. it will be delete'd on mpWindow destruction * @param refreshDisplay States whether to refresh the display (UpdateAll) after adding the layer. - * @retval TRUE Success - * @retval FALSE Failure due to out of memory. + * @retval true Success + * @retval false Failure due to out of memory. */ bool AddLayer( mpLayer* layer, bool refreshDisplay = true ); @@ -1090,19 +1090,23 @@ public: * @param position position of the layer in the layers list * @return pointer to mpLayer */ - mpLayer* GetLayer( int position ); + mpLayer* GetLayer( int position ) const; /*! Get the layer by its name (case sensitive). * @param name The name of the layer to retrieve * @return A pointer to the mpLayer object, or NULL if not found. */ - mpLayer* GetLayerByName( const wxString& name ); + const mpLayer* GetLayerByName( const wxString& name ) const; + mpLayer* GetLayerByName( const wxString& name ) + { + return const_cast( static_cast( this )->GetLayerByName( name ) ); + } /** Get current view's X scale. * See @ref mpLayer::Plot "rules for coordinate transformation" * @return Scale */ - double GetXscl() { return m_scaleX; } + double GetXscl() const { return m_scaleX; } double GetScaleX( void ) const { return m_scaleX; }; // Schaling's method: maybe another method esists with the same name /** Get current view's Y scale. @@ -1154,7 +1158,7 @@ public: */ void SetScaleY( double scaleY ) { - if( scaleY!=0 ) + if( scaleY != 0 ) m_scaleY = scaleY; UpdateAll(); @@ -1221,13 +1225,13 @@ public: * an unlocked aspect, but any other action changing the view scale will * lock the aspect again. */ - void LockAspect( bool enable = TRUE ); + void LockAspect( bool enable = true ); /** Checks whether the X/Y scale aspect is locked. - * @retval TRUE Locked - * @retval FALSE Unlocked + * @retval true Locked + * @retval false Unlocked */ - inline bool IsAspectLocked() { return m_lockaspect; } + inline bool IsAspectLocked() const { return m_lockaspect; } /** Set view to fit global bounding box of all plot layers and refresh display. * Scale and position will be set to show all attached mpLayers. @@ -1283,11 +1287,11 @@ public: * which have a bounding box. * \return The number of profiles plotted. */ - unsigned int CountLayers(); + unsigned int CountLayers() const; /** Counts the number of plot layers, whether or not they have a bounding box. * \return The number of layers in the mpWindow. */ - unsigned int CountAllLayers() { return m_layers.size(); }; + unsigned int CountAllLayers() const { return m_layers.size(); }; #if 0 /** Draws the mpWindow on a page for printing @@ -1300,30 +1304,30 @@ public: * (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). * @sa Fit */ - double GetDesiredXmin() { return m_desiredXmin; } + double GetDesiredXmin() const { return m_desiredXmin; } /** Returns the right-border layer coordinate that the user wants the mpWindow to show * (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). * @sa Fit */ - double GetDesiredXmax() { return m_desiredXmax; } + double GetDesiredXmax() const { return m_desiredXmax; } /** Returns the bottom-border layer coordinate that the user wants the mpWindow to show * (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). * @sa Fit */ - double GetDesiredYmin() { return m_desiredYmin; } + double GetDesiredYmin() const { return m_desiredYmin; } /** Returns the top layer-border coordinate that the user wants the mpWindow to show * (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). * @sa Fit */ - double GetDesiredYmax() { return m_desiredYmax; } + double GetDesiredYmax() const { return m_desiredYmax; } /** Returns the bounding box coordinates * @param bbox Pointer to a 6-element double array where to store bounding box coordinates. */ - void GetBoundingBox( double* bbox ); + void GetBoundingBox( double* bbox ) const; /** Enable/disable scrollbars * @param status Set to true to show scrollbars */ @@ -1331,7 +1335,7 @@ public: /** Get scrollbars status. * @return true if scrollbars are visible */ - bool GetMPScrollbars() { return m_enableScrollBars; }; + bool GetMPScrollbars() const { return m_enableScrollBars; }; /** Draw the window on a wxBitmap, then save it to a file. * @param filename File name where to save the screenshot @@ -1365,13 +1369,13 @@ public: void SetMarginLeft( int left ) { m_marginLeft = left; }; /** @return the top margin. */ - int GetMarginTop() { return m_marginTop; }; + int GetMarginTop() const { return m_marginTop; }; /** @return the right margin. */ - int GetMarginRight() { return m_marginRight; }; + int GetMarginRight() const { return m_marginRight; }; /** @return the bottom margin. */ - int GetMarginBottom() { return m_marginBottom; }; + int GetMarginBottom() const { return m_marginBottom; }; /** @return the left margin. */ - int GetMarginLeft() { return m_marginLeft; }; + int GetMarginLeft() const { return m_marginLeft; }; #if 0 /** Sets whether to show coordinate tooltip when mouse passes over the plot. @@ -1398,7 +1402,7 @@ public: /** Check whether a layer with given name is visible * @param name The layer name * @return layer visibility status */ - bool IsLayerVisible( const wxString& name ); + bool IsLayerVisible( const wxString& name ) const; /** Sets the visibility of a layer by its position in layer list. * @param position The layer position in layer list @@ -1408,7 +1412,7 @@ public: /** Check whether the layer at given position is visible * @param position The layer position in layer list * @return layer visibility status */ - bool IsLayerVisible( const unsigned int position ); + bool IsLayerVisible( unsigned int position ) const; /** Set Color theme. Provide colours to set a new colour theme. * @param bgColour Background colour @@ -1609,24 +1613,24 @@ protected: */ bool GetNextXY( double& x, double& y ) override; - size_t GetCount() override; + size_t GetCount() const override; public: /** Returns the actual minimum X data (loaded in SetData). */ - double GetMinX() override { return m_minX; } + double GetMinX() const override { return m_minX; } /** Returns the actual minimum Y data (loaded in SetData). */ - double GetMinY() override { return m_minY; } + double GetMinY() const override { return m_minY; } /** Returns the actual maximum X data (loaded in SetData). */ - double GetMaxX() override { return m_maxX; } + double GetMaxX() const override { return m_maxX; } /** Returns the actual maximum Y data (loaded in SetData). */ - double GetMaxY() override { return m_maxY; } + double GetMaxY() const override { return m_maxY; } protected: @@ -1678,7 +1682,7 @@ public: virtual void Plot( wxDC& dc, mpWindow& w ) override; /** mpText should not be used for scaling decisions. */ - virtual bool HasBBox() override { return FALSE; } + virtual bool HasBBox() const override { return false; } protected: int m_offsetx; // !< Holds offset for X in percentage @@ -1758,23 +1762,23 @@ public: ShapeUpdated(); } - virtual bool HasBBox() override { return m_trans_shape_xs.size()!=0; } + virtual bool HasBBox() const override { return m_trans_shape_xs.size()!=0; } /** Get inclusive left border of bounding box. */ - virtual double GetMinX() override { return m_bbox_min_x; } + virtual double GetMinX() const override { return m_bbox_min_x; } /** Get inclusive right border of bounding box. */ - virtual double GetMaxX() override { return m_bbox_max_x; } + virtual double GetMaxX() const override { return m_bbox_max_x; } /** Get inclusive bottom border of bounding box. */ - virtual double GetMinY() override { return m_bbox_min_y; } + virtual double GetMinY() const override { return m_bbox_min_y; } /** Get inclusive top border of bounding box. */ - virtual double GetMaxY() override { return m_bbox_max_y; } + virtual double GetMaxY() const override { return m_bbox_max_y; } virtual void Plot( wxDC& dc, mpWindow& w ) override; @@ -1972,23 +1976,23 @@ public: */ void SetBitmap( const wxImage& inBmp, double x, double y, double lx, double ly ); - virtual bool HasBBox() override { return true; } + virtual bool HasBBox() const override { return true; } /** Get inclusive left border of bounding box. */ - virtual double GetMinX() override { return m_min_x; } + virtual double GetMinX() const override { return m_min_x; } /** Get inclusive right border of bounding box. */ - virtual double GetMaxX() override { return m_max_x; } + virtual double GetMaxX() const override { return m_max_x; } /** Get inclusive bottom border of bounding box. */ - virtual double GetMinY() override { return m_min_y; } + virtual double GetMinY() const override { return m_min_y; } /** Get inclusive top border of bounding box. */ - virtual double GetMaxY() override { return m_max_y; } + virtual double GetMaxY() const override { return m_max_y; } virtual void Plot( wxDC& dc, mpWindow& w ) override; diff --git a/libs/kimath/include/geometry/shape_poly_set.h b/libs/kimath/include/geometry/shape_poly_set.h index 708c90b43e..e575bb63a5 100644 --- a/libs/kimath/include/geometry/shape_poly_set.h +++ b/libs/kimath/include/geometry/shape_poly_set.h @@ -418,7 +418,7 @@ public: /** * @return the indices of the current polygon, contour and vertex. */ - VERTEX_INDEX GetIndex() + VERTEX_INDEX GetIndex() const { VERTEX_INDEX index; @@ -434,7 +434,7 @@ public: * @return true if both iterators point to the same segment of the same contour of * the same polygon of the same polygon set; false otherwise. */ - bool IsAdjacent( SEGMENT_ITERATOR_TEMPLATE aOther ) + bool IsAdjacent( SEGMENT_ITERATOR_TEMPLATE aOther ) const { // Check that both iterators point to the same contour of the same polygon of the // same polygon set. @@ -449,7 +449,7 @@ public: // are adjacent. The only missing case where they also are adjacent is when // the segments are the first and last one, in which case the difference // always equals the total number of segments minus one. - int indexDiff = abs( m_currentSegment - aOther.m_currentSegment ); + int indexDiff = std::abs( m_currentSegment - aOther.m_currentSegment ); return ( indexDiff == 1 ) || ( indexDiff == (numSeg - 1) ); } @@ -495,7 +495,7 @@ public: ~SHAPE_POLY_SET(); - SHAPE_POLY_SET& operator=( const SHAPE_POLY_SET& ); + SHAPE_POLY_SET& operator=( const SHAPE_POLY_SET& aOther ); void CacheTriangulation( bool aPartition = true ); bool IsTriangulationUpToDate() const; @@ -530,7 +530,7 @@ public: * @return true if the relative indices are correct; false otherwise. The computed * global index is returned in the \p aGlobalIdx reference. */ - bool GetGlobalIndex( VERTEX_INDEX aRelativeIndices, int& aGlobalIdx ); + bool GetGlobalIndex( VERTEX_INDEX aRelativeIndices, int& aGlobalIdx ) const; /// @copydoc SHAPE::Clone() SHAPE* Clone() const override; @@ -871,7 +871,13 @@ public: return IterateSegments( 0, OutlineCount() - 1 ); } - ///< Return an iterator object, for all outlines in the set (with holes). + ///< Returns an iterator object, for all outlines in the set (no holes) + CONST_SEGMENT_ITERATOR CIterateSegments() const + { + return CIterateSegments( 0, OutlineCount() - 1 ); + } + + ///< Returns an iterator object, for all outlines in the set (with holes) SEGMENT_ITERATOR IterateSegmentsWithHoles() { return IterateSegments( 0, OutlineCount() - 1, true ); @@ -1161,7 +1167,7 @@ public: ///< Return true if the set is empty (no polygons at all) bool IsEmpty() const { - return m_polys.size() == 0; + return m_polys.empty(); } /** @@ -1402,4 +1408,4 @@ private: MD5_HASH m_hash; }; -#endif +#endif // __SHAPE_POLY_SET_H diff --git a/libs/kimath/src/geometry/shape_compound.cpp b/libs/kimath/src/geometry/shape_compound.cpp index 1bf6bb198c..87e0128b47 100644 --- a/libs/kimath/src/geometry/shape_compound.cpp +++ b/libs/kimath/src/geometry/shape_compound.cpp @@ -51,7 +51,7 @@ SHAPE_COMPOUND::SHAPE_COMPOUND( const std::vector& aShapes ) : SHAPE_COMPOUND::SHAPE_COMPOUND( const SHAPE_COMPOUND& aOther ) : SHAPE( SH_COMPOUND ) { - for ( auto shape : aOther.Shapes() ) + for ( const SHAPE* shape : aOther.Shapes() ) m_shapes.push_back( shape->Clone() ); m_dirty = true; diff --git a/libs/kimath/src/geometry/shape_poly_set.cpp b/libs/kimath/src/geometry/shape_poly_set.cpp index bf66c71549..73156d52d3 100644 --- a/libs/kimath/src/geometry/shape_poly_set.cpp +++ b/libs/kimath/src/geometry/shape_poly_set.cpp @@ -143,7 +143,7 @@ bool SHAPE_POLY_SET::GetRelativeIndices( int aGlobalIdx, bool SHAPE_POLY_SET::GetGlobalIndex( SHAPE_POLY_SET::VERTEX_INDEX aRelativeIndices, - int& aGlobalIdx ) + int& aGlobalIdx ) const { int selectedVertex = aRelativeIndices.m_vertex; unsigned int selectedContour = aRelativeIndices.m_contour; @@ -1334,9 +1334,9 @@ bool SHAPE_POLY_SET::Collide( const SHAPE* aShape, int aClearance, int* aActual, int actual = INT_MAX; VECTOR2I location; - for( auto& tpoly : m_triangulatedPolys ) + for( const auto& tpoly : m_triangulatedPolys ) { - for ( auto& tri : tpoly->Triangles() ) + for ( const auto& tri : tpoly->Triangles() ) { int triActual; VECTOR2I triLocation; diff --git a/pcb_calculator/params_read_write.cpp b/pcb_calculator/params_read_write.cpp index 3a462c4c39..1b9681c8be 100644 --- a/pcb_calculator/params_read_write.cpp +++ b/pcb_calculator/params_read_write.cpp @@ -136,7 +136,7 @@ bool IsSelectedInDialog( enum PRMS_ID aPrmId ) * @param aPrmId = param id to write * @return the value always in normalized unit (meter, Hz, Ohm, radian) */ -double PCB_CALCULATOR_FRAME::GetPrmValue( enum PRMS_ID aPrmId ) +double PCB_CALCULATOR_FRAME::GetPrmValue( enum PRMS_ID aPrmId ) const { TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType]; for( unsigned ii = 0; ii < tr_ident->GetPrmsCount(); ii++ ) @@ -238,7 +238,7 @@ void PCB_CALCULATOR_FRAME::SetResult( int aLineNumber, const wxString& aText ) * @return true if the param aPrmId is selected * Has meaning only for params that have a radio button */ -bool PCB_CALCULATOR_FRAME::IsPrmSelected( enum PRMS_ID aPrmId ) +bool PCB_CALCULATOR_FRAME::IsPrmSelected( enum PRMS_ID aPrmId ) const { switch( aPrmId ) { diff --git a/pcb_calculator/pcb_calculator_frame.h b/pcb_calculator/pcb_calculator_frame.h index d41e4a0a0e..9fb48dff5e 100644 --- a/pcb_calculator/pcb_calculator_frame.h +++ b/pcb_calculator/pcb_calculator_frame.h @@ -344,14 +344,14 @@ public: * @param aPrmId = param id to write * @return the value always in normalized unit (meter, Hz, Ohm, radian) */ - double GetPrmValue( enum PRMS_ID aPrmId ); + double GetPrmValue( enum PRMS_ID aPrmId ) const; /** * Function IsPrmSelected * @return true if the param aPrmId is selected * Has meaning only for params that have a radio button */ - bool IsPrmSelected( enum PRMS_ID aPrmId ); + bool IsPrmSelected( enum PRMS_ID aPrmId ) const; // Board classes panel: void OnBoardClassesUnitsSelection( wxCommandEvent& event ) override; diff --git a/pcb_calculator/transline_ident.h b/pcb_calculator/transline_ident.h index d0d93da62d..3aeb6adbf5 100644 --- a/pcb_calculator/transline_ident.h +++ b/pcb_calculator/transline_ident.h @@ -114,16 +114,16 @@ public: } - TRANSLINE_PRM* GetPrm( unsigned aIdx ) + TRANSLINE_PRM* GetPrm( unsigned aIdx ) const { - if( aIdx < m_prms_List.size() ) + if( aIdx < m_prms_List.size() ) return m_prms_List[aIdx]; else return NULL; } - unsigned GetPrmsCount() + unsigned GetPrmsCount() const { return m_prms_List.size(); } diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 8f71a6fc5f..b14494201a 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -289,7 +289,7 @@ TRACKS BOARD::TracksInNet( int aNetCode ) INSPECTOR_FUNC inspector = [aNetCode, &ret]( EDA_ITEM* item, void* testData ) { - TRACK* t = (TRACK*) item; + TRACK* t = static_cast( item ); if( t->GetNetCode() == aNetCode ) ret.push_back( t ); @@ -543,7 +543,7 @@ void BOARD::SetElementVisibility( GAL_LAYER_ID aLayer, bool isEnabled ) } -bool BOARD::IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) +bool BOARD::IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const { switch( aLayer ) { @@ -904,7 +904,7 @@ void BOARD::FillItemMap( std::map& aMap ) } -wxString BOARD::ConvertCrossReferencesToKIIDs( const wxString& aSource ) +wxString BOARD::ConvertCrossReferencesToKIIDs( const wxString& aSource ) const { wxString newbuf; size_t sourceLen = aSource.length(); @@ -932,7 +932,7 @@ wxString BOARD::ConvertCrossReferencesToKIIDs( const wxString& aSource ) wxString remainder; wxString ref = token.BeforeFirst( ':', &remainder ); - for( FOOTPRINT* footprint : Footprints() ) + for( const FOOTPRINT* footprint : Footprints() ) { if( footprint->GetReference().CmpNoCase( ref ) == 0 ) { @@ -958,7 +958,7 @@ wxString BOARD::ConvertCrossReferencesToKIIDs( const wxString& aSource ) } -wxString BOARD::ConvertKIIDsToCrossReferences( const wxString& aSource ) +wxString BOARD::ConvertKIIDsToCrossReferences( const wxString& aSource ) const { wxString newbuf; size_t sourceLen = aSource.length(); @@ -1389,11 +1389,11 @@ int BOARD::SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount ) } -std::vector BOARD::GetNetClassAssignmentCandidates() +std::vector BOARD::GetNetClassAssignmentCandidates() const { std::vector names; - for( NETINFO_ITEM* net : m_NetInfo ) + for( const NETINFO_ITEM* net : m_NetInfo ) { if( !net->GetNetname().IsEmpty() ) names.emplace_back( net->GetNetname() ); @@ -1477,7 +1477,7 @@ int BOARD::SetAreasNetCodesFromNetNames() } -PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet ) +PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet ) const { if( !aLayerSet.any() ) aLayerSet = LSET::AllCuMask(); @@ -1497,7 +1497,7 @@ PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet ) } -PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint ) +PAD* BOARD::GetPad( const TRACK* aTrace, ENDPOINT_T aEndPoint ) const { const wxPoint& aPosition = aTrace->GetEndPoint( aEndPoint ); @@ -1507,7 +1507,7 @@ PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint ) } -PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerSet ) +PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerSet ) const { for( FOOTPRINT* footprint : Footprints() ) { @@ -1526,11 +1526,11 @@ PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerSet ) } -PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, LSET aLayerSet ) +PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, LSET aLayerSet ) const { // Search aPadList for aPosition // aPadList is sorted by X then Y values, and a fast binary search is used - int idxmax = aPadList.size()-1; + int idxmax = aPadList.size() - 1; int delta = aPadList.size(); @@ -1568,7 +1568,7 @@ PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, LSET return pad; } // search previous - for( int ii = idx-1 ;ii >=0; ii-- ) + for( int ii = idx - 1 ;ii >=0; ii-- ) { pad = aPadList[ii]; @@ -1634,13 +1634,13 @@ bool sortPadsByXthenYCoord( PAD* const & aLH, PAD* const & aRH ) } -void BOARD::GetSortedPadListByXthenYCoord( std::vector& aVector, int aNetCode ) +void BOARD::GetSortedPadListByXthenYCoord( std::vector& aVector, int aNetCode ) const { for( FOOTPRINT* footprint : Footprints() ) { for( PAD* pad : footprint->Pads( ) ) { - if( aNetCode < 0 || pad->GetNetCode() == aNetCode ) + if( aNetCode < 0 || pad->GetNetCode() == aNetCode ) aVector.push_back( pad ); } } @@ -1703,7 +1703,7 @@ std::tuple BOARD::GetTrackLength( const TRACK& aTrack ) con FOOTPRINT* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer, - bool aVisibleOnly, bool aIgnoreLocked ) + bool aVisibleOnly, bool aIgnoreLocked ) const { FOOTPRINT* footprint = NULL; FOOTPRINT* alt_footprint = NULL; @@ -1740,7 +1740,7 @@ FOOTPRINT* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLa if( dist <= min_dim ) { // better footprint shown on the active side - footprint = candidate; + footprint = candidate; min_dim = dist; } } @@ -1749,7 +1749,7 @@ FOOTPRINT* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLa if( dist <= alt_min_dim ) { // better footprint shown on the other side - alt_footprint = candidate; + alt_footprint = candidate; alt_min_dim = dist; } } @@ -1766,7 +1766,7 @@ FOOTPRINT* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLa } -std::list BOARD::GetZoneList( bool aIncludeZonesInFootprints ) +std::list BOARD::GetZoneList( bool aIncludeZonesInFootprints ) const { std::list zones; diff --git a/pcbnew/board.h b/pcbnew/board.h index f7401b20cc..9929cca758 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -404,8 +404,8 @@ public: /** * Convert cross-references back and forth between ${refDes:field} and ${kiid:field} */ - wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ); - wxString ConvertKIIDsToCrossReferences( const wxString& aSource ); + wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const; + wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const; /** * Return a list of missing connections between components/tracks. @@ -583,7 +583,7 @@ public: * @param aLayer One of the two allowed layers for footprints: F_Cu or B_Cu * @return bool - true if the layer is visible, else false. */ - bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ); + bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const; /** * @return the BOARD_DESIGN_SETTINGS for this BOARD @@ -635,7 +635,7 @@ public: * @param aLayer = A copper layer, like B_Cu, etc. * @param aOutlines The SHAPE_POLY_SET to fill in with items outline. */ - void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ); + void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const; /** * Return the ID of a layer. @@ -861,7 +861,7 @@ public: * Tokens may appear more than once if they were harvested from hierarchical nets * (ie: /CLK, /sheet1/CLK). */ - std::vector GetNetClassAssignmentCandidates(); + std::vector GetNetClassAssignmentCandidates() const; /** * Copy NETCLASS info to each NET, based on NET membership in a NETCLASS. @@ -919,7 +919,7 @@ public: /** * @return a std::list of pointers to all board zones (possibly including zones in footprints) */ - std::list GetZoneList( bool aIncludeZonesInFootprints = false ); + std::list GetZoneList( bool aIncludeZonesInFootprints = false ) const; /** * @return The number of copper pour areas or ZONEs. @@ -981,8 +981,8 @@ public: * @param aLayerMask A layer or layers to mask the hit test. * @return A pointer to a PAD object if found or NULL if not found. */ - PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask ); - PAD* GetPad( const wxPoint& aPosition ) + PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask ) const; + PAD* GetPad( const wxPoint& aPosition ) const { return GetPad( aPosition, LSET().set() ); } @@ -994,7 +994,7 @@ public: * @param aEndPoint The end point of \a aTrace the hit test against. * @return A pointer to a PAD object if found or NULL if not found. */ - PAD* GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint ); + PAD* GetPad( const TRACK* aTrace, ENDPOINT_T aEndPoint ) const; /** * Return pad found at \a aPosition on \a aLayerMask using the fast search method. @@ -1005,7 +1005,7 @@ public: * @param aLayerMask A layer or layers to mask the hit test. * @return A pointer to a PAD object if found or NULL if not found. */ - PAD* GetPadFast( const wxPoint& aPosition, LSET aLayerMask ); + PAD* GetPadFast( const wxPoint& aPosition, LSET aLayerMask ) const; /** * Locate the pad connected at \a aPosition on \a aLayer starting at list position @@ -1021,7 +1021,7 @@ public: * @param aLayerMask A layer or layers to mask the hit test. * @return a PAD object pointer to the connected pad. */ - PAD* GetPad( std::vector& aPadList, const wxPoint& aPosition, LSET aLayerMask ); + PAD* GetPad( std::vector& aPadList, const wxPoint& aPosition, LSET aLayerMask ) const; /** * Delete a given pad from the BOARD by removing it from its footprint and from the @@ -1040,7 +1040,7 @@ public: * = -1 to build the full pad list. * = a given netcode to build the pad list relative to the given net */ - void GetSortedPadListByXthenYCoord( std::vector& aVector, int aNetCode = -1 ); + void GetSortedPadListByXthenYCoord( std::vector& aVector, int aNetCode = -1 ) const; /** * Returns data on the length and number of track segments connected to a given track. @@ -1072,7 +1072,7 @@ public: * @param aIgnoreLocked Ignore locked footprints when true. */ FOOTPRINT* GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer, - bool aVisibleOnly, bool aIgnoreLocked = false ); + bool aVisibleOnly, bool aIgnoreLocked = false ) const; /** * Reset all items' netcodes to 0 (no net). diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 1dd736109a..2207abfb32 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -66,12 +66,12 @@ static void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData ) } -void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) +void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const { int maxError = GetDesignSettings().m_MaxError; // convert tracks and vias: - for( TRACK* track : m_tracks ) + for( const TRACK* track : m_tracks ) { if( !track->IsOnLayer( aLayer ) ) continue; @@ -81,7 +81,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ } // convert pads and other copper items in footprints - for( FOOTPRINT* footprint : m_footprints ) + for( const FOOTPRINT* footprint : m_footprints ) { footprint->TransformPadsWithClearanceToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE ); @@ -92,7 +92,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ true, /* include text */ true /* include shapes */ ); - for( ZONE* zone : footprint->Zones() ) + for( const ZONE* zone : footprint->Zones() ) { if( zone->GetLayerSet().test( aLayer ) ) zone->TransformSolidAreasShapesToPolygon( aLayer, aOutlines ); @@ -100,14 +100,14 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ } // convert copper zones - for( ZONE* zone : Zones() ) + for( const ZONE* zone : Zones() ) { if( zone->GetLayerSet().test( aLayer ) ) zone->TransformSolidAreasShapesToPolygon( aLayer, aOutlines ); } // convert graphic items on copper layers (texts) - for( BOARD_ITEM* item : m_drawings ) + for( const BOARD_ITEM* item : m_drawings ) { if( !item->IsOnLayer( aLayer ) ) continue; @@ -116,7 +116,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ { case PCB_SHAPE_T: { - PCB_SHAPE* shape = static_cast( item ); + const PCB_SHAPE* shape = static_cast( item ); shape->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE ); } @@ -124,7 +124,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ case PCB_TEXT_T: { - PCB_TEXT* text = static_cast( item ); + const PCB_TEXT* text = static_cast( item ); text->TransformTextShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE ); } @@ -144,7 +144,7 @@ void FOOTPRINT::TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuff bool aSkipPlatedPads, bool aSkipNonPlatedPads ) const { - for( PAD* pad : m_pads ) + for( const PAD* pad : m_pads ) { if( aLayer != UNDEFINED_LAYER && !pad->IsOnLayer(aLayer) ) continue; @@ -255,7 +255,7 @@ void FOOTPRINT::TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCorner if( item->Type() == PCB_FP_SHAPE_T && aIncludeShapes ) { - FP_SHAPE* outline = static_cast( item ); + const FP_SHAPE* outline = static_cast( item ); if( aLayer != UNDEFINED_LAYER && outline->GetLayer() == aLayer ) { @@ -274,7 +274,7 @@ void FOOTPRINT::TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCorner texts.push_back( &Value() ); } - for( FP_TEXT* text : texts ) + for( const FP_TEXT* text : texts ) { text->TransformTextShapeWithClearanceToPolygon( aCornerBuffer, aLayer, aClearance, aError, aErrorLoc ); @@ -506,7 +506,7 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf offset = footprint->GetPosition(); // Build the polygon with the actual position and orientation: - std::vector< wxPoint> poly; + std::vector poly; poly = BuildPolyPointsList(); for( wxPoint& point : poly ) @@ -519,7 +519,7 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf { aCornerBuffer.NewOutline(); - for( wxPoint& point : poly ) + for( const wxPoint& point : poly ) aCornerBuffer.Append( point.x, point.y ); } @@ -527,7 +527,7 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf { wxPoint pt1( poly[ poly.size() - 1] ); - for( wxPoint pt2 : poly ) + for( const wxPoint& pt2 : poly ) { if( pt2 != pt1 ) TransformOvalToPolygon( aCornerBuffer, pt1, pt2, width, aError, aErrorLoc ); @@ -547,7 +547,7 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf for( unsigned ii = 1; ii < poly.size(); ii++ ) { - TransformOvalToPolygon( aCornerBuffer, poly[ii-1], poly[ii], width, aError, aErrorLoc ); + TransformOvalToPolygon( aCornerBuffer, poly[ii - 1], poly[ii], width, aError, aErrorLoc ); } } break; @@ -582,8 +582,8 @@ void TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, const ARC* arc = static_cast( this ); int width = m_Width + ( 2 * aClearanceValue ); - TransformArcToPolygon( aCornerBuffer, (wxPoint) arc->GetStart(), (wxPoint) arc->GetMid(), - (wxPoint) arc->GetEnd(), width, aError, aErrorLoc ); + TransformArcToPolygon( aCornerBuffer, arc->GetStart(), arc->GetMid(), + arc->GetEnd(), width, aError, aErrorLoc ); } break; diff --git a/pcbnew/cleanup_item.h b/pcbnew/cleanup_item.h index bff66d06f7..ea6b4dffbe 100644 --- a/pcbnew/cleanup_item.h +++ b/pcbnew/cleanup_item.h @@ -83,12 +83,12 @@ public: { } - int GetCount( int aSeverity = -1 ) override + int GetCount( int aSeverity = -1 ) const override { return m_sourceVector->size(); } - std::shared_ptr GetItem( int aIndex ) override + std::shared_ptr GetItem( int aIndex ) const override { return m_sourceVector->at( aIndex ); } diff --git a/pcbnew/connectivity/from_to_cache.cpp b/pcbnew/connectivity/from_to_cache.cpp index 3ef065b255..c84884ac9a 100644 --- a/pcbnew/connectivity/from_to_cache.cpp +++ b/pcbnew/connectivity/from_to_cache.cpp @@ -156,12 +156,12 @@ int FROM_TO_CACHE::cacheFromToPaths( const wxString& aFrom, const wxString& aTo if( pitem->Type() != PCB_PAD_T ) continue; - PAD *pad = static_cast( pitem ); + const PAD *pad = static_cast( pitem ); wxString toName = pad->GetParent()->GetReference() + "-" + pad->GetName(); - for ( auto& endpoint : m_ftEndpoints ) + for ( const auto& endpoint : m_ftEndpoints ) { if( pad == endpoint.parent ) { @@ -213,7 +213,7 @@ int FROM_TO_CACHE::cacheFromToPaths( const wxString& aFrom, const wxString& aTo if( result == PS_NO_PATH ) continue; - for( auto item : upath ) + for( const auto item : upath ) { path.pathItems.insert( item->Parent() ); } @@ -222,7 +222,7 @@ int FROM_TO_CACHE::cacheFromToPaths( const wxString& aFrom, const wxString& aTo newPaths++; } - //reportAux( _("Cached %d paths\n"), newPaths ); + // reportAux( _("Cached %d paths\n"), newPaths ); return newPaths; } diff --git a/pcbnew/dialogs/dialog_board_statistics.cpp b/pcbnew/dialogs/dialog_board_statistics.cpp index 49361a9e9a..0417365854 100644 --- a/pcbnew/dialogs/dialog_board_statistics.cpp +++ b/pcbnew/dialogs/dialog_board_statistics.cpp @@ -234,7 +234,7 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB() auto it = m_drillTypes.begin(); - for( ; it != m_drillTypes.end(); it++ ) + for( ; it != m_drillTypes.end(); ++it ) { if( *it == drill ) { @@ -272,7 +272,7 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB() auto it = m_drillTypes.begin(); - for( ; it != m_drillTypes.end(); it++ ) + for( ; it != m_drillTypes.end(); ++it ) { if( *it == drill ) { @@ -348,10 +348,10 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB() void DIALOG_BOARD_STATISTICS::updateWidets() { - int totalPads = 0; + int totalPads = 0; int currentRow = 0; - for( auto& type : m_padsTypes ) + for( const auto& type : m_padsTypes ) { m_gridPads->SetCellValue( currentRow, COL_LABEL, type.title ); m_gridPads->SetCellValue( @@ -366,7 +366,7 @@ void DIALOG_BOARD_STATISTICS::updateWidets() int totalVias = 0; currentRow = 0; - for( auto& type : m_viasTypes ) + for( const auto& type : m_viasTypes ) { m_gridVias->SetCellValue( currentRow, COL_LABEL, type.title ); m_gridVias->SetCellValue( @@ -380,12 +380,12 @@ void DIALOG_BOARD_STATISTICS::updateWidets() int totalFront = 0; - int totalBack = 0; + int totalBack = 0; // We don't use row 0, as there labels are currentRow = 1; - for( auto& type : m_componentsTypes ) + for( const auto& type : m_componentsTypes ) { m_gridComponents->SetCellValue( currentRow, COL_LABEL, type.title ); m_gridComponents->SetCellValue( @@ -395,7 +395,7 @@ void DIALOG_BOARD_STATISTICS::updateWidets() m_gridComponents->SetCellValue( currentRow, 3, wxString::Format( wxT( "%i " ), type.frontSideQty + type.backSideQty ) ); totalFront += type.frontSideQty; - totalBack += type.backSideQty; + totalBack += type.backSideQty; currentRow++; } @@ -439,7 +439,7 @@ void DIALOG_BOARD_STATISTICS::updateDrillGrid() BOARD* board = m_parentFrame->GetBoard(); int currentRow = 0; - for( auto& type : m_drillTypes ) + for( const auto& type : m_drillTypes ) { wxString shapeStr; wxString startLayerStr; diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 6793140efa..057e367cc7 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -452,7 +452,7 @@ const BOX2I DIMENSION_BASE::ViewBBox() const } -OPT_VECTOR2I DIMENSION_BASE::segPolyIntersection( SHAPE_POLY_SET& aPoly, SEG& aSeg, bool aStart ) +OPT_VECTOR2I DIMENSION_BASE::segPolyIntersection( const SHAPE_POLY_SET& aPoly, const SEG& aSeg, bool aStart ) { VECTOR2I start( aStart ? aSeg.A : aSeg.B ); VECTOR2I endpoint( aStart ? aSeg.B : aSeg.A ); @@ -460,7 +460,7 @@ OPT_VECTOR2I DIMENSION_BASE::segPolyIntersection( SHAPE_POLY_SET& aPoly, SEG& aS if( aPoly.Contains( start ) ) return NULLOPT; - for( SHAPE_POLY_SET::SEGMENT_ITERATOR seg = aPoly.IterateSegments(); seg; seg++ ) + for( SHAPE_POLY_SET::CONST_SEGMENT_ITERATOR seg = aPoly.CIterateSegments(); seg; ++seg ) { if( OPT_VECTOR2I intersection = ( *seg ).Intersect( aSeg ) ) { diff --git a/pcbnew/dimension.h b/pcbnew/dimension.h index 20a47c870d..cf38b402c5 100644 --- a/pcbnew/dimension.h +++ b/pcbnew/dimension.h @@ -206,8 +206,8 @@ public: */ const wxString GetText() const; - PCB_TEXT& Text() { return m_text; } - PCB_TEXT& Text() const { return *( const_cast ( &m_text ) ); } + PCB_TEXT& Text() { return m_text; } + const PCB_TEXT& Text() const { return m_text; } /** * @return a list of line segments that make up this dimension (for drawing, plotting, etc) @@ -271,9 +271,9 @@ protected: * @param aStart if true will start from aSeg.A, otherwise aSeg.B * @return a point on aSeg that collides with aPoly closest to the start, if one exists */ - static OPT_VECTOR2I segPolyIntersection( SHAPE_POLY_SET& aPoly, SEG& aSeg, bool aStart = true ); + static OPT_VECTOR2I segPolyIntersection( const SHAPE_POLY_SET& aPoly, const SEG& aSeg, bool aStart = true ); static OPT_VECTOR2I segCircleIntersection( CIRCLE& aCircle, SEG& aSeg, bool aStart = true ); - + // Value format bool m_overrideTextEnabled; ///< Manually specify the displayed measurement value wxString m_valueString; ///< Displayed value when m_overrideValue = true diff --git a/pcbnew/drc/drc_results_provider.h b/pcbnew/drc/drc_results_provider.h index cb35e574de..cf40386f17 100644 --- a/pcbnew/drc/drc_results_provider.h +++ b/pcbnew/drc/drc_results_provider.h @@ -75,7 +75,7 @@ public: } } - int GetCount( int aSeverity = -1 ) override + int GetCount( int aSeverity = -1 ) const override { if( aSeverity < 0 ) return m_filteredMarkers.size(); @@ -100,7 +100,7 @@ public: return count; } - std::shared_ptr GetItem( int aIndex ) override + std::shared_ptr GetItem( int aIndex ) const override { PCB_MARKER* marker = m_filteredMarkers[ aIndex ]; @@ -167,7 +167,7 @@ public: } } - int GetCount( int aSeverity = -1 ) override + int GetCount( int aSeverity = -1 ) const override { if( aSeverity < 0 ) return m_filteredVector.size(); @@ -187,7 +187,7 @@ public: return count; } - std::shared_ptr GetItem( int aIndex ) override + std::shared_ptr GetItem( int aIndex ) const override { return (m_filteredVector)[aIndex]; } diff --git a/pcbnew/drc/drc_rtree.h b/pcbnew/drc/drc_rtree.h index 7b0d6c8dd9..35c84329f8 100644 --- a/pcbnew/drc/drc_rtree.h +++ b/pcbnew/drc/drc_rtree.h @@ -431,19 +431,19 @@ public: } }; - DRC_LAYER OnLayer( PCB_LAYER_ID aLayer ) + DRC_LAYER OnLayer( PCB_LAYER_ID aLayer ) const { return DRC_LAYER( m_tree[int( aLayer )] ); } - DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const wxPoint& aPoint, int aAccuracy = 0 ) + DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const wxPoint& aPoint, int aAccuracy = 0 ) const { EDA_RECT rect( aPoint, wxSize( 0, 0 ) ); rect.Inflate( aAccuracy ); return DRC_LAYER( m_tree[int( aLayer )], rect ); } - DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const EDA_RECT& aRect ) + DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const EDA_RECT& aRect ) const { return DRC_LAYER( m_tree[int( aLayer )], aRect ); } diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index d40d28745e..e52f31a8d1 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -398,7 +398,7 @@ FOOTPRINT& FOOTPRINT::operator=( const FOOTPRINT& aOther ) for( PCB_GROUP* group : aOther.Groups() ) { PCB_GROUP* newGroup = static_cast( group->Clone() ); - const_cast*>( &newGroup->GetItems() )->clear(); + newGroup->GetItems().clear(); for( BOARD_ITEM* member : group->GetItems() ) newGroup->AddItem( ptrMap[ member ] ); @@ -410,7 +410,7 @@ FOOTPRINT& FOOTPRINT::operator=( const FOOTPRINT& aOther ) m_3D_Drawings.clear(); m_3D_Drawings = aOther.m_3D_Drawings; m_doc = aOther.m_doc; - m_keywords = aOther.m_keywords; + m_keywords = aOther.m_keywords; m_properties = aOther.m_properties; m_initial_comments = aOther.m_initial_comments ? diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index e52ffb80ea..63a1f9cd74 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -175,7 +175,7 @@ void PCB_BASE_FRAME::AddFootprintToBoard( FOOTPRINT* aFootprint ) } -EDA_ITEM* PCB_BASE_FRAME::GetItem( const KIID& aId ) +EDA_ITEM* PCB_BASE_FRAME::GetItem( const KIID& aId ) const { return GetBoard()->GetItem( aId ); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 690e4ae03d..47cd1cbe18 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -147,27 +147,27 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOption switch( aOptions.m_DisplayNetNamesMode ) { case 0: - m_netNamesOnPads = false; + m_netNamesOnPads = false; m_netNamesOnTracks = false; - m_netNamesOnVias = false; + m_netNamesOnVias = false; break; case 1: - m_netNamesOnPads = true; + m_netNamesOnPads = true; m_netNamesOnTracks = false; - m_netNamesOnVias = true; // Follow pads or tracks? For now we chose pads.... + m_netNamesOnVias = true; // Follow pads or tracks? For now we chose pads.... break; case 2: - m_netNamesOnPads = false; + m_netNamesOnPads = false; m_netNamesOnTracks = true; - m_netNamesOnVias = false; // Follow pads or tracks? For now we chose pads.... + m_netNamesOnVias = false; // Follow pads or tracks? For now we chose pads.... break; case 3: - m_netNamesOnPads = true; + m_netNamesOnPads = true; m_netNamesOnTracks = true; - m_netNamesOnVias = true; + m_netNamesOnVias = true; break; } @@ -982,7 +982,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) shapes = std::dynamic_pointer_cast( aPad->GetEffectiveShape() ); } - for( SHAPE* shape : shapes->Shapes() ) + for( const SHAPE* shape : shapes->Shapes() ) { // Drawing components of compound shapes in outline mode produces a mess. if( m_pcbSettings.m_sketchMode[LAYER_PADS_TH] ) @@ -1009,13 +1009,13 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) if( simpleShapes ) { - for( SHAPE* shape : shapes->Shapes() ) + for( const SHAPE* shape : shapes->Shapes() ) { switch( shape->Type() ) { case SH_SEGMENT: { - const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape; + const SHAPE_SEGMENT* seg = (const SHAPE_SEGMENT*) shape; int effectiveWidth = seg->GetWidth() + 2 * margin.x; if( effectiveWidth > 0 ) @@ -1025,7 +1025,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) case SH_CIRCLE: { - const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape; + const SHAPE_CIRCLE* circle = (const SHAPE_CIRCLE*) shape; int effectiveRadius = circle->GetRadius() + margin.x; if( effectiveRadius > 0 ) @@ -1035,7 +1035,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) case SH_RECT: { - const SHAPE_RECT* r = (SHAPE_RECT*) shape; + const SHAPE_RECT* r = (const SHAPE_RECT*) shape; VECTOR2I position = r->GetPosition(); VECTOR2I effectiveSize = r->GetSize() + margin; @@ -1277,8 +1277,8 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer ) case S_POLYGON: { - SHAPE_POLY_SET& shape = const_cast( aShape )->GetPolyShape(); - FOOTPRINT* parentFootprint = aShape->GetParentFootprint(); + SHAPE_POLY_SET& shape = const_cast( aShape )->GetPolyShape(); + const FOOTPRINT* parentFootprint = aShape->GetParentFootprint(); if( shape.OutlineCount() == 0 ) break; @@ -1657,8 +1657,8 @@ void PCB_PAINTER::draw( const DIMENSION_BASE* aDimension, int aLayer ) } } // Draw text - PCB_TEXT& text = aDimension->Text(); - VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y ); + const PCB_TEXT& text = aDimension->Text(); + VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y ); if( m_pcbSettings.m_sketchText ) { diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 6b11e657f5..af74e0b409 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -83,7 +83,7 @@ const wxString GetGerberProtelExtension( LAYER_NUM aLayer ) } -const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer ) +const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, LAYER_NUM aLayer ) { wxString attrib; @@ -276,7 +276,7 @@ static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMo } -void AddGerberX2Header( PLOTTER * aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode ) +void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard, bool aUseX1CompatibilityMode ) { wxString text; @@ -347,8 +347,8 @@ void AddGerberX2Header( PLOTTER * aPlotter, const BOARD *aBoard, bool aUseX1Comp } -void AddGerberX2Attribute( PLOTTER * aPlotter, - const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode ) +void AddGerberX2Attribute( PLOTTER* aPlotter, + const BOARD* aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode ) { AddGerberX2Header( aPlotter, aBoard, aUseX1CompatibilityMode ); @@ -398,7 +398,7 @@ void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir, } -PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD *aBoard ) +PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD* aBoard ) { m_plotter = NULL; m_board = aBoard; diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index 9689d25156..04e3c9c261 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -78,7 +78,7 @@ public: * (useful for controlling toner bleeding during direct transfer) * added to track width and via/pads size */ - int getFineWidthAdj() + int getFineWidthAdj() const { if( GetFormat() == PLOT_FORMAT::POST ) return GetWidthAdjust(); @@ -87,22 +87,22 @@ public: } // Basic functions to plot a board item - void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; } - void PlotFootprintGraphicItems( FOOTPRINT* aFootprint ); - void PlotFootprintGraphicItem( FP_SHAPE* aShape ); - void PlotFootprintTextItem( FP_TEXT* aText, COLOR4D aColor ); + void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; } + void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ); + void PlotFootprintGraphicItem( const FP_SHAPE* aShape ); + void PlotFootprintTextItem( const FP_TEXT* aText, COLOR4D aColor ); /* * Reference, Value, and other fields are plotted only if the corresponding option is enabled. * Invisible text fields are plotted only if PlotInvisibleText option is set. */ - void PlotFootprintTextItems( FOOTPRINT* aFootprint ); + void PlotFootprintTextItems( const FOOTPRINT* aFootprint ); - void PlotDimension( DIMENSION_BASE* Dimension ); - void PlotPcbTarget( PCB_TARGET* PtMire ); - void PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& aPolysList ); - void PlotPcbText( PCB_TEXT* aText ); - void PlotPcbShape( PCB_SHAPE* aShape ); + void PlotDimension( const DIMENSION_BASE* aDim ); + void PlotPcbTarget( const PCB_TARGET* aMire ); + void PlotFilledAreas( const ZONE* aZone, const SHAPE_POLY_SET& aPolysList ); + void PlotPcbText( const PCB_TEXT* aText ); + void PlotPcbShape( const PCB_SHAPE* aShape ); /** * Plot a pad. @@ -110,7 +110,7 @@ public: * and be drawn as a non filled item although the plot mode is filled * color and plot mode are needed by this function */ - void PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode ); + void PlotPad( const PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode ); /** * plot items like text and graphics, @@ -134,7 +134,7 @@ public: * and in B&W mode, is plotted as white but other colors are plotted in BLACK * so the returned color is LIGHTGRAY when the layer color is WHITE */ - COLOR4D getColor( LAYER_NUM aLayer ); + COLOR4D getColor( LAYER_NUM aLayer ) const; private: /** Helper function to plot a single drill mark. It compensate and clamp @@ -148,7 +148,7 @@ private: }; PLOTTER* StartPlotBoard( BOARD* aBoard, - PCB_PLOT_PARAMS* aPlotOpts, + const PCB_PLOT_PARAMS* aPlotOpts, int aLayer, const wxString& aFullFileName, const wxString& aSheetDesc ); @@ -163,7 +163,7 @@ PLOTTER* StartPlotBoard( BOARD* aBoard, * @param aLayer = the layer id to plot * @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only */ -void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer, +void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS& aPlotOpt ); /** @@ -198,7 +198,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask, * @param aLayerMask = the mask to define the layers to plot * @param aPlotOpt = the plot options. Has meaning for some formats only */ -void PlotLayerOutlines( BOARD *aBoard, PLOTTER* aPlotter, +void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ); /** @@ -236,7 +236,7 @@ const wxString GetGerberProtelExtension( LAYER_NUM aLayer ); * @param aLayer = the layer number to create the attribute for * @return The attribute, as a text string */ -const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer ); +const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, LAYER_NUM aLayer ); /** * Calculates some X2 attributes, as defined in the @@ -252,8 +252,8 @@ const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aL * use X1 compatibility (X2 attributes added as structured comments, * starting by "G04 #@! " followed by the X2 attribute */ -void AddGerberX2Header( PLOTTER * aPlotter, - const BOARD *aBoard, bool aUseX1CompatibilityMode = false ); +void AddGerberX2Header( PLOTTER* aPlotter, + const BOARD* aBoard, bool aUseX1CompatibilityMode = false ); /** * Calculates some X2 attributes, as defined in the Gerber file format @@ -271,7 +271,7 @@ void AddGerberX2Header( PLOTTER * aPlotter, * use X1 compatibility (X2 attributes added as structured comments, * starting by "G04 #@! " followed by the X2 attribute */ -void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard, +void AddGerberX2Attribute( PLOTTER* aPlotter, const BOARD* aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode ); #endif // PCBPLOT_H_ diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index cf3cad63d1..2c9ab9acff 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -222,11 +222,11 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, itemplotter.PlotBoardGraphicItems(); // Draw footprint texts: - for( FOOTPRINT* footprint : aBoard->Footprints() ) + for( const FOOTPRINT* footprint : aBoard->Footprints() ) itemplotter.PlotFootprintTextItems( footprint ); // Draw footprint other graphic items: - for( FOOTPRINT* footprint : aBoard->Footprints() ) + for( const FOOTPRINT* footprint : aBoard->Footprints() ) itemplotter.PlotFootprintGraphicItems( footprint ); // Plot footprint pads @@ -269,7 +269,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, int width_adj = 0; if( onCopperLayer ) - width_adj = itemplotter.getFineWidthAdj(); + width_adj = itemplotter.getFineWidthAdj(); if( onSolderMaskLayer ) margin.x = margin.y = pad->GetSolderMaskMargin(); @@ -288,7 +288,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, // Store these parameters that can be modified to plot inflated/deflated pads shape PAD_SHAPE_T padShape = pad->GetShape(); - wxSize padSize = pad->GetSize(); + wxSize padSize = pad->GetSize(); wxSize padDelta = pad->GetDelta(); // has meaning only for trapezoidal pads double padCornerRadius = pad->GetRoundRectCornerRadius(); @@ -424,7 +424,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, aPlotter->StartBlock( NULL ); - for( TRACK* track : aBoard->Tracks() ) + for( const TRACK* track : aBoard->Tracks() ) { const VIA* via = dyn_cast( track ); @@ -487,7 +487,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); // Plot tracks (not vias) : - for( TRACK* track : aBoard->Tracks() ) + for( const TRACK* track : aBoard->Tracks() ) { if( track->Type() == PCB_VIA_T ) continue; @@ -505,7 +505,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, if( track->Type() == PCB_ARC_T ) { - ARC* arc = static_cast( track ); + const ARC* arc = static_cast( track ); VECTOR2D center( arc->GetCenter() ); int radius = arc->GetRadius(); double start_angle = arc->GetArcAngleStart(); @@ -529,7 +529,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, NETINFO_ITEM nonet( aBoard ); - for( ZONE* zone : aBoard->Zones() ) + for( const ZONE* zone : aBoard->Zones() ) { for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() ) { @@ -652,7 +652,7 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask, // Now we have one or more basic polygons: plot each polygon for( int ii = 0; ii < outlines.OutlineCount(); ii++ ) { - for(int kk = 0; kk <= outlines.HoleCount (ii); kk++ ) + for( int kk = 0; kk <= outlines.HoleCount(ii); kk++ ) { cornerList.clear(); const SHAPE_LINE_CHAIN& path = (kk == 0) ? outlines.COutline( ii ) : outlines.CHole( ii, kk - 1 ); @@ -943,8 +943,8 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, * page size is the 'drawing' page size, * paper size is the physical page size */ -static void initializePlotter( PLOTTER *aPlotter, BOARD * aBoard, - PCB_PLOT_PARAMS *aPlotOpts ) +static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, + const PCB_PLOT_PARAMS* aPlotOpts ) { PAGE_INFO pageA4( wxT( "A4" ) ); const PAGE_INFO& pageInfo = aBoard->GetPageSettings(); @@ -1042,7 +1042,7 @@ static void FillNegativeKnockout( PLOTTER *aPlotter, const EDA_RECT &aBbbox ) /** * Calculate the effective size of HPGL pens and set them in the plotter object */ -static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts ) +static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS *aPlotOpts ) { // Compute penDiam (the value is given in mils) in pcb units, with plot scale (if Scale is 2, // penDiam value is always m_HPGLPenDiam so apparent penDiam is actually penDiam / Scale @@ -1060,7 +1060,7 @@ static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlo * and prepare the page for plotting. * Return the plotter object if OK, NULL if the file is not created (or has a problem) */ -PLOTTER* StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts, int aLayer, +PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString& aFullFileName, const wxString& aSheetDesc ) { // Create the plotter driver and set the few plotter specific options diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index b218b437e8..1ea29875b4 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -73,7 +73,7 @@ * and a group of board items */ -COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer ) +COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer ) const { COLOR4D color = ColorSettings()->GetColor( aLayer ); @@ -86,7 +86,7 @@ COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer ) } -void BRDITEMS_PLOTTER::PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode ) +void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode ) { wxPoint shape_pos = aPad->ShapePos(); GBR_METADATA gbr_metadata; @@ -286,9 +286,9 @@ void BRDITEMS_PLOTTER::PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMod } -void BRDITEMS_PLOTTER::PlotFootprintTextItems( FOOTPRINT* aFootprint ) +void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint ) { - FP_TEXT* textItem = &aFootprint->Reference(); + const FP_TEXT* textItem = &aFootprint->Reference(); LAYER_NUM textLayer = textItem->GetLayer(); // Reference and value are specfic items, not in graphic items list @@ -298,7 +298,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( FOOTPRINT* aFootprint ) PlotFootprintTextItem( textItem, getColor( textLayer ) ); } - textItem = &aFootprint->Value(); + textItem = &aFootprint->Value(); textLayer = textItem->GetLayer(); if( GetPlotValue() && m_layerMask[textLayer] @@ -307,9 +307,9 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( FOOTPRINT* aFootprint ) PlotFootprintTextItem( textItem, getColor( textLayer ) ); } - for( BOARD_ITEM* item : aFootprint->GraphicalItems() ) + for( const BOARD_ITEM* item : aFootprint->GraphicalItems() ) { - textItem = dyn_cast( item ); + textItem = dyn_cast( item ); if( !textItem ) continue; @@ -372,7 +372,7 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItems() } } -void BRDITEMS_PLOTTER::PlotFootprintTextItem( FP_TEXT* aTextMod, COLOR4D aColor ) +void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, COLOR4D aColor ) { if( aColor == COLOR4D::WHITE ) aColor = COLOR4D( LIGHTGRAY ); @@ -380,9 +380,9 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( FP_TEXT* aTextMod, COLOR4D aColor m_plotter->SetColor( aColor ); // calculate some text parameters : - wxSize size = aTextMod->GetTextSize(); - wxPoint pos = aTextMod->GetTextPos(); - double orient = aTextMod->GetDrawRotation(); + wxSize size = aTextMod->GetTextSize(); + wxPoint pos = aTextMod->GetTextPos(); + double orient = aTextMod->GetDrawRotation(); int thickness = aTextMod->GetEffectiveTextPenWidth(); if( aTextMod->IsMirrored() ) @@ -396,7 +396,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( FP_TEXT* aTextMod, COLOR4D aColor GBR_METADATA gbr_metadata; gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP ); - FOOTPRINT* parent = static_cast ( aTextMod->GetParent() ); + const FOOTPRINT* parent = static_cast ( aTextMod->GetParent() ); gbr_metadata.SetCmpReference( parent->GetReference() ); m_plotter->SetCurrentLineWidth( thickness ); @@ -407,7 +407,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( FP_TEXT* aTextMod, COLOR4D aColor } -void BRDITEMS_PLOTTER::PlotDimension( DIMENSION_BASE* aDim ) +void BRDITEMS_PLOTTER::PlotDimension( const DIMENSION_BASE* aDim ) { if( !m_layerMask[aDim->GetLayer()] ) return; @@ -462,16 +462,16 @@ void BRDITEMS_PLOTTER::PlotDimension( DIMENSION_BASE* aDim ) } -void BRDITEMS_PLOTTER::PlotPcbTarget( PCB_TARGET* aMire ) +void BRDITEMS_PLOTTER::PlotPcbTarget( const PCB_TARGET* aMire ) { - int dx1, dx2, dy1, dy2, radius; + int dx1, dx2, dy1, dy2, radius; if( !m_layerMask[aMire->GetLayer()] ) return; m_plotter->SetColor( getColor( aMire->GetLayer() ) ); - PCB_SHAPE draw; + PCB_SHAPE draw; draw.SetShape( S_CIRCLE ); draw.SetFilled( false ); @@ -517,11 +517,11 @@ void BRDITEMS_PLOTTER::PlotPcbTarget( PCB_TARGET* aMire ) // Plot footprints graphic items (outlines) -void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( FOOTPRINT* aFootprint ) +void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) { - for( BOARD_ITEM* item : aFootprint->GraphicalItems() ) + for( const BOARD_ITEM* item : aFootprint->GraphicalItems() ) { - FP_SHAPE* shape = dynamic_cast( item ); + const FP_SHAPE* shape = dynamic_cast( item ); if( shape && m_layerMask[ shape->GetLayer() ] ) PlotFootprintGraphicItem( shape ); @@ -530,7 +530,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( FOOTPRINT* aFootprint ) //* Plot a graphic item (outline) relative to a footprint -void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( FP_SHAPE* aShape ) +void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape ) { if( aShape->Type() != PCB_FP_SHAPE_T ) return; @@ -544,7 +544,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( FP_SHAPE* aShape ) GBR_METADATA gbr_metadata; gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP ); - FOOTPRINT* parent = static_cast ( aShape->GetParent() ); + const FOOTPRINT* parent = static_cast ( aShape->GetParent() ); gbr_metadata.SetCmpReference( parent->GetReference() ); bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any(); @@ -627,7 +627,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( FP_SHAPE* aShape ) // We must compute board coordinates from m_PolyList which are relative to the parent // position at orientation 0 - FOOTPRINT *parentFootprint = aShape->GetParentFootprint(); + const FOOTPRINT *parentFootprint = aShape->GetParentFootprint(); std::vector cornerList; @@ -691,7 +691,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( FP_SHAPE* aShape ) // Plot a PCB Text, i.e. a text found on a copper or technical layer -void BRDITEMS_PLOTTER::PlotPcbText( PCB_TEXT* aText ) +void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText ) { wxString shownText( aText->GetShownText() ); @@ -734,7 +734,7 @@ void BRDITEMS_PLOTTER::PlotPcbText( PCB_TEXT* aText ) aText->GetLinePositions( positions, strings_list.Count() ); - for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) + for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxString& txt = strings_list.Item( ii ); m_plotter->Text( positions[ii], color, txt, orient, size, aText->GetHorizJustify(), @@ -751,7 +751,7 @@ void BRDITEMS_PLOTTER::PlotPcbText( PCB_TEXT* aText ) } -void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList ) +void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, const SHAPE_POLY_SET& polysList ) { if( polysList.IsEmpty() ) return; @@ -796,7 +796,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList ) for( int idx = 0; idx < polysList.OutlineCount(); ++idx ) { - SHAPE_LINE_CHAIN& outline = polysList.Outline( idx ); + const SHAPE_LINE_CHAIN& outline = polysList.Outline( idx ); cornerList.clear(); cornerList.reserve( outline.PointCount() ); @@ -855,7 +855,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList ) /* Plot items type PCB_SHAPE on layers allowed by aLayerMask */ -void BRDITEMS_PLOTTER::PlotPcbShape( PCB_SHAPE* aShape ) +void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape ) { if( !m_layerMask[aShape->GetLayer()] ) return; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index f0eaf184f1..7f63873595 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -702,7 +702,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) bool restore_state = false; VECTOR2I totalMovement; PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() ); - TOOL_EVENT* evt = const_cast( &aEvent ); + TOOL_EVENT* evt = &aEvent; VECTOR2I prevPos; // Prime the pump diff --git a/pcbnew/tools/zone_create_helper.cpp b/pcbnew/tools/zone_create_helper.cpp index cde19faf26..61c8b7f345 100644 --- a/pcbnew/tools/zone_create_helper.cpp +++ b/pcbnew/tools/zone_create_helper.cpp @@ -132,7 +132,7 @@ std::unique_ptr ZONE_CREATE_HELPER::createZoneFromExisting( const ZONE& aS } -void ZONE_CREATE_HELPER::performZoneCutout( ZONE& aZone, ZONE& aCutout ) +void ZONE_CREATE_HELPER::performZoneCutout( ZONE& aZone, const ZONE& aCutout ) { BOARD_COMMIT commit( &m_tool ); BOARD* board = m_tool.getModel(); diff --git a/pcbnew/tools/zone_create_helper.h b/pcbnew/tools/zone_create_helper.h index 33f8bf27bd..aa2d793faa 100644 --- a/pcbnew/tools/zone_create_helper.h +++ b/pcbnew/tools/zone_create_helper.h @@ -104,7 +104,7 @@ public: * @param aZone the zone to removed area from * @param aCutout the area to remove */ - void performZoneCutout( ZONE& aZone, ZONE& aCutout ); + void performZoneCutout( ZONE& aZone, const ZONE& aCutout ); /** * Commit the current zone-in-progress to the BOARD. @@ -132,4 +132,4 @@ private: std::unique_ptr m_zone; }; -#endif /* __DRAWING_TOOL_H */ +#endif // TOOLS_ZONE_CREATE_HELPER__H_