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.
*
* 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];

View File

@ -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
@ -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,
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<EDA_TEXT, wxString>( _HKI( "Text" ),
&EDA_TEXT::SetText, &EDA_TEXT::GetText ) );
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" ),
&EDA_TEXT::SetItalic, &EDA_TEXT::IsItalic ) );
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" ),
&EDA_TEXT::SetVisible, &EDA_TEXT::IsVisible ) );
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" ),
&EDA_TEXT::SetTextHeight, &EDA_TEXT::GetTextHeight, PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, 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::SetTextHeight,
&EDA_TEXT::GetTextHeight,
PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT,
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;

View File

@ -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 )

View File

@ -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<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" );
@ -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 )
@ -658,11 +657,13 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem )
break;
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 +
// 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:
@ -674,10 +675,13 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem )
break;
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 +
// 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 ) )

View File

@ -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;

View File

@ -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; }

View File

@ -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;
}

View File

@ -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,7 +26,6 @@
#define LIB_CIRCLE_H
#include <lib_item.h>
#include <trigo.h> // for GetLineLength
class LIB_CIRCLE : public LIB_ITEM
@ -57,7 +56,7 @@ public:
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 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 );
}

View File

@ -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;

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* 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
* modify it under the terms of the GNU General Public License
@ -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.

View File

@ -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() )

View File

@ -75,9 +75,9 @@ public:
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;
bool ContinueEdit( const wxPoint aNextPoint ) override;
bool ContinueEdit( const wxPoint& aNextPoint ) override;
void EndEdit() 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.
*
* 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;
}

View File

@ -59,7 +59,7 @@ public:
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 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.
*
* 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 );
}

View File

@ -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;

View File

@ -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 );

View File

@ -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
{

View File

@ -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 );

View File

@ -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;

View File

@ -53,6 +53,7 @@
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
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 );

View File

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

View File

@ -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.

View File

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

View File

@ -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 <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.
*
* 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 );
}

View File

@ -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.

View File

@ -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
}

View File

@ -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.

View File

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

View File

@ -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; }

View File

@ -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; }

View File

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

View File

@ -41,6 +41,7 @@
#include <core/typeinfo.h>
#include <properties.h>
#include <trace_helpers.h>
#include <trigo.h>
#include <general.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;

View File

@ -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;

View File

@ -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 {}

View File

@ -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 );

View File

@ -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
{

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;

View File

@ -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;

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();
RotatePoint( &pt, aCenter, 900 );
@ -467,7 +467,6 @@ bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& 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 );

View File

@ -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<void( SCH_ITEM* )>& aFunction ) override;
void Rotate( wxPoint aCenter ) override;
void Rotate( const wxPoint& aCenter ) override;
void Rotate90( bool aClockwise ) 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.
*
* 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 ) { };
@ -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
};

View File

@ -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

View File

@ -133,8 +133,7 @@ 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,
virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
double aEndAngle ) {};
/**
@ -153,8 +152,7 @@ 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,
virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
double aEndAngle, double aWidth ) {};
/**
@ -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.
*
@ -1173,6 +1172,7 @@ protected:
///< about how to draw texts
KICURSOR m_currentNativeCursor; ///< Current cursor
private:
struct TEXT_PROPERTIES
{

View File

@ -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 );
@ -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 );

View File

@ -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<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.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
*
* This program is free software; you can redistribute it and/or
@ -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" );

View File

@ -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 );