From c0f480eea8e144d4ef1594ed0fed6184ad537354 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 20 Apr 2024 21:50:40 +0100 Subject: [PATCH] Lint reduction. --- eeschema/sch_painter.cpp | 14 +++++++------- eeschema/sch_painter.h | 6 +++--- eeschema/sch_pin.cpp | 14 +++++++------- eeschema/sch_pin.h | 14 +++++++------- eeschema/tools/ee_selection_tool.cpp | 23 ++++++++++++----------- eeschema/tools/ee_selection_tool.h | 8 ++++---- 6 files changed, 40 insertions(+), 39 deletions(-) diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 4e886c7fe6..02f945dcae 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -527,21 +527,21 @@ static bool isFieldsLayer( int aLayer ) void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, - const TEXT_ATTRIBUTES& aAttributes, + const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ) { - KIFONT::FONT* font = aAttributes.m_Font; + KIFONT::FONT* font = aAttrs.m_Font; if( !font ) { - font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttributes.m_Bold, - aAttributes.m_Italic ); + font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold, + aAttrs.m_Italic ); } m_gal->SetIsFill( font->IsOutline() ); m_gal->SetIsStroke( font->IsStroke() ); - font->Draw( m_gal, aText, aPosition, aAttributes, aFontMetrics ); + font->Draw( m_gal, aText, aPosition, aAttrs, aFontMetrics ); } @@ -2848,13 +2848,13 @@ void SCH_PAINTER::draw( const SCH_BUS_ENTRY_BASE *aEntry, int aLayer ) if( aEntry->IsDanglingStart() ) { m_gal->DrawCircle( aEntry->GetPosition(), - aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) ); + aEntry->GetPenWidth() + KiROUND( TARGET_BUSENTRY_RADIUS / 2.0 ) ); } if( aEntry->IsDanglingEnd() ) { m_gal->DrawCircle( aEntry->GetEnd(), - aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) ); + aEntry->GetPenWidth() + KiROUND( TARGET_BUSENTRY_RADIUS / 2.0 ) ); } } else diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index ee4f34efd8..fa0363292e 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -90,7 +90,7 @@ private: void draw( const SCH_TEXTBOX* aTextBox, int aLayer, bool aDimmed ); void draw( const SCH_TEXT* aText, int aLayer, bool aDimmed ); void draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed ); - void draw( const SCH_LABEL* aText, int aLayer ); + void draw( const SCH_LABEL* aLabel, int aLayer ); void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer ); void draw( const SCH_HIERLABEL* aLabel, int aLayer ); void draw( const SCH_GLOBALLABEL* aLabel, int aLayer ); @@ -127,9 +127,9 @@ private: void triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c ); void strokeText( const wxString& aText, const VECTOR2D& aPosition, - const TEXT_ATTRIBUTES& aAttributes, const KIFONT::METRICS& aFontMetrics ); + const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ); void bitmapText( const wxString& aText, const VECTOR2D& aPosition, - const TEXT_ATTRIBUTES& aAttributes ); + const TEXT_ATTRIBUTES& aAttrs ); void knockoutText( const wxString& aText, const VECTOR2D& aPosition, const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ); void boxText( const wxString& aText, const VECTOR2D& aPosition, diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 0a5236dcb0..1b7799c831 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -42,7 +42,7 @@ // small margin in internal units between the pin text and the pin line #define PIN_TEXT_MARGIN 4 -const wxString SCH_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType ) +wxString SCH_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType ) { // These strings are the canonical name of the electrictal type // Not translated, no space in name, only ASCII chars. @@ -163,7 +163,7 @@ SCH_PIN::SCH_PIN( SCH_PIN* aLibPin, SCH_SYMBOL* aParentSymbol ) : SetName( m_libPin->GetName() ); SetNumber( m_libPin->GetNumber() ); - SetPosition( m_libPin->GetPosition() ); + m_position = m_libPin->GetPosition(); m_layer = LAYER_PIN; } @@ -255,7 +255,7 @@ bool SCH_PIN::IsStacked( const SCH_PIN* aPin ) const } -bool SCH_PIN::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxDat ) const +bool SCH_PIN::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const { const SCH_SEARCH_DATA& schSearchData = dynamic_cast( aSearchData ); @@ -1205,7 +1205,7 @@ int SCH_PIN::compare( const SCH_ITEM& aOther, int aCompareFlags ) const return m_nameTextSize.value_or( 0 ) - tmp->m_nameTextSize.value_or( 0 ); if( m_alternates.size() != tmp->m_alternates.size() ) - return (int) m_alternates.size() - tmp->m_alternates.size(); + return static_cast( m_alternates.size() - tmp->m_alternates.size() ); auto lhsItem = m_alternates.begin(); auto rhsItem = tmp->m_alternates.begin(); @@ -1568,8 +1568,8 @@ void SCH_PIN::validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxStri } -const BOX2I SCH_PIN::GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, - bool aIncludeElectricalType ) const +BOX2I SCH_PIN::GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, + bool aIncludeElectricalType ) const { if( const SCH_SYMBOL* symbol = dynamic_cast( GetParentSymbol() ) ) { @@ -1747,7 +1747,7 @@ bool SCH_PIN::ConnectionPropagatesTo( const EDA_ITEM* aItem ) const wxCHECK( m_libPin, false ); // Reciprocal checking is done in CONNECTION_GRAPH anyway - return !( m_libPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ); + return m_libPin->GetType() != ELECTRICAL_PINTYPE::PT_NC; } diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index a94700a8d7..515b8218bf 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -52,7 +52,7 @@ public: SCH_PIN( LIB_SYMBOL* aParentSymbol, const wxString& aName, const wxString& aNumber, PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength, - int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos, int aUnit ); + int aNameTextSize, int aNumTextSize, int aBodyStyle, const VECTOR2I& aPos, int aUnit ); SCH_PIN( SCH_PIN* aLibPin, SCH_SYMBOL* aParentSymbol ); @@ -289,8 +289,8 @@ public: * @param aIncludeLabelsOnInvisiblePins - if false, do not include labels for invisible pins * in the calculation. */ - const BOX2I GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, - bool aIncludeElectricalType ) const; + BOX2I GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, + bool aIncludeElectricalType ) const; /** * Return whether this pin forms a global power connection: i.e., is part of a power symbol @@ -357,7 +357,7 @@ public: * @param aType is the electrical type (see enum ELECTRICAL_PINTYPE ) * @return The electrical name for a pin type (see enun MsgPinElectricType for names). */ - static const wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType ); + static wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType ); bool IsConnectable() const override { return true; } @@ -393,10 +393,10 @@ public: const wxString& GetOperatingPoint() const { return m_operatingPoint; } void SetOperatingPoint( const wxString& aText ) { m_operatingPoint = aText; } - double Similarity( const SCH_ITEM& aItem ) const override; + double Similarity( const SCH_ITEM& aOther ) const override; - bool operator==( const SCH_ITEM& aItem ) const override; - bool operator!=( const SCH_ITEM& aItem ) const { return !operator==( aItem ); } + bool operator==( const SCH_ITEM& aOther ) const override; + bool operator!=( const SCH_ITEM& aOther ) const { return !operator==( aOther ); } bool operator<( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; } bool operator>( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 13978de5ef..7c05f2fc51 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1384,14 +1384,13 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const { EDA_ITEM* item = collector[ i ]; - if( !exactHits.count( item ) ) + if( !exactHits.contains( item ) ) collector.Transfer( item ); } } // Find the closest item. (Note that at this point all hits are either exact or non-exact.) - VECTOR2I pos( aPos ); - SEG poss( mapCoords( pos, m_isSymbolEditor ), mapCoords( pos, m_isSymbolEditor ) ); + SEG poss( mapCoords( aPos, m_isSymbolEditor ), mapCoords( aPos, m_isSymbolEditor ) ); EDA_ITEM* closest = nullptr; int closestDist = INT_MAX / 4; @@ -1400,7 +1399,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const BOX2I bbox = item->GetBoundingBox(); int dist = INT_MAX / 4; - if( exactHits.count( item ) ) + if( exactHits.contains( item ) ) { if( item->Type() == SCH_PIN_T || item->Type() == SCH_JUNCTION_T ) { @@ -1417,7 +1416,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const if( line ) { dist = KiROUND( DistanceLinePoint( line->GetStartPoint(), - line->GetEndPoint(), pos ) ); + line->GetEndPoint(), aPos ) ); } else if( field ) { @@ -1463,14 +1462,14 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() ); - if( bbox.Contains( pos ) ) - dist = KiROUND( EuclideanNorm( bbox.GetCenter() - pos ) ); + if( bbox.Contains( aPos ) ) + dist = KiROUND( EuclideanNorm( bbox.GetCenter() - aPos ) ); else rect.Collide( poss, closestDist, &dist ); } else { - dist = KiROUND( EuclideanNorm( bbox.GetCenter() - pos ) ); + dist = KiROUND( EuclideanNorm( bbox.GetCenter() - aPos ) ); } } else @@ -2235,7 +2234,7 @@ void EE_SELECTION_TOOL::ZoomFitCrossProbeBBox( const BOX2I& aBBox ) BOX2I bbox = aBBox; bbox.Normalize(); - VECTOR2I bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize(); + VECTOR2I bbSize = bbox.Inflate( KiROUND( bbox.GetWidth() * 0.2f ) ).GetSize(); VECTOR2D screenSize = getView()->GetViewport().GetSize(); // This code tries to come up with a zoom factor that doesn't simply zoom in to the cross @@ -2274,7 +2273,7 @@ void EE_SELECTION_TOOL::ZoomFitCrossProbeBBox( const BOX2I& aBBox ) // linearly interpolate "second" which gives the scaling factor needed. if( compRatio >= lut.front().first ) { - for( it = lut.begin(); it < lut.end() - 1; it++ ) + for( it = lut.begin(); it < lut.end() - 1; ++it ) { if( it->first <= compRatio && next( it )->first >= compRatio ) { @@ -2590,6 +2589,7 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup if( aItem->GetParent() && aItem->GetParent()->Type() != SCHEMATIC_T ) getView()->Update( aItem->GetParent(), KIGFX::REPAINT ); + getView()->Update( aItem, KIGFX::REPAINT ); } @@ -2638,6 +2638,7 @@ void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGro if( aItem->GetParent() && aItem->GetParent()->Type() != SCHEMATIC_T ) getView()->Update( aItem->GetParent(), KIGFX::REPAINT ); + getView()->Update( aItem, KIGFX::REPAINT ); } @@ -2645,7 +2646,7 @@ void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGro bool EE_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const { const unsigned GRIP_MARGIN = 20; - double margin = getView()->ToWorld( GRIP_MARGIN ); + int margin = KiROUND( getView()->ToWorld( GRIP_MARGIN ) ); // Check if the point is located within any of the currently selected items bounding boxes for( EDA_ITEM* item : m_selection ) diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index f77e28d41f..efc9f4ee70 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -267,19 +267,19 @@ private: * Highlight the item visually. * * @param aItem The item to be highlighted. - * @param aHighlightMode Either SELECTED or BRIGHTENED + * @param aMode Either SELECTED or BRIGHTENED * @param aGroup [otpional] A group to add the item to. */ - void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override; + void highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup = nullptr ) override; /** * Unhighlight the item visually. * * @param aItem is an item to be highlighted. - * @param aHighlightMode should be either SELECTED or BRIGHTENED + * @param aMode should be either SELECTED or BRIGHTENED * @param aGroup [optional] A group to remove the item from. */ - void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) override; + void unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup = nullptr ) override; /** * Set the reference point to the anchor of the top-left item.