plot: Correct a couple SVG output errors
Plotting to closed lines for polygons in SVG. Also correct the filled polygon line width for non-copper zones. Fixes: lp:1813964 * https://bugs.launchpad.net/kicad/+bug/1813964
This commit is contained in:
parent
0415c89c5b
commit
37741048ce
|
@ -206,12 +206,13 @@ void SVG_PLOTTER::setFillMode( FILL_T fill )
|
|||
}
|
||||
|
||||
|
||||
void SVG_PLOTTER::setSVGPlotStyle()
|
||||
void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle )
|
||||
{
|
||||
fputs( "</g>\n<g style=\"", outputFile );
|
||||
fputs( "fill:#", outputFile );
|
||||
if( aIsGroup )
|
||||
fputs( "</g>\n<g ", outputFile );
|
||||
|
||||
// output the background fill color
|
||||
fprintf( outputFile, "%6.6lX; ", m_brush_rgb_color );
|
||||
fprintf( outputFile, "style=\"fill:#%6.6lX; ", m_brush_rgb_color );
|
||||
|
||||
switch( m_fillMode )
|
||||
{
|
||||
|
@ -249,9 +250,20 @@ void SVG_PLOTTER::setSVGPlotStyle()
|
|||
break;
|
||||
}
|
||||
|
||||
fputs( "\">\n", outputFile );
|
||||
if( aExtraStyle.length() )
|
||||
{
|
||||
fputs( aExtraStyle.c_str(), outputFile );
|
||||
}
|
||||
|
||||
m_graphics_changed = false;
|
||||
fputs( "\"", outputFile );
|
||||
|
||||
if( aIsGroup )
|
||||
{
|
||||
fputs( ">", outputFile );
|
||||
m_graphics_changed = false;
|
||||
}
|
||||
|
||||
fputs( "\n", outputFile );
|
||||
}
|
||||
|
||||
/* Set the current line width (in IUs) for the next plot
|
||||
|
@ -470,21 +482,22 @@ void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
|
|||
|
||||
setFillMode( aFill );
|
||||
SetCurrentLineWidth( aWidth );
|
||||
fprintf( outputFile, "<path ");
|
||||
|
||||
switch( aFill )
|
||||
{
|
||||
case NO_FILL:
|
||||
fprintf( outputFile, "<polyline fill=\"none;\"\n" );
|
||||
setSVGPlotStyle( false, "fill:none" );
|
||||
break;
|
||||
|
||||
case FILLED_WITH_BG_BODYCOLOR:
|
||||
case FILLED_SHAPE:
|
||||
fprintf( outputFile, "<polyline style=\"fill-rule:evenodd;\"\n" );
|
||||
setSVGPlotStyle( false, "fill-rule:evenodd;" );
|
||||
break;
|
||||
}
|
||||
|
||||
DPOINT pos = userToDeviceCoordinates( aCornerList[0] );
|
||||
fprintf( outputFile, "points=\"%d,%d\n", (int) pos.x, (int) pos.y );
|
||||
fprintf( outputFile, "d=\"M %d,%d\n", (int) pos.x, (int) pos.y );
|
||||
|
||||
for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
|
||||
{
|
||||
|
@ -492,16 +505,7 @@ void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
|
|||
fprintf( outputFile, "%d,%d\n", (int) pos.x, (int) pos.y );
|
||||
}
|
||||
|
||||
// ensure the shape is closed, for filled shapes (that are closed polygons):
|
||||
// (svg does not close automatically a polygon
|
||||
if( aCornerList.front() != aCornerList.back() && aFill != NO_FILL )
|
||||
{
|
||||
pos = userToDeviceCoordinates( aCornerList.front() );
|
||||
fprintf( outputFile, "%d,%d\n", (int) pos.x, (int) pos.y );
|
||||
}
|
||||
|
||||
// Close/(fill) the path
|
||||
fprintf( outputFile, "\" /> \n" );
|
||||
fprintf( outputFile, "Z\" /> \n" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -975,9 +975,12 @@ protected:
|
|||
|
||||
/**
|
||||
* function setSVGPlotStyle()
|
||||
* output the string which define pen and brush color, shape, transparence
|
||||
* output the string which define pen and brush color, shape, transparency
|
||||
*
|
||||
* @param aIsGroup If false, do not form a new group for the style.
|
||||
* @param aExtraStyle If given, the string will be added into the style string before closing
|
||||
*/
|
||||
void setSVGPlotStyle();
|
||||
void setSVGPlotStyle( bool aIsGroup = true, const std::string& aExtraStyle = {} );
|
||||
|
||||
/**
|
||||
* function setFillMode()
|
||||
|
|
|
@ -681,7 +681,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
|
|||
{
|
||||
// Plot the filled area polygon.
|
||||
// The area can be filled by segments or uses solid polygons
|
||||
if( aZone->GetFillMode() == 0 ) // We are using solid polygons
|
||||
if( aZone->GetFillMode() == ZONE_FILL_MODE::ZFM_POLYGONS ) // We are using solid polygons
|
||||
{
|
||||
m_plotter->PlotPoly( cornerList, FILLED_SHAPE, aZone->GetMinThickness(), &gbr_metadata );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue