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,54 +389,59 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||||
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
|
|
||||||
|
|
||||||
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
|
||||||
{
|
|
||||||
switch( GetShape() )
|
|
||||||
{
|
|
||||||
case SHAPE_T::ARC:
|
|
||||||
GRArc( DC, pt1, pt2, c, penWidth, color );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHAPE_T::CIRCLE:
|
|
||||||
GRCircle( DC, pt1, GetRadius(), penWidth, color );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHAPE_T::RECT:
|
|
||||||
GRRect( DC, pt1, pt2, penWidth, color );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHAPE_T::POLY:
|
|
||||||
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHAPE_T::BEZIER:
|
|
||||||
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
|
penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
|
||||||
|
}
|
||||||
|
|
||||||
for( SHAPE* shape : shapes )
|
if( penWidth > 0 )
|
||||||
|
{
|
||||||
|
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
||||||
{
|
{
|
||||||
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
|
switch( GetShape() )
|
||||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
{
|
||||||
{
|
case SHAPE_T::ARC:
|
||||||
VECTOR2I pts = aTransform.TransformCoordinate( a ) + aOffset;
|
GRArc( DC, pt1, pt2, c, penWidth, color );
|
||||||
VECTOR2I pte = aTransform.TransformCoordinate( b ) + aOffset;
|
break;
|
||||||
GRLine( DC, pts.x, pts.y, pte.x, pte.y, penWidth, color );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( SHAPE* shape : shapes )
|
case SHAPE_T::CIRCLE:
|
||||||
delete shape;
|
GRCircle( DC, pt1, GetRadius(), penWidth, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::RECT:
|
||||||
|
GRRect( DC, pt1, pt2, penWidth, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::POLY:
|
||||||
|
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::BEZIER:
|
||||||
|
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
|
||||||
|
|
||||||
|
for( SHAPE* shape : shapes )
|
||||||
|
{
|
||||||
|
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
|
||||||
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||||
|
{
|
||||||
|
VECTOR2I pts = aTransform.TransformCoordinate( a ) + aOffset;
|
||||||
|
VECTOR2I pte = aTransform.TransformCoordinate( b ) + aOffset;
|
||||||
|
GRLine( DC, pts.x, pts.y, pte.x, pte.y, penWidth, color );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( SHAPE* shape : shapes )
|
||||||
|
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,33 +343,35 @@ 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( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
if( GetFillMode() == FILL_T::FILLED_SHAPE )
|
||||||
|
fillColor = color;
|
||||||
|
else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
||||||
|
fillColor = GetFillColor();
|
||||||
|
|
||||||
|
if( fillColor != COLOR4D::UNSPECIFIED )
|
||||||
{
|
{
|
||||||
switch( GetShape() )
|
switch( GetShape() )
|
||||||
{
|
{
|
||||||
case SHAPE_T::ARC:
|
case SHAPE_T::ARC:
|
||||||
GRArc( DC, GetEnd(), GetStart(), getCenter(), penWidth, color );
|
GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, fillColor, fillColor );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHAPE_T::CIRCLE:
|
case SHAPE_T::CIRCLE:
|
||||||
GRCircle( DC, GetStart(), GetRadius(), penWidth, color );
|
GRFilledCircle( DC, GetStart(), GetRadius(), 0, fillColor, fillColor );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHAPE_T::RECT:
|
case SHAPE_T::RECT:
|
||||||
GRRect( DC, GetStart(), GetEnd(), penWidth, color );
|
GRFilledRect( DC, GetStart(), GetEnd(), 0, fillColor, fillColor );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHAPE_T::POLY:
|
case SHAPE_T::POLY:
|
||||||
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHAPE_T::BEZIER:
|
case SHAPE_T::BEZIER:
|
||||||
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -372,19 +380,55 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
|
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
|
||||||
|
}
|
||||||
|
|
||||||
for( SHAPE* shape : shapes )
|
if( penWidth > 0 )
|
||||||
|
{
|
||||||
|
if( GetEffectiveLineStyle() == PLOT_DASH_TYPE::SOLID )
|
||||||
{
|
{
|
||||||
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
|
switch( GetShape() )
|
||||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
{
|
||||||
{
|
case SHAPE_T::ARC:
|
||||||
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
|
GRArc( DC, GetEnd(), GetStart(), getCenter(), penWidth, color );
|
||||||
} );
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
for( SHAPE* shape : shapes )
|
case SHAPE_T::CIRCLE:
|
||||||
delete shape;
|
GRCircle( DC, GetStart(), GetRadius(), penWidth, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::RECT:
|
||||||
|
GRRect( DC, GetStart(), GetEnd(), penWidth, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::POLY:
|
||||||
|
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHAPE_T::BEZIER:
|
||||||
|
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
|
||||||
|
|
||||||
|
for( SHAPE* shape : shapes )
|
||||||
|
{
|
||||||
|
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 );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( SHAPE* shape : shapes )
|
||||||
|
delete shape;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
|
Loading…
Reference in New Issue