Pass objects by reference instead of on the stack.

This commit is contained in:
Wayne Stambaugh 2021-06-08 10:09:24 -04:00
parent b00d01dcc4
commit 9ebabb222c
51 changed files with 228 additions and 202 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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: // calculate the left common area coordinate:
int left = std::max( me.m_pos.x, rect.m_pos.x ); int left = std::max( me.m_pos.x, rect.m_pos.x );
// calculate the right common area coordinate: // 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 ); 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: // calculate the upper common area coordinate:
int top = std::max( me.m_pos.y, aRect.m_pos.y ); int top = std::max( me.m_pos.y, aRect.m_pos.y );
// calculate the lower common area coordinate: // 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 ); 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]; wxPoint corners[4];
/* Test A : Any corners exist in rotated rect? */ /* Test A : Any corners exist in rotated rect? */
corners[0] = m_pos; corners[0] = m_pos;
corners[1] = m_pos + wxPoint( m_size.x, 0 ); corners[1] = m_pos + wxPoint( m_size.x, 0 );
corners[2] = m_pos + wxPoint( m_size.x, m_size.y ); 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 */ /* Test C : Any sides of rotated rect intersect this */
if( Intersects( corners[0], corners[1] ) || Intersects( corners[1], corners[2] ) if( Intersects( corners[0], corners[1] ) || Intersects( corners[1], corners[2] )
|| Intersects( corners[2], corners[3] ) || Intersects( corners[3], corners[0] ) ) || 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( bool EDA_RECT::IntersectsCircleEdge( const wxPoint& aCenter, const int aRadius,
const wxPoint& aCenter, const int aRadius, const int aWidth ) const const int aWidth ) const
{ {
if( !m_init ) if( !m_init )
return false; return false;
@ -469,6 +470,7 @@ void EDA_RECT::Merge( const wxPoint& aPoint )
Normalize(); // ensure width and height >= 0 Normalize(); // ensure width and height >= 0
wxPoint end = GetEnd(); wxPoint end = GetEnd();
// Change origin and size in order to contain the given rect // Change origin and size in order to contain the given rect
m_pos.x = std::min( m_pos.x, aPoint.x ); m_pos.x = std::min( m_pos.x, aPoint.x );
m_pos.y = std::min( m_pos.y, aPoint.y ); 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]; wxPoint corners[4];
@ -541,4 +543,4 @@ const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngl
bbox.SetEnd( end ); bbox.SetEnd( end );
return bbox; return bbox;
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -42,7 +42,7 @@
#include <gal/stroke_font.h> // for STROKE_FONT #include <gal/stroke_font.h> // for STROKE_FONT
#include <gr_text.h> // for GRText #include <gr_text.h> // for GRText
#include <kicad_string.h> // for UnescapeString #include <kicad_string.h> // for UnescapeString
#include <math/util.h> // for KiROUND #include <math/util.h> // for KiROUND
#include <math/vector2d.h> // for VECTOR2D #include <math/vector2d.h> // for VECTOR2D
#include <richio.h> #include <richio.h>
#include <render_settings.h> #include <render_settings.h>
@ -459,7 +459,7 @@ void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& aPositions, int aLineCoun
} }
void EDA_TEXT::printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, 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 ) const wxString& aText, const wxPoint &aPos )
{ {
wxDC* DC = aSettings->GetPrintDC(); wxDC* DC = aSettings->GetPrintDC();
@ -529,7 +529,8 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
FormatInternalUnits( GetTextWidth() ).c_str() ); FormatInternalUnits( GetTextWidth() ).c_str() );
if( GetTextThickness() ) if( GetTextThickness() )
aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetTextThickness() ).c_str() ); aFormatter->Print( 0, " (thickness %s)",
FormatInternalUnits( GetTextThickness() ).c_str() );
if( IsBold() ) if( IsBold() )
aFormatter->Print( 0, " bold" ); aFormatter->Print( 0, " bold" );
@ -546,13 +547,15 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Print( 0, " (justify"); aFormatter->Print( 0, " (justify");
if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ) 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 ) if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" ); aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
if( IsMirrored() ) if( IsMirrored() )
aFormatter->Print( 0, " mirror" ); aFormatter->Print( 0, " mirror" );
aFormatter->Print( 0, ")" ); // (justify aFormatter->Print( 0, ")" ); // (justify
} }
@ -654,7 +657,9 @@ static struct EDA_TEXT_DESC
propMgr.AddProperty( new PROPERTY<EDA_TEXT, wxString>( _HKI( "Text" ), propMgr.AddProperty( new PROPERTY<EDA_TEXT, wxString>( _HKI( "Text" ),
&EDA_TEXT::SetText, &EDA_TEXT::GetText ) ); &EDA_TEXT::SetText, &EDA_TEXT::GetText ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Thickness" ), propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Thickness" ),
&EDA_TEXT::SetTextThickness, &EDA_TEXT::GetTextThickness, PROPERTY_DISPLAY::DISTANCE ) ); &EDA_TEXT::SetTextThickness,
&EDA_TEXT::GetTextThickness,
PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Italic" ), propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Italic" ),
&EDA_TEXT::SetItalic, &EDA_TEXT::IsItalic ) ); &EDA_TEXT::SetItalic, &EDA_TEXT::IsItalic ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Bold" ), propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Bold" ),
@ -664,13 +669,21 @@ static struct EDA_TEXT_DESC
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Visible" ), propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Visible" ),
&EDA_TEXT::SetVisible, &EDA_TEXT::IsVisible ) ); &EDA_TEXT::SetVisible, &EDA_TEXT::IsVisible ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Width" ), propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Width" ),
&EDA_TEXT::SetTextWidth, &EDA_TEXT::GetTextWidth, PROPERTY_DISPLAY::DISTANCE ) ); &EDA_TEXT::SetTextWidth,
&EDA_TEXT::GetTextWidth,
PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Height" ), propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Height" ),
&EDA_TEXT::SetTextHeight, &EDA_TEXT::GetTextHeight, PROPERTY_DISPLAY::DISTANCE ) ); &EDA_TEXT::SetTextHeight,
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, EDA_TEXT_HJUSTIFY_T>( _HKI( "Horizontal Justification" ), &EDA_TEXT::GetTextHeight,
&EDA_TEXT::SetHorizJustify, &EDA_TEXT::GetHorizJustify ) ); PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, EDA_TEXT_VJUSTIFY_T>( _HKI( "Vertical Justification" ), propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT,
&EDA_TEXT::SetVertJustify, &EDA_TEXT::GetVertJustify ) ); EDA_TEXT_HJUSTIFY_T>( _HKI( "Horizontal Justification" ),
&EDA_TEXT::SetHorizJustify,
&EDA_TEXT::GetHorizJustify ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT,
EDA_TEXT_VJUSTIFY_T>( _HKI( "Vertical Justification" ),
&EDA_TEXT::SetVertJustify,
&EDA_TEXT::GetVertJustify ) );
} }
} _EDA_TEXT_DESC; } _EDA_TEXT_DESC;

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
{ {
wxString converted; 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 // No new-lines allowed in quoted strings
aString.Replace( "\r\n", "\r" ); str.Replace( "\r\n", "\r" );
aString.Replace( "\n", "\r" ); str.Replace( "\n", "\r" );
std::string utf8 = TO_UTF8( aString ); 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* strBeginning,
wxString* strDigits, wxString* strDigits,
wxString* strEnd ) wxString* strEnd )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019 CERN * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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<const TOOL_ACTION*>& aActions ) ACTION_GROUP::ACTION_GROUP( const std::string& aName,
const std::vector<const TOOL_ACTION*>& aActions )
{ {
wxASSERT_MSG( aActions.size() > 0, "Action groups must have at least one action" ); 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 ); m_panel->SetSizer( m_mainSizer );
Connect( wxEVT_CHAR_HOOK, wxCharEventHandler( ACTION_TOOLBAR_PALETTE::onCharHook ), 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 #endif
Connect( wxEVT_COMMAND_TOOL_CLICKED, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolEvent ), Connect( wxEVT_COMMAND_TOOL_CLICKED, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolEvent ),
NULL, this ); nullptr, this );
Connect( wxEVT_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolRightClick ), Connect( wxEVT_AUITOOLBAR_RIGHT_CLICK,
NULL, this ); wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolRightClick ),
nullptr, this );
Connect( wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onItemDrag ), Connect( wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onItemDrag ),
NULL, this ); nullptr, this );
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this );
NULL, this ); Connect( wxEVT_LEFT_UP, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this );
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), Connect( m_paletteTimer->GetId(), wxEVT_TIMER,
NULL, this ); wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ), nullptr, this );
Connect( m_paletteTimer->GetId(), wxEVT_TIMER, wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ),
NULL, this );
} }
@ -371,10 +371,10 @@ void ACTION_TOOLBAR::UpdateControlWidth( int aID )
if( wxSizerItem* szrItem = item->GetSizerItem() ) if( wxSizerItem* szrItem = item->GetSizerItem() )
szrItem->SetMinSize( bestSize ); szrItem->SetMinSize( bestSize );
// 2. The controls have a second sizer that allows for padding above/below the control with stretch // 2. The controls have a second sizer that allows for padding above/below the control with
// space, so we also need to update the sizer item for the control in that sizer with the new size. // stretch space, so we also need to update the sizer item for the control in that sizer with
// We let wx do the search for us, since SetItemMinSize is recursive and will locate the control // the new size. We let wx do the search for us, since SetItemMinSize is recursive and will
// on that sizer. // locate the control on that sizer.
if( m_sizer ) if( m_sizer )
{ {
m_sizer->SetItemMinSize( control, bestSize ); m_sizer->SetItemMinSize( control, bestSize );
@ -404,8 +404,7 @@ void ACTION_TOOLBAR::SetToolBitmap( const TOOL_ACTION& aAction, const wxBitmap&
int toolId = aAction.GetUIId(); int toolId = aAction.GetUIId();
wxAuiToolBar::SetToolBitmap( toolId, aBitmap ); wxAuiToolBar::SetToolBitmap( toolId, aBitmap );
// Set the disabled bitmap: we use the disabled bitmap version // Set the disabled bitmap: we use the disabled bitmap version of aBitmap.
// of aBitmap.
wxAuiToolBarItem* tb_item = wxAuiToolBar::FindTool( toolId ); wxAuiToolBarItem* tb_item = wxAuiToolBar::FindTool( toolId );
if( tb_item ) if( tb_item )
@ -641,8 +640,8 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem )
size_t numActions = group->m_actions.size(); size_t numActions = group->m_actions.size();
// The size of the palette in the long dimension // The size of the palette in the long dimension
int paletteLongDim = ( 2 * PALETTE_BORDER ) // The border on all sides 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 + ( BUTTON_BORDER ) // The border on the start of the buttons
+ ( numActions * BUTTON_BORDER ) // The other button borders + ( numActions * BUTTON_BORDER ) // The other button borders
+ ( numActions * toolRect.GetHeight() ); // The size of the buttons + ( numActions * toolRect.GetHeight() ); // The size of the buttons
@ -651,33 +650,38 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem )
{ {
case wxAUI_DOCK_TOP: case wxAUI_DOCK_TOP:
// Top toolbars need to shift the palette window down by the toolbar padding // 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 = ClientToScreen( toolRect.GetBottomLeft() );
pos += wxPoint( -PALETTE_BORDER, // Shift left to align the button edges pos += wxPoint( -PALETTE_BORDER, // Shift left to align the button edges
m_bottomPadding ); // Shift down to move away from the toolbar m_bottomPadding ); // Shift down to move away from the toolbar
break; break;
case wxAUI_DOCK_BOTTOM: case wxAUI_DOCK_BOTTOM:
// Bottom toolbars need to shift the palette window up by its height (all buttons + border + toolbar padding) // Bottom toolbars need to shift the palette window up by its height (all buttons +
dir = true; // Buttons are vertical in the palette // border + toolbar padding)
dir = true; // Buttons are vertical in the palette
pos = ClientToScreen( toolRect.GetTopLeft() ); pos = ClientToScreen( toolRect.GetTopLeft() );
pos += wxPoint( -PALETTE_BORDER, // Shift left to align the button 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; break;
case wxAUI_DOCK_LEFT: case wxAUI_DOCK_LEFT:
// Left toolbars need to shift the palette window up by the toolbar padding // 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 = ClientToScreen( toolRect.GetTopRight() );
pos += wxPoint( m_rightPadding, // Shift right to move away from the toolbar pos += wxPoint( m_rightPadding, // Shift right to move away from the toolbar
-( PALETTE_BORDER ) ); // Shift up to align the button tops -( PALETTE_BORDER ) ); // Shift up to align the button tops
break; break;
case wxAUI_DOCK_RIGHT: case wxAUI_DOCK_RIGHT:
// Right toolbars need to shift the palette window left by its width (all buttons + border + toolbar padding) // Right toolbars need to shift the palette window left by its width (all buttons +
dir = false; // Buttons are horizontal in the palette // border + toolbar padding)
dir = false; // Buttons are horizontal in the palette
pos = ClientToScreen( toolRect.GetTopLeft() ); 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 -( PALETTE_BORDER ) ); // Shift up to align the button
break; break;
} }
@ -688,7 +692,7 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem )
m_palette->SetGroup( group ); m_palette->SetGroup( group );
m_palette->SetButtonSize( toolRect ); m_palette->SetButtonSize( toolRect );
m_palette->Connect( wxEVT_BUTTON, wxCommandEventHandler( ACTION_TOOLBAR::onPaletteEvent ), 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 // 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, void ACTION_TOOLBAR::OnCustomRender(wxDC& aDc, const wxAuiToolBarItem& aItem, const wxRect& aRect )
const wxRect& aRect )
{ {
auto it = m_actionGroups.find( aItem.GetId() ); auto it = m_actionGroups.find( aItem.GetId() );
@ -766,14 +769,16 @@ void ACTION_TOOLBAR::OnCustomRender(wxDC& aDc, const wxAuiToolBarItem& aItem,
bool ACTION_TOOLBAR::KiRealize() bool ACTION_TOOLBAR::KiRealize()
{ {
wxClientDC dc( this ); wxClientDC dc( this );
if( !dc.IsOk() ) if( !dc.IsOk() )
return false; return false;
// calculate hint sizes for both horizontal and vertical // calculate hint sizes for both horizontal and vertical
// in the order that leaves toolbar in correct final state // 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; bool retval = true;
if( m_orientation == wxHORIZONTAL ) if( m_orientation == wxHORIZONTAL )
{ {
if( !( GetWindowStyle() & wxAUI_TB_HORIZONTAL ) ) if( !( GetWindowStyle() & wxAUI_TB_HORIZONTAL ) )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * Copyright (C) 2019 CERN
* *
* This program is free software; you can redistribute it and/or * 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_ArcStart = m_ArcEnd = aPosition;
m_editState = 1; m_editState = 1;

View File

@ -60,7 +60,7 @@ public:
int GetPenWidth() const override; int GetPenWidth() const override;
void BeginEdit( const wxPoint aStartPoint ) override; void BeginEdit( const wxPoint& aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override; void CalcEdit( const wxPoint& aPosition ) override;
void SetEditState( int aState ) { m_editState = aState; } void SetEditState( int aState ) { m_editState = aState; }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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; m_Pos = aPosition;
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -26,13 +26,12 @@
#define LIB_CIRCLE_H #define LIB_CIRCLE_H
#include <lib_item.h> #include <lib_item.h>
#include <trigo.h> // for GetLineLength
class LIB_CIRCLE : public LIB_ITEM class LIB_CIRCLE : public LIB_ITEM
{ {
public: 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. // 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<MSG_PANEL_ITEM>& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
void BeginEdit( const wxPoint aStartPoint ) override; void BeginEdit( const wxPoint& aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override; void CalcEdit( const wxPoint& aPosition ) override;
void Offset( const wxPoint& aOffset ) override; void Offset( const wxPoint& aOffset ) override;

View File

@ -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 ); SetTextPos( aPosition );
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -108,7 +108,7 @@ public:
void Init( int idfield ); 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 * The first four field IDs are reserved and therefore always return their respective
* names. * names.
@ -171,7 +171,7 @@ public:
SCH_LAYER_ID GetDefaultLayer() const; SCH_LAYER_ID GetDefaultLayer() const;
void BeginEdit( const wxPoint aStartPoint ) override; void BeginEdit( const wxPoint& aStartPoint ) override;
void Offset( const wxPoint& aOffset ) override; void Offset( const wxPoint& aOffset ) override;

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -63,7 +63,7 @@ class LIB_ITEM : public EDA_ITEM
{ {
public: public:
LIB_ITEM( KICAD_T aType, LIB_PART* aComponent = NULL, int aUnit = 0, int aConvert = 0, 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. // 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. * @param aPosition The position in drawing coordinates where the drawing was started.
* May or may not be required depending on the item being drawn. * 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. * 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. * @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. * @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. * End an object editing action.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ); // Start point of first segment.
m_PolyPoints.push_back( aPosition ); // End 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 // do not add zero length segments
if( m_PolyPoints[m_PolyPoints.size() - 2] != m_PolyPoints.back() ) if( m_PolyPoints[m_PolyPoints.size() - 2] != m_PolyPoints.back() )

View File

@ -75,9 +75,9 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
void BeginEdit( const wxPoint aStartPoint ) override; void BeginEdit( const wxPoint& aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override; void CalcEdit( const wxPoint& aPosition ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override; bool ContinueEdit( const wxPoint& aNextPoint ) override;
void EndEdit() override; void EndEdit() override;
void Offset( const wxPoint& aOffset ) override; void Offset( const wxPoint& aOffset ) override;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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; m_Pos = m_End = aPosition;
} }

View File

@ -59,7 +59,7 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
void BeginEdit( const wxPoint aStartPoint ) override; void BeginEdit( const wxPoint& aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override; void CalcEdit( const wxPoint& aPosition ) override;
void Offset( const wxPoint& aOffset ) override; void Offset( const wxPoint& aOffset ) override;

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ); SetTextPos( aPosition );
} }

View File

@ -83,7 +83,7 @@ public:
const EDA_RECT GetBoundingBox() const override; 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 CalcEdit( const wxPoint& aPosition ) override;
void Offset( const wxPoint& aOffset ) override; void Offset( const wxPoint& aOffset ) override;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2011 jean-pierre.charras * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ); RotatePoint( &m_pos, aCenter, 900 );
m_image->Rotate( false ); m_image->Rotate( false );

View File

@ -122,7 +122,7 @@ public:
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( 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 wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
{ {

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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_pos, aCenter, 900 );
RotatePoint( &m_size.x, &m_size.y, 900 ); RotatePoint( &m_size.x, &m_size.y, 900 );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -90,7 +90,7 @@ public:
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override; void MirrorVertically( int aCenter ) override;
void Rotate( wxPoint aCenter ) override; void Rotate( const wxPoint& aCenter ) override;
bool IsDangling() const override; bool IsDangling() const override;

View File

@ -53,6 +53,7 @@
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/ee_actions.h> #include <tools/ee_actions.h>
SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_ITEM* aParent, SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_ITEM* aParent,
const wxString& aName ) : const wxString& aName ) :
SCH_ITEM( aParent, SCH_FIELD_T ), 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(); wxPoint pt = GetPosition();
RotatePoint( &pt, aCenter, 900 ); RotatePoint( &pt, aCenter, 900 );

View File

@ -150,7 +150,7 @@ public:
Offset( aMoveVector ); Offset( aMoveVector );
} }
void Rotate( wxPoint aCenter ) override; void Rotate( const wxPoint& aCenter ) override;
/** /**
* @copydoc SCH_ITEM::MirrorVertically() * @copydoc SCH_ITEM::MirrorVertically()

View File

@ -233,7 +233,7 @@ public:
virtual bool IsMovableFromAnchorPoint() const { return true; } virtual bool IsMovableFromAnchorPoint() const { return true; }
wxPoint& GetStoredPos() { return m_storedPos; } 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. * 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. * 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. * Add the schematic item end points to \a aItemList if the item has end points.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ); RotatePoint( &m_pos, aCenter, 900 );
} }

View File

@ -67,7 +67,7 @@ public:
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override; void MirrorVertically( int aCenter ) override;
void Rotate( wxPoint aCenter ) override; void Rotate( const wxPoint& aCenter ) override;
void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override; void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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_start, aCenter, 900 );
RotatePoint( &m_end, 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 ); RotatePoint( &m_start, aCenter, 900 );
} }
void SCH_LINE::RotateEnd( wxPoint aCenter ) void SCH_LINE::RotateEnd( const wxPoint& aCenter )
{ {
RotatePoint( &m_end, aCenter, 900 ); RotatePoint( &m_end, aCenter, 900 );
} }

View File

@ -170,9 +170,9 @@ public:
void MirrorVertically( int aCenter ) override; void MirrorVertically( int aCenter ) override;
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void Rotate( wxPoint aCenter ) override; void Rotate( const wxPoint& aCenter ) override;
void RotateStart( wxPoint aCenter ); void RotateStart( const wxPoint& aCenter );
void RotateEnd( wxPoint aCenter ); void RotateEnd( const wxPoint& aCenter );
/** /**
* Check line against \a aLine to see if it overlaps and merge if it does. * Check line against \a aLine to see if it overlaps and merge if it does.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 // Marker geometry isn't user-editable
} }

View File

@ -78,7 +78,7 @@ public:
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( 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. * Compare DRC marker main and auxiliary text against search string.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ); RotatePoint( &m_pos, aCenter, 900 );
} }

View File

@ -80,7 +80,7 @@ public:
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( 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; } bool IsConnectable() const override { return true; }

View File

@ -72,7 +72,7 @@ public:
void MirrorHorizontally( int aCenter ) override {} void MirrorHorizontally( int aCenter ) override {}
void MirrorVertically( 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(); } wxPoint GetPosition() const override { return GetTransformedPosition(); }
const wxPoint GetLocalPosition() const { return m_position; } const wxPoint GetLocalPosition() const { return m_position; }

View File

@ -53,6 +53,7 @@
#include <sch_sheet_pin.h> #include <sch_sheet_pin.h>
#include <sch_plugins/kicad/sch_sexpr_parser.h> #include <sch_plugins/kicad/sch_sexpr_parser.h>
#include <template_fieldnames.h> #include <template_fieldnames.h>
#include <trigo.h>
using namespace TSCHEMATIC_T; using namespace TSCHEMATIC_T;

View File

@ -41,6 +41,7 @@
#include <core/typeinfo.h> #include <core/typeinfo.h>
#include <properties.h> #include <properties.h>
#include <trace_helpers.h> #include <trace_helpers.h>
#include <trigo.h>
#include <general.h> #include <general.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>

View File

@ -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; wxPoint prev = m_pos;

View File

@ -330,7 +330,7 @@ public:
void Move( const wxPoint& aMoveVector ) override; void Move( const wxPoint& aMoveVector ) override;
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( 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; bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;

View File

@ -78,7 +78,7 @@ public:
void Move( const wxPoint& aMoveVector ) override {} void Move( const wxPoint& aMoveVector ) override {}
void MirrorHorizontally( int aCenter ) override {} void MirrorHorizontally( int aCenter ) override {}
void MirrorVertically( int aCenter ) override {} void MirrorVertically( int aCenter ) override {}
void Rotate( wxPoint aCenter ) override {} void Rotate( const wxPoint& aCenter ) override {}
#if defined(DEBUG) #if defined(DEBUG)
void Show( int , std::ostream& ) const override {} void Show( int , std::ostream& ) const override {}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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(); wxPoint pt = GetTextPos();
RotatePoint( &pt, aCenter, 900 ); RotatePoint( &pt, aCenter, 900 );

View File

@ -152,7 +152,7 @@ public:
void MirrorVertically( int aCenter ) override; void MirrorVertically( int aCenter ) override;
void MirrorHorizontally( 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 bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
{ {

View File

@ -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; wxPoint prev = m_pos;

View File

@ -573,7 +573,7 @@ public:
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( 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; bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;

View File

@ -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(); wxPoint pt = GetTextPos();
RotatePoint( &pt, aCenter, 900 ); RotatePoint( &pt, aCenter, 900 );
@ -467,7 +467,6 @@ bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
break; break;
case BUS_START_END: case BUS_START_END:
m_connectionType = CONNECTION_TYPE::BUS; m_connectionType = CONNECTION_TYPE::BUS;
KI_FALLTHROUGH; 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(); wxPoint pt = GetTextPos();
RotatePoint( &pt, aCenter, 900 ); RotatePoint( &pt, aCenter, 900 );

View File

@ -75,13 +75,13 @@ public:
LABEL_SPIN_STYLE RotateCCW(); 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(); 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(); LABEL_SPIN_STYLE MirrorY();
@ -113,7 +113,7 @@ public:
KICAD_T aType = SCH_TEXT_T ); 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 * for the #m_isDangling member which is set to false. This prevents newly
* copied objects derived from #SCH_TEXT from having their connection state * copied objects derived from #SCH_TEXT from having their connection state
* improperly set. * 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 * @param[out] aVars
*/ */
@ -203,7 +203,7 @@ public:
void MirrorHorizontally( int aCenter ) override; void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( 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 Rotate90( bool aClockwise );
virtual void MirrorSpinStyle( bool aLeftRight ); virtual void MirrorSpinStyle( bool aLeftRight );
@ -354,7 +354,7 @@ public:
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override; void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
void Rotate( wxPoint aCenter ) override; void Rotate( const wxPoint& aCenter ) override;
void Rotate90( bool aClockwise ) override; void Rotate90( bool aClockwise ) override;
void MirrorSpinStyle( bool aLeftRight ) override; void MirrorSpinStyle( bool aLeftRight ) override;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -41,11 +41,6 @@
*/ */
class EDA_RECT class EDA_RECT
{ {
private:
wxPoint m_pos; // Rectangle Origin
wxSize m_size; // Rectangle Size
bool m_init; // Is the rectangle initialized
public: public:
EDA_RECT() : m_init( false ) { }; EDA_RECT() : m_init( false ) { };
@ -190,7 +185,7 @@ public:
m_init = true; m_init = true;
} }
void SetEnd( const wxPoint &pos ) void SetEnd( const wxPoint& pos )
{ {
m_size.x = pos.x - m_pos.x; m_size.x = pos.x - m_pos.x;
m_size.y = pos.y - m_pos.y; 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. * 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 aAngle the rotation angle in 0.1 deg.
* @param aRotCenter the rotation point. * @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
}; };

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 aText the single line of text to draw.
* @param aPos the position of this line ). * @param aPos the position of this line ).
*/ */
void printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, COLOR4D aColor, void printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
OUTLINE_MODE aFillMode, const wxString& aText, const wxPoint& aPos ); const COLOR4D& aColor, OUTLINE_MODE aFillMode, const wxString& aText,
const wxPoint& aPos );
wxString m_text; wxString m_text;
wxString m_shown_text; // Cache of unescaped text for efficient access wxString m_shown_text; // Cache of unescaped text for efficient access

View File

@ -133,9 +133,8 @@ public:
* @param aStartAngle is the start angle of the arc. * @param aStartAngle is the start angle of the arc.
* @param aEndAngle is the end angle of the arc. * @param aEndAngle is the end angle of the arc.
*/ */
virtual void virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle ) {};
double aEndAngle ) {};
/** /**
* Draw an arc segment. * Draw an arc segment.
@ -153,9 +152,8 @@ public:
* @param aEndAngle is the end angle of the arc. * @param aEndAngle is the end angle of the arc.
* @param aWidth is the thickness of the arc (pen size). * @param aWidth is the thickness of the arc (pen size).
*/ */
virtual void virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth ) {};
double aEndAngle, double aWidth ) {};
/** /**
* Draw a rectangle. * Draw a rectangle.
@ -412,7 +410,7 @@ public:
* *
* @param aGlyphSize is the new font glyph size. * @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; } const VECTOR2D& GetGlyphSize() const { return textProperties.m_glyphSize; }
/** /**
@ -420,7 +418,7 @@ public:
* *
* @param aBold tells if the font should be bold or not. * @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; } inline bool IsFontBold() const { return textProperties.m_bold; }
/** /**
@ -439,7 +437,7 @@ public:
* *
* @param aMirrored tells if the text should be mirrored or not. * @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; } inline bool IsTextMirrored() const { return textProperties.m_mirrored; }
/** /**
@ -838,6 +836,7 @@ public:
return m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS || return m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS ||
( m_gridVisibility && m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID ); ( m_gridVisibility && m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID );
} }
/** /**
* Set the origin point for the grid. * Set the origin point for the grid.
* *
@ -952,7 +951,7 @@ public:
/** /**
* Compute the point position in world coordinates from given screen coordinates. * 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. * @return the point position in world coordinates.
*/ */
inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
@ -963,7 +962,7 @@ public:
/** /**
* Compute the point position in screen coordinates from given world coordinates. * 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. * @return the point position in screen coordinates.
*/ */
inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
@ -1173,6 +1172,7 @@ protected:
///< about how to draw texts ///< about how to draw texts
KICURSOR m_currentNativeCursor; ///< Current cursor KICURSOR m_currentNativeCursor; ///< Current cursor
private: private:
struct TEXT_PROPERTIES struct TEXT_PROPERTIES
{ {

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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. * @return true if any characters required conversion.
*/ */
@ -57,6 +57,13 @@ enum ESCAPE_CONTEXT
CTX_FILENAME 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 EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext );
wxString UnescapeString( const wxString& aSource ); wxString UnescapeString( const wxString& aSource );
@ -105,7 +112,7 @@ int ReadDelimitedText( wxString* aDest, const char* aSource );
* @param aString is the input string to convert. * @param aString is the input string to convert.
* @return the escaped input text, without the wrapping double quotes. * @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. * 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. * 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 * 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 ); 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. * alphabetic ending.
* *
* For example C10A is split to C 10 A * For example C10A is split to C 10 A
*/ */
int SplitString( wxString strToSplit, int SplitString( const wxString& strToSplit,
wxString* strBeginning, wxString* strBeginning,
wxString* strDigits, wxString* strDigits,
wxString* strEnd ); wxString* strEnd );
@ -224,7 +231,7 @@ extern "C" char* strtok_r( char* str, const char* delim, char** nextp );
*/ */
struct rsort_wxString 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 sA = strA.rbegin();
wxString::const_reverse_iterator eA = strA.rend(); wxString::const_reverse_iterator eA = strA.rend();
@ -246,14 +253,14 @@ struct rsort_wxString
while( sA != eA && sB != eB ) while( sA != eA && sB != eB )
{ {
if( (*sA) == (*sB) ) if( ( *sA ) == ( *sB ) )
{ {
++sA; ++sA;
++sB; ++sB;
continue; continue;
} }
if( (*sA) < (*sB) ) if( ( *sA ) < ( *sB ) )
return true; return true;
else else
return false; 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 * @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; aDesc << aItem;
} }
/** /**
* Split \a aString to a string list separated at \a aSplitter. * 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 ); 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) * We want to avoid scientific notation in S-expr files (not easy to read)
* for floating numbers. * 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 * this helper function uses the %f format when needed, or %g when %f is
* not well working and then removes trailing 0 * not well working and then removes trailing 0
*/ */
std::string Double2Str( double aValue ); std::string Double2Str( double aValue );
/** /**
* A helper to convert the \a double \a aAngle (in internal unit) * A helper to convert the \a double \a aAngle (in internal unit) to a string in degrees.
* to a string in degrees
*/ */
wxString AngleToStringDegrees( double aAngle ); wxString AngleToStringDegrees( double aAngle );

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 // Make the toolbar a friend so it can easily access everything inside here
friend class ACTION_TOOLBAR; friend class ACTION_TOOLBAR;
ACTION_GROUP( std::string aName, const std::vector<const TOOL_ACTION*>& aActions ); ACTION_GROUP( const std::string& aName, const std::vector<const TOOL_ACTION*>& aActions );
/** /**
* Set the default action to use when first creating the toolbar palette icon. * Set the default action to use when first creating the toolbar palette icon.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* 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 * Copyright (C) 2018 CERN
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -46,8 +46,8 @@ class GRID_CELL_TEXT_EDITOR : public wxGridCellTextEditor
public: public:
GRID_CELL_TEXT_EDITOR(); GRID_CELL_TEXT_EDITOR();
virtual void SetValidator(const wxValidator& validator) override; virtual void SetValidator( const wxValidator& validator ) override;
virtual void StartingKey(wxKeyEvent& event) override; virtual void StartingKey( wxKeyEvent& event ) override;
protected: protected:
wxScopedPtr<wxValidator> m_validator; wxScopedPtr<wxValidator> m_validator;
@ -63,7 +63,7 @@ protected:
class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator
{ {
public: 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 class FILE_NAME_WITH_PATH_CHAR_VALIDATOR : public wxTextValidator
{ {
public: 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 class ENV_VAR_NAME_VALIDATOR : public wxTextValidator
{ {
public: 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 ); ENV_VAR_NAME_VALIDATOR( const ENV_VAR_NAME_VALIDATOR& val );
virtual ~ENV_VAR_NAME_VALIDATOR(); 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. // if you're passing a reference to a validator.
virtual wxObject *Clone() const override virtual wxObject *Clone() const override
{ {
@ -120,7 +120,7 @@ public:
* @param aRegEx is a regular expression to validate strings. * @param aRegEx is a regular expression to validate strings.
* @param aValue is a pointer to a wxString containing the value to validate. * @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 ) : wxTextValidator( wxFILTER_NONE, aValue )
{ {
compileRegEx( aRegEx, wxRE_DEFAULT ); compileRegEx( aRegEx, wxRE_DEFAULT );
@ -131,7 +131,7 @@ public:
* @param aFlags are compilation flags (normally wxRE_DEFAULT). * @param aFlags are compilation flags (normally wxRE_DEFAULT).
* @param aValue is a pointer to a wxString containing the value to validate. * @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 ) : wxTextValidator( wxFILTER_NONE, aValue )
{ {
compileRegEx( aRegEx, aFlags ); compileRegEx( aRegEx, aFlags );
@ -176,7 +176,7 @@ public:
* @param aLibIdType is the type of #LIB_ID object to validate. * @param aLibIdType is the type of #LIB_ID object to validate.
* @param aValue is a pointer to a wxString containing the value 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 ) wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{ {
SetCharExcludes( "\r\n\t" ); SetCharExcludes( "\r\n\t" );

View File

@ -40,42 +40,43 @@ class BITMAP_BUTTON : public wxPanel
{ {
public: public:
BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos = wxDefaultPosition, 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(); ~BITMAP_BUTTON();
/** /**
* Set the amount of padding present on each side of the bitmap. * 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 ); void SetPadding( int aPadding );
/** /**
* Set the bitmap shown when the button is enabled. * 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 ); void SetBitmap( const wxBitmap& aBmp );
/** /**
* Set the bitmap shown when the button is disabled. * 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 ); void SetDisabledBitmap( const wxBitmap& aBmp );
/** /**
* Enable the button. * 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; bool Enable( bool aEnable = true ) override;
/** /**
* Check the control. This is the equivalent to toggling a toolbar button. * 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 ); void Check( bool aCheck = true );
@ -86,7 +87,7 @@ protected:
void OnLeftButtonDown( wxMouseEvent& aEvent ); void OnLeftButtonDown( wxMouseEvent& aEvent );
void OnPaint( wxPaintEvent& aEvent ); void OnPaint( wxPaintEvent& aEvent );
void setFlag( int aFlag) void setFlag( int aFlag )
{ {
m_buttonState |= aFlag; m_buttonState |= aFlag;
} }