From d5a6452934e1e5327ec9fa0704ed97a380cd8888 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 27 Jun 2022 19:12:13 -0600 Subject: [PATCH] Get rid of special default line style for Eeschema. Fixes https://gitlab.com/kicad/code/kicad/issues/11882 --- eeschema/sch_line.cpp | 35 +++++++------------ eeschema/sch_line.h | 11 ------ .../sch_plugins/legacy/sch_legacy_plugin.cpp | 7 ++-- eeschema/sch_shape.h | 2 +- eeschema/sch_sheet.cpp | 6 ---- eeschema/sch_sheet.h | 12 ------- eeschema/sch_textbox.cpp | 4 +-- 7 files changed, 19 insertions(+), 58 deletions(-) diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 8a9e072c10..7a5f726675 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -36,7 +36,6 @@ #include #include #include -#include SCH_LINE::SCH_LINE( const VECTOR2I& pos, int layer ) : @@ -67,7 +66,7 @@ SCH_LINE::SCH_LINE( const VECTOR2I& pos, int layer ) : else m_lastResolvedWidth = Mils2iu( DEFAULT_LINE_WIDTH_MILS ); - m_lastResolvedLineStyle = GetDefaultStyle(); + m_lastResolvedLineStyle = PLOT_DASH_TYPE::SOLID; m_lastResolvedColor = COLOR4D::UNSPECIFIED; } @@ -93,7 +92,8 @@ wxString SCH_LINE::GetNetname( const SCH_SHEET_PATH& aSheet ) return FindWireSegmentNetNameRecursive( this, checkedLines, aSheet ); } -wxString SCH_LINE::FindWireSegmentNetNameRecursive( SCH_LINE *line, std::list &checkedLines, +wxString SCH_LINE::FindWireSegmentNetNameRecursive( SCH_LINE *line, + std::list &checkedLines, const SCH_SHEET_PATH& aSheet ) const { for ( auto connected : line->ConnectedItems( aSheet ) ) @@ -102,10 +102,13 @@ wxString SCH_LINE::FindWireSegmentNetNameRecursive( SCH_LINE *line, std::list( connected ); + SCH_LINE* connectedLine = static_cast( connected ); checkedLines.push_back( connectedLine ); - auto netName = FindWireSegmentNetNameRecursive( connectedLine, checkedLines, aSheet ); - if (!netName.IsEmpty()) + + wxString netName = FindWireSegmentNetNameRecursive( connectedLine, checkedLines, + aSheet ); + + if( !netName.IsEmpty() ) return netName; } } @@ -255,15 +258,6 @@ COLOR4D SCH_LINE::GetLineColor() const } -PLOT_DASH_TYPE SCH_LINE::GetDefaultStyle() const -{ - if( IsGraphicLine() ) - return PLOT_DASH_TYPE::DASH; - - return PLOT_DASH_TYPE::SOLID; -} - - void SCH_LINE::SetLineStyle( const int aStyleId ) { SetLineStyle( static_cast( aStyleId ) ); @@ -282,7 +276,7 @@ PLOT_DASH_TYPE SCH_LINE::GetLineStyle() const if( m_stroke.GetPlotStyle() != PLOT_DASH_TYPE::DEFAULT ) return m_stroke.GetPlotStyle(); - return GetDefaultStyle(); + return PLOT_DASH_TYPE::SOLID; } @@ -304,7 +298,7 @@ PLOT_DASH_TYPE SCH_LINE::GetEffectiveLineStyle() const } else { - m_lastResolvedLineStyle = PLOT_DASH_TYPE::DASH; + m_lastResolvedLineStyle = PLOT_DASH_TYPE::SOLID; } return m_lastResolvedLineStyle; @@ -958,14 +952,9 @@ bool SCH_LINE::IsWire() const return ( GetLayer() == LAYER_WIRE ); } + bool SCH_LINE::IsBus() const { return ( GetLayer() == LAYER_BUS ); } -bool SCH_LINE::UsesDefaultStroke() const -{ - return m_stroke.GetWidth() == 0 && m_stroke.GetColor() == COLOR4D::UNSPECIFIED - && ( m_stroke.GetPlotStyle() == GetDefaultStyle() - || m_stroke.GetPlotStyle() == PLOT_DASH_TYPE::DEFAULT ); -} diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index e86146f4a4..60aa30f5c4 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -147,8 +147,6 @@ public: } } - PLOT_DASH_TYPE GetDefaultStyle() const; - void SetLineStyle( const PLOT_DASH_TYPE aStyle ); void SetLineStyle( const int aStyleId ); PLOT_DASH_TYPE GetLineStyle() const; @@ -186,15 +184,6 @@ public: || ( style_a == PLOT_DASH_TYPE::SOLID && style_b == PLOT_DASH_TYPE::DEFAULT ); } - /** - * Test if the #SCH_LINE object uses the default stroke settings. - * - * The stroke settings include the line width, style, and color. - * - * @return True if the #SCH_LINE object uses the default stroke settings. - */ - bool UsesDefaultStroke() const; - int GetLineSize() const { return m_stroke.GetWidth(); } void ViewGetLayers( int aLayers[], int& aCount ) const override; diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index cc4c5bd864..3998e41786 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -1859,13 +1859,14 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine ) if( aLine->GetLineSize() != 0 ) m_out->Print( 0, " %s %d", T_WIDTH, Iu2Mils( aLine->GetLineSize() ) ); - if( aLine->GetLineStyle() != aLine->GetDefaultStyle() ) - m_out->Print( 0, " %s %s", T_STYLE, - TO_UTF8( STROKE_PARAMS::GetLineStyleToken( aLine->GetLineStyle() ) ) ); + m_out->Print( 0, " %s %s", T_STYLE, + TO_UTF8( STROKE_PARAMS::GetLineStyleToken( aLine->GetLineStyle() ) ) ); if( aLine->GetLineColor() != COLOR4D::UNSPECIFIED ) + { m_out->Print( 0, " %s", TO_UTF8( aLine->GetLineColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) ) ); + } } m_out->Print( 0, "\n" ); diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index 95e5aea251..42c2794aec 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -67,7 +67,7 @@ public: PLOT_DASH_TYPE GetEffectiveLineStyle() const { if( m_stroke.GetPlotStyle() == PLOT_DASH_TYPE::DEFAULT ) - return PLOT_DASH_TYPE::DASH; + return PLOT_DASH_TYPE::SOLID; else return m_stroke.GetPlotStyle(); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 1ca99d3a2a..a9a65bf9b6 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -268,12 +268,6 @@ bool SCH_SHEET::ResolveTextVar( wxString* token, int aDepth ) const } -bool SCH_SHEET::UsesDefaultStroke() const -{ - return m_borderWidth == 0 && m_borderColor == COLOR4D::UNSPECIFIED; -} - - void SCH_SHEET::SwapData( SCH_ITEM* aItem ) { wxCHECK_RET( aItem->Type() == SCH_SHEET_T, diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index fa0a20216b..80dbefa955 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -113,18 +113,6 @@ public: KIGFX::COLOR4D GetBackgroundColor() const { return m_backgroundColor; } void SetBackgroundColor( KIGFX::COLOR4D aColor ) { m_backgroundColor = aColor; } - /** - * Test this sheet to see if the default stroke is used to draw the outline. - * - * The default stroke is defined as follows: - * * The outline width is the default line width or 0. - * * The outline style is set to #PLOT_DASH_TYPE::DEFAULT or #PLOT_DASH_TYPE::SOLID. - * * The outline color is set to #COLOR4D::UNSPECIFIED. - * - * @return True if the outline stroke meets the default criteria. - */ - bool UsesDefaultStroke() const; - /** * @return true if this sheet is the root sheet. */ diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 9bcbe879d0..e70da6e1ea 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -210,7 +210,7 @@ void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs color = aSettings->GetLayerColor( m_layer ); if( lineStyle == PLOT_DASH_TYPE::DEFAULT ) - lineStyle = PLOT_DASH_TYPE::DASH; + lineStyle = PLOT_DASH_TYPE::SOLID; if( lineStyle == PLOT_DASH_TYPE::SOLID ) { @@ -352,7 +352,7 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground ) const color = settings->GetLayerColor( m_layer ); if( lineStyle == PLOT_DASH_TYPE::DEFAULT ) - lineStyle = PLOT_DASH_TYPE::DASH; + lineStyle = PLOT_DASH_TYPE::SOLID; aPlotter->SetColor( color ); aPlotter->SetDash( lineStyle );