Workaround wxWidgets enforced min pen width by using transparent pen.
Also fixes some bugs in our shape printing code when a border is not specified but a fill is. Fixes https://gitlab.com/kicad/code/kicad/issues/13891
This commit is contained in:
parent
2b1040ae67
commit
03484aedbc
|
@ -91,6 +91,11 @@ void GRSetColorPen( wxDC* DC, const COLOR4D& Color, int width, wxPenStyle style
|
||||||
if( s_ForceBlackPen )
|
if( s_ForceBlackPen )
|
||||||
color = COLOR4D::BLACK;
|
color = COLOR4D::BLACK;
|
||||||
|
|
||||||
|
// wxWidgets will enforce a minimum pen width when printing, so we have to make the pen
|
||||||
|
// transparent when we don't want the object stroked.
|
||||||
|
if( width == 0 )
|
||||||
|
color = COLOR4D::UNSPECIFIED;
|
||||||
|
|
||||||
const wxPen& curr_pen = DC->GetPen();
|
const wxPen& curr_pen = DC->GetPen();
|
||||||
|
|
||||||
if( !curr_pen.IsOk() || curr_pen.GetColour() != color.ToColour()
|
if( !curr_pen.IsOk() || curr_pen.GetColour() != color.ToColour()
|
||||||
|
|
|
@ -389,9 +389,13 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||||
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
|
penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( penWidth > 0 )
|
||||||
|
{
|
||||||
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
||||||
{
|
{
|
||||||
switch( GetShape() )
|
switch( GetShape() )
|
||||||
|
@ -438,6 +442,7 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||||
for( SHAPE* shape : shapes )
|
for( SHAPE* shape : shapes )
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,9 +311,15 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||||
{
|
{
|
||||||
int penWidth = GetPenWidth();
|
int penWidth = GetPenWidth();
|
||||||
wxDC* DC = aSettings->GetPrintDC();
|
wxDC* DC = aSettings->GetPrintDC();
|
||||||
COLOR4D color;
|
COLOR4D color = GetStroke().GetColor();
|
||||||
|
|
||||||
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
|
if( color == COLOR4D::UNSPECIFIED )
|
||||||
|
color = aSettings->GetLayerColor( LAYER_NOTES );
|
||||||
|
|
||||||
|
COLOR4D bg = aSettings->GetBackgroundColor();
|
||||||
|
|
||||||
|
if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
|
||||||
|
bg = COLOR4D::WHITE;
|
||||||
|
|
||||||
unsigned ptCount = 0;
|
unsigned ptCount = 0;
|
||||||
VECTOR2I* buffer = nullptr;
|
VECTOR2I* buffer = nullptr;
|
||||||
|
@ -337,11 +343,48 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||||
buffer[ii] = m_bezierPoints[ii];
|
buffer[ii] = m_bezierPoints[ii];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( GetStroke().GetColor() == COLOR4D::UNSPECIFIED )
|
COLOR4D fillColor = COLOR4D::UNSPECIFIED;
|
||||||
color = aSettings->GetLayerColor( LAYER_NOTES );
|
|
||||||
else
|
|
||||||
color = GetStroke().GetColor();
|
|
||||||
|
|
||||||
|
if( GetFillMode() == FILL_T::FILLED_SHAPE )
|
||||||
|
fillColor = color;
|
||||||
|
else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
||||||
|
fillColor = GetFillColor();
|
||||||
|
|
||||||
|
if( fillColor != COLOR4D::UNSPECIFIED )
|
||||||
|
{
|
||||||
|
switch( GetShape() )
|
||||||
|
{
|
||||||
|
case SHAPE_T::ARC:
|
||||||
|
GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, fillColor, fillColor );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::CIRCLE:
|
||||||
|
GRFilledCircle( DC, GetStart(), GetRadius(), 0, fillColor, fillColor );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::RECT:
|
||||||
|
GRFilledRect( DC, GetStart(), GetEnd(), 0, fillColor, fillColor );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::POLY:
|
||||||
|
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::BEZIER:
|
||||||
|
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( penWidth > 0 )
|
||||||
|
{
|
||||||
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
||||||
{
|
{
|
||||||
switch( GetShape() )
|
switch( GetShape() )
|
||||||
|
@ -386,6 +429,7 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||||
for( SHAPE* shape : shapes )
|
for( SHAPE* shape : shapes )
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue