diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp index 4d6e20f814..8099c16df0 100644 --- a/common/class_plotter.cpp +++ b/common/class_plotter.cpp @@ -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 #include #include +#include + 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; diff --git a/common/common_plotSVG_functions.cpp b/common/common_plotSVG_functions.cpp index 50671d14ae..e95f8dd841 100644 --- a/common/common_plotSVG_functions.cpp +++ b/common/common_plotSVG_functions.cpp @@ -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& 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" ); } diff --git a/include/plot_common.h b/include/plot_common.h index d0d4052f1c..e84db08aaa 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -39,6 +39,7 @@ #include // 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 diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 56e171d51d..8df4105c20 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -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 * Copyright (C) 2011 Wayne Stambaugh - * 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 diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index bff82b5fc0..68fff41483 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -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 ); }