From ac94d72d2de64936a2973d039c8a6d2867c6f195 Mon Sep 17 00:00:00 2001 From: Dominik Wernberger Date: Sun, 20 Dec 2020 19:44:13 +0100 Subject: [PATCH] Add more const specifiers --- common/richio.cpp | 8 +- common/tool/tool_event.cpp | 8 +- eeschema/class_libentry.cpp | 2 +- eeschema/class_libentry.h | 4 +- eeschema/generate_alias_info.cpp | 4 +- eeschema/sch_bitmap.h | 4 +- eeschema/sch_bus_entry.h | 2 +- eeschema/sch_component.cpp | 4 +- eeschema/sch_component.h | 10 ++- eeschema/sch_draw_panel.cpp | 4 +- eeschema/sch_draw_panel.h | 4 +- eeschema/sch_item.h | 2 +- eeschema/sch_line.cpp | 4 +- eeschema/sch_line.h | 4 +- eeschema/sch_painter.cpp | 61 +++++++------- eeschema/sch_painter.h | 56 ++++++------- eeschema/sch_rtree.h | 2 +- eeschema/sch_sheet.cpp | 8 +- eeschema/sch_sheet.h | 17 ++-- eeschema/sch_view.cpp | 4 +- eeschema/sch_view.h | 4 +- include/board_design_settings.h | 1 + include/eda_item.h | 2 +- include/pcb_group.h | 5 ++ include/render_settings.h | 2 +- include/richio.h | 6 +- include/tool/tool_event.h | 8 +- libs/kimath/include/geometry/shape_poly_set.h | 5 ++ pcb_calculator/class_regulator_data.h | 2 +- pcb_calculator/transline_dlg_funct.cpp | 2 +- pcbnew/board.h | 7 +- .../class_board_stackup.cpp | 9 +- .../class_board_stackup.h | 4 +- .../panel_board_stackup.cpp | 4 +- pcbnew/exporters/export_hyperlynx.cpp | 4 +- pcbnew/exporters/gerber_jobfile_writer.cpp | 2 +- pcbnew/fp_text.h | 2 +- pcbnew/plugins/kicad/kicad_plugin.cpp | 84 +++++++++---------- pcbnew/plugins/kicad/kicad_plugin.h | 38 ++++----- pcbnew/zone.cpp | 2 +- pcbnew/zone.h | 4 +- utils/idftools/idf_common.cpp | 10 +-- utils/idftools/idf_common.h | 12 +-- 43 files changed, 225 insertions(+), 206 deletions(-) diff --git a/common/richio.cpp b/common/richio.cpp index 0bb7a30bde..28b10cb74d 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -362,12 +362,12 @@ const char* OUTPUTFORMATTER::GetQuoteChar( const char* wrapee, const char* quote } -const char* OUTPUTFORMATTER::GetQuoteChar( const char* wrapee ) +const char* OUTPUTFORMATTER::GetQuoteChar( const char* wrapee ) const { return GetQuoteChar( wrapee, quoteChar ); } -int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap ) +int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap ) { // This function can call vsnprintf twice. // But internally, vsnprintf retrieves arguments from the va_list identified by arg as if @@ -434,7 +434,7 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) } -std::string OUTPUTFORMATTER::Quotes( const std::string& aWrapee ) +std::string OUTPUTFORMATTER::Quotes( const std::string& aWrapee ) const { std::string ret; @@ -473,7 +473,7 @@ std::string OUTPUTFORMATTER::Quotes( const std::string& aWrapee ) } -std::string OUTPUTFORMATTER::Quotew( const wxString& aWrapee ) +std::string OUTPUTFORMATTER::Quotew( const wxString& aWrapee ) const { // wxStrings are always encoded as UTF-8 as we convert to a byte sequence. // The non-virutal function calls the virtual workhorse function, and if diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index a4bece2777..c9a1d4b4a4 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -187,7 +187,7 @@ bool TOOL_EVENT::IsDblClick( int aButtonMask ) const } -bool TOOL_EVENT::IsCancelInteractive() +bool TOOL_EVENT::IsCancelInteractive() const { return( ( m_commandStr.is_initialized() && m_commandStr.get() == ACTIONS::cancelInteractive.GetName() ) @@ -197,7 +197,7 @@ bool TOOL_EVENT::IsCancelInteractive() } -bool TOOL_EVENT::IsSelectionEvent() +bool TOOL_EVENT::IsSelectionEvent() const { return Matches( EVENTS::ClearedEvent ) || Matches( EVENTS::UnselectedEvent ) @@ -205,7 +205,7 @@ bool TOOL_EVENT::IsSelectionEvent() } -bool TOOL_EVENT::IsPointEditor() +bool TOOL_EVENT::IsPointEditor() const { return( ( m_commandStr.is_initialized() && m_commandStr.get().find( "PointEditor" ) != GetCommandStr()->npos ) @@ -214,7 +214,7 @@ bool TOOL_EVENT::IsPointEditor() } -bool TOOL_EVENT::IsMoveTool() +bool TOOL_EVENT::IsMoveTool() const { return( m_commandStr.is_initialized() && m_commandStr.get().find( "InteractiveMove" ) != GetCommandStr()->npos ); diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index f04fe72d51..911aa859d6 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -621,7 +621,7 @@ void LIB_PART::AddDrawItem( LIB_ITEM* aItem ) } -LIB_ITEM* LIB_PART::GetNextDrawItem( LIB_ITEM* aItem, KICAD_T aType ) +LIB_ITEM* LIB_PART::GetNextDrawItem( const LIB_ITEM* aItem, KICAD_T aType ) { if( aItem == NULL ) { diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 54f93311a2..58f8ac6c74 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -122,6 +122,7 @@ public: void SetParent( LIB_PART* aParent = nullptr ); PART_REF& GetParent() { return m_parent; } + const PART_REF& GetParent() const { return m_parent; } virtual wxString GetClass() const override { @@ -353,7 +354,7 @@ public: * if TYPE_NOT_INIT search for all items types * @return - The next drawing object in the list if found, otherwise NULL. */ - LIB_ITEM* GetNextDrawItem( LIB_ITEM* aItem = NULL, KICAD_T aType = TYPE_NOT_INIT ); + LIB_ITEM* GetNextDrawItem( const LIB_ITEM* aItem = NULL, KICAD_T aType = TYPE_NOT_INIT ); size_t GetPinCount() const { return m_drawings.size( LIB_PIN_T ); } @@ -468,6 +469,7 @@ public: * @return LIB_ITEMS_CONTAINER& - Reference to the draw item object container. */ LIB_ITEMS_CONTAINER& GetDrawItems() { return m_drawings; } + const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; } SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; diff --git a/eeschema/generate_alias_info.cpp b/eeschema/generate_alias_info.cpp index ecfcbc6e97..3e547f229d 100644 --- a/eeschema/generate_alias_info.cpp +++ b/eeschema/generate_alias_info.cpp @@ -99,7 +99,7 @@ public: /** * Return the generated HTML. */ - wxString GetHtml() + wxString GetHtml() const { return m_html; } @@ -156,7 +156,7 @@ protected: } - wxString GetHtmlFieldRow( LIB_FIELD const & aField ) + wxString GetHtmlFieldRow( const LIB_FIELD& aField ) const { wxString name = aField.GetCanonicalName(); wxString text = aField.GetFullText( m_unit > 0 ? m_unit : 1 ); diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index bf86619cc6..31e41cf352 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -56,7 +56,7 @@ public: SCH_BITMAP& operator=( const SCH_ITEM& aItem ); - BITMAP_BASE* GetImage() + BITMAP_BASE* GetImage() const { wxCHECK_MSG( m_image != NULL, NULL, "Invalid SCH_BITMAP init, m_image is NULL." ); return m_image; @@ -122,7 +122,7 @@ public: * and false for items moved with no reference to anchor * @return false for a bus entry */ - bool IsMovableFromAnchorPoint() override { return false; } + bool IsMovableFromAnchorPoint() const override { return false; } void MirrorY( int aYaxis_position ) override; void MirrorX( int aXaxis_position ) override; diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 900b60fecd..2644ed706c 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -56,7 +56,7 @@ public: * and false for items moved with no reference to anchor * @return false for a bus entry */ - bool IsMovableFromAnchorPoint() override { return false; } + bool IsMovableFromAnchorPoint() const override { return false; } wxPoint GetEnd() const; diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 30896a9ae3..9201aa93c5 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -811,7 +811,7 @@ void SCH_COMPONENT::RunOnChildren( const std::function& aFunc } -SCH_PIN* SCH_COMPONENT::GetPin( const wxString& aNumber ) +SCH_PIN* SCH_COMPONENT::GetPin( const wxString& aNumber ) const { for( const std::unique_ptr& pin : m_pins ) { @@ -823,7 +823,7 @@ SCH_PIN* SCH_COMPONENT::GetPin( const wxString& aNumber ) } -void SCH_COMPONENT::GetLibPins( std::vector& aPinsList ) +void SCH_COMPONENT::GetLibPins( std::vector& aPinsList ) const { if( m_part ) m_part->GetPins( aPinsList, m_unit, m_convert ); diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 2412916ab2..617cb635db 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -182,7 +182,7 @@ public: * * @return true for a component */ - bool IsMovableFromAnchorPoint() override { return true; } + bool IsMovableFromAnchorPoint() const override { return true; } void SetLibId( const LIB_ID& aName ); @@ -204,6 +204,7 @@ public: bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); } std::unique_ptr< LIB_PART >& GetPartRef() { return m_part; } + const std::unique_ptr< LIB_PART >& GetPartRef() const { return m_part; } /** * Set this schematic symbol library symbol reference to \a aLibSymbol @@ -269,7 +270,8 @@ public: void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; } - TRANSFORM& GetTransform() const { return const_cast< TRANSFORM& >( m_transform ); } + TRANSFORM& GetTransform() { return m_transform; } + const TRANSFORM& GetTransform() const { return m_transform; } void SetTransform( const TRANSFORM& aTransform ); @@ -467,14 +469,14 @@ public: * * @return Pin object if found, otherwise NULL. */ - SCH_PIN* GetPin( const wxString& number ); + SCH_PIN* GetPin( const wxString& number ) const; /** * Populate a vector with all the pins from the library object. * * @param aPinsList is the list to populate with all of the pins. */ - void GetLibPins( std::vector& aPinsList ); + void GetLibPins( std::vector& aPinsList ) const; SCH_PIN* GetPin( LIB_PIN* aLibPin ); diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index 8baefa6e10..a81f863b9d 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -106,7 +106,7 @@ SCH_DRAW_PANEL::~SCH_DRAW_PANEL() } -void SCH_DRAW_PANEL::DisplayComponent( const LIB_PART* aComponent ) +void SCH_DRAW_PANEL::DisplayComponent( LIB_PART* aComponent ) { GetView()->Clear(); GetView()->DisplayComponent( const_cast(aComponent) ); @@ -114,7 +114,7 @@ void SCH_DRAW_PANEL::DisplayComponent( const LIB_PART* aComponent ) } -void SCH_DRAW_PANEL::DisplaySheet( const SCH_SCREEN *aScreen ) +void SCH_DRAW_PANEL::DisplaySheet( SCH_SCREEN *aScreen ) { GetView()->Clear(); diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index f108de1646..8dfaab6be1 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -44,8 +44,8 @@ public: ~SCH_DRAW_PANEL(); - void DisplayComponent( const LIB_PART *aComponent ); - void DisplaySheet( const SCH_SCREEN *aScreen ); + void DisplayComponent( LIB_PART *aComponent ); + void DisplaySheet( SCH_SCREEN *aScreen ); bool SwitchBackend( GAL_TYPE aGalType ) override; diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 9fa010ac6b..e510671b21 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -244,7 +244,7 @@ public: * Usually return true for small items (labels, junctions) and false for * items which can be large (hierarchical sheets, symbols) */ - virtual bool IsMovableFromAnchorPoint() { return true; } + virtual bool IsMovableFromAnchorPoint() const { return true; } wxPoint& GetStoredPos() { return m_storedPos; } void SetStoredPos( wxPoint aPos ) { m_storedPos = aPos; } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 5ccaf07e3f..4b8a595f25 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -365,7 +365,7 @@ void SCH_LINE::RotateEnd( wxPoint aPosition ) } -bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition ) +bool SCH_LINE::IsSameQuadrant( const SCH_LINE* aLine, const wxPoint& aPosition ) const { wxPoint first; wxPoint second; @@ -388,7 +388,7 @@ bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition ) } -bool SCH_LINE::IsParallel( SCH_LINE* aLine ) +bool SCH_LINE::IsParallel( const SCH_LINE* aLine ) const { wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false, wxT( "Cannot test line segment for overlap." ) ); diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index cc8afed8f9..14a267ec11 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -201,9 +201,9 @@ public: * @param aPosition - Point to reference against lines * @return true if lines are mostly in different quadrants of aPosition, false otherwise */ - bool IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition ); + bool IsSameQuadrant( const SCH_LINE* aLine, const wxPoint& aPosition ) const; - bool IsParallel( SCH_LINE* aLine ); + bool IsParallel( const SCH_LINE* aLine ) const; void GetEndPoints( std::vector& aItemList ) override; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index a8f3280a73..f3b7361dbb 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -228,7 +228,7 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) } -bool SCH_PAINTER::isUnitAndConversionShown( const LIB_ITEM* aItem ) +bool SCH_PAINTER::isUnitAndConversionShown( const LIB_ITEM* aItem ) const { if( m_schSettings.m_ShowUnit // showing a specific unit && aItem->GetUnit() // item is unit-specific @@ -248,7 +248,7 @@ bool SCH_PAINTER::isUnitAndConversionShown( const LIB_ITEM* aItem ) } -float SCH_PAINTER::getShadowWidth() +float SCH_PAINTER::getShadowWidth() const { const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix(); @@ -258,7 +258,7 @@ float SCH_PAINTER::getShadowWidth() } -COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows ) +COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows ) const { COLOR4D color = m_schSettings.GetLayerColor( aLayer ); @@ -318,7 +318,7 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr } -float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ) +float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ) const { float width = (float) std::max( aItem->GetPenWidth(), m_schSettings.GetDefaultPenWidth() ); @@ -329,7 +329,7 @@ float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ) } -float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) +float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const { wxCHECK( aItem, static_cast( m_schSettings.m_DefaultWireThickness ) ); @@ -342,7 +342,7 @@ float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) } -float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ) +float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ) const { float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() ); @@ -353,7 +353,7 @@ float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows } -float SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ) +float SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ) const { float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() ); @@ -364,7 +364,7 @@ float SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadow } -float SCH_PAINTER::getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ) +float SCH_PAINTER::getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ) const { float width = (float) std::max( aItem->GetEffectiveTextPenWidth(), m_schSettings.GetDefaultPenWidth() ); @@ -376,7 +376,7 @@ float SCH_PAINTER::getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadow } -float SCH_PAINTER::getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ) +float SCH_PAINTER::getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ) const { float width = (float) std::max( aItem->GetEffectiveTextPenWidth(), m_schSettings.GetDefaultPenWidth() ); @@ -394,7 +394,7 @@ void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, } -void SCH_PAINTER::draw( LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit, int aConvert ) +void SCH_PAINTER::draw( const LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit, int aConvert ) { if( !aUnit ) aUnit = m_schSettings.m_ShowUnit; @@ -403,7 +403,7 @@ void SCH_PAINTER::draw( LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit aConvert = m_schSettings.m_ShowConvert; std::unique_ptr< LIB_PART > tmpPart; - LIB_PART* drawnPart = aPart; + const LIB_PART* drawnPart = aPart; if( aPart->IsAlias() ) { @@ -504,7 +504,7 @@ void SCH_PAINTER::fillIfSelection( int aLayer ) } -void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer ) +void SCH_PAINTER::draw( const LIB_RECTANGLE *aRect, int aLayer ) { if( !isUnitAndConversionShown( aRect ) ) return; @@ -517,7 +517,7 @@ void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer ) } -void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer ) +void SCH_PAINTER::draw( const LIB_CIRCLE *aCircle, int aLayer ) { if( !isUnitAndConversionShown( aCircle ) ) return; @@ -530,7 +530,7 @@ void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer ) } -void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer ) +void SCH_PAINTER::draw( const LIB_ARC *aArc, int aLayer ) { if( !isUnitAndConversionShown( aArc ) ) return; @@ -572,7 +572,7 @@ void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer ) } -void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer ) +void SCH_PAINTER::draw( const LIB_POLYLINE *aLine, int aLayer ) { if( !isUnitAndConversionShown( aLine ) ) return; @@ -591,7 +591,7 @@ void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer ) } -void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer ) +void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -670,7 +670,7 @@ void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer ) } -void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer ) +void SCH_PAINTER::draw( const LIB_TEXT *aText, int aLayer ) { if( !isUnitAndConversionShown( aText ) ) return; @@ -1146,7 +1146,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) } -void SCH_PAINTER::draw( LIB_BEZIER *aCurve, int aLayer ) +void SCH_PAINTER::draw( const LIB_BEZIER *aCurve, int aLayer ) { if( !isUnitAndConversionShown( aCurve ) ) return; @@ -1182,7 +1182,7 @@ void SCH_PAINTER::drawDanglingSymbol( const wxPoint& aPos, int aWidth, bool aDra } -void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer ) +void SCH_PAINTER::draw( const SCH_JUNCTION *aJct, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -1205,7 +1205,7 @@ void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer ) } -void SCH_PAINTER::draw( SCH_LINE *aLine, int aLayer ) +void SCH_PAINTER::draw( const SCH_LINE *aLine, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -1284,7 +1284,7 @@ void SCH_PAINTER::draw( SCH_LINE *aLine, int aLayer ) } -void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer ) +void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -1461,12 +1461,12 @@ void SCH_PAINTER::draw( SCH_COMPONENT *aSymbol, int aLayer ) draw( &tempPart, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() ); // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated - for( SCH_FIELD& field : aSymbol->GetFields() ) + for( const SCH_FIELD& field : aSymbol->GetFields() ) draw( &field, aLayer ); } -void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer ) +void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -1640,10 +1640,11 @@ void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer ) m_gal->SetStrokeColor( color ); m_gal->DrawPolyline( pts2 ); - draw( static_cast( aLabel ), aLayer ); + draw( static_cast( aLabel ), aLayer ); } -void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer ) + +void SCH_PAINTER::draw( const SCH_SHEET *aSheet, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -1705,13 +1706,13 @@ void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer ) if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children && aSheet->IsSelected() ) return; - for( SCH_FIELD& field : aSheet->GetFields() ) + for( const SCH_FIELD& field : aSheet->GetFields() ) draw( &field, aLayer ); } } -void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer ) +void SCH_PAINTER::draw( const SCH_NO_CONNECT *aNC, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -1731,7 +1732,7 @@ void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer ) } -void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer ) +void SCH_PAINTER::draw( const SCH_BUS_ENTRY_BASE *aEntry, int aLayer ) { SCH_LINE line; bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; @@ -1774,7 +1775,7 @@ void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer ) } -void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer ) +void SCH_PAINTER::draw( const SCH_BITMAP *aBitmap, int aLayer ) { m_gal->Save(); m_gal->Translate( aBitmap->GetPosition() ); @@ -1819,7 +1820,7 @@ void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer ) } -void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer ) +void SCH_PAINTER::draw( const SCH_MARKER *aMarker, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 543d52525f..821a1007fa 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -96,7 +96,7 @@ public: m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ] = aColor; } - float GetDanglineSymbolThickness() + float GetDanglineSymbolThickness() const { return (float) m_defaultPenWidth / 3.0F; } @@ -156,27 +156,27 @@ public: } private: - void draw( LIB_RECTANGLE* aRect, int aLayer ); - void draw( LIB_PIN* aPin, int aLayer ); - void draw( LIB_CIRCLE* aCircle, int aLayer ); - void draw( LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 ); - void draw( LIB_ARC* aArc, int aLayer ); - void draw( LIB_POLYLINE* aLine, int aLayer ); - void draw( LIB_FIELD* aField, int aLayer ); - void draw( LIB_TEXT* aText, int aLayer ); - void draw( LIB_BEZIER* aCurve, int aLayer ); + void draw( const LIB_RECTANGLE* aRect, int aLayer ); + void draw( LIB_PIN* aPin, int aLayer ); + void draw( const LIB_CIRCLE* aCircle, int aLayer ); + void draw( const LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 ); + void draw( const LIB_ARC* aArc, int aLayer ); + void draw( const LIB_POLYLINE* aLine, int aLayer ); + void draw( const LIB_FIELD* aField, int aLayer ); + void draw( const LIB_TEXT* aText, int aLayer ); + void draw( const LIB_BEZIER* aCurve, int aLayer ); void draw( SCH_COMPONENT* aSymbol, int aLayer ); - void draw( SCH_JUNCTION* aJct, int aLayer ); - void draw( SCH_FIELD* aField, int aLayer ); - void draw( SCH_TEXT* aText, int aLayer ); + void draw( const SCH_JUNCTION* aJct, int aLayer ); + void draw( const SCH_FIELD* aField, int aLayer ); + void draw( const SCH_TEXT* aText, int aLayer ); void draw( SCH_HIERLABEL* aLabel, int aLayer ); void draw( SCH_GLOBALLABEL* aLabel, int aLayer ); - void draw( SCH_SHEET* aSheet, int aLayer ); - void draw( SCH_NO_CONNECT* aNC, int aLayer ); - void draw( SCH_MARKER* aMarker, int aLayer ); - void draw( SCH_BITMAP* aBitmap, int aLayer ); - void draw( SCH_LINE* aLine, int aLayer ); - void draw( SCH_BUS_ENTRY_BASE* aEntry, int aLayer ); + void draw( const SCH_SHEET* aSheet, int aLayer ); + void draw( const SCH_NO_CONNECT* aNC, int aLayer ); + void draw( const SCH_MARKER* aMarker, int aLayer ); + void draw( const SCH_BITMAP* aBitmap, int aLayer ); + void draw( const SCH_LINE* aLine, int aLayer ); + void draw( const SCH_BUS_ENTRY_BASE* aEntry, int aLayer ); void drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows ); void drawDanglingSymbol( const wxPoint& aPos, int aWidth, bool aDrawingShadows ); @@ -184,16 +184,16 @@ private: int internalPinDecoSize( const LIB_PIN &aPin ); int externalPinDecoSize( const LIB_PIN &aPin ); - bool isUnitAndConversionShown( const LIB_ITEM* aItem ); + bool isUnitAndConversionShown( const LIB_ITEM* aItem ) const; - float getShadowWidth(); - COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows ); - float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ); - float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ); - float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ); - float getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ); - float getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ); - float getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ); + float getShadowWidth() const; + COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows ) const; + float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ) const; + float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const; + float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ) const; + float getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ) const; + float getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ) const; + float getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ) const; bool setDeviceColors( const LIB_ITEM* aItem, int aLayer ); void fillIfSelection( int aLayer ); diff --git a/eeschema/sch_rtree.h b/eeschema/sch_rtree.h index 1db374ea78..dc101abbe3 100644 --- a/eeschema/sch_rtree.h +++ b/eeschema/sch_rtree.h @@ -216,7 +216,7 @@ public: } }; - EE_TYPE OfType( KICAD_T aType ) + EE_TYPE OfType( KICAD_T aType ) const { return EE_TYPE( m_tree, aType ); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 2e5e619f5a..6290d57d02 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -288,12 +288,12 @@ void SCH_SHEET::AddPin( SCH_SHEET_PIN* aSheetPin ) } -void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin ) +void SCH_SHEET::RemovePin( const SCH_SHEET_PIN* aSheetPin ) { wxASSERT( aSheetPin != NULL ); wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T ); - for( auto i = m_pins.begin(); i < m_pins.end(); ++i ) + for( auto i = m_pins.begin(); i < m_pins.end(); ++i ) { if( *i == aSheetPin ) { @@ -305,7 +305,7 @@ void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin ) } -bool SCH_SHEET::HasPin( const wxString& aName ) +bool SCH_SHEET::HasPin( const wxString& aName ) const { for( SCH_SHEET_PIN* pin : m_pins ) { @@ -350,7 +350,7 @@ bool SCH_SHEET::IsVerticalOrientation() const } -bool SCH_SHEET::HasUndefinedPins() +bool SCH_SHEET::HasUndefinedPins() const { for( SCH_SHEET_PIN* pin : m_pins ) { diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 0ff9417da4..48f26b7c57 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -119,7 +119,7 @@ public: * * @return true for a hierarchical sheet pin */ - bool IsMovableFromAnchorPoint() override { return true; } + bool IsMovableFromAnchorPoint() const override { return true; } void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override; @@ -265,9 +265,10 @@ public: * * @return false for a hierarchical sheet */ - bool IsMovableFromAnchorPoint() override { return false; } + bool IsMovableFromAnchorPoint() const override { return false; } std::vector& GetFields() { return m_fields; } + const std::vector& GetFields() const { return m_fields; } /** * Set multiple schematic fields. @@ -283,7 +284,7 @@ public: SCH_SCREEN* GetScreen() const { return m_screen; } - wxSize GetSize() { return m_size; } + wxSize GetSize() const { return m_size; } void SetSize( const wxSize& aSize ) { m_size = aSize; } int GetBorderWidth() const { return m_borderWidth; } @@ -363,7 +364,7 @@ public: std::vector& GetPins() { return m_pins; } - std::vector& GetPins() const + const std::vector& GetPins() const { return const_cast< std::vector& >( m_pins ); } @@ -373,7 +374,7 @@ public: * * @param aSheetPin The sheet pin item to remove from the sheet. */ - void RemovePin( SCH_SHEET_PIN* aSheetPin ); + void RemovePin( const SCH_SHEET_PIN* aSheetPin ); /** * Delete sheet label which do not have a corresponding hierarchical label. @@ -399,16 +400,16 @@ public: * * @return True if sheet pin with \a aName is found, otherwise false. */ - bool HasPin( const wxString& aName ); + bool HasPin( const wxString& aName ) const; - bool HasPins() { return !m_pins.empty(); } + bool HasPins() const { return !m_pins.empty(); } /** * Check all sheet labels against schematic for undefined hierarchical labels. * * @return True if there are any undefined labels. */ - bool HasUndefinedPins(); + bool HasUndefinedPins() const; /** * Return the minimum width of the sheet based on the widths of the sheet pin text. diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 8c6e150f67..d35c592d00 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -82,7 +82,7 @@ void SCH_VIEW::SetScale( double aScale, VECTOR2D aAnchor ) } -void SCH_VIEW::ResizeSheetWorkingArea( SCH_SCREEN* aScreen ) +void SCH_VIEW::ResizeSheetWorkingArea( const SCH_SCREEN* aScreen ) { const PAGE_INFO& page_info = aScreen->GetPageSettings(); double max_size_x = page_info.GetWidthIU() * 3.0; @@ -92,7 +92,7 @@ void SCH_VIEW::ResizeSheetWorkingArea( SCH_SCREEN* aScreen ) } -void SCH_VIEW::DisplaySheet( SCH_SCREEN *aScreen ) +void SCH_VIEW::DisplaySheet( const SCH_SCREEN *aScreen ) { for( SCH_ITEM* item : aScreen->Items() ) Add( item ); diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index 60f1369cd9..60cf604e57 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -79,11 +79,11 @@ public: void Cleanup(); - void DisplaySheet( SCH_SCREEN* aScreen ); + void DisplaySheet( const SCH_SCREEN* aScreen ); void DisplayComponent( LIB_PART* aPart ); // Call it to set new draw area limits (max working and draw area size) - void ResizeSheetWorkingArea( SCH_SCREEN *aScreen ); + void ResizeSheetWorkingArea( const SCH_SCREEN *aScreen ); void SetScale( double aScale, VECTOR2D aAnchor = { 0, 0 } ) override; diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 895aa150a5..171775db06 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -229,6 +229,7 @@ public: bool LoadFromFile( const wxString& aDirectory = "" ) override; BOARD_STACKUP& GetStackupDescriptor() { return m_stackup; } + const BOARD_STACKUP& GetStackupDescriptor() const { return m_stackup; } SEVERITY GetSeverity( int aDRCErrorCode ); diff --git a/include/eda_item.h b/include/eda_item.h index 2ff421efec..8919e10fb5 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -201,7 +201,7 @@ public: void SetFlags( STATUS_FLAGS aMask ) { m_flags |= aMask; } void ClearFlags( STATUS_FLAGS aMask = EDA_ITEM_ALL_FLAGS ) { m_flags &= ~aMask; } STATUS_FLAGS GetFlags() const { return m_flags; } - bool HasFlag( STATUS_FLAGS aFlag ) { return ( m_flags & aFlag ) == aFlag; } + bool HasFlag( STATUS_FLAGS aFlag ) const { return ( m_flags & aFlag ) == aFlag; } STATUS_FLAGS GetEditFlags() const { diff --git a/include/pcb_group.h b/include/pcb_group.h index ac16cacdb8..395930590c 100644 --- a/include/pcb_group.h +++ b/include/pcb_group.h @@ -65,6 +65,11 @@ public: wxString GetName() const { return m_name; } void SetName( wxString aName ) { m_name = aName; } + std::unordered_set& GetItems() + { + return m_items; + } + const std::unordered_set& GetItems() const { return m_items; diff --git a/include/render_settings.h b/include/render_settings.h index f76f0c36c1..5eb82e2c2c 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -254,7 +254,7 @@ public: void SetHighContrastFactor( float aFactor ) { m_hiContrastFactor = aFactor; } // TODO: these can go away once the worksheet is moved to Cairo-based printing - wxDC* GetPrintDC() { return m_printDC; } + wxDC* GetPrintDC() const { return m_printDC; } void SetPrintDC( wxDC* aDC ) { m_printDC = aDC; } protected: diff --git a/include/richio.h b/include/richio.h index e855bdd7ef..00e751660a 100644 --- a/include/richio.h +++ b/include/richio.h @@ -375,7 +375,7 @@ public: * @return the quote_char as a single character string, or "" if the wrapee does not need * to be wrapped. */ - virtual const char* GetQuoteChar( const char* wrapee ); + virtual const char* GetQuoteChar( const char* wrapee ) const; /** * Check \a aWrapee input string for a need to be quoted (e.g. contains a ')' character @@ -389,9 +389,9 @@ public: * * @throw IO_ERROR, if there is any kind of problem with the input string. */ - virtual std::string Quotes( const std::string& aWrapee ); + virtual std::string Quotes( const std::string& aWrapee ) const; - std::string Quotew( const wxString& aWrapee ); + std::string Quotew( const wxString& aWrapee ) const; private: std::vector m_buffer; diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index 487421700a..22f993fb9c 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -396,12 +396,12 @@ public: * Indicate the event should restart/end an ongoing interactive tool's event loop (eg esc * key, click cancel, start different tool). */ - bool IsCancelInteractive(); + bool IsCancelInteractive() const; /** * Indicate an selection-changed notification event. */ - bool IsSelectionEvent(); + bool IsSelectionEvent() const; /** * Indicate if the event is from one of the point editors. @@ -409,14 +409,14 @@ public: * Usually used to allow the point editor to activate itself without de-activating the * current drawing tool. */ - bool IsPointEditor(); + bool IsPointEditor() const; /** * Indicate if the event is from one of the move tools. * * Usually used to allow move to be done without de-activating the current drawing tool. */ - bool IsMoveTool(); + bool IsMoveTool() const; /** * Return a non-standard parameter assigned to the event. Its meaning depends on the diff --git a/libs/kimath/include/geometry/shape_poly_set.h b/libs/kimath/include/geometry/shape_poly_set.h index 8b3d966eb3..17766b19e9 100644 --- a/libs/kimath/include/geometry/shape_poly_set.h +++ b/libs/kimath/include/geometry/shape_poly_set.h @@ -656,6 +656,11 @@ public: return m_polys[aIndex][0]; } + const SHAPE_LINE_CHAIN& Outline( int aIndex ) const + { + return m_polys[aIndex][0]; + } + /** * Function Subset * returns a subset of the polygons in this set, the ones between aFirstPolygon and diff --git a/pcb_calculator/class_regulator_data.h b/pcb_calculator/class_regulator_data.h index 88d5a8d0cf..0843320cb2 100644 --- a/pcb_calculator/class_regulator_data.h +++ b/pcb_calculator/class_regulator_data.h @@ -134,7 +134,7 @@ public: } } - wxArrayString GetRegList() + wxArrayString GetRegList() const { wxArrayString list; for( unsigned ii = 0; ii < m_List.size(); ii++ ) diff --git a/pcb_calculator/transline_dlg_funct.cpp b/pcb_calculator/transline_dlg_funct.cpp index a90fe41b34..4409274cdd 100644 --- a/pcb_calculator/transline_dlg_funct.cpp +++ b/pcb_calculator/transline_dlg_funct.cpp @@ -34,7 +34,7 @@ extern double DoubleFromString( const wxString& TextValue ); // A helper function to find the choice in a list of values // return true if a index in aList that matches aValue is found. -static bool findMatch(wxArrayString& aList, wxString& aValue, int& aIdx ) +static bool findMatch(wxArrayString& aList, const wxString& aValue, int& aIdx ) { bool success = false; // Find the previous choice index: diff --git a/pcbnew/board.h b/pcbnew/board.h index 94ff3c15d1..60947685a1 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -264,14 +264,14 @@ public: * * @return what the board is being used for */ - BOARD_USE GetBoardUse() { return m_boardUse; } + BOARD_USE GetBoardUse() const { return m_boardUse; } /** * Find out if the board is being used to hold a single footprint for editing/viewing. * * @return if the board is just holding a footprint */ - bool IsFootprintHolder() + bool IsFootprintHolder() const { return m_boardUse == BOARD_USE::FPHOLDER; } @@ -293,6 +293,7 @@ public: const ZONES& Zones() const { return m_zones; } MARKERS& Markers() { return m_markers; } + const MARKERS& Markers() const { return m_markers; } /** * The groups must maintain the following invariants. These are checked by @@ -303,6 +304,7 @@ public: * - The graph of groups containing subgroups must be acyclic. */ GROUPS& Groups() { return m_groups; } + const GROUPS& Groups() const { return m_groups; } const std::vector AllConnectedItems(); @@ -591,6 +593,7 @@ public: void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; } TITLE_BLOCK& GetTitleBlock() { return m_titles; } + const TITLE_BLOCK& GetTitleBlock() const { return m_titles; } void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; } wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/pcbnew/board_stackup_manager/class_board_stackup.cpp b/pcbnew/board_stackup_manager/class_board_stackup.cpp index ef0c08c3d4..d7db2d9a63 100644 --- a/pcbnew/board_stackup_manager/class_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/class_board_stackup.cpp @@ -442,7 +442,7 @@ bool BOARD_STACKUP::SynchronizeWithBoard( BOARD_DESIGN_SETTINGS* aSettings ) { bool found = false; // Search for initial settings: - for( BOARD_STACKUP_ITEM* initial_item: m_list ) + for( const BOARD_STACKUP_ITEM* initial_item : m_list ) { if( item->GetBrdLayerId() != UNDEFINED_LAYER ) { @@ -488,7 +488,7 @@ bool BOARD_STACKUP::SynchronizeWithBoard( BOARD_DESIGN_SETTINGS* aSettings ) } -void BOARD_STACKUP::BuildDefaultStackupList( BOARD_DESIGN_SETTINGS* aSettings, +void BOARD_STACKUP::BuildDefaultStackupList( const BOARD_DESIGN_SETTINGS* aSettings, int aActiveCopperLayersCount ) { // Creates a default stackup, according to the current BOARD_DESIGN_SETTINGS settings. @@ -605,8 +605,7 @@ void BOARD_STACKUP::BuildDefaultStackupList( BOARD_DESIGN_SETTINGS* aSettings, // Transfer other stackup settings from aSettings if( aSettings ) { - BOARD_STACKUP& source_stackup = aSettings->GetStackupDescriptor(); - m_HasDielectricConstrains = source_stackup.m_HasDielectricConstrains; + const BOARD_STACKUP& source_stackup = aSettings->GetStackupDescriptor(); m_EdgeConnectorConstraints = source_stackup.m_EdgeConnectorConstraints; m_CastellatedPads = source_stackup.m_CastellatedPads; m_EdgePlating = source_stackup.m_EdgePlating; @@ -616,7 +615,7 @@ void BOARD_STACKUP::BuildDefaultStackupList( BOARD_DESIGN_SETTINGS* aSettings, void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter, - BOARD* aBoard, int aNestLevel ) const + const BOARD* aBoard, int aNestLevel ) const { // Board stackup is the ordered list from top to bottom of // physical layers and substrate used to build the board. diff --git a/pcbnew/board_stackup_manager/class_board_stackup.h b/pcbnew/board_stackup_manager/class_board_stackup.h index eccf0a3eaa..50b9b554e6 100644 --- a/pcbnew/board_stackup_manager/class_board_stackup.h +++ b/pcbnew/board_stackup_manager/class_board_stackup.h @@ -292,7 +292,7 @@ public: * of copper layers to use to calculate a default dielectric thickness. * ((<= 0 to use all copper layers) */ - void BuildDefaultStackupList( BOARD_DESIGN_SETTINGS* aSettings, + void BuildDefaultStackupList( const BOARD_DESIGN_SETTINGS* aSettings, int aActiveCopperLayersCount = 0 ); /** @@ -302,7 +302,7 @@ public: * @param aNestLevel is the index to nest level to indent the lines in file */ void FormatBoardStackup( OUTPUTFORMATTER* aFormatter, - BOARD* aBoard, int aNestLevel ) const; + const BOARD* aBoard, int aNestLevel ) const; }; diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index b58225fae1..1a2a2daaec 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -335,7 +335,7 @@ int PANEL_SETUP_BOARD_STACKUP::GetPcbThickness() void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard( bool aFullSync ) { - BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor(); + const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor(); if( aFullSync ) { @@ -813,7 +813,7 @@ void PANEL_SETUP_BOARD_STACKUP::buildLayerStackPanel( bool aCreatedInitialStacku // but if the number of layer is changed in the dialog, the corresponding // widgets will be available with their previous values. m_stackup.BuildDefaultStackupList( nullptr, m_brdSettings->GetCopperLayerCount() ); - BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor(); + const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor(); // Now initialize all stackup items to the board values, when exist for( BOARD_STACKUP_ITEM* item: m_stackup.GetList() ) diff --git a/pcbnew/exporters/export_hyperlynx.cpp b/pcbnew/exporters/export_hyperlynx.cpp index 5f32b9916d..bbba99e13b 100644 --- a/pcbnew/exporters/export_hyperlynx.cpp +++ b/pcbnew/exporters/export_hyperlynx.cpp @@ -167,7 +167,7 @@ private: return m_padStacks.back(); } - const std::string formatPadShape( HYPERLYNX_PAD_STACK& aStack ) + const std::string formatPadShape( const HYPERLYNX_PAD_STACK& aStack ) { int shapeId = 0; char buf[1024]; @@ -334,7 +334,7 @@ bool HYPERLYNX_EXPORTER::writeStackupInfo() LSEQ layers = m_board->GetDesignSettings().GetEnabledLayers().CuStack(); // Get the board physical stackup structure - BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor(); + const BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor(); m_out->Print( 0, "{STACKUP\n" ); diff --git a/pcbnew/exporters/gerber_jobfile_writer.cpp b/pcbnew/exporters/gerber_jobfile_writer.cpp index 7dd5285570..793d3c76db 100644 --- a/pcbnew/exporters/gerber_jobfile_writer.cpp +++ b/pcbnew/exporters/gerber_jobfile_writer.cpp @@ -280,7 +280,7 @@ void GERBER_JOBFILE_WRITER::addJSONGeneralSpecs() mapValue( m_pcb->GetDesignSettings().GetBoardThickness() ); // Copper finish - BOARD_STACKUP brd_stackup = m_pcb->GetDesignSettings().GetStackupDescriptor(); + const BOARD_STACKUP brd_stackup = m_pcb->GetDesignSettings().GetStackupDescriptor(); if( !brd_stackup.m_FinishType.IsEmpty() ) m_json["GeneralSpecs"]["Finish"] = brd_stackup.m_FinishType; diff --git a/pcbnew/fp_text.h b/pcbnew/fp_text.h index 3654cba8a0..b6d6cbaa48 100644 --- a/pcbnew/fp_text.h +++ b/pcbnew/fp_text.h @@ -105,7 +105,7 @@ public: * @return force the text rotation to be always between -90 .. 90 deg. Otherwise the text is not easy to read * if false, the text rotation is free. */ - bool IsKeepUpright() + bool IsKeepUpright() const { return m_keepUpright; } diff --git a/pcbnew/plugins/kicad/kicad_plugin.cpp b/pcbnew/plugins/kicad/kicad_plugin.cpp index 60c212b881..72fe8b878a 100644 --- a/pcbnew/plugins/kicad/kicad_plugin.cpp +++ b/pcbnew/plugins/kicad/kicad_plugin.cpp @@ -384,64 +384,64 @@ BOARD_ITEM* PCB_IO::Parse( const wxString& aClipboardSourceInput ) } -void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const +void PCB_IO::Format( const BOARD_ITEM* aItem, int aNestLevel ) const { LOCALE_IO toggle; // public API function, perform anything convenient for caller switch( aItem->Type() ) { case PCB_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_DIM_ALIGNED_T: case PCB_DIM_CENTER_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_SHAPE_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_FP_SHAPE_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_TARGET_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_FOOTPRINT_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_PAD_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_TEXT_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_FP_TEXT_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_GROUP_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_TRACE_T: case PCB_ARC_T: case PCB_VIA_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; case PCB_FP_ZONE_T: case PCB_ZONE_T: - format( static_cast( aItem ), aNestLevel ); + format( static_cast( aItem ), aNestLevel ); break; default: @@ -458,13 +458,13 @@ void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const } -void PCB_IO::formatSetup( BOARD* aBoard, int aNestLevel ) const +void PCB_IO::formatSetup( const BOARD* aBoard, int aNestLevel ) const { // Setup m_out->Print( aNestLevel, "(setup\n" ); // Save the board physical stackup structure - BOARD_STACKUP& stackup = aBoard->GetDesignSettings().GetStackupDescriptor(); + const BOARD_STACKUP& stackup = aBoard->GetDesignSettings().GetStackupDescriptor(); if( aBoard->GetDesignSettings().m_HasStackup ) stackup.FormatBoardStackup( m_out, aBoard, aNestLevel+1 ); @@ -487,7 +487,7 @@ void PCB_IO::formatSetup( BOARD* aBoard, int aNestLevel ) const } -void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const +void PCB_IO::formatGeneral( const BOARD* aBoard, int aNestLevel ) const { const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings(); @@ -503,7 +503,7 @@ void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const } -void PCB_IO::formatBoardLayers( BOARD* aBoard, int aNestLevel ) const +void PCB_IO::formatBoardLayers( const BOARD* aBoard, int aNestLevel ) const { m_out->Print( aNestLevel, "(layers\n" ); @@ -573,7 +573,7 @@ void PCB_IO::formatBoardLayers( BOARD* aBoard, int aNestLevel ) const } -void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const +void PCB_IO::formatNetInformation( const BOARD* aBoard, int aNestLevel ) const { for( NETINFO_ITEM* net : *m_mapping ) { @@ -589,7 +589,7 @@ void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const } -void PCB_IO::formatProperties( BOARD* aBoard, int aNestLevel ) const +void PCB_IO::formatProperties( const BOARD* aBoard, int aNestLevel ) const { for( const std::pair& prop : aBoard->GetProperties() ) { @@ -602,7 +602,7 @@ void PCB_IO::formatProperties( BOARD* aBoard, int aNestLevel ) const } -void PCB_IO::formatHeader( BOARD* aBoard, int aNestLevel ) const +void PCB_IO::formatHeader( const BOARD* aBoard, int aNestLevel ) const { formatGeneral( aBoard, aNestLevel ); // Layers list. @@ -619,7 +619,7 @@ void PCB_IO::formatHeader( BOARD* aBoard, int aNestLevel ) const } -void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const +void PCB_IO::format( const BOARD* aBoard, int aNestLevel ) const { std::set sorted_footprints( aBoard->Footprints().begin(), aBoard->Footprints().end() ); @@ -667,12 +667,12 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const } -void PCB_IO::format( DIMENSION_BASE* aDimension, int aNestLevel ) const +void PCB_IO::format( const DIMENSION_BASE* aDimension, int aNestLevel ) const { - ALIGNED_DIMENSION* aligned = dynamic_cast( aDimension ); - ORTHOGONAL_DIMENSION* ortho = dynamic_cast( aDimension ); - CENTER_DIMENSION* center = dynamic_cast( aDimension ); - LEADER* leader = dynamic_cast( aDimension ); + const ALIGNED_DIMENSION* aligned = dynamic_cast( aDimension ); + const ORTHOGONAL_DIMENSION* ortho = dynamic_cast( aDimension ); + const CENTER_DIMENSION* center = dynamic_cast( aDimension ); + const LEADER* leader = dynamic_cast( aDimension ); m_out->Print( aNestLevel, "(dimension" ); @@ -759,7 +759,7 @@ void PCB_IO::format( DIMENSION_BASE* aDimension, int aNestLevel ) const } -void PCB_IO::format( PCB_SHAPE* aShape, int aNestLevel ) const +void PCB_IO::format( const PCB_SHAPE* aShape, int aNestLevel ) const { switch( aShape->GetShape() ) { @@ -795,9 +795,9 @@ void PCB_IO::format( PCB_SHAPE* aShape, int aNestLevel ) const case S_POLYGON: // Polygon if( aShape->IsPolyShapeValid() ) { - SHAPE_POLY_SET& poly = aShape->GetPolyShape(); - SHAPE_LINE_CHAIN& outline = poly.Outline( 0 ); - int pointsCount = outline.PointCount(); + const SHAPE_POLY_SET& poly = aShape->GetPolyShape(); + const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 ); + const int pointsCount = outline.PointCount(); m_out->Print( aNestLevel, "(gr_poly (pts\n" ); @@ -862,7 +862,7 @@ void PCB_IO::format( PCB_SHAPE* aShape, int aNestLevel ) const } -void PCB_IO::format( FP_SHAPE* aFPShape, int aNestLevel ) const +void PCB_IO::format( const FP_SHAPE* aFPShape, int aNestLevel ) const { switch( aFPShape->GetShape() ) { @@ -894,8 +894,8 @@ void PCB_IO::format( FP_SHAPE* aFPShape, int aNestLevel ) const case S_POLYGON: // Polygonal segment if( aFPShape->IsPolyShapeValid() ) { - SHAPE_POLY_SET& poly = aFPShape->GetPolyShape(); - SHAPE_LINE_CHAIN& outline = poly.Outline( 0 ); + const SHAPE_POLY_SET& poly = aFPShape->GetPolyShape(); + const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 ); int pointsCount = outline.PointCount(); m_out->Print( aNestLevel, "(fp_poly (pts" ); @@ -960,7 +960,7 @@ void PCB_IO::format( FP_SHAPE* aFPShape, int aNestLevel ) const } -void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const +void PCB_IO::format( const PCB_TARGET* aTarget, int aNestLevel ) const { m_out->Print( aNestLevel, "(target %s (at %s) (size %s)", ( aTarget->GetShape() ) ? "x" : "plus", @@ -978,7 +978,7 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const } -void PCB_IO::format( FOOTPRINT* aFootprint, int aNestLevel ) const +void PCB_IO::format( const FOOTPRINT* aFootprint, int aNestLevel ) const { if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) ) { @@ -1262,7 +1262,7 @@ void PCB_IO::formatLayers( LSET aLayerMask, int aNestLevel ) const } -void PCB_IO::format( PAD* aPad, int aNestLevel ) const +void PCB_IO::format( const PAD* aPad, int aNestLevel ) const { const char* shape; @@ -1572,7 +1572,7 @@ void PCB_IO::format( PAD* aPad, int aNestLevel ) const } -void PCB_IO::format( PCB_TEXT* aText, int aNestLevel ) const +void PCB_IO::format( const PCB_TEXT* aText, int aNestLevel ) const { m_out->Print( aNestLevel, "(gr_text %s (at %s", m_out->Quotew( aText->GetText() ).c_str(), @@ -1595,7 +1595,7 @@ void PCB_IO::format( PCB_TEXT* aText, int aNestLevel ) const } -void PCB_IO::format( PCB_GROUP* aGroup, int aNestLevel ) const +void PCB_IO::format( const PCB_GROUP* aGroup, int aNestLevel ) const { // Don't write empty groups if( aGroup->GetItems().empty() ) @@ -1622,7 +1622,7 @@ void PCB_IO::format( PCB_GROUP* aGroup, int aNestLevel ) const } -void PCB_IO::format( FP_TEXT* aText, int aNestLevel ) const +void PCB_IO::format( const FP_TEXT* aText, int aNestLevel ) const { std::string type; @@ -1684,7 +1684,7 @@ void PCB_IO::format( FP_TEXT* aText, int aNestLevel ) const } -void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const +void PCB_IO::format( const TRACK* aTrack, int aNestLevel ) const { if( aTrack->Type() == PCB_VIA_T ) { @@ -1772,7 +1772,7 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const } -void PCB_IO::format( ZONE* aZone, int aNestLevel ) const +void PCB_IO::format( const ZONE* aZone, int aNestLevel ) const { // Save the NET info; For keepout zones, net code and net name are irrelevant // so be sure a dummy value is stored, just for ZONE compatibility @@ -1934,7 +1934,7 @@ void PCB_IO::format( ZONE* aZone, int aNestLevel ) const bool new_polygon = true; bool is_closed = false; - for( auto iterator = aZone->IterateWithHoles(); iterator; iterator++ ) + for( auto iterator = aZone->CIterateWithHoles(); iterator; ++iterator ) { if( new_polygon ) { diff --git a/pcbnew/plugins/kicad/kicad_plugin.h b/pcbnew/plugins/kicad/kicad_plugin.h index 7ca6775ff7..ad4116ec3d 100644 --- a/pcbnew/plugins/kicad/kicad_plugin.h +++ b/pcbnew/plugins/kicad/kicad_plugin.h @@ -193,7 +193,7 @@ public: * @param aNestLevel The indentation nest level. * @throw IO_ERROR on write error. */ - void Format( BOARD_ITEM* aItem, int aNestLevel = 0 ) const; + void Format( const BOARD_ITEM* aItem, int aNestLevel = 0 ) const; std::string GetStringOutput( bool doClear ) { @@ -218,47 +218,47 @@ protected: void init( const PROPERTIES* aProperties ); /// formats the board setup information - void formatSetup( BOARD* aBoard, int aNestLevel = 0 ) const; + void formatSetup( const BOARD* aBoard, int aNestLevel = 0 ) const; /// formats the General section of the file - void formatGeneral( BOARD* aBoard, int aNestLevel = 0 ) const; + void formatGeneral( const BOARD* aBoard, int aNestLevel = 0 ) const; /// formats the board layer information - void formatBoardLayers( BOARD* aBoard, int aNestLevel = 0 ) const; + void formatBoardLayers( const BOARD* aBoard, int aNestLevel = 0 ) const; /// formats the Nets and Netclasses - void formatNetInformation( BOARD* aBoard, int aNestLevel = 0 ) const; + void formatNetInformation( const BOARD* aBoard, int aNestLevel = 0 ) const; /// formats the Nets and Netclasses - void formatProperties( BOARD* aBoard, int aNestLevel = 0 ) const; + void formatProperties( const BOARD* aBoard, int aNestLevel = 0 ) const; /// writes everything that comes before the board_items, like settings and layers etc - void formatHeader( BOARD* aBoard, int aNestLevel = 0 ) const; + void formatHeader( const BOARD* aBoard, int aNestLevel = 0 ) const; private: - void format( BOARD* aBoard, int aNestLevel = 0 ) const; + void format( const BOARD* aBoard, int aNestLevel = 0 ) const; - void format( DIMENSION_BASE* aDimension, int aNestLevel = 0 ) const; + void format( const DIMENSION_BASE* aDimension, int aNestLevel = 0 ) const; - void format( FP_SHAPE* aFPShape, int aNestLevel = 0 ) const; + void format( const FP_SHAPE* aFPShape, int aNestLevel = 0 ) const; - void format( PCB_GROUP* aGroup, int aNestLevel = 0 ) const; + void format( const PCB_GROUP* aGroup, int aNestLevel = 0 ) const; - void format( PCB_SHAPE* aSegment, int aNestLevel = 0 ) const; + void format( const PCB_SHAPE* aSegment, int aNestLevel = 0 ) const; - void format( PCB_TARGET* aTarget, int aNestLevel = 0 ) const; + void format( const PCB_TARGET* aTarget, int aNestLevel = 0 ) const; - void format( FOOTPRINT* aFootprint, int aNestLevel = 0 ) const; + void format( const FOOTPRINT* aFootprint, int aNestLevel = 0 ) const; - void format( PAD* aPad, int aNestLevel = 0 ) const; + void format( const PAD* aPad, int aNestLevel = 0 ) const; - void format( PCB_TEXT* aText, int aNestLevel = 0 ) const; + void format( const PCB_TEXT* aText, int aNestLevel = 0 ) const; - void format( FP_TEXT* aText, int aNestLevel = 0 ) const; + void format( const FP_TEXT* aText, int aNestLevel = 0 ) const; - void format( TRACK* aTrack, int aNestLevel = 0 ) const; + void format( const TRACK* aTrack, int aNestLevel = 0 ) const; - void format( ZONE* aZone, int aNestLevel = 0 ) const; + void format( const ZONE* aZone, int aNestLevel = 0 ) const; void formatLayer( const BOARD_ITEM* aItem ) const; diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index b5c094eeda..004dcf4c65 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -1122,7 +1122,7 @@ void ZONE::CacheTriangulation( PCB_LAYER_ID aLayer ) } -bool ZONE::IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) +bool ZONE::IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const { if( GetNetCode() < 1 ) return true; diff --git a/pcbnew/zone.h b/pcbnew/zone.h index 1f9e5d3558..4c971528dd 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -321,7 +321,7 @@ public: } SHAPE_POLY_SET* Outline() { return m_Poly; } - const SHAPE_POLY_SET* Outline() const { return const_cast< SHAPE_POLY_SET* >( m_Poly ); } + const SHAPE_POLY_SET* Outline() const { return m_Poly; } void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; } @@ -687,7 +687,7 @@ public: * @param aPolyIdx is an inndex into m_FilledPolysList[aLayer] * @return true if the given polygon is insulated (i.e. has no net connection) */ - bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ); + bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const; void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) { diff --git a/utils/idftools/idf_common.cpp b/utils/idftools/idf_common.cpp index 393ecf37e4..f888defbb3 100644 --- a/utils/idftools/idf_common.cpp +++ b/utils/idftools/idf_common.cpp @@ -376,7 +376,7 @@ IDF_DRILL_DATA::IDF_DRILL_DATA( double aDrillDia, double aPosX, double aPosY, owner = aOwner; } // IDF_DRILL_DATA::IDF_DRILL_DATA( ... ) -bool IDF_DRILL_DATA::Matches( double aDrillDia, double aPosX, double aPosY ) +bool IDF_DRILL_DATA::Matches( double aDrillDia, double aPosX, double aPosY ) const { double ddia = aDrillDia - dia; IDF_POINT p1, p2; @@ -717,17 +717,17 @@ void IDF_DRILL_DATA::write( std::ostream& aBoardFile, IDF3::IDF_UNIT aBoardUnit } // IDF_DRILL_DATA::Write( aBoardFile, unitMM ) -double IDF_DRILL_DATA::GetDrillDia() +double IDF_DRILL_DATA::GetDrillDia() const { return dia; } -double IDF_DRILL_DATA::GetDrillXPos() +double IDF_DRILL_DATA::GetDrillXPos() const { return x; } -double IDF_DRILL_DATA::GetDrillYPos() +double IDF_DRILL_DATA::GetDrillYPos() const { return y; } @@ -793,7 +793,7 @@ void IDF3::PrintSeg( IDF_SEGMENT* aSegment ) #endif -bool IDF_POINT::Matches( const IDF_POINT& aPoint, double aRadius ) +bool IDF_POINT::Matches( const IDF_POINT& aPoint, double aRadius ) const { double dx = x - aPoint.x; double dy = y - aPoint.y; diff --git a/utils/idftools/idf_common.h b/utils/idftools/idf_common.h index 74ae60b6d4..3614745b25 100644 --- a/utils/idftools/idf_common.h +++ b/utils/idftools/idf_common.h @@ -414,25 +414,25 @@ public: * * @return bool: true if the diameter and position match this object */ - bool Matches( double aDrillDia, double aPosX, double aPosY ); + bool Matches( double aDrillDia, double aPosX, double aPosY ) const; /** * Function GettDrillDia * returns the drill diameter in mm */ - double GetDrillDia(); + double GetDrillDia() const; /** * Function GettDrillXPos * returns the drill's X position in mm */ - double GetDrillXPos(); + double GetDrillXPos() const; /** * Function GettDrillYPos * returns the drill's Y position in mm */ - double GetDrillYPos(); + double GetDrillYPos() const; /** * Function GetDrillPlating @@ -455,7 +455,7 @@ public: */ const std::string& GetDrillHoleType(); - IDF3::KEY_OWNER GetDrillOwner() + IDF3::KEY_OWNER GetDrillOwner() const { return owner; } @@ -494,7 +494,7 @@ public: * * @return bool: true if this point matches the given point */ - bool Matches( const IDF_POINT& aPoint, double aRadius = 1e-5 ); + bool Matches( const IDF_POINT& aPoint, double aRadius = 1e-5 ) const; /** * Function CalcDistance()