Get rid of special default line style for Eeschema.

Fixes https://gitlab.com/kicad/code/kicad/issues/11882
This commit is contained in:
Jeff Young 2022-06-27 19:12:13 -06:00
parent c1efd9b020
commit d5a6452934
7 changed files with 19 additions and 58 deletions

View File

@ -36,7 +36,6 @@
#include <project/net_settings.h>
#include <trigo.h>
#include <board_item.h>
#include <advanced_config.h>
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<const SCH_LINE *> &checkedLines,
wxString SCH_LINE::FindWireSegmentNetNameRecursive( SCH_LINE *line,
std::list<const SCH_LINE *> &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<co
{
if( std::find(checkedLines.begin(), checkedLines.end(), connected ) == checkedLines.end() )
{
auto connectedLine = static_cast<SCH_LINE*>( connected );
SCH_LINE* connectedLine = static_cast<SCH_LINE*>( 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<PLOT_DASH_TYPE>( 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 );
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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