From 97964b2a4c363fd740d9e961673972b88827b16d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 27 Jul 2020 21:46:22 +0100 Subject: [PATCH] Use netclass colour for junction dots and when printing/plotting. Fixes https://gitlab.com/kicad/code/kicad/issues/4986 Fixes https://gitlab.com/kicad/code/kicad/issues/4982 --- eeschema/sch_junction.cpp | 41 +++++++++++++++++++++++++++------------ eeschema/sch_junction.h | 2 +- eeschema/sch_line.cpp | 22 +++++++++++---------- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 9c07042a0b..4e7eaa3e80 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -99,16 +99,19 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const void SCH_JUNCTION::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) { wxDC* DC = aSettings->GetPrintDC(); - COLOR4D color = ( m_color == COLOR4D::UNSPECIFIED ) ? aSettings->GetLayerColor( GetLayer() ) : - m_color ; - int diameter = - Schematic() ? Schematic()->Settings().m_JunctionSize : Mils2iu( DEFAULT_JUNCTION_DIAM ); + COLOR4D color = GetColor(); + + if( color == COLOR4D::UNSPECIFIED ) + color = aSettings->GetLayerColor( GetLayer() ); + + int diameter = Schematic() ? Schematic()->Settings().m_JunctionSize + : Mils2iu( DEFAULT_JUNCTION_DIAM ); if( m_diameter != 0 ) diameter = m_diameter; - GRFilledCircle( nullptr, DC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, - diameter / 2, 0, color, color ); + GRFilledCircle( nullptr, DC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, diameter / 2, 0, + color, color ); } @@ -170,6 +173,17 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) const #endif +COLOR4D SCH_JUNCTION::GetColor() const +{ + NETCLASSPTR netclass = NetClass(); + + if( netclass && netclass->GetSchematicColor() != COLOR4D::UNSPECIFIED ) + return netclass->GetSchematicColor(); + + return m_color; +} + + bool SCH_JUNCTION::HitTest( const wxPoint& aPosition, int aAccuracy ) const { EDA_RECT rect = GetBoundingBox(); @@ -204,17 +218,20 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const void SCH_JUNCTION::Plot( PLOTTER* aPlotter ) { - auto* settings = static_cast( aPlotter->RenderSettings() ); + auto* settings = static_cast( aPlotter->RenderSettings() ); + COLOR4D color = GetColor(); - COLOR4D color = ( m_color == COLOR4D::UNSPECIFIED ) ? settings->GetLayerColor( GetLayer() ) : - m_color; - int diameter = - Schematic() ? Schematic()->Settings().m_JunctionSize : Mils2iu( DEFAULT_JUNCTION_DIAM ); + if( color == COLOR4D::UNSPECIFIED ) + color = settings->GetLayerColor( GetLayer() ); + + aPlotter->SetColor( color ); + + int diameter = Schematic() ? Schematic()->Settings().m_JunctionSize + : Mils2iu( DEFAULT_JUNCTION_DIAM ); if( m_diameter != 0 ) diameter = m_diameter; - aPlotter->SetColor( color ); aPlotter->Circle( m_pos, diameter, FILLED_SHAPE ); } diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 9743ae5341..cf1e826a6c 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -100,7 +100,7 @@ public: int GetDiameter() const { return m_diameter; } void SetDiameter( int aDiameter ) { m_diameter = aDiameter; } - COLOR4D GetColor() const { return m_color; } + COLOR4D GetColor() const; void SetColor( const COLOR4D& aColor ) { m_color = aColor; } bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 2ab1ba89f0..4bc45a834e 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -284,14 +284,15 @@ int SCH_LINE::GetPenWidth() const void SCH_LINE::Print( RENDER_SETTINGS* aSettings, const wxPoint& offset ) { wxDC* DC = aSettings->GetPrintDC(); - COLOR4D color = m_stroke.GetColor(); + COLOR4D color = GetLineColor(); + + if( color == COLOR4D::UNSPECIFIED ) + color = aSettings->GetLayerColor( GetLayer() ); + wxPoint start = m_start; wxPoint end = m_end; int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); - if( color == COLOR4D::UNSPECIFIED ) - color = aSettings->GetLayerColor( m_Layer ); - GRLine( nullptr, DC, start.x, start.y, end.x, end.y, penWidth, color, GetwxPenStyle( GetEffectiveLineStyle() ) ); } @@ -727,13 +728,14 @@ bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const void SCH_LINE::Plot( PLOTTER* aPlotter ) { - auto* settings = static_cast( aPlotter->RenderSettings() ); - int penWidth; + auto* settings = static_cast( aPlotter->RenderSettings() ); + int penWidth; + COLOR4D color = GetLineColor(); - if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED ) - aPlotter->SetColor( m_stroke.GetColor() ); - else - aPlotter->SetColor( settings->GetLayerColor( GetLayer() ) ); + if( color == COLOR4D::UNSPECIFIED ) + color = settings->GetLayerColor( GetLayer() ); + + aPlotter->SetColor( color ); switch( m_Layer ) {