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
This commit is contained in:
Jeff Young 2020-07-27 21:46:22 +01:00
parent 2ea5528cd0
commit 97964b2a4c
3 changed files with 42 additions and 23 deletions

View File

@ -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<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( 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 );
}

View File

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

View File

@ -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<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
int penWidth;
auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( 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 )
{