Iron out some issues with linestyle handling in SCH printing and plotting.
Fixes https://gitlab.com/kicad/code/kicad/issues/11498
This commit is contained in:
parent
3589eb33f0
commit
dc1e063b00
|
@ -172,9 +172,10 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs
|
|||
std::swap( start, end );
|
||||
}
|
||||
|
||||
int penWidth;
|
||||
COLOR4D color;
|
||||
FILL_T fill = m_fill;
|
||||
int penWidth;
|
||||
COLOR4D color = GetStroke().GetColor();
|
||||
PLOT_DASH_TYPE lineStyle = GetStroke().GetPlotStyle();
|
||||
FILL_T fill = m_fill;
|
||||
|
||||
if( aBackground )
|
||||
{
|
||||
|
@ -199,19 +200,26 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs
|
|||
}
|
||||
|
||||
penWidth = 0;
|
||||
lineStyle = PLOT_DASH_TYPE::SOLID;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
||||
color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
if( lineStyle == PLOT_DASH_TYPE::DEFAULT )
|
||||
lineStyle = PLOT_DASH_TYPE::DASH;
|
||||
|
||||
if( m_fill == FILL_T::FILLED_SHAPE )
|
||||
fill = m_fill;
|
||||
else
|
||||
fill = FILL_T::NO_FILL;
|
||||
|
||||
penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() );
|
||||
color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
}
|
||||
|
||||
aPlotter->SetColor( color );
|
||||
aPlotter->SetDash( lineStyle );
|
||||
|
||||
switch( GetShape() )
|
||||
{
|
||||
|
@ -235,6 +243,8 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs
|
|||
default:
|
||||
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
||||
}
|
||||
|
||||
aPlotter->SetDash( PLOT_DASH_TYPE::SOLID );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -276,20 +276,10 @@ void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const VECTOR2I& offset,
|
|||
int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
|
||||
VECTOR2I pos = aTransform.TransformCoordinate( txtpos ) + offset;
|
||||
|
||||
// Get color
|
||||
COLOR4D color;
|
||||
COLOR4D color = GetTextColor();
|
||||
|
||||
if( plotter->GetColorMode() )
|
||||
{
|
||||
if( GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
else
|
||||
color = plotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
}
|
||||
else
|
||||
{
|
||||
color = COLOR4D::BLACK;
|
||||
}
|
||||
if( !plotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
||||
color = plotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
RENDER_SETTINGS* settings = plotter->RenderSettings();
|
||||
|
||||
|
@ -322,12 +312,12 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
|||
const TRANSFORM& aTransform )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_DEVICE );
|
||||
COLOR4D color = GetTextColor();
|
||||
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
||||
int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() );
|
||||
|
||||
if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
||||
color = aSettings->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
// Calculate the text orientation, according to the symbol orientation/mirror (needed when
|
||||
// draw text in schematic)
|
||||
|
|
|
@ -193,26 +193,30 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
|
|||
if( IsPrivate() )
|
||||
return;
|
||||
|
||||
bool forceNoFill = static_cast<bool>( aData );
|
||||
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
||||
int penWidth = GetEffectivePenWidth( aSettings );
|
||||
bool forceNoFill = static_cast<bool>( aData );
|
||||
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
||||
int penWidth = GetEffectivePenWidth( aSettings );
|
||||
COLOR4D color = GetStroke().GetColor();
|
||||
PLOT_DASH_TYPE lineStyle = GetStroke().GetPlotStyle();
|
||||
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
VECTOR2I pt1 = aTransform.TransformCoordinate( m_start ) + aOffset;
|
||||
VECTOR2I pt2 = aTransform.TransformCoordinate( m_end ) + aOffset;
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
if( !forceNoFill && GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode )
|
||||
GRFilledRect( DC, pt1, pt2, penWidth, color, GetFillColor() );
|
||||
|
||||
if( GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetStroke().GetColor();
|
||||
GRFilledRect( DC, pt1, pt2, penWidth, GetFillColor(), GetFillColor() );
|
||||
|
||||
if( penWidth > 0 )
|
||||
{
|
||||
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
|
||||
|
||||
if( GetStroke().GetPlotStyle() <= PLOT_DASH_TYPE::FIRST_TYPE )
|
||||
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
||||
color = aSettings->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
if( lineStyle == PLOT_DASH_TYPE::DEFAULT )
|
||||
lineStyle = PLOT_DASH_TYPE::DASH;
|
||||
|
||||
if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
|
||||
{
|
||||
GRRect( DC, pt1, pt2, penWidth, color );
|
||||
}
|
||||
|
@ -222,7 +226,7 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
|
|||
|
||||
for( SHAPE* shape : shapes )
|
||||
{
|
||||
STROKE_PARAMS::Stroke( shape, GetStroke().GetPlotStyle(), penWidth, aSettings,
|
||||
STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
|
||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||
{
|
||||
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
|
||||
|
@ -236,8 +240,10 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
|
|||
|
||||
LIB_TEXTBOX text( *this );
|
||||
|
||||
if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
color = GetTextColor();
|
||||
|
||||
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
||||
color = aSettings->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetMinPenWidth() );
|
||||
|
||||
|
@ -324,34 +330,31 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOf
|
|||
return;
|
||||
}
|
||||
|
||||
VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset;
|
||||
VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset;
|
||||
int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() );
|
||||
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset;
|
||||
VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset;
|
||||
int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() );
|
||||
COLOR4D color = GetStroke().GetColor();
|
||||
PLOT_DASH_TYPE lineStyle = GetStroke().GetPlotStyle();
|
||||
|
||||
if( penWidth > 0 )
|
||||
{
|
||||
if( aPlotter->GetColorMode() && GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
|
||||
aPlotter->SetColor( GetStroke().GetColor() );
|
||||
else
|
||||
aPlotter->SetColor( color );
|
||||
if( !aPlotter->GetColorMode() || color != COLOR4D::UNSPECIFIED )
|
||||
color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
if( lineStyle == PLOT_DASH_TYPE::DEFAULT )
|
||||
lineStyle = PLOT_DASH_TYPE::DASH;
|
||||
|
||||
aPlotter->SetColor( color );
|
||||
aPlotter->SetDash( lineStyle );
|
||||
aPlotter->Rect( start, end, FILL_T::NO_FILL, penWidth );
|
||||
}
|
||||
|
||||
LIB_TEXTBOX text( *this );
|
||||
|
||||
if( aPlotter->GetColorMode() )
|
||||
{
|
||||
if( GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
else
|
||||
color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
}
|
||||
else
|
||||
{
|
||||
color = COLOR4D::BLACK;
|
||||
}
|
||||
color = GetTextColor();
|
||||
|
||||
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
||||
color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
penWidth = std::max( GetEffectiveTextPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() );
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
|||
else
|
||||
color = GetStroke().GetColor();
|
||||
|
||||
if( GetStroke().GetPlotStyle() <= PLOT_DASH_TYPE::FIRST_TYPE )
|
||||
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
||||
{
|
||||
switch( GetShape() )
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
|||
|
||||
for( SHAPE* shape : shapes )
|
||||
{
|
||||
STROKE_PARAMS::Stroke( shape, GetStroke().GetPlotStyle(), penWidth, aSettings,
|
||||
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
|
||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||
{
|
||||
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
|
||||
|
|
|
@ -287,12 +287,12 @@ KIFONT::FONT* SCH_TEXT::GetDrawFont() const
|
|||
|
||||
void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
|
||||
{
|
||||
COLOR4D color = aSettings->GetLayerColor( m_layer );
|
||||
COLOR4D color = GetTextColor();
|
||||
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
||||
VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings );
|
||||
|
||||
if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
||||
color = aSettings->GetLayerColor( m_layer );
|
||||
|
||||
// Adjust text drawn in an outline font to more closely mimic the positioning of
|
||||
// SCH_FIELD text.
|
||||
|
@ -431,13 +431,13 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground ) const
|
|||
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
|
||||
SCH_CONNECTION* connection = Connection();
|
||||
int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
|
||||
COLOR4D color = settings->GetLayerColor( layer );
|
||||
COLOR4D color = GetTextColor();
|
||||
int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
|
||||
KIFONT::FONT* font = GetDrawFont();
|
||||
VECTOR2I text_offset = GetSchematicTextOffset( aPlotter->RenderSettings() );
|
||||
|
||||
if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
||||
color = settings->GetLayerColor( layer );
|
||||
|
||||
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
||||
aPlotter->SetCurrentLineWidth( penWidth );
|
||||
|
|
|
@ -191,12 +191,13 @@ KIFONT::FONT* SCH_TEXTBOX::GetDrawFont() const
|
|||
|
||||
void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
int penWidth = GetPenWidth();
|
||||
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
||||
VECTOR2I pt1 = GetStart();
|
||||
VECTOR2I pt2 = GetEnd();
|
||||
COLOR4D color;
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
int penWidth = GetPenWidth();
|
||||
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
||||
VECTOR2I pt1 = GetStart();
|
||||
VECTOR2I pt2 = GetEnd();
|
||||
COLOR4D color = GetStroke().GetColor();
|
||||
PLOT_DASH_TYPE lineStyle = GetStroke().GetPlotStyle();
|
||||
|
||||
if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode )
|
||||
GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() );
|
||||
|
@ -205,12 +206,13 @@ void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
|
|||
{
|
||||
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
|
||||
|
||||
if( GetStroke().GetColor() == COLOR4D::UNSPECIFIED )
|
||||
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
||||
color = aSettings->GetLayerColor( m_layer );
|
||||
else
|
||||
color = GetStroke().GetColor();
|
||||
|
||||
if( GetStroke().GetPlotStyle() <= PLOT_DASH_TYPE::FIRST_TYPE )
|
||||
if( lineStyle == PLOT_DASH_TYPE::DEFAULT )
|
||||
lineStyle = PLOT_DASH_TYPE::DASH;
|
||||
|
||||
if( lineStyle == PLOT_DASH_TYPE::SOLID )
|
||||
{
|
||||
GRRect( DC, pt1, pt2, penWidth, color );
|
||||
}
|
||||
|
@ -220,7 +222,7 @@ void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
|
|||
|
||||
for( SHAPE* shape : shapes )
|
||||
{
|
||||
STROKE_PARAMS::Stroke( shape, GetStroke().GetPlotStyle(), penWidth, aSettings,
|
||||
STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
|
||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||
{
|
||||
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
|
||||
|
@ -232,10 +234,10 @@ void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
|
|||
}
|
||||
}
|
||||
|
||||
color = aSettings->GetLayerColor( m_layer );
|
||||
color = GetTextColor();
|
||||
|
||||
if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
||||
color = aSettings->GetLayerColor( m_layer );
|
||||
|
||||
EDA_TEXT::Print( aSettings, aOffset, color );
|
||||
}
|
||||
|
@ -339,22 +341,28 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground ) const
|
|||
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
|
||||
KIFONT::FONT* font = GetDrawFont();
|
||||
int penWidth = GetPenWidth();
|
||||
COLOR4D color = settings->GetLayerColor( LAYER_NOTES );
|
||||
COLOR4D color = GetStroke().GetColor();
|
||||
PLOT_DASH_TYPE lineStyle = GetStroke().GetPlotStyle();
|
||||
|
||||
if( penWidth > 0 )
|
||||
{
|
||||
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
||||
|
||||
if( aPlotter->GetColorMode() && GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
|
||||
aPlotter->SetColor( GetStroke().GetColor() );
|
||||
else
|
||||
aPlotter->SetColor( color );
|
||||
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
||||
color = settings->GetLayerColor( m_layer );
|
||||
|
||||
if( lineStyle == PLOT_DASH_TYPE::DEFAULT )
|
||||
lineStyle = PLOT_DASH_TYPE::DASH;
|
||||
|
||||
aPlotter->SetColor( color );
|
||||
aPlotter->SetDash( lineStyle );
|
||||
aPlotter->Rect( m_start, m_end, FILL_T::NO_FILL, penWidth );
|
||||
}
|
||||
|
||||
if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = GetTextColor();
|
||||
color = GetTextColor();
|
||||
|
||||
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
||||
color = settings->GetLayerColor( m_layer );
|
||||
|
||||
penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
|
||||
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
||||
|
|
Loading…
Reference in New Issue