From a9619c051bfc730575a7559d3f327f1a4ca015fc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 16 Oct 2020 14:43:43 +0200 Subject: [PATCH] Better name for a plot style variable and accessors. Accessors were previously GetType() and SetType(), but this is a bad name: These names are already widely used in code as accessors for a data type. We do not set a data type, but a style, so use a better name (GetPlotStyle/SetPlotStyle). --- eeschema/dialogs/dialog_edit_line_style.cpp | 8 ++++---- eeschema/sch_bus_entry.cpp | 2 +- eeschema/sch_bus_entry.h | 2 +- eeschema/sch_item.h | 12 ++++++------ eeschema/sch_line.cpp | 18 +++++++++--------- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 10 +++++----- .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_line_style.cpp b/eeschema/dialogs/dialog_edit_line_style.cpp index f5d3b0b5be..c335945f70 100644 --- a/eeschema/dialogs/dialog_edit_line_style.cpp +++ b/eeschema/dialogs/dialog_edit_line_style.cpp @@ -112,10 +112,10 @@ bool DIALOG_EDIT_LINE_STYLE::TransferDataToWindow() if( std::all_of( m_strokeItems.begin() + 1, m_strokeItems.end(), [&]( const SCH_ITEM* r ) { - return r->GetStroke().GetType() == first_stroke_item->GetStroke().GetType(); + return r->GetStroke().GetPlotStyle() == first_stroke_item->GetStroke().GetPlotStyle(); } ) ) { - int style = static_cast( first_stroke_item->GetStroke().GetType() ); + int style = static_cast( first_stroke_item->GetStroke().GetPlotStyle() ); if( style == -1 ) m_typeCombo->SetStringSelection( DEFAULT_STYLE ); @@ -166,9 +166,9 @@ bool DIALOG_EDIT_LINE_STYLE::TransferDataFromWindow() std::advance( it, m_typeCombo->GetSelection() ); if( it == lineTypeNames.end() ) - stroke.SetType( PLOT_DASH_TYPE::DEFAULT ); + stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); else - stroke.SetType( it->first ); + stroke.SetPlotStyle( it->first ); stroke.SetColor( m_colorSwatch->GetSwatchColor() ); diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 2d1992d960..2bc99127e8 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -141,7 +141,7 @@ PLOT_DASH_TYPE SCH_BUS_ENTRY_BASE::GetStrokeStyle() const if( netclass ) return (PLOT_DASH_TYPE) netclass->GetLineStyle(); - return m_stroke.GetType(); + return m_stroke.GetPlotStyle(); } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 37f61899ef..9370eb81dc 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -78,7 +78,7 @@ public: virtual void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; } PLOT_DASH_TYPE GetStrokeStyle() const; - void SetStrokeStyle( PLOT_DASH_TYPE aStyle ) { m_stroke.SetType( aStyle ); } + void SetStrokeStyle( PLOT_DASH_TYPE aStyle ) { m_stroke.SetPlotStyle( aStyle ); } COLOR4D GetStrokeColor() const; void SetStrokeColor( const COLOR4D& aColor ) { m_stroke.SetColor( aColor ); } diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 42d7243772..167c0ba7b1 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -153,15 +153,15 @@ typedef std::unordered_set SCH_ITEM_SET; class STROKE_PARAMS { int m_width; - PLOT_DASH_TYPE m_type; + PLOT_DASH_TYPE m_plotstyle; COLOR4D m_color; public: STROKE_PARAMS( int aWidth = Mils2iu( DEFAULT_LINE_THICKNESS ), - PLOT_DASH_TYPE aType = PLOT_DASH_TYPE::DEFAULT, + PLOT_DASH_TYPE aPlotStyle = PLOT_DASH_TYPE::DEFAULT, const COLOR4D& aColor = COLOR4D::UNSPECIFIED ) : m_width( aWidth ), - m_type( aType ), + m_plotstyle( aPlotStyle ), m_color( aColor ) { } @@ -169,8 +169,8 @@ public: int GetWidth() const { return m_width; } void SetWidth( int aWidth ) { m_width = aWidth; } - PLOT_DASH_TYPE GetType() const { return m_type; } - void SetType( PLOT_DASH_TYPE aType ) { m_type = aType; } + PLOT_DASH_TYPE GetPlotStyle() const { return m_plotstyle; } + void SetPlotStyle( PLOT_DASH_TYPE aPlotStyle ) { m_plotstyle = aPlotStyle; } COLOR4D GetColor() const { return m_color; } void SetColor( const COLOR4D& aColor ) { m_color = aColor; } @@ -178,7 +178,7 @@ public: bool operator!=( const STROKE_PARAMS& aOther ) { return m_width != aOther.m_width - || m_type != aOther.m_type + || m_plotstyle != aOther.m_plotstyle || m_color != aOther.m_color; } }; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 22ba73f24a..69bb94307a 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -40,7 +40,7 @@ SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) : m_end = pos; m_startIsDangling = m_endIsDangling = false; m_stroke.SetWidth( 0 ); - m_stroke.SetType( PLOT_DASH_TYPE::DEFAULT ); + m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); m_stroke.SetColor( COLOR4D::UNSPECIFIED ); switch( layer ) @@ -237,16 +237,16 @@ void SCH_LINE::SetLineStyle( const int aStyleId ) void SCH_LINE::SetLineStyle( const PLOT_DASH_TYPE aStyle ) { if( aStyle == GetDefaultStyle() ) - m_stroke.SetType( PLOT_DASH_TYPE::DEFAULT ); + m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); else - m_stroke.SetType( aStyle ); + m_stroke.SetPlotStyle( aStyle ); } PLOT_DASH_TYPE SCH_LINE::GetLineStyle() const { - if( m_stroke.GetType() != PLOT_DASH_TYPE::DEFAULT ) - return m_stroke.GetType(); + if( m_stroke.GetPlotStyle() != PLOT_DASH_TYPE::DEFAULT ) + return m_stroke.GetPlotStyle(); return GetDefaultStyle(); } @@ -254,8 +254,8 @@ PLOT_DASH_TYPE SCH_LINE::GetLineStyle() const PLOT_DASH_TYPE SCH_LINE::GetEffectiveLineStyle() const { - if( m_stroke.GetType() != PLOT_DASH_TYPE::DEFAULT ) - return m_stroke.GetType(); + if( m_stroke.GetPlotStyle() != PLOT_DASH_TYPE::DEFAULT ) + return m_stroke.GetPlotStyle(); NETCLASSPTR netclass = NetClass(); @@ -858,6 +858,6 @@ bool SCH_LINE::IsWire() const bool SCH_LINE::UsesDefaultStroke() const { return m_stroke.GetWidth() == 0 && m_stroke.GetColor() == COLOR4D::UNSPECIFIED - && ( m_stroke.GetType() == GetDefaultStyle() - || m_stroke.GetType() == PLOT_DASH_TYPE::DEFAULT ); + && ( m_stroke.GetPlotStyle() == GetDefaultStyle() + || m_stroke.GetPlotStyle() == PLOT_DASH_TYPE::DEFAULT ); } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index e6ea858745..dec35348f2 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -429,7 +429,7 @@ void SCH_SEXPR_PARSER::parseStroke( STROKE_PARAMS& aStroke ) wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a stroke." ) ); aStroke.SetWidth( Mils2iu( DEFAULT_LINE_THICKNESS ) ); - aStroke.SetType( PLOT_DASH_TYPE::DEFAULT ); + aStroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); aStroke.SetColor( COLOR4D::UNSPECIFIED ); T token; @@ -454,10 +454,10 @@ void SCH_SEXPR_PARSER::parseStroke( STROKE_PARAMS& aStroke ) switch( token ) { - case T_dash: aStroke.SetType( PLOT_DASH_TYPE::DASH ); break; - case T_dot: aStroke.SetType( PLOT_DASH_TYPE::DOT ); break; - case T_dash_dot: aStroke.SetType( PLOT_DASH_TYPE::DASHDOT ); break; - case T_solid: aStroke.SetType( PLOT_DASH_TYPE::SOLID ); break; + case T_dash: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DASH ); break; + case T_dot: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DOT ); break; + case T_dash_dot: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DASHDOT ); break; + case T_solid: aStroke.SetPlotStyle( PLOT_DASH_TYPE::SOLID ); break; default: Expecting( "solid, dash, dash_dot, or dot" ); } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 9dcf3256a5..d5273df6e6 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -270,7 +270,7 @@ static void formatStroke( OUTPUTFORMATTER* aFormatter, int aNestLevel, aFormatter->Print( aNestLevel, "(stroke (width %s) (type %s) (color %d %d %d %s))", FormatInternalUnits( aStroke.GetWidth() ).c_str(), - TO_UTF8( getLineStyleToken( aStroke.GetType() ) ), + TO_UTF8( getLineStyleToken( aStroke.GetPlotStyle() ) ), KiROUND( aStroke.GetColor().r * 255.0 ), KiROUND( aStroke.GetColor().g * 255.0 ), KiROUND( aStroke.GetColor().b * 255.0 ),