Add support of DRAWSEGMENT S_POLYGON shape to plot functions.
Fixes: lp:1732570 https://bugs.launchpad.net/kicad/+bug/1732570
This commit is contained in:
parent
25f9c6e4f9
commit
2ec3a46984
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -47,6 +47,8 @@
|
|||
#include <macros.h>
|
||||
#include <class_base_screen.h>
|
||||
#include <drawtxt.h>
|
||||
#include <geometry/shape_line_chain.h>
|
||||
|
||||
|
||||
PLOTTER::PLOTTER( )
|
||||
{
|
||||
|
@ -507,7 +509,8 @@ void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
|
|||
}
|
||||
|
||||
|
||||
void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, EDA_DRAW_MODE_T tracemode, void* aData )
|
||||
void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width,
|
||||
EDA_DRAW_MODE_T tracemode, void* aData )
|
||||
{
|
||||
if( tracemode == FILLED )
|
||||
Circle( pos, diametre, NO_FILL, width );
|
||||
|
@ -520,6 +523,18 @@ void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, EDA_DRAW
|
|||
}
|
||||
|
||||
|
||||
void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill,
|
||||
int aWidth, void * aData )
|
||||
{
|
||||
std::vector< wxPoint > cornerList;
|
||||
|
||||
for( int ii = 0; ii < aCornerList.PointCount(); ii++ )
|
||||
cornerList.push_back( wxPoint( aCornerList.CPoint( ii ) ) );
|
||||
|
||||
PlotPoly( cornerList , aFill, aWidth, aData );
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings )
|
||||
{
|
||||
pageInfo = aPageSettings;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -480,6 +480,14 @@ 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" );
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <eda_text.h> // FILL_T
|
||||
|
||||
class SHAPE_POLY_SET;
|
||||
class SHAPE_LINE_CHAIN;
|
||||
class GBR_NETLIST_METADATA;
|
||||
|
||||
/**
|
||||
|
@ -262,7 +263,7 @@ public:
|
|||
/**
|
||||
* Function PlotPoly
|
||||
* @brief Draw a polygon ( filled or not )
|
||||
* @param aCornerList = corners list
|
||||
* @param aCornerList = corners list (a std::vector< wxPoint >)
|
||||
* @param aFill = type of fill
|
||||
* @param aWidth = line width
|
||||
* @param aData an auxiliary info (mainly for gerber format)
|
||||
|
@ -270,6 +271,17 @@ public:
|
|||
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill,
|
||||
int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) = 0;
|
||||
|
||||
/**
|
||||
* Function PlotPoly
|
||||
* @brief Draw a polygon ( filled or not )
|
||||
* @param aCornerList = corners list (a SHAPE_LINE_CHAIN)
|
||||
* @param aFill = type of fill
|
||||
* @param aWidth = line width
|
||||
* @param aData an auxiliary info (mainly for gerber format)
|
||||
*/
|
||||
virtual void PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill,
|
||||
int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL );
|
||||
|
||||
/**
|
||||
* Function PlotImage
|
||||
* Only Postscript plotters can plot bitmaps
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
|
||||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -768,6 +768,20 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg )
|
|||
}
|
||||
break;
|
||||
|
||||
case S_POLYGON:
|
||||
{
|
||||
m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
|
||||
// Draw the polygon: only one polygon is expected
|
||||
// However we provide a multi polygon shape drawing
|
||||
// ( for the future or to show a non expected shape )
|
||||
for( int jj = 0; jj < aSeg->GetPolyShape().OutlineCount(); ++jj )
|
||||
{
|
||||
SHAPE_LINE_CHAIN& poly = aSeg->GetPolyShape().Outline( jj );
|
||||
m_plotter->PlotPoly( poly, FILLED_SHAPE, thickness, &gbr_metadata );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue