diff --git a/common/eda_rect.cpp b/common/eda_rect.cpp index e5d64cd033..ea666ee3ff 100644 --- a/common/eda_rect.cpp +++ b/common/eda_rect.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -161,10 +161,13 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const // calculate the left common area coordinate: int left = std::max( me.m_pos.x, rect.m_pos.x ); + // calculate the right common area coordinate: int right = std::min( me.m_pos.x + me.m_size.x, rect.m_pos.x + rect.m_size.x ); + // calculate the upper common area coordinate: int top = std::max( me.m_pos.y, aRect.m_pos.y ); + // calculate the lower common area coordinate: int bottom = std::min( me.m_pos.y + me.m_size.y, rect.m_pos.y + rect.m_size.y ); @@ -229,7 +232,6 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect, double aRot ) const wxPoint corners[4]; /* Test A : Any corners exist in rotated rect? */ - corners[0] = m_pos; corners[1] = m_pos + wxPoint( m_size.x, 0 ); corners[2] = m_pos + wxPoint( m_size.x, m_size.y ); @@ -272,7 +274,6 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect, double aRot ) const } /* Test C : Any sides of rotated rect intersect this */ - if( Intersects( corners[0], corners[1] ) || Intersects( corners[1], corners[2] ) || Intersects( corners[2], corners[3] ) || Intersects( corners[3], corners[0] ) ) { @@ -327,8 +328,8 @@ bool EDA_RECT::IntersectsCircle( const wxPoint& aCenter, const int aRadius ) con } -bool EDA_RECT::IntersectsCircleEdge( - const wxPoint& aCenter, const int aRadius, const int aWidth ) const +bool EDA_RECT::IntersectsCircleEdge( const wxPoint& aCenter, const int aRadius, + const int aWidth ) const { if( !m_init ) return false; @@ -469,6 +470,7 @@ void EDA_RECT::Merge( const wxPoint& aPoint ) Normalize(); // ensure width and height >= 0 wxPoint end = GetEnd(); + // Change origin and size in order to contain the given rect m_pos.x = std::min( m_pos.x, aPoint.x ); m_pos.y = std::min( m_pos.y, aPoint.y ); @@ -508,7 +510,7 @@ EDA_RECT EDA_RECT::Common( const EDA_RECT& aRect ) const } -const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ) const +const EDA_RECT EDA_RECT::GetBoundingBoxRotated( const wxPoint& aRotCenter, double aAngle ) const { wxPoint corners[4]; @@ -541,4 +543,4 @@ const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngl bbox.SetEnd( end ); return bbox; -} \ No newline at end of file +} diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 34fc886d95..d008a8a76d 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -42,7 +42,7 @@ #include // for STROKE_FONT #include // for GRText #include // for UnescapeString -#include // for KiROUND +#include // for KiROUND #include // for VECTOR2D #include #include @@ -459,7 +459,7 @@ void EDA_TEXT::GetLinePositions( std::vector& aPositions, int aLineCoun } void EDA_TEXT::printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, - COLOR4D aColor, OUTLINE_MODE aFillMode, + const COLOR4D& aColor, OUTLINE_MODE aFillMode, const wxString& aText, const wxPoint &aPos ) { wxDC* DC = aSettings->GetPrintDC(); @@ -529,7 +529,8 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl FormatInternalUnits( GetTextWidth() ).c_str() ); if( GetTextThickness() ) - aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetTextThickness() ).c_str() ); + aFormatter->Print( 0, " (thickness %s)", + FormatInternalUnits( GetTextThickness() ).c_str() ); if( IsBold() ) aFormatter->Print( 0, " bold" ); @@ -546,13 +547,15 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl aFormatter->Print( 0, " (justify"); if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ) - aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" ); + aFormatter->Print( 0, + ( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) ? " left" : " right" ); if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" ); if( IsMirrored() ) aFormatter->Print( 0, " mirror" ); + aFormatter->Print( 0, ")" ); // (justify } @@ -654,7 +657,9 @@ static struct EDA_TEXT_DESC propMgr.AddProperty( new PROPERTY( _HKI( "Text" ), &EDA_TEXT::SetText, &EDA_TEXT::GetText ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Thickness" ), - &EDA_TEXT::SetTextThickness, &EDA_TEXT::GetTextThickness, PROPERTY_DISPLAY::DISTANCE ) ); + &EDA_TEXT::SetTextThickness, + &EDA_TEXT::GetTextThickness, + PROPERTY_DISPLAY::DISTANCE ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Italic" ), &EDA_TEXT::SetItalic, &EDA_TEXT::IsItalic ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Bold" ), @@ -664,13 +669,21 @@ static struct EDA_TEXT_DESC propMgr.AddProperty( new PROPERTY( _HKI( "Visible" ), &EDA_TEXT::SetVisible, &EDA_TEXT::IsVisible ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Width" ), - &EDA_TEXT::SetTextWidth, &EDA_TEXT::GetTextWidth, PROPERTY_DISPLAY::DISTANCE ) ); + &EDA_TEXT::SetTextWidth, + &EDA_TEXT::GetTextWidth, + PROPERTY_DISPLAY::DISTANCE ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Height" ), - &EDA_TEXT::SetTextHeight, &EDA_TEXT::GetTextHeight, PROPERTY_DISPLAY::DISTANCE ) ); - propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Horizontal Justification" ), - &EDA_TEXT::SetHorizJustify, &EDA_TEXT::GetHorizJustify ) ); - propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Vertical Justification" ), - &EDA_TEXT::SetVertJustify, &EDA_TEXT::GetVertJustify ) ); + &EDA_TEXT::SetTextHeight, + &EDA_TEXT::GetTextHeight, + PROPERTY_DISPLAY::DISTANCE ) ); + propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Horizontal Justification" ), + &EDA_TEXT::SetHorizJustify, + &EDA_TEXT::GetHorizJustify ) ); + propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Vertical Justification" ), + &EDA_TEXT::SetVertJustify, + &EDA_TEXT::GetVertJustify ) ); } } _EDA_TEXT_DESC; diff --git a/common/string.cpp b/common/string.cpp index bdb6d39c91..b37af0ba4a 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -68,13 +68,6 @@ bool ConvertSmartQuotesAndDashes( wxString* aString ) } -/** - * These Escape/Unescape routines use HTML-entity-reference-style encoding to handle - * characters which are: - * (a) not legal in filenames - * (b) used as control characters in LIB_IDs - * (c) used to delineate hierarchical paths - */ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) { wxString converted; @@ -326,11 +319,13 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize ) } -std::string EscapedUTF8( wxString aString ) +std::string EscapedUTF8( const wxString& aString ) { + wxString str = aString; + // No new-lines allowed in quoted strings - aString.Replace( "\r\n", "\r" ); - aString.Replace( "\n", "\r" ); + str.Replace( "\r\n", "\r" ); + str.Replace( "\n", "\r" ); std::string utf8 = TO_UTF8( aString ); @@ -387,9 +382,11 @@ wxString EscapeHTML( const wxString& aString ) } -bool NoPrintableChars( wxString aString ) +bool NoPrintableChars( const wxString& aString ) { - return aString.Trim( true ).Trim( false ).IsEmpty(); + wxString tmp = aString; + + return tmp.Trim( true ).Trim( false ).IsEmpty(); } @@ -673,7 +670,7 @@ int ValueStringCompare( wxString strFWord, wxString strSWord ) } -int SplitString( wxString strToSplit, +int SplitString( const wxString& strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ) diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index 49e1e75ca6..772271f98e 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019 KiCad Developers, see CHANGELOG.txt for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see CHANGELOG.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -53,7 +53,8 @@ wxBitmap MakeDisabledBitmap( const wxBitmap& aSource ) } -ACTION_GROUP::ACTION_GROUP( std::string aName, const std::vector& aActions ) +ACTION_GROUP::ACTION_GROUP( const std::string& aName, + const std::vector& aActions ) { wxASSERT_MSG( aActions.size() > 0, "Action groups must have at least one action" ); @@ -112,7 +113,7 @@ ACTION_TOOLBAR_PALETTE::ACTION_TOOLBAR_PALETTE( wxWindow* aParent, bool aVertica m_panel->SetSizer( m_mainSizer ); Connect( wxEVT_CHAR_HOOK, wxCharEventHandler( ACTION_TOOLBAR_PALETTE::onCharHook ), - NULL, this ); + nullptr, this ); } @@ -195,17 +196,16 @@ ACTION_TOOLBAR::ACTION_TOOLBAR( EDA_BASE_FRAME* parent, wxWindowID id, const wxP #endif Connect( wxEVT_COMMAND_TOOL_CLICKED, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolEvent ), - NULL, this ); - Connect( wxEVT_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolRightClick ), - NULL, this ); + nullptr, this ); + Connect( wxEVT_AUITOOLBAR_RIGHT_CLICK, + wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolRightClick ), + nullptr, this ); Connect( wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onItemDrag ), - NULL, this ); - Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), - NULL, this ); - Connect( wxEVT_LEFT_UP, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), - NULL, this ); - Connect( m_paletteTimer->GetId(), wxEVT_TIMER, wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ), - NULL, this ); + nullptr, this ); + Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this ); + Connect( wxEVT_LEFT_UP, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this ); + Connect( m_paletteTimer->GetId(), wxEVT_TIMER, + wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ), nullptr, this ); } @@ -371,10 +371,10 @@ void ACTION_TOOLBAR::UpdateControlWidth( int aID ) if( wxSizerItem* szrItem = item->GetSizerItem() ) szrItem->SetMinSize( bestSize ); - // 2. The controls have a second sizer that allows for padding above/below the control with stretch - // space, so we also need to update the sizer item for the control in that sizer with the new size. - // We let wx do the search for us, since SetItemMinSize is recursive and will locate the control - // on that sizer. + // 2. The controls have a second sizer that allows for padding above/below the control with + // stretch space, so we also need to update the sizer item for the control in that sizer with + // the new size. We let wx do the search for us, since SetItemMinSize is recursive and will + // locate the control on that sizer. if( m_sizer ) { m_sizer->SetItemMinSize( control, bestSize ); @@ -404,8 +404,7 @@ void ACTION_TOOLBAR::SetToolBitmap( const TOOL_ACTION& aAction, const wxBitmap& int toolId = aAction.GetUIId(); wxAuiToolBar::SetToolBitmap( toolId, aBitmap ); - // Set the disabled bitmap: we use the disabled bitmap version - // of aBitmap. + // Set the disabled bitmap: we use the disabled bitmap version of aBitmap. wxAuiToolBarItem* tb_item = wxAuiToolBar::FindTool( toolId ); if( tb_item ) @@ -641,8 +640,8 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem ) size_t numActions = group->m_actions.size(); // The size of the palette in the long dimension - int paletteLongDim = ( 2 * PALETTE_BORDER ) // The border on all sides of the buttons - + ( BUTTON_BORDER ) // The border on the start of the buttons + int paletteLongDim = ( 2 * PALETTE_BORDER ) // The border on all sides of the buttons + + ( BUTTON_BORDER ) // The border on the start of the buttons + ( numActions * BUTTON_BORDER ) // The other button borders + ( numActions * toolRect.GetHeight() ); // The size of the buttons @@ -651,33 +650,38 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem ) { case wxAUI_DOCK_TOP: // Top toolbars need to shift the palette window down by the toolbar padding - dir = true; // Buttons are vertical in the palette + dir = true; // Buttons are vertical in the palette pos = ClientToScreen( toolRect.GetBottomLeft() ); - pos += wxPoint( -PALETTE_BORDER, // Shift left to align the button edges - m_bottomPadding ); // Shift down to move away from the toolbar + pos += wxPoint( -PALETTE_BORDER, // Shift left to align the button edges + m_bottomPadding ); // Shift down to move away from the toolbar break; case wxAUI_DOCK_BOTTOM: - // Bottom toolbars need to shift the palette window up by its height (all buttons + border + toolbar padding) - dir = true; // Buttons are vertical in the palette + // Bottom toolbars need to shift the palette window up by its height (all buttons + + // border + toolbar padding) + dir = true; // Buttons are vertical in the palette pos = ClientToScreen( toolRect.GetTopLeft() ); pos += wxPoint( -PALETTE_BORDER, // Shift left to align the button - -( paletteLongDim + m_topPadding ) ); // Shift up by the entire length of the palette + // Shift up by the entire length of the palette. + -( paletteLongDim + m_topPadding ) ); break; case wxAUI_DOCK_LEFT: // Left toolbars need to shift the palette window up by the toolbar padding - dir = false; // Buttons are horizontal in the palette + dir = false; // Buttons are horizontal in the palette pos = ClientToScreen( toolRect.GetTopRight() ); - pos += wxPoint( m_rightPadding, // Shift right to move away from the toolbar - -( PALETTE_BORDER ) ); // Shift up to align the button tops + pos += wxPoint( m_rightPadding, // Shift right to move away from the toolbar + -( PALETTE_BORDER ) ); // Shift up to align the button tops break; case wxAUI_DOCK_RIGHT: - // Right toolbars need to shift the palette window left by its width (all buttons + border + toolbar padding) - dir = false; // Buttons are horizontal in the palette + // Right toolbars need to shift the palette window left by its width (all buttons + + // border + toolbar padding) + dir = false; // Buttons are horizontal in the palette pos = ClientToScreen( toolRect.GetTopLeft() ); - pos += wxPoint( -( paletteLongDim + m_leftPadding ), // Shift left by the entire length of the palette + + // Shift left by the entire length of the palette. + pos += wxPoint( -( paletteLongDim + m_leftPadding ), -( PALETTE_BORDER ) ); // Shift up to align the button break; } @@ -688,7 +692,7 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem ) m_palette->SetGroup( group ); m_palette->SetButtonSize( toolRect ); m_palette->Connect( wxEVT_BUTTON, wxCommandEventHandler( ACTION_TOOLBAR::onPaletteEvent ), - NULL, this ); + nullptr, this ); // Add the actions in the group to the palette and update their enabled state @@ -725,8 +729,7 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem ) } -void ACTION_TOOLBAR::OnCustomRender(wxDC& aDc, const wxAuiToolBarItem& aItem, - const wxRect& aRect ) +void ACTION_TOOLBAR::OnCustomRender(wxDC& aDc, const wxAuiToolBarItem& aItem, const wxRect& aRect ) { auto it = m_actionGroups.find( aItem.GetId() ); @@ -766,14 +769,16 @@ void ACTION_TOOLBAR::OnCustomRender(wxDC& aDc, const wxAuiToolBarItem& aItem, bool ACTION_TOOLBAR::KiRealize() { wxClientDC dc( this ); + if( !dc.IsOk() ) return false; // calculate hint sizes for both horizontal and vertical // in the order that leaves toolbar in correct final state - // however, skip calculating alternate orientations if we dont need them due to window style + // however, skip calculating alternate orientations if we don't need them due to window style bool retval = true; + if( m_orientation == wxHORIZONTAL ) { if( !( GetWindowStyle() & wxAUI_TB_HORIZONTAL ) ) diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 65bae0190f..bf0d887ffc 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019 CERN * * This program is free software; you can redistribute it and/or @@ -421,7 +421,7 @@ BITMAPS LIB_ARC::GetMenuImage() const } -void LIB_ARC::BeginEdit( const wxPoint aPosition ) +void LIB_ARC::BeginEdit( const wxPoint& aPosition ) { m_ArcStart = m_ArcEnd = aPosition; m_editState = 1; diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index 22fd28f6df..b92211a30a 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -60,7 +60,7 @@ public: int GetPenWidth() const override; - void BeginEdit( const wxPoint aStartPoint ) override; + void BeginEdit( const wxPoint& aStartPoint ) override; void CalcEdit( const wxPoint& aPosition ) override; void SetEditState( int aState ) { m_editState = aState; } diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index b15155ff51..a026a35aa1 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -284,7 +284,7 @@ BITMAPS LIB_CIRCLE::GetMenuImage() const } -void LIB_CIRCLE::BeginEdit( const wxPoint aPosition ) +void LIB_CIRCLE::BeginEdit( const wxPoint& aPosition ) { m_Pos = aPosition; } diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index cfc0e205f7..405382a54e 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,13 +26,12 @@ #define LIB_CIRCLE_H #include -#include // for GetLineLength class LIB_CIRCLE : public LIB_ITEM { public: - LIB_CIRCLE( LIB_PART * aParent ); + LIB_CIRCLE( LIB_PART* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -57,7 +56,7 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - void BeginEdit( const wxPoint aStartPoint ) override; + void BeginEdit( const wxPoint& aStartPoint ) override; void CalcEdit( const wxPoint& aPosition ) override; void Offset( const wxPoint& aOffset ) override; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index c86bfac2ce..3652a62ab9 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -409,7 +409,7 @@ wxString LIB_FIELD::GetSelectMenuText( EDA_UNITS aUnits ) const } -void LIB_FIELD::BeginEdit( const wxPoint aPosition ) +void LIB_FIELD::BeginEdit( const wxPoint& aPosition ) { SetTextPos( aPosition ); } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index e3d5b3ba87..7840e1ca73 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -108,7 +108,7 @@ public: void Init( int idfield ); /** - * Returns the field name. + * Return the field name. * * The first four field IDs are reserved and therefore always return their respective * names. @@ -171,7 +171,7 @@ public: SCH_LAYER_ID GetDefaultLayer() const; - void BeginEdit( const wxPoint aStartPoint ) override; + void BeginEdit( const wxPoint& aStartPoint ) override; void Offset( const wxPoint& aOffset ) override; diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index 938ff25254..ed294bccb5 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -63,7 +63,7 @@ class LIB_ITEM : public EDA_ITEM { public: LIB_ITEM( KICAD_T aType, LIB_PART* aComponent = NULL, int aUnit = 0, int aConvert = 0, - FILL_TYPE aFillType = FILL_TYPE::NO_FILL ); + FILL_TYPE aFillType = FILL_TYPE::NO_FILL ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -96,7 +96,7 @@ public: * @param aPosition The position in drawing coordinates where the drawing was started. * May or may not be required depending on the item being drawn. */ - virtual void BeginEdit( const wxPoint aPosition ) {} + virtual void BeginEdit( const wxPoint& aPosition ) {} /** * Continue an edit in progress at \a aPosition. @@ -108,7 +108,7 @@ public: * @param aPosition The position of the mouse left click in drawing coordinates. * @return True if additional mouse clicks are required to complete the edit in progress. */ - virtual bool ContinueEdit( const wxPoint aPosition ) { return false; } + virtual bool ContinueEdit( const wxPoint& aPosition ) { return false; } /** * End an object editing action. diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index d076aa9869..4a63b1d020 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -359,14 +359,14 @@ BITMAPS LIB_POLYLINE::GetMenuImage() const } -void LIB_POLYLINE::BeginEdit( const wxPoint aPosition ) +void LIB_POLYLINE::BeginEdit( const wxPoint& aPosition ) { m_PolyPoints.push_back( aPosition ); // Start point of first segment. m_PolyPoints.push_back( aPosition ); // End point of first segment. } -bool LIB_POLYLINE::ContinueEdit( const wxPoint aPosition ) +bool LIB_POLYLINE::ContinueEdit( const wxPoint& aPosition ) { // do not add zero length segments if( m_PolyPoints[m_PolyPoints.size() - 2] != m_PolyPoints.back() ) diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 1333e9a42d..5a5cc26517 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -75,9 +75,9 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - void BeginEdit( const wxPoint aStartPoint ) override; + void BeginEdit( const wxPoint& aStartPoint ) override; void CalcEdit( const wxPoint& aPosition ) override; - bool ContinueEdit( const wxPoint aNextPoint ) override; + bool ContinueEdit( const wxPoint& aNextPoint ) override; void EndEdit() override; void Offset( const wxPoint& aOffset ) override; diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 2d2e424e69..8512bb0307 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -288,7 +288,7 @@ BITMAPS LIB_RECTANGLE::GetMenuImage() const } -void LIB_RECTANGLE::BeginEdit( const wxPoint aPosition ) +void LIB_RECTANGLE::BeginEdit( const wxPoint& aPosition ) { m_Pos = m_End = aPosition; } diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 6f7164e6ce..6168a91705 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -59,7 +59,7 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - void BeginEdit( const wxPoint aStartPoint ) override; + void BeginEdit( const wxPoint& aStartPoint ) override; void CalcEdit( const wxPoint& aPosition ) override; void Offset( const wxPoint& aOffset ) override; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 76cdeb4448..cd0b2fe447 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -390,7 +390,7 @@ BITMAPS LIB_TEXT::GetMenuImage() const } -void LIB_TEXT::BeginEdit( const wxPoint aPosition ) +void LIB_TEXT::BeginEdit( const wxPoint& aPosition ) { SetTextPos( aPosition ); } diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 5a52e71baf..1cf218279d 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -83,7 +83,7 @@ public: const EDA_RECT GetBoundingBox() const override; - void BeginEdit( const wxPoint aStartPoint ) override; + void BeginEdit( const wxPoint& aStartPoint ) override; void CalcEdit( const wxPoint& aPosition ) override; void Offset( const wxPoint& aOffset ) override; diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index e37d5d61c5..e5c28a40c0 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011 jean-pierre.charras - * Copyright (C) 2011-2019 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2011-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -142,7 +142,7 @@ void SCH_BITMAP::MirrorHorizontally( int aCenter ) } -void SCH_BITMAP::Rotate( wxPoint aCenter ) +void SCH_BITMAP::Rotate( const wxPoint& aCenter ) { RotatePoint( &m_pos, aCenter, 900 ); m_image->Rotate( false ); diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index b6ee3f6773..7e9e8f27f1 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -122,7 +122,7 @@ public: void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override { diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 8aa33c9107..b9134f468b 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -268,7 +268,7 @@ void SCH_BUS_ENTRY_BASE::MirrorHorizontally( int aCenter ) } -void SCH_BUS_ENTRY_BASE::Rotate( wxPoint aCenter ) +void SCH_BUS_ENTRY_BASE::Rotate( const wxPoint& aCenter ) { RotatePoint( &m_pos, aCenter, 900 ); RotatePoint( &m_size.x, &m_size.y, 900 ); diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index dd9e17f8a9..b960d72962 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -90,7 +90,7 @@ public: void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; bool IsDangling() const override; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index caeb1df51a..f894c9199a 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -53,6 +53,7 @@ #include #include + SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_ITEM* aParent, const wxString& aName ) : SCH_ITEM( aParent, SCH_FIELD_T ), @@ -460,7 +461,7 @@ bool SCH_FIELD::Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) } -void SCH_FIELD::Rotate( wxPoint aCenter ) +void SCH_FIELD::Rotate( const wxPoint& aCenter ) { wxPoint pt = GetPosition(); RotatePoint( &pt, aCenter, 900 ); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 5639766b9b..bf956fe4bc 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -150,7 +150,7 @@ public: Offset( aMoveVector ); } - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; /** * @copydoc SCH_ITEM::MirrorVertically() diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index c723c1b965..0f0e653a24 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -233,7 +233,7 @@ public: virtual bool IsMovableFromAnchorPoint() const { return true; } wxPoint& GetStoredPos() { return m_storedPos; } - void SetStoredPos( wxPoint aPos ) { m_storedPos = aPos; } + void SetStoredPos( const wxPoint& aPos ) { m_storedPos = aPos; } /** * Searches the item hierarchy to find a SCHEMATIC. @@ -316,7 +316,7 @@ public: /** * Rotate the item around \a aCenter 90 degrees in the clockwise direction. */ - virtual void Rotate( wxPoint aCenter ) = 0; + virtual void Rotate( const wxPoint& aCenter ) = 0; /** * Add the schematic item end points to \a aItemList if the item has end points. diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index c2449be316..533b3e2621 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -135,7 +135,7 @@ void SCH_JUNCTION::MirrorHorizontally( int aCenter ) } -void SCH_JUNCTION::Rotate( wxPoint aCenter ) +void SCH_JUNCTION::Rotate( const wxPoint& aCenter ) { RotatePoint( &m_pos, aCenter, 900 ); } diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index a78f4194c8..0126f9fef7 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -67,7 +67,7 @@ public: void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; void GetEndPoints( std::vector & aItemList ) override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index f7ababb77f..21cd13c495 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -392,20 +392,20 @@ void SCH_LINE::MirrorHorizontally( int aCenter ) } -void SCH_LINE::Rotate( wxPoint aCenter ) +void SCH_LINE::Rotate( const wxPoint& aCenter ) { RotatePoint( &m_start, aCenter, 900 ); RotatePoint( &m_end, aCenter, 900 ); } -void SCH_LINE::RotateStart( wxPoint aCenter ) +void SCH_LINE::RotateStart( const wxPoint& aCenter ) { RotatePoint( &m_start, aCenter, 900 ); } -void SCH_LINE::RotateEnd( wxPoint aCenter ) +void SCH_LINE::RotateEnd( const wxPoint& aCenter ) { RotatePoint( &m_end, aCenter, 900 ); } diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 58dec82c74..6cf1bc8ff0 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -170,9 +170,9 @@ public: void MirrorVertically( int aCenter ) override; void MirrorHorizontally( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; - void RotateStart( wxPoint aCenter ); - void RotateEnd( wxPoint aCenter ); + void Rotate( const wxPoint& aCenter ) override; + void RotateStart( const wxPoint& aCenter ); + void RotateEnd( const wxPoint& aCenter ); /** * Check line against \a aLine to see if it overlaps and merge if it does. diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index 34b2a704ef..6dcbcc0289 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -173,7 +173,7 @@ BITMAPS SCH_MARKER::GetMenuImage() const } -void SCH_MARKER::Rotate( wxPoint aCenter ) +void SCH_MARKER::Rotate( const wxPoint& aCenter ) { // Marker geometry isn't user-editable } diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index b678e242c3..7f74bdabd6 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -78,7 +78,7 @@ public: void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; /** * Compare DRC marker main and auxiliary text against search string. diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index f0e5ae0ac7..e6cbdccbf9 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanoadoo.fr - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -127,7 +127,7 @@ void SCH_NO_CONNECT::MirrorHorizontally( int aCenter ) } -void SCH_NO_CONNECT::Rotate( wxPoint aCenter ) +void SCH_NO_CONNECT::Rotate( const wxPoint& aCenter ) { RotatePoint( &m_pos, aCenter, 900 ); } diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index d2374dc49f..ae4ec93508 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -80,7 +80,7 @@ public: void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; bool IsConnectable() const override { return true; } diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index ad7214ef26..e53a07b665 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -72,7 +72,7 @@ public: void MirrorHorizontally( int aCenter ) override {} void MirrorVertically( int aCenter ) override {} - void Rotate( wxPoint aCenter ) override {} + void Rotate( const wxPoint& aCenter ) override {} wxPoint GetPosition() const override { return GetTransformedPosition(); } const wxPoint GetLocalPosition() const { return m_position; } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 07f21dd43d..7b43d0a21f 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -53,6 +53,7 @@ #include #include #include +#include using namespace TSCHEMATIC_T; diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index 5b2fd4a0e1..f95498d65c 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 4a0c58154f..9a656121af 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -731,7 +731,7 @@ void SCH_SHEET::Move( const wxPoint& aMoveVector ) } -void SCH_SHEET::Rotate( wxPoint aCenter ) +void SCH_SHEET::Rotate( const wxPoint& aCenter ) { wxPoint prev = m_pos; diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 88f1212e3f..e9c1e2e8dc 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -330,7 +330,7 @@ public: void Move( const wxPoint& aMoveVector ) override; void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override; diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index f85616274c..aef4a189ee 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -78,7 +78,7 @@ public: void Move( const wxPoint& aMoveVector ) override {} void MirrorHorizontally( int aCenter ) override {} void MirrorVertically( int aCenter ) override {} - void Rotate( wxPoint aCenter ) override {} + void Rotate( const wxPoint& aCenter ) override {} #if defined(DEBUG) void Show( int , std::ostream& ) const override {} diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index e56c54d4f3..c5096fb0bb 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -244,7 +244,7 @@ void SCH_SHEET_PIN::MirrorHorizontally( int aCenter ) } -void SCH_SHEET_PIN::Rotate( wxPoint aCenter ) +void SCH_SHEET_PIN::Rotate( const wxPoint& aCenter ) { wxPoint pt = GetTextPos(); RotatePoint( &pt, aCenter, 900 ); diff --git a/eeschema/sch_sheet_pin.h b/eeschema/sch_sheet_pin.h index 1e81fb5b87..fba63fd15c 100644 --- a/eeschema/sch_sheet_pin.h +++ b/eeschema/sch_sheet_pin.h @@ -152,7 +152,7 @@ public: void MirrorVertically( int aCenter ) override; void MirrorHorizontally( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override { diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 4f93719fb5..57a529c4fd 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1466,7 +1466,7 @@ void SCH_COMPONENT::MirrorVertically( int aCenter ) } -void SCH_COMPONENT::Rotate( wxPoint aCenter ) +void SCH_COMPONENT::Rotate( const wxPoint& aCenter ) { wxPoint prev = m_pos; diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index a671eda75a..dda1fa8824 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -573,7 +573,7 @@ public: void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 4595c38e4f..eb5965af7b 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -284,7 +284,7 @@ void SCH_TEXT::MirrorVertically( int aCenter ) } -void SCH_TEXT::Rotate( wxPoint aCenter ) +void SCH_TEXT::Rotate( const wxPoint& aCenter ) { wxPoint pt = GetTextPos(); RotatePoint( &pt, aCenter, 900 ); @@ -467,7 +467,6 @@ bool SCH_TEXT::UpdateDanglingState( std::vector& aItemList, break; - case BUS_START_END: m_connectionType = CONNECTION_TYPE::BUS; KI_FALLTHROUGH; @@ -1048,7 +1047,7 @@ void SCH_GLOBALLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) } -void SCH_GLOBALLABEL::Rotate( wxPoint aCenter ) +void SCH_GLOBALLABEL::Rotate( const wxPoint& aCenter ) { wxPoint pt = GetTextPos(); RotatePoint( &pt, aCenter, 900 ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 75db9a9624..b94708b618 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -75,13 +75,13 @@ public: LABEL_SPIN_STYLE RotateCCW(); - /* - * Mirrors the label spin style across the X axis or simply swaps up and bottom + /** + * Mirror the label spin style across the X axis or simply swaps up and bottom. */ LABEL_SPIN_STYLE MirrorX(); - /* - * Mirrors the label spin style across the Y axis or simply swaps left and right + /** + * Mirror the label spin style across the Y axis or simply swaps left and right. */ LABEL_SPIN_STYLE MirrorY(); @@ -113,7 +113,7 @@ public: KICAD_T aType = SCH_TEXT_T ); /** - * Clones \a aText into a new object. All members are copied as is except + * Clone \a aText into a new object. All members are copied as is except * for the #m_isDangling member which is set to false. This prevents newly * copied objects derived from #SCH_TEXT from having their connection state * improperly set. @@ -133,7 +133,7 @@ public: } /** - * Returns the set of contextual text variable tokens for this text item. + * Return the set of contextual text variable tokens for this text item. * * @param[out] aVars */ @@ -203,7 +203,7 @@ public: void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; virtual void Rotate90( bool aClockwise ); virtual void MirrorSpinStyle( bool aLeftRight ); @@ -354,7 +354,7 @@ public: void RunOnChildren( const std::function& aFunction ) override; - void Rotate( wxPoint aCenter ) override; + void Rotate( const wxPoint& aCenter ) override; void Rotate90( bool aClockwise ) override; void MirrorSpinStyle( bool aLeftRight ) override; diff --git a/include/eda_rect.h b/include/eda_rect.h index 1e64a54857..65fd665524 100644 --- a/include/eda_rect.h +++ b/include/eda_rect.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -41,11 +41,6 @@ */ class EDA_RECT { -private: - wxPoint m_pos; // Rectangle Origin - wxSize m_size; // Rectangle Size - bool m_init; // Is the rectangle initialized - public: EDA_RECT() : m_init( false ) { }; @@ -190,7 +185,7 @@ public: m_init = true; } - void SetEnd( const wxPoint &pos ) + void SetEnd( const wxPoint& pos ) { m_size.x = pos.x - m_pos.x; m_size.y = pos.y - m_pos.y; @@ -343,11 +338,16 @@ public: /** * Useful to calculate bounding box of rotated items, when rotation if not k*90 degrees. * - * @return the bounding box of this, after rotation. * @param aAngle the rotation angle in 0.1 deg. * @param aRotCenter the rotation point. + * @return the bounding box of this, after rotation. */ - const EDA_RECT GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ) const; + const EDA_RECT GetBoundingBoxRotated( const wxPoint& aRotCenter, double aAngle ) const; + +private: + wxPoint m_pos; // Rectangle Origin + wxSize m_size; // Rectangle Size + bool m_init; // Is the rectangle initialized }; diff --git a/include/eda_text.h b/include/eda_text.h index 337c419826..628dfa0818 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jpe.charras at wanadoo.fr - * Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -383,8 +383,9 @@ private: * @param aText the single line of text to draw. * @param aPos the position of this line ). */ - void printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, COLOR4D aColor, - OUTLINE_MODE aFillMode, const wxString& aText, const wxPoint& aPos ); + void printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, + const COLOR4D& aColor, OUTLINE_MODE aFillMode, const wxString& aText, + const wxPoint& aPos ); wxString m_text; wxString m_shown_text; // Cache of unescaped text for efficient access diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 6505953c45..3bb6a67a7c 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -133,9 +133,8 @@ public: * @param aStartAngle is the start angle of the arc. * @param aEndAngle is the end angle of the arc. */ - virtual void - DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, - double aEndAngle ) {}; + virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, + double aEndAngle ) {}; /** * Draw an arc segment. @@ -153,9 +152,8 @@ public: * @param aEndAngle is the end angle of the arc. * @param aWidth is the thickness of the arc (pen size). */ - virtual void - DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, - double aEndAngle, double aWidth ) {}; + virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, + double aEndAngle, double aWidth ) {}; /** * Draw a rectangle. @@ -412,7 +410,7 @@ public: * * @param aGlyphSize is the new font glyph size. */ - inline void SetGlyphSize( const VECTOR2D aSize ) { textProperties.m_glyphSize = aSize; } + inline void SetGlyphSize( const VECTOR2D& aSize ) { textProperties.m_glyphSize = aSize; } const VECTOR2D& GetGlyphSize() const { return textProperties.m_glyphSize; } /** @@ -420,7 +418,7 @@ public: * * @param aBold tells if the font should be bold or not. */ - inline void SetFontBold( const bool aBold ) { textProperties.m_bold = aBold; } + inline void SetFontBold( bool aBold ) { textProperties.m_bold = aBold; } inline bool IsFontBold() const { return textProperties.m_bold; } /** @@ -439,7 +437,7 @@ public: * * @param aMirrored tells if the text should be mirrored or not. */ - inline void SetTextMirrored( const bool aMirrored ) { textProperties.m_mirrored = aMirrored; } + inline void SetTextMirrored( bool aMirrored ) { textProperties.m_mirrored = aMirrored; } inline bool IsTextMirrored() const { return textProperties.m_mirrored; } /** @@ -838,6 +836,7 @@ public: return m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS || ( m_gridVisibility && m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID ); } + /** * Set the origin point for the grid. * @@ -952,7 +951,7 @@ public: /** * Compute the point position in world coordinates from given screen coordinates. * - * @param aPoint the pointposition in screen coordinates. + * @param aPoint the point position in screen coordinates. * @return the point position in world coordinates. */ inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const @@ -963,7 +962,7 @@ public: /** * Compute the point position in screen coordinates from given world coordinates. * - * @param aPoint the pointposition in world coordinates. + * @param aPoint the point position in world coordinates. * @return the point position in screen coordinates. */ inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const @@ -1173,6 +1172,7 @@ protected: ///< about how to draw texts KICURSOR m_currentNativeCursor; ///< Current cursor + private: struct TEXT_PROPERTIES { diff --git a/include/kicad_string.h b/include/kicad_string.h index e9cc9cac3e..23d204aeed 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,7 +39,7 @@ /** - * Converts curly quotes and em/en dashes to straight quotes and dashes. + * Convert curly quotes and em/en dashes to straight quotes and dashes. * * @return true if any characters required conversion. */ @@ -57,6 +57,13 @@ enum ESCAPE_CONTEXT CTX_FILENAME }; +/** + * The Escape/Unescape routines use HTML-entity-reference-style encoding to handle + * characters which are: + * (a) not legal in filenames + * (b) used as control characters in LIB_IDs + * (c) used to delineate hierarchical paths + */ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ); wxString UnescapeString( const wxString& aSource ); @@ -105,7 +112,7 @@ int ReadDelimitedText( wxString* aDest, const char* aSource ); * @param aString is the input string to convert. * @return the escaped input text, without the wrapping double quotes. */ -std::string EscapedUTF8( wxString aString ); +std::string EscapedUTF8( const wxString& aString ); /** * Return a new wxString escaped for embedding in HTML. @@ -122,7 +129,7 @@ char* GetLine( FILE* aFile, char* Line, int* LineNum = nullptr, int SizeLine = 2 /** * Return true if the string is empty or contains only whitespace. */ -bool NoPrintableChars( wxString aString ); +bool NoPrintableChars( const wxString& aString ); /** * Remove leading and training spaces, tabs and end of line chars in \a text @@ -171,12 +178,12 @@ bool WildCompareString( const wxString& pattern, int ValueStringCompare( wxString strFWord, wxString strSWord ); /** - * Breaks a string into three parts: he alphabetic preamble, the numeric part, and any + * Break a string into three parts: he alphabetic preamble, the numeric part, and any * alphabetic ending. * * For example C10A is split to C 10 A */ -int SplitString( wxString strToSplit, +int SplitString( const wxString& strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ); @@ -224,7 +231,7 @@ extern "C" char* strtok_r( char* str, const char* delim, char** nextp ); */ struct rsort_wxString { - bool operator() (const wxString& strA, const wxString& strB ) const + bool operator() ( const wxString& strA, const wxString& strB ) const { wxString::const_reverse_iterator sA = strA.rbegin(); wxString::const_reverse_iterator eA = strA.rend(); @@ -246,14 +253,14 @@ struct rsort_wxString while( sA != eA && sB != eB ) { - if( (*sA) == (*sB) ) + if( ( *sA ) == ( *sB ) ) { ++sA; ++sB; continue; } - if( (*sA) < (*sB) ) + if( ( *sA ) < ( *sB ) ) return true; else return false; @@ -267,7 +274,7 @@ struct rsort_wxString }; /** - * Splits the input string into a vector of output strings + * Split the input string into a vector of output strings * * @note Multiple delimiters are considered to be separate records with empty strings * @@ -309,7 +316,6 @@ inline void AccumulateDescription( wxString& aDesc, const wxString& aItem ) aDesc << aItem; } - /** * Split \a aString to a string list separated at \a aSplitter. * @@ -328,18 +334,18 @@ void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSpli void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed = 1 ); /** - * Prints a float number without using scientific notation and no trailing 0 + * Print a float number without using scientific notation and no trailing 0 * We want to avoid scientific notation in S-expr files (not easy to read) * for floating numbers. - * So we cannot always just use the %g or the %f format to print a fp number + * + * We cannot always just use the %g or the %f format to print a fp number * this helper function uses the %f format when needed, or %g when %f is * not well working and then removes trailing 0 */ std::string Double2Str( double aValue ); /** - * A helper to convert the \a double \a aAngle (in internal unit) - * to a string in degrees + * A helper to convert the \a double \a aAngle (in internal unit) to a string in degrees. */ wxString AngleToStringDegrees( double aAngle ); diff --git a/include/tool/action_toolbar.h b/include/tool/action_toolbar.h index 316f97a306..91c9830466 100644 --- a/include/tool/action_toolbar.h +++ b/include/tool/action_toolbar.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -49,7 +49,7 @@ public: // Make the toolbar a friend so it can easily access everything inside here friend class ACTION_TOOLBAR; - ACTION_GROUP( std::string aName, const std::vector& aActions ); + ACTION_GROUP( const std::string& aName, const std::vector& aActions ); /** * Set the default action to use when first creating the toolbar palette icon. diff --git a/include/validators.h b/include/validators.h index 719bbf9fe3..cdb1c20fe8 100644 --- a/include/validators.h +++ b/include/validators.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018 CERN * * This program is free software; you can redistribute it and/or @@ -46,8 +46,8 @@ class GRID_CELL_TEXT_EDITOR : public wxGridCellTextEditor public: GRID_CELL_TEXT_EDITOR(); - virtual void SetValidator(const wxValidator& validator) override; - virtual void StartingKey(wxKeyEvent& event) override; + virtual void SetValidator( const wxValidator& validator ) override; + virtual void StartingKey( wxKeyEvent& event ) override; protected: wxScopedPtr m_validator; @@ -63,7 +63,7 @@ protected: class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator { public: - FOOTPRINT_NAME_VALIDATOR( wxString* aValue = NULL ); + FOOTPRINT_NAME_VALIDATOR( wxString* aValue = nullptr ); }; @@ -76,7 +76,7 @@ public: class FILE_NAME_WITH_PATH_CHAR_VALIDATOR : public wxTextValidator { public: - FILE_NAME_WITH_PATH_CHAR_VALIDATOR( wxString* aValue = NULL ); + FILE_NAME_WITH_PATH_CHAR_VALIDATOR( wxString* aValue = nullptr ); }; @@ -91,12 +91,12 @@ public: class ENV_VAR_NAME_VALIDATOR : public wxTextValidator { public: - ENV_VAR_NAME_VALIDATOR( wxString* aValue = NULL ); + ENV_VAR_NAME_VALIDATOR( wxString* aValue = nullptr ); ENV_VAR_NAME_VALIDATOR( const ENV_VAR_NAME_VALIDATOR& val ); virtual ~ENV_VAR_NAME_VALIDATOR(); - // Make a clone of this validator (or return NULL) - currently necessary + // Make a clone of this validator (or return nullptr) - currently necessary // if you're passing a reference to a validator. virtual wxObject *Clone() const override { @@ -120,7 +120,7 @@ public: * @param aRegEx is a regular expression to validate strings. * @param aValue is a pointer to a wxString containing the value to validate. */ - REGEX_VALIDATOR( const wxString& aRegEx, wxString* aValue = NULL ) + REGEX_VALIDATOR( const wxString& aRegEx, wxString* aValue = nullptr ) : wxTextValidator( wxFILTER_NONE, aValue ) { compileRegEx( aRegEx, wxRE_DEFAULT ); @@ -131,7 +131,7 @@ public: * @param aFlags are compilation flags (normally wxRE_DEFAULT). * @param aValue is a pointer to a wxString containing the value to validate. */ - REGEX_VALIDATOR( const wxString& aRegEx, int aFlags, wxString* aValue = NULL ) + REGEX_VALIDATOR( const wxString& aRegEx, int aFlags, wxString* aValue = nullptr ) : wxTextValidator( wxFILTER_NONE, aValue ) { compileRegEx( aRegEx, aFlags ); @@ -176,7 +176,7 @@ public: * @param aLibIdType is the type of #LIB_ID object to validate. * @param aValue is a pointer to a wxString containing the value to validate. */ - LIB_ID_VALIDATOR( wxString* aValue = NULL ) : + LIB_ID_VALIDATOR( wxString* aValue = nullptr ) : wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ) { SetCharExcludes( "\r\n\t" ); diff --git a/include/widgets/bitmap_button.h b/include/widgets/bitmap_button.h index 1abde2945c..e312a7dd8e 100644 --- a/include/widgets/bitmap_button.h +++ b/include/widgets/bitmap_button.h @@ -40,42 +40,43 @@ class BITMAP_BUTTON : public wxPanel { public: BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos = wxDefaultPosition, - const wxSize& aSize = wxDefaultSize, int aStyles = wxBORDER_NONE | wxTAB_TRAVERSAL ); + const wxSize& aSize = wxDefaultSize, + int aStyles = wxBORDER_NONE | wxTAB_TRAVERSAL ); ~BITMAP_BUTTON(); /** * Set the amount of padding present on each side of the bitmap. * - * @param aPadding is the amount in px of padding for each side + * @param aPadding is the amount in px of padding for each side. */ void SetPadding( int aPadding ); /** * Set the bitmap shown when the button is enabled. * - * @param aBmp is the enabled bitmap + * @param aBmp is the enabled bitmap. */ void SetBitmap( const wxBitmap& aBmp ); /** * Set the bitmap shown when the button is disabled. * - * @param aBmp is the disabled bitmap + * @param aBmp is the disabled bitmap. */ void SetDisabledBitmap( const wxBitmap& aBmp ); /** * Enable the button. * - * @param aEnable is true to enable, false to disable + * @param aEnable is true to enable, false to disable. */ bool Enable( bool aEnable = true ) override; /** * Check the control. This is the equivalent to toggling a toolbar button. * - * @param aCheck is true to check, false to uncheck + * @param aCheck is true to check, false to uncheck. */ void Check( bool aCheck = true ); @@ -86,7 +87,7 @@ protected: void OnLeftButtonDown( wxMouseEvent& aEvent ); void OnPaint( wxPaintEvent& aEvent ); - void setFlag( int aFlag) + void setFlag( int aFlag ) { m_buttonState |= aFlag; }