2014-10-19 20:20:16 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-09-19 11:01:36 +00:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2020-06-24 17:35:33 +00:00
|
|
|
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-19 20:20:16 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
/**
|
|
|
|
* Common plot library \n
|
2012-05-03 18:37:56 +00:00
|
|
|
* Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF)
|
2009-06-28 16:50:42 +00:00
|
|
|
*
|
2009-01-19 19:08:42 +00:00
|
|
|
* @file plot_common.h
|
|
|
|
*/
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
#ifndef PLOT_COMMON_H_
|
|
|
|
#define PLOT_COMMON_H_
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
#include <vector>
|
2013-03-28 16:30:09 +00:00
|
|
|
#include <math/box2.h>
|
2019-05-31 12:15:25 +00:00
|
|
|
#include <gr_text.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <page_info.h>
|
2020-06-28 08:37:36 +00:00
|
|
|
#include <base_struct.h> // FILL_T
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
class COLOR_SETTINGS;
|
2016-02-10 16:02:40 +00:00
|
|
|
class SHAPE_POLY_SET;
|
2017-11-16 11:09:24 +00:00
|
|
|
class SHAPE_LINE_CHAIN;
|
2016-09-19 11:01:36 +00:00
|
|
|
class GBR_NETLIST_METADATA;
|
2016-02-10 16:02:40 +00:00
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
/**
|
|
|
|
* Enum PlotFormat
|
2010-12-12 02:29:33 +00:00
|
|
|
* is the set of supported output plot formats. They should be kept in order
|
|
|
|
* of the radio buttons in the plot panel/windows.
|
2008-03-22 05:55:06 +00:00
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
enum class PLOT_FORMAT
|
|
|
|
{
|
|
|
|
UNDEFINED = -1,
|
|
|
|
FIRST_FORMAT = 0,
|
|
|
|
HPGL = FIRST_FORMAT,
|
|
|
|
GERBER,
|
|
|
|
POST,
|
|
|
|
DXF,
|
|
|
|
PDF,
|
|
|
|
SVG,
|
|
|
|
LAST_FORMAT = SVG
|
2008-03-22 05:55:06 +00:00
|
|
|
};
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* Enum for choosing which kind of text to output with the PSLIKE
|
|
|
|
* plotters. You can:
|
|
|
|
* 1) only use the internal vector font
|
|
|
|
* 2) only use native postscript fonts
|
|
|
|
* 3) use the internal vector font and add 'phantom' text to aid
|
|
|
|
* searching
|
2013-04-05 08:55:46 +00:00
|
|
|
* 4) keep the default for the plot driver
|
2012-08-29 16:59:50 +00:00
|
|
|
*
|
|
|
|
* This is recognized by the DXF driver too, where NATIVE emits
|
|
|
|
* TEXT entities instead of stroking the text
|
2012-05-03 18:37:56 +00:00
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
enum class PLOT_TEXT_MODE
|
|
|
|
{
|
|
|
|
STROKE,
|
|
|
|
NATIVE,
|
|
|
|
PHANTOM,
|
|
|
|
DEFAULT
|
2012-05-03 18:37:56 +00:00
|
|
|
};
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2017-11-13 03:53:27 +00:00
|
|
|
/**
|
|
|
|
* Enum for choosing dashed line type
|
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
enum class PLOT_DASH_TYPE
|
|
|
|
{
|
|
|
|
DEFAULT = -1,
|
|
|
|
SOLID = 0,
|
|
|
|
FIRST_TYPE = SOLID,
|
|
|
|
DASH,
|
|
|
|
DOT,
|
|
|
|
DASHDOT,
|
|
|
|
LAST_TYPE = DASHDOT
|
2017-11-13 03:53:27 +00:00
|
|
|
};
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2020-06-24 17:35:33 +00:00
|
|
|
/**
|
|
|
|
* Convert KiCad line plot styles to wxWidgets device context styles.
|
|
|
|
*
|
|
|
|
* @param aType The KiCad line plot style to convert.
|
|
|
|
*
|
|
|
|
* @return The equivalent wxPenStyle of \a aType.
|
|
|
|
*/
|
|
|
|
wxPenStyle GetwxPenStyle( PLOT_DASH_TYPE aType );
|
|
|
|
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* Base plotter engine class. General rule: all the interface with the caller
|
|
|
|
* is done in IU, the IU size is specified with SetViewport. Internal and
|
|
|
|
* output processing is usually done in decimils (or whatever unit the
|
|
|
|
* effective engine class need to use)
|
|
|
|
*/
|
2009-08-29 10:20:48 +00:00
|
|
|
class PLOTTER
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
public:
|
2016-09-19 11:01:36 +00:00
|
|
|
// These values are used as flag for pen or aperture selection
|
|
|
|
static const int DO_NOT_SET_LINE_WIDTH = -2; // Skip selection
|
|
|
|
static const int USE_DEFAULT_LINE_WIDTH = -1; // use the default pen
|
2012-08-29 16:59:50 +00:00
|
|
|
|
2013-02-06 15:21:37 +00:00
|
|
|
PLOTTER();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2013-02-06 11:54:51 +00:00
|
|
|
virtual ~PLOTTER();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2012-05-03 18:37:56 +00:00
|
|
|
* Returns the effective plot engine in use. It's not very OO but for
|
|
|
|
* now is required since some things are only done with some output devices
|
|
|
|
* (like drill marks, emitted only for postscript
|
2009-08-29 10:20:48 +00:00
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual PLOT_FORMAT GetPlotterType() const = 0;
|
2009-08-29 10:20:48 +00:00
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
virtual bool StartPlot() = 0;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual bool EndPlot() = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2018-11-02 08:23:16 +00:00
|
|
|
virtual void SetNegative( bool aNegative )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2018-11-02 08:23:16 +00:00
|
|
|
negativeMode = aNegative;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2018-11-02 08:23:16 +00:00
|
|
|
/** Plot in B/W or color.
|
|
|
|
* @param aColorMode = true to plot in color, false to plot in black and white
|
|
|
|
*/
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual void SetColorMode( bool aColorMode ) { colorMode = aColorMode; }
|
|
|
|
bool GetColorMode() const { return colorMode; }
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void SetRenderSettings( RENDER_SETTINGS* aSettings ) { m_renderSettings = aSettings; }
|
|
|
|
RENDER_SETTINGS* RenderSettings() { return m_renderSettings; }
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) { pageInfo = aPageSettings; }
|
|
|
|
PAGE_INFO& PageSettings() { return pageInfo; }
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* Set the line width for the next drawing.
|
|
|
|
* @param width is specified in IUs
|
2016-09-19 11:01:36 +00:00
|
|
|
* @param aData is an auxiliary parameter, mainly used in gerber plotter
|
2012-05-03 18:37:56 +00:00
|
|
|
*/
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) = 0;
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual int GetCurrentLineWidth() const { return currentPenWidth; }
|
2012-01-07 06:02:38 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
virtual void SetColor( COLOR4D color ) = 0;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetDash( PLOT_DASH_TYPE dashed ) = 0;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2015-03-25 13:07:05 +00:00
|
|
|
virtual void SetCreator( const wxString& aCreator )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2015-03-25 13:07:05 +00:00
|
|
|
creator = aCreator;
|
|
|
|
}
|
|
|
|
|
2017-01-20 21:00:20 +00:00
|
|
|
virtual void SetTitle( const wxString& aTitle )
|
|
|
|
{
|
|
|
|
title = aTitle;
|
|
|
|
}
|
|
|
|
|
2015-03-25 13:07:05 +00:00
|
|
|
/**
|
|
|
|
* Function AddLineToHeader
|
|
|
|
* Add a line to the list of free lines to print at the beginning of the file
|
|
|
|
* @param aExtraString is the string to print
|
|
|
|
*/
|
|
|
|
void AddLineToHeader( const wxString& aExtraString )
|
|
|
|
{
|
|
|
|
m_headerExtraLines.Add( aExtraString );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ClearHeaderLinesList
|
|
|
|
* remove all lines from the list of free lines to print at the beginning of the file
|
|
|
|
*/
|
|
|
|
void ClearHeaderLinesList()
|
|
|
|
{
|
|
|
|
m_headerExtraLines.Clear();
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* Set the plot offset and scaling for the current plot
|
2012-09-12 17:28:55 +00:00
|
|
|
* @param aOffset is the plot offset
|
|
|
|
* @param aIusPerDecimil gives the scaling factor from IUs to device units
|
2012-05-03 18:37:56 +00:00
|
|
|
* @param aScale is the user set plot scaling factor (either explicitly
|
|
|
|
* or using 'fit to A4')
|
|
|
|
* @param aMirror flips the plot in the Y direction (useful for toner
|
|
|
|
* transfers or some kind of film)
|
|
|
|
*/
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2013-02-06 15:21:37 +00:00
|
|
|
double aScale, bool aMirror ) = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
/**
|
|
|
|
* Open or create the plot file aFullFilename
|
|
|
|
* @param aFullFilename = the full file name of the file to create
|
|
|
|
* @return true if success, false if the file cannot be created/opened
|
|
|
|
*
|
|
|
|
* Virtual because some plotters use ascii files, some others binary files (PDF)
|
|
|
|
* The base class open the file in text mode
|
|
|
|
*/
|
|
|
|
virtual bool OpenFile( const wxString& aFullFilename );
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
/**
|
|
|
|
* The IUs per decimil are an essential scaling factor when
|
|
|
|
* plotting; they are set and saved when establishing the viewport.
|
|
|
|
* Here they can be get back again
|
|
|
|
*/
|
|
|
|
double GetIUsPerDecimil() const { return m_IUsPerDecimil; }
|
|
|
|
|
2019-05-22 13:33:48 +00:00
|
|
|
int GetPlotterArcLowDef() const { return m_IUsPerDecimil * 8; }
|
|
|
|
int GetPlotterArcHighDef() const { return m_IUsPerDecimil * 2; }
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
// Low level primitives
|
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2015-05-21 09:04:47 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) = 0;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2015-05-21 09:04:47 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) = 0;
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic fallback: arc rendered as a polyline
|
|
|
|
*/
|
2013-12-06 18:31:15 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
|
2015-05-21 09:04:47 +00:00
|
|
|
int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH );
|
2011-04-20 08:13:21 +00:00
|
|
|
|
2019-11-05 13:27:07 +00:00
|
|
|
/**
|
|
|
|
* Generic fallback: Cubic Bezier curve rendered as a polyline
|
|
|
|
* In Kicad the bezier curves have 4 control points:
|
|
|
|
* start ctrl1 ctrl2 end
|
|
|
|
*/
|
|
|
|
virtual void BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
|
|
|
|
const wxPoint& aControl2, const wxPoint& aEnd,
|
|
|
|
int aTolerance,
|
|
|
|
int aLineThickness = USE_DEFAULT_LINE_WIDTH );
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* moveto/lineto primitive, moves the 'pen' to the specified direction
|
2012-09-12 17:28:55 +00:00
|
|
|
* @param pos is the target position
|
2012-05-03 18:37:56 +00:00
|
|
|
* @param plume specifies the kind of motion: 'U' only moves the pen,
|
|
|
|
* 'D' draw a line from the current position and 'Z' finish
|
|
|
|
* the drawing and returns the 'pen' to rest (flushes the trace)
|
|
|
|
*/
|
|
|
|
virtual void PenTo( const wxPoint& pos, char plume ) = 0;
|
|
|
|
|
|
|
|
// Convenience functions for PenTo
|
|
|
|
void MoveTo( const wxPoint& pos )
|
|
|
|
{
|
|
|
|
PenTo( pos, 'U' );
|
|
|
|
}
|
|
|
|
|
|
|
|
void LineTo( const wxPoint& pos )
|
|
|
|
{
|
|
|
|
PenTo( pos, 'D' );
|
|
|
|
}
|
|
|
|
|
|
|
|
void FinishTo( const wxPoint& pos )
|
|
|
|
{
|
|
|
|
PenTo( pos, 'D' );
|
|
|
|
PenTo( pos, 'Z' );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PenFinish()
|
|
|
|
{
|
|
|
|
// The point is not important with Z motion
|
|
|
|
PenTo( wxPoint( 0, 0 ), 'Z' );
|
|
|
|
}
|
|
|
|
|
2011-04-20 08:13:21 +00:00
|
|
|
/**
|
|
|
|
* Function PlotPoly
|
|
|
|
* @brief Draw a polygon ( filled or not )
|
2017-11-16 11:09:24 +00:00
|
|
|
* @param aCornerList = corners list (a std::vector< wxPoint >)
|
2012-05-03 18:37:56 +00:00
|
|
|
* @param aFill = type of fill
|
2011-04-20 08:13:21 +00:00
|
|
|
* @param aWidth = line width
|
2016-09-19 11:01:36 +00:00
|
|
|
* @param aData an auxiliary info (mainly for gerber format)
|
2011-04-20 08:13:21 +00:00
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill,
|
2016-09-19 11:01:36 +00:00
|
|
|
int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) = 0;
|
2011-04-20 08:13:21 +00:00
|
|
|
|
2017-11-16 11:09:24 +00:00
|
|
|
/**
|
|
|
|
* Function PlotPoly
|
|
|
|
* @brief Draw a polygon ( filled or not )
|
2019-09-18 09:48:49 +00:00
|
|
|
* @param aCornerList = corners list (a SHAPE_LINE_CHAIN).
|
|
|
|
* must be closed (IsClosed() == true) for a polygon. Otherwise this is a polyline
|
2017-11-16 11:09:24 +00:00
|
|
|
* @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 );
|
|
|
|
|
2011-08-31 14:59:20 +00:00
|
|
|
/**
|
|
|
|
* Function PlotImage
|
|
|
|
* Only Postscript plotters can plot bitmaps
|
|
|
|
* for plotters that cannot plot a bitmap, a rectangle is plotted
|
|
|
|
* @brief Draw an image bitmap
|
|
|
|
* @param aImage = the bitmap
|
|
|
|
* @param aPos = position of the center of the bitmap
|
|
|
|
* @param aScaleFactor = the scale factor to apply to the bitmap size
|
|
|
|
* (this is not the plot scale factor)
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotImage( const wxImage & aImage, const wxPoint& aPos,
|
|
|
|
double aScaleFactor );
|
|
|
|
|
|
|
|
// Higher level primitives -- can be drawn as line, sketch or 'filled'
|
|
|
|
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData );
|
2013-12-06 18:31:15 +00:00
|
|
|
virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
|
2016-09-19 11:01:36 +00:00
|
|
|
int rayon, int width, EDA_DRAW_MODE_T tracemode, void* aData );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Flash primitives
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* virtual function FlashPadCircle
|
|
|
|
* @param aPadPos Position of the shape (center of the rectangle
|
2017-06-15 09:28:36 +00:00
|
|
|
* @param aDiameter diameter of round pad
|
2016-09-19 11:01:36 +00:00
|
|
|
* @param aTraceMode FILLED or SKETCH
|
2017-06-15 18:49:30 +00:00
|
|
|
* @param aData an auxiliary info (mainly for gerber format attributes)
|
2016-09-19 11:01:36 +00:00
|
|
|
*/
|
2015-05-21 09:04:47 +00:00
|
|
|
virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virtual function FlashPadOval
|
|
|
|
* @param aPadPos Position of the shape (center of the rectangle
|
2017-06-15 09:28:36 +00:00
|
|
|
* @param aSize = size of oblong shape
|
|
|
|
* @param aPadOrient The rotation of the shape
|
2016-09-19 11:01:36 +00:00
|
|
|
* @param aTraceMode FILLED or SKETCH
|
2017-06-15 18:49:30 +00:00
|
|
|
* @param aData an auxiliary info (mainly for gerber format attributes)
|
2016-09-19 11:01:36 +00:00
|
|
|
*/
|
2015-05-21 09:04:47 +00:00
|
|
|
virtual void FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virtual function FlashPadRect
|
|
|
|
* @param aPadPos Position of the shape (center of the rectangle
|
|
|
|
* @param aSize = size of rounded rect
|
2017-06-15 09:28:36 +00:00
|
|
|
* @param aPadOrient The rotation of the shape
|
2016-09-19 11:01:36 +00:00
|
|
|
* @param aTraceMode FILLED or SKETCH
|
2017-06-15 18:49:30 +00:00
|
|
|
* @param aData an auxuliary info (mainly for gerber format attributes)
|
2016-09-19 11:01:36 +00:00
|
|
|
*/
|
2015-05-21 09:04:47 +00:00
|
|
|
virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
|
2016-09-19 11:01:36 +00:00
|
|
|
double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2016-02-10 16:02:40 +00:00
|
|
|
/**
|
|
|
|
* virtual function FlashPadRoundRect
|
|
|
|
* @param aPadPos Position of the shape (center of the rectangle
|
|
|
|
* @param aSize = size of rounded rect
|
2017-06-16 00:31:42 +00:00
|
|
|
* @param aCornerRadius Radius of the rounded corners
|
|
|
|
* @param aOrient The rotation of the shape
|
2016-02-10 16:02:40 +00:00
|
|
|
* @param aTraceMode FILLED or SKETCH
|
2017-06-15 18:49:30 +00:00
|
|
|
* @param aData an auxiliary info (mainly for gerber format attributes)
|
2016-02-10 16:02:40 +00:00
|
|
|
*/
|
|
|
|
virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
int aCornerRadius, double aOrient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
|
2016-02-10 16:02:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* virtual function FlashPadCustom
|
|
|
|
* @param aPadPos Position of the shape (center of the rectangle
|
|
|
|
* @param aSize = size of round reference pad
|
|
|
|
* @param aPolygons the shape as polygon set
|
|
|
|
* @param aTraceMode FILLED or SKETCH
|
2017-06-15 18:49:30 +00:00
|
|
|
* @param aData an auxiliary info (mainly for gerber format attributes)
|
2016-02-10 16:02:40 +00:00
|
|
|
*/
|
|
|
|
virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
SHAPE_POLY_SET* aPolygons,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0;
|
2016-02-10 16:02:40 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/** virtual function FlashPadTrapez
|
2010-09-13 11:51:09 +00:00
|
|
|
* flash a trapezoidal pad
|
|
|
|
* @param aPadPos = the position of the shape
|
2012-05-03 18:37:56 +00:00
|
|
|
* @param aCorners = the list of 4 corners positions,
|
|
|
|
* relative to the shape position, pad orientation 0
|
2010-09-13 11:51:09 +00:00
|
|
|
* @param aPadOrient = the rotation of the shape
|
2017-06-16 07:14:28 +00:00
|
|
|
* @param aTraceMode = FILLED or SKETCH
|
2017-06-15 18:49:30 +00:00
|
|
|
* @param aData an auxiliary info (mainly for gerber format attributes)
|
2010-09-13 11:51:09 +00:00
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
2017-06-15 18:49:30 +00:00
|
|
|
double aPadOrient, EDA_DRAW_MODE_T aTraceMode,
|
|
|
|
void* aData ) = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2019-10-02 15:16:27 +00:00
|
|
|
/** Flash a regular polygon. Usefull only in Gerber files to flash a regular polygon
|
|
|
|
* @param aShapePos is the center of the circle containing the polygon
|
|
|
|
* @param aRadius is the radius of the circle containing the polygon
|
|
|
|
* @param aCornerCount is the number of vertices
|
|
|
|
* @param aOrient is the polygon rotation in degrees
|
|
|
|
* @param aData is a auxiliary parameter used (if needed) to handle extra info
|
|
|
|
* specific to the plotter
|
|
|
|
*/
|
|
|
|
virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount,
|
|
|
|
double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) = 0 ;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* Draws text with the plotter. For convenience it accept the color to use
|
2016-09-19 11:01:36 +00:00
|
|
|
* for specific plotters (GERBER) aData is used to pass extra parameters
|
2012-05-03 18:37:56 +00:00
|
|
|
*/
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
2017-02-20 16:57:41 +00:00
|
|
|
const COLOR4D aColor,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxString& aText,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aOrient,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
2013-12-23 16:25:13 +00:00
|
|
|
bool aBold,
|
2016-09-19 11:01:36 +00:00
|
|
|
bool aMultilineAllowed = false,
|
|
|
|
void* aData = NULL );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* Draw a marker (used for the drill map)
|
|
|
|
*/
|
|
|
|
static const unsigned MARKER_COUNT = 58;
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
2017-06-15 09:28:36 +00:00
|
|
|
* Draw a pattern shape number aShapeId, to coord position.
|
2014-10-19 20:20:16 +00:00
|
|
|
* Diameter diameter = (coord table) hole
|
|
|
|
* AShapeId = index (used to generate forms characters)
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void Marker( const wxPoint& position, int diametre, unsigned aShapeId );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-06 22:18:39 +00:00
|
|
|
/**
|
|
|
|
* Function SetLayerPolarity
|
2010-12-06 22:05:12 +00:00
|
|
|
* sets current Gerber layer polarity to positive or negative
|
|
|
|
* by writing \%LPD*\% or \%LPC*\% to the Gerber file, respectively.
|
2012-05-03 18:37:56 +00:00
|
|
|
* (obviously starts a new Gerber layer, too)
|
2010-12-12 02:29:33 +00:00
|
|
|
* @param aPositive is the layer polarity and true for positive.
|
2012-05-03 18:37:56 +00:00
|
|
|
* It's not useful with most other plotter since they can't 'scratch'
|
|
|
|
* the film like photoplotter imagers do
|
2010-12-06 22:05:12 +00:00
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive )
|
|
|
|
{
|
|
|
|
// NOP for most plotters
|
|
|
|
}
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
/**
|
|
|
|
* Change the current text mode. See the PlotTextMode
|
|
|
|
* explanation at the beginning of the file
|
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetTextMode( PLOT_TEXT_MODE mode )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
2014-07-04 14:22:38 +00:00
|
|
|
// NOP for most plotters.
|
2014-06-19 06:26:53 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false )
|
|
|
|
{
|
|
|
|
// NOP for most plotters. Only for Gerber plotter
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-20 22:02:03 +00:00
|
|
|
virtual void SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches = false )
|
|
|
|
{
|
|
|
|
// NOP for most plotters. Only for SVG plotter
|
|
|
|
}
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
/**
|
2018-07-08 12:12:38 +00:00
|
|
|
* calling this function allows one to define the beginning of a group
|
2016-09-19 11:01:36 +00:00
|
|
|
* of drawing items, for instance in SVG or Gerber format.
|
|
|
|
* (example: group all segments of a letter or a text)
|
|
|
|
* @param aData can define any parameter
|
|
|
|
* for most of plotters: do nothing
|
|
|
|
*/
|
|
|
|
virtual void StartBlock( void* aData ) {}
|
|
|
|
|
|
|
|
/**
|
2018-07-08 12:12:38 +00:00
|
|
|
* calling this function allows one to define the end of a group of drawing
|
|
|
|
* items for instance in SVG or Gerber format.
|
2016-09-19 11:01:36 +00:00
|
|
|
* the group is started by StartBlock()
|
|
|
|
* @param aData can define any parameter
|
|
|
|
* for most of plotters: do nothing
|
|
|
|
*/
|
|
|
|
virtual void EndBlock( void* aData ) {}
|
|
|
|
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2010-12-12 02:29:33 +00:00
|
|
|
// These are marker subcomponents
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
|
|
|
* Plot a circle centered on the position. Building block for markers
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerCircle( const wxPoint& pos, int radius );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a - bar centered on the position. Building block for markers
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerHBar( const wxPoint& pos, int radius );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a / bar centered on the position. Building block for markers
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerSlash( const wxPoint& pos, int radius );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a \ bar centered on the position. Building block for markers
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerBackSlash( const wxPoint& pos, int radius );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a | bar centered on the position. Building block for markers
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerVBar( const wxPoint& pos, int radius );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a square centered on the position. Building block for markers
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerSquare( const wxPoint& position, int radius );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a lozenge centered on the position. Building block for markers
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerLozenge( const wxPoint& position, int radius );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Helper function for sketched filler segment
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cdonvert a thick segment and plot it as an oval
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void segmentAsOval( const wxPoint& start, const wxPoint& end, int width,
|
2014-10-19 20:20:16 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
|
|
|
|
|
|
|
void sketchOval( const wxPoint& pos, const wxSize& size, double orient, int width );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
// Coordinate and scaling conversion functions
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies coordinates according to the orientation,
|
|
|
|
* scale factor, and offsets trace. Also convert from a wxPoint to DPOINT,
|
|
|
|
* since some output engines needs floating point coordinates.
|
|
|
|
*/
|
2013-12-06 18:31:15 +00:00
|
|
|
virtual DPOINT userToDeviceCoordinates( const wxPoint& aCoordinate );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies size according to the plotter scale factors
|
|
|
|
* (wxSize version, returns a DPOINT)
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual DPOINT userToDeviceSize( const wxSize& size );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies size according to the plotter scale factors
|
|
|
|
* (simple double version)
|
|
|
|
*/
|
2015-03-10 20:00:50 +00:00
|
|
|
virtual double userToDeviceSize( double size ) const;
|
|
|
|
|
2017-11-13 03:53:27 +00:00
|
|
|
double GetDotMarkLenIU() const;
|
|
|
|
|
2015-03-10 20:00:50 +00:00
|
|
|
double GetDashMarkLenIU() const;
|
|
|
|
|
|
|
|
double GetDashGapLenIU() const;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2015-03-25 13:07:05 +00:00
|
|
|
protected: // variables used in most of plotters:
|
2012-05-03 18:37:56 +00:00
|
|
|
/// Plot scale - chosen by the user (even implicitly with 'fit in a4')
|
|
|
|
double plotScale;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2014-06-30 10:00:21 +00:00
|
|
|
/* Caller scale (how many IUs in a decimil - always); it's a double
|
2012-08-29 16:59:50 +00:00
|
|
|
* because in eeschema there are 0.1 IUs in a decimil (eeschema
|
|
|
|
* always works in mils internally) while pcbnew can work in decimil
|
|
|
|
* or nanometers, so this value would be >= 1 */
|
|
|
|
double m_IUsPerDecimil;
|
|
|
|
|
2014-06-30 10:00:21 +00:00
|
|
|
/// Device scale (from IUs to plotter device units - usually decimils)
|
2012-05-03 18:37:56 +00:00
|
|
|
double iuPerDeviceUnit;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/// Plot offset (in IUs)
|
|
|
|
wxPoint plotOffset;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2013-12-06 18:31:15 +00:00
|
|
|
/// X axis orientation (SVG)
|
|
|
|
/// and plot mirrored (only for PS, PDF HPGL and SVG)
|
|
|
|
bool m_plotMirror;
|
|
|
|
bool m_mirrorIsHorizontal; /// true to mirror horizontally (else vertically)
|
|
|
|
bool m_yaxisReversed; /// true if the Y axis is top to bottom (SVG)
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
/// Output file
|
2012-05-03 18:37:56 +00:00
|
|
|
FILE* outputFile;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Pen handling
|
2020-04-14 12:25:00 +00:00
|
|
|
bool colorMode; // true to plot in color, false to plot in black & white
|
|
|
|
bool negativeMode; // true to generate a negative image (PS mode mainly)
|
|
|
|
int currentPenWidth;
|
|
|
|
char penState; // Current pen state: 'U', 'D' or 'Z' (see PenTo)
|
|
|
|
wxPoint penLastpos; // Last pen positions; set to -1,-1 when the pen is
|
|
|
|
// at rest
|
|
|
|
wxString creator;
|
|
|
|
wxString filename;
|
|
|
|
wxString title;
|
|
|
|
PAGE_INFO pageInfo;
|
|
|
|
wxSize paperSize; // Paper size in IU - not in mils
|
|
|
|
|
|
|
|
wxArrayString m_headerExtraLines; // a set of string to print in header file
|
|
|
|
|
|
|
|
RENDER_SETTINGS* m_renderSettings;
|
2009-06-28 16:50:42 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class HPGL_PLOTTER : public PLOTTER
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
public:
|
2012-09-28 17:47:41 +00:00
|
|
|
HPGL_PLOTTER();
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual PLOT_FORMAT GetPlotterType() const override
|
2009-08-29 10:20:48 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_FORMAT::HPGL;
|
2009-08-29 10:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
static wxString GetDefaultFileExtension()
|
|
|
|
{
|
2012-09-28 17:47:41 +00:00
|
|
|
return wxString( wxT( "plt" ) );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool StartPlot() override;
|
|
|
|
virtual bool EndPlot() override;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/// HPGL doesn't handle line thickness or color
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
// This is the truth
|
|
|
|
currentPenWidth = userToDeviceSize( penDiameter );
|
2011-12-31 05:44:00 +00:00
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetDash( PLOT_DASH_TYPE dashed ) override;
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
virtual void SetColor( COLOR4D color ) override {}
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetPenSpeed( int speed )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
penSpeed = speed;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetPenNumber( int number )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
penNumber = number;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 12:14:46 +00:00
|
|
|
virtual void SetPenDiameter( double diameter );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScale, bool aMirror ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2016-09-19 11:01:36 +00:00
|
|
|
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
|
|
|
|
void * aData = NULL) override;
|
2011-04-20 08:13:21 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData ) override;
|
2013-12-06 18:31:15 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
|
2016-09-24 18:53:15 +00:00
|
|
|
int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
|
|
|
|
virtual void PenTo( const wxPoint& pos, char plume ) override;
|
2017-06-16 00:31:42 +00:00
|
|
|
virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
|
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
|
|
|
virtual void FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
|
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2017-06-15 18:49:30 +00:00
|
|
|
virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
|
2017-06-16 00:31:42 +00:00
|
|
|
double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2016-02-10 16:02:40 +00:00
|
|
|
virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
int aCornerRadius, double aOrient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2016-02-10 16:02:40 +00:00
|
|
|
virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
SHAPE_POLY_SET* aPolygons,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
2017-06-16 07:14:28 +00:00
|
|
|
double aPadOrient, EDA_DRAW_MODE_T aTraceMode,
|
2017-06-15 18:49:30 +00:00
|
|
|
void* aData ) override;
|
2019-10-02 15:16:27 +00:00
|
|
|
virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount,
|
|
|
|
double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2012-05-03 18:37:56 +00:00
|
|
|
void penControl( char plume );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
int penSpeed;
|
|
|
|
int penNumber;
|
|
|
|
double penDiameter;
|
2009-06-28 16:50:42 +00:00
|
|
|
};
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* The PSLIKE_PLOTTER class is an intermediate class to handle common
|
|
|
|
* routines for engines working more or less with the postscript imaging
|
|
|
|
* model
|
|
|
|
*/
|
|
|
|
class PSLIKE_PLOTTER : public PLOTTER
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
public:
|
2020-04-14 12:25:00 +00:00
|
|
|
PSLIKE_PLOTTER() :
|
|
|
|
plotScaleAdjX( 1 ),
|
|
|
|
plotScaleAdjY( 1 ),
|
|
|
|
m_textMode( PLOT_TEXT_MODE::PHANTOM )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
2012-08-29 16:59:50 +00:00
|
|
|
* PS and PDF fully implement native text (for the Latin-1 subset)
|
2012-05-03 18:37:56 +00:00
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetTextMode( PLOT_TEXT_MODE mode ) override
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( mode != PLOT_TEXT_MODE::DEFAULT )
|
2013-04-05 08:55:46 +00:00
|
|
|
m_textMode = mode;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the 'fine' scaling for the postscript engine
|
|
|
|
*/
|
|
|
|
void SetScaleAdjust( double scaleX, double scaleY )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
plotScaleAdjX = scaleX;
|
|
|
|
plotScaleAdjY = scaleY;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
// Pad routines are handled with lower level primitives
|
2017-06-16 00:31:42 +00:00
|
|
|
virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
|
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
|
|
|
virtual void FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
|
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
|
|
|
virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
double aPadOrient, EDA_DRAW_MODE_T aTraceMode,
|
|
|
|
void* aData ) override;
|
2016-02-10 16:02:40 +00:00
|
|
|
virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
int aCornerRadius, double aOrient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2016-02-10 16:02:40 +00:00
|
|
|
virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
SHAPE_POLY_SET* aPolygons,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
2017-06-16 07:14:28 +00:00
|
|
|
double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2019-10-02 15:16:27 +00:00
|
|
|
virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount,
|
|
|
|
double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
/** The SetColor implementation is split with the subclasses:
|
|
|
|
* The PSLIKE computes the rgb values, the subclass emits the
|
|
|
|
* operator to actually do it
|
2011-04-20 08:13:21 +00:00
|
|
|
*/
|
2017-02-20 16:57:41 +00:00
|
|
|
virtual void SetColor( COLOR4D color ) override;
|
2011-04-20 08:13:21 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
protected:
|
|
|
|
void computeTextParameters( const wxPoint& aPos,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
2017-08-15 13:52:46 +00:00
|
|
|
bool aMirror,
|
2012-05-03 18:37:56 +00:00
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold,
|
|
|
|
double *wideningFactor,
|
|
|
|
double *ctm_a,
|
|
|
|
double *ctm_b,
|
|
|
|
double *ctm_c,
|
|
|
|
double *ctm_d,
|
|
|
|
double *ctm_e,
|
|
|
|
double *ctm_f,
|
|
|
|
double *heightFactor );
|
|
|
|
void postscriptOverlinePositions( const wxString& aText, int aXSize,
|
|
|
|
bool aItalic, bool aBold,
|
|
|
|
std::vector<int> *pos_pairs );
|
2020-07-26 13:57:07 +00:00
|
|
|
|
|
|
|
/// convert a wxString unicode string to a char string compatible with the accepted
|
|
|
|
/// string plotter format (convert special chars and non ascii7 chars)
|
|
|
|
virtual std::string encodeStringForPlotter( const wxString& aUnicode );
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
/// Virtual primitive for emitting the setrgbcolor operator
|
|
|
|
virtual void emitSetRGBColor( double r, double g, double b ) = 0;
|
|
|
|
|
|
|
|
/// Height of the postscript font (from the AFM)
|
2012-09-20 13:54:35 +00:00
|
|
|
static const double postscriptTextAscent; // = 0.718;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
int returnPostscriptTextWidth( const wxString& aText, int aXSize,
|
|
|
|
bool aItalic, bool aBold );
|
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
/// Fine user scale adjust ( = 1.0 if no correction)
|
2012-05-03 18:37:56 +00:00
|
|
|
double plotScaleAdjX, plotScaleAdjY;
|
|
|
|
|
|
|
|
/// How to draw text
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_TEXT_MODE m_textMode;
|
2012-05-03 18:37:56 +00:00
|
|
|
};
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
class PS_PLOTTER : public PSLIKE_PLOTTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PS_PLOTTER()
|
|
|
|
{
|
2013-04-05 08:55:46 +00:00
|
|
|
// The phantom plot in postscript is an hack and reportedly
|
|
|
|
// crashes Adobe's own postscript interpreter!
|
2019-12-28 00:55:11 +00:00
|
|
|
m_textMode = PLOT_TEXT_MODE::STROKE;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
static wxString GetDefaultFileExtension()
|
|
|
|
{
|
2012-09-15 12:13:03 +00:00
|
|
|
return wxString( wxT( "ps" ) );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual PLOT_FORMAT GetPlotterType() const override
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_FORMAT::POST;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool StartPlot() override;
|
|
|
|
virtual bool EndPlot() override;
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetDash( PLOT_DASH_TYPE dashed ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScale, bool aMirror ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2013-05-05 07:17:48 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
|
2016-09-24 18:53:15 +00:00
|
|
|
int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2016-09-19 11:01:36 +00:00
|
|
|
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
|
|
|
|
void * aData = NULL ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScaleFactor ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void PenTo( const wxPoint& pos, char plume ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Text( const wxPoint& aPos,
|
2017-02-20 16:57:41 +00:00
|
|
|
const COLOR4D aColor,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxString& aText,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aOrient,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
2014-04-28 16:13:18 +00:00
|
|
|
bool aBold,
|
2016-09-19 11:01:36 +00:00
|
|
|
bool aMultilineAllowed = false,
|
|
|
|
void* aData = NULL ) override;
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void emitSetRGBColor( double r, double g, double b ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PDF_PLOTTER : public PSLIKE_PLOTTER
|
|
|
|
{
|
|
|
|
public:
|
2020-04-14 12:25:00 +00:00
|
|
|
PDF_PLOTTER() :
|
|
|
|
pageTreeHandle( 0 ),
|
|
|
|
fontResDictHandle( 0 ),
|
|
|
|
pageStreamHandle( 0 ),
|
|
|
|
streamLengthHandle( 0 ),
|
|
|
|
workFile( nullptr )
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual PLOT_FORMAT GetPlotterType() const override
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_FORMAT::PDF;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
static wxString GetDefaultFileExtension()
|
|
|
|
{
|
2012-09-15 12:13:03 +00:00
|
|
|
return wxString( wxT( "pdf" ) );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
/**
|
|
|
|
* Open or create the plot file aFullFilename
|
|
|
|
* @param aFullFilename = the full file name of the file to create
|
|
|
|
* @return true if success, false if the file cannot be created/opened
|
|
|
|
*
|
|
|
|
* The base class open the file in text mode, so we should have this
|
|
|
|
* function overlaid for PDF files, which are binary files
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool OpenFile( const wxString& aFullFilename ) override;
|
2012-10-13 18:54:33 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool StartPlot() override;
|
|
|
|
virtual bool EndPlot() override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void StartPage();
|
|
|
|
virtual void ClosePage();
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetDash( PLOT_DASH_TYPE dashed ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
/** PDF can have multiple pages, so SetPageSettings can be called
|
|
|
|
* with the outputFile open (but not inside a page stream!) */
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScale, bool aMirror ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2013-05-05 07:17:48 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
|
2016-09-24 18:53:15 +00:00
|
|
|
int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2016-09-19 11:01:36 +00:00
|
|
|
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
|
|
|
|
void * aData = NULL ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void PenTo( const wxPoint& pos, char plume ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
2017-02-20 16:57:41 +00:00
|
|
|
const COLOR4D aColor,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxString& aText,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aOrient,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
2014-04-28 16:13:18 +00:00
|
|
|
bool aBold,
|
2016-09-19 11:01:36 +00:00
|
|
|
bool aMultilineAllowed = false,
|
|
|
|
void* aData = NULL ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScaleFactor ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
2020-07-26 13:57:07 +00:00
|
|
|
/// convert a wxString unicode string to a char string compatible with the accepted
|
|
|
|
/// string PDF format (convert special chars and non ascii7 chars)
|
|
|
|
std::string encodeStringForPlotter( const wxString& aUnicode ) override;
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void emitSetRGBColor( double r, double g, double b ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
int allocPdfObject();
|
|
|
|
int startPdfObject(int handle = -1);
|
|
|
|
void closePdfObject();
|
|
|
|
int startPdfStream(int handle = -1);
|
|
|
|
void closePdfStream();
|
|
|
|
int pageTreeHandle; /// Handle to the root of the page tree object
|
|
|
|
int fontResDictHandle; /// Font resource dictionary
|
|
|
|
std::vector<int> pageHandles;/// Handles to the page objects
|
|
|
|
int pageStreamHandle; /// Handle of the page content object
|
|
|
|
int streamLengthHandle; /// Handle to the deferred stream length
|
|
|
|
wxString workFilename;
|
|
|
|
FILE* workFile; /// Temporary file to costruct the stream before zipping
|
|
|
|
std::vector<long> xrefTable; /// The PDF xref offset table
|
2009-06-28 16:50:42 +00:00
|
|
|
};
|
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
class SVG_PLOTTER : public PSLIKE_PLOTTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SVG_PLOTTER();
|
|
|
|
|
|
|
|
static wxString GetDefaultFileExtension()
|
|
|
|
{
|
|
|
|
return wxString( wxT( "svg" ) );
|
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual PLOT_FORMAT GetPlotterType() const override
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_FORMAT::SVG;
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
virtual void SetColor( COLOR4D color ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool StartPlot() override;
|
|
|
|
virtual bool EndPlot() override;
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetDash( PLOT_DASH_TYPE dashed ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScale, bool aMirror ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2013-05-05 07:17:48 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
|
2016-09-24 18:53:15 +00:00
|
|
|
int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2019-11-05 13:27:07 +00:00
|
|
|
virtual void BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
|
|
|
|
const wxPoint& aControl2, const wxPoint& aEnd,
|
|
|
|
int aTolerance,
|
|
|
|
int aLineThickness = USE_DEFAULT_LINE_WIDTH ) override;
|
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2016-09-19 11:01:36 +00:00
|
|
|
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
|
|
|
|
void * aData = NULL ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScaleFactor ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void PenTo( const wxPoint& pos, char plume ) override;
|
2019-01-27 00:58:33 +00:00
|
|
|
|
2020-04-20 22:02:03 +00:00
|
|
|
/**
|
|
|
|
* Function SetSvgCoordinatesFormat
|
|
|
|
* selection of SVG step size (number of digits needed for 1 mm or 1 inch )
|
|
|
|
* @param aResolution = number of digits in mantissa of coordinate
|
|
|
|
* use a value from 3-6
|
|
|
|
* do not use value > 6 to avoid overflow in PCBNEW
|
|
|
|
* do not use value > 4 to avoid overflow for other parts
|
|
|
|
* @param aUseInches = true to use inches, false to use mm (default)
|
|
|
|
*
|
|
|
|
* Should be called only after SetViewport() is called
|
|
|
|
*/
|
|
|
|
virtual void SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches = false ) override;
|
2019-01-27 00:58:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* calling this function allows one to define the beginning of a group
|
|
|
|
* of drawing items (used in SVG format to separate components)
|
|
|
|
* @param aData should be a string for the SVG ID tage
|
|
|
|
*/
|
|
|
|
virtual void StartBlock( void* aData ) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* calling this function allows one to define the end of a group of drawing
|
|
|
|
* items the group is started by StartBlock()
|
|
|
|
* @param aData should be null
|
|
|
|
*/
|
|
|
|
virtual void EndBlock( void* aData ) override;
|
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
virtual void Text( const wxPoint& aPos,
|
2017-02-20 16:57:41 +00:00
|
|
|
const COLOR4D aColor,
|
2012-09-15 12:13:03 +00:00
|
|
|
const wxString& aText,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aOrient,
|
2012-09-15 12:13:03 +00:00
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
2014-04-28 16:13:18 +00:00
|
|
|
bool aBold,
|
2016-09-19 11:01:36 +00:00
|
|
|
bool aMultilineAllowed = false,
|
|
|
|
void* aData = NULL ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
protected:
|
2020-04-20 22:02:03 +00:00
|
|
|
FILL_T m_fillMode; // true if the current contour
|
|
|
|
// rect, arc, circle, polygon must be filled
|
|
|
|
long m_pen_rgb_color; // current rgb color value: each color has
|
|
|
|
// a value 0 ... 255, and the 3 colors are
|
|
|
|
// grouped in a 3x8 bits value
|
|
|
|
// (written in hex to svg files)
|
|
|
|
long m_brush_rgb_color; // same as m_pen_rgb_color, used to fill
|
|
|
|
// some contours.
|
|
|
|
bool m_graphics_changed; // true if a pen/brush parameter is modified
|
|
|
|
// color, pen size, fil mode ...
|
|
|
|
// the new SVG stype must be output on file
|
|
|
|
PLOT_DASH_TYPE m_dashed; // plot line style
|
|
|
|
bool m_useInch; // is 0 if the step size is 10**-n*mm
|
|
|
|
// is 1 if the step size is 10**-n*inch
|
|
|
|
// Where n is given from m_precision
|
|
|
|
unsigned m_precision; // How fine the step size is
|
|
|
|
// Use 3-6 (3 means um precision, 6 nm precision) in pcbnew
|
|
|
|
// 3-4 in other moduls (avoid values >4 to avoid overflow)
|
|
|
|
// see also comment for m_useInch.
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* function emitSetRGBColor()
|
|
|
|
* initialize m_pen_rgb_color from reduced values r, g ,b
|
|
|
|
* ( reduced values are 0.0 to 1.0 )
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void emitSetRGBColor( double r, double g, double b ) override;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* function setSVGPlotStyle()
|
2019-01-30 15:25:57 +00:00
|
|
|
* 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
|
2012-09-15 12:13:03 +00:00
|
|
|
*/
|
2019-01-30 15:25:57 +00:00
|
|
|
void setSVGPlotStyle( bool aIsGroup = true, const std::string& aExtraStyle = {} );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* function setFillMode()
|
|
|
|
* prepare parameters for setSVGPlotStyle()
|
|
|
|
*/
|
|
|
|
void setFillMode( FILL_T fill );
|
|
|
|
};
|
|
|
|
|
2019-10-02 15:16:27 +00:00
|
|
|
/* Class to handle a D_CODE when plotting a board using Standard Aperture Templates
|
|
|
|
* (complex apertures need aperture macros
|
|
|
|
* 5 types:
|
|
|
|
* Circle (round)
|
|
|
|
* Rectangle
|
|
|
|
* Obround (oval)
|
|
|
|
* regular polygon
|
|
|
|
*
|
|
|
|
* We need round apertures to plot lines, so we also defined a aperture type for plotting
|
|
|
|
*/
|
2009-06-28 16:50:42 +00:00
|
|
|
#define FIRST_DCODE_VALUE 10 // D_CODE < 10 is a command, D_CODE >= 10 is a tool
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
class APERTURE
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2016-09-19 11:01:36 +00:00
|
|
|
public:
|
2012-05-03 18:37:56 +00:00
|
|
|
enum APERTURE_TYPE {
|
2019-10-02 15:16:27 +00:00
|
|
|
AT_CIRCLE = 1, // round aperture, to flash pads
|
|
|
|
AT_RECT = 2, // rect aperture, to flash pads
|
|
|
|
AT_PLOTTING = 3, // round aperture, to plot lines
|
|
|
|
AT_OVAL = 4, // oval aperture, to flash pads
|
|
|
|
AT_REGULAR_POLY = 5,// Regular polygon (n vertices, n = 3 .. 12, with rotation)
|
|
|
|
AT_REGULAR_POLY3, // Regular polygon 3 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY4, // Regular polygon 4 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY5, // Regular polygon 5 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY6, // Regular polygon 6 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY7, // Regular polygon 7 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY8, // Regular polygon 8 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY9, // Regular polygon 9 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY10, // Regular polygon 10 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY11, // Regular polygon 11 vertices, with rotation
|
|
|
|
AT_REGULAR_POLY12, // Regular polygon 12 vertices, with rotation
|
2009-06-28 16:50:42 +00:00
|
|
|
};
|
|
|
|
|
2019-10-02 15:16:27 +00:00
|
|
|
void SetSize( const wxSize& aSize )
|
|
|
|
{
|
|
|
|
m_Size = aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
const wxSize GetSize()
|
|
|
|
{
|
|
|
|
return m_Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDiameter( int aDiameter )
|
|
|
|
{
|
|
|
|
m_Size.x = aDiameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetDiameter()
|
|
|
|
{
|
|
|
|
return m_Size.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetVerticeCount( int aCount )
|
|
|
|
{
|
|
|
|
if( aCount < 3 )
|
|
|
|
aCount = 3;
|
|
|
|
else if( aCount > 12 )
|
|
|
|
aCount = 12;
|
|
|
|
|
|
|
|
m_Type = (APERTURE_TYPE)(AT_REGULAR_POLY3 - 3 + aCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetVerticeCount()
|
|
|
|
{
|
|
|
|
return m_Type - AT_REGULAR_POLY3 + 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetRotation( double aRotDegree )
|
|
|
|
{
|
|
|
|
// The rotation is stored in 1/1000 degree
|
|
|
|
m_Size.y = int( aRotDegree * 1000.0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
double GetRotation()
|
|
|
|
{
|
|
|
|
// The rotation is stored in 1/1000 degree
|
|
|
|
return m_Size.y / 1000.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type ( Line, rect , circulaire , ovale poly 3 to 12 vertices )
|
|
|
|
APERTURE_TYPE m_Type;
|
|
|
|
|
|
|
|
// horiz and Vert size, or diameter and rotation for regular polygon
|
|
|
|
// The diameter (for circle and polygons) is stored in m_Size.x
|
|
|
|
// the rotation is stored in m_Size.y in 1/1000 degree
|
|
|
|
wxSize m_Size;
|
|
|
|
|
|
|
|
// code number ( >= 10 )
|
|
|
|
int m_DCode;
|
|
|
|
|
|
|
|
// the attribute attached to this aperture
|
|
|
|
// Only one attribute is allowed by aperture
|
|
|
|
// 0 = no specific aperture attribute
|
|
|
|
int m_ApertureAttribute;
|
2009-06-28 16:50:42 +00:00
|
|
|
};
|
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class GERBER_PLOTTER : public PLOTTER
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
public:
|
2014-07-04 14:22:38 +00:00
|
|
|
GERBER_PLOTTER();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual PLOT_FORMAT GetPlotterType() const override
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_FORMAT::GERBER;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
2011-04-20 08:13:21 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
static wxString GetDefaultFileExtension()
|
|
|
|
{
|
2014-06-30 10:00:21 +00:00
|
|
|
return wxString( wxT( "gbr" ) );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
|
|
|
* Function StartPlot
|
|
|
|
* Write GERBER header to file
|
|
|
|
* initialize global variable g_Plot_PlotOutputFile
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool StartPlot() override;
|
|
|
|
virtual bool EndPlot() override;
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
|
2011-08-31 14:59:20 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
// RS274X has no dashing, nor colours
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetDash( PLOT_DASH_TYPE dashed ) override
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
virtual void SetColor( COLOR4D color ) override {}
|
2014-07-04 14:22:38 +00:00
|
|
|
// Currently, aScale and aMirror are not used in gerber plotter
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScale, bool aMirror ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2013-12-06 18:31:15 +00:00
|
|
|
virtual void Arc( const wxPoint& aCenter, double aStAngle, double aEndAngle,
|
2016-09-24 18:53:15 +00:00
|
|
|
int aRadius, FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
|
2014-10-19 20:20:16 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
|
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData ) override;
|
|
|
|
|
|
|
|
virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
|
|
|
|
int rayon, int width, EDA_DRAW_MODE_T tracemode, void* aData ) override;
|
|
|
|
virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
|
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData ) override;
|
|
|
|
virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
|
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData ) override;
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
|
|
|
* Gerber polygon: they can (and *should*) be filled with the
|
|
|
|
* appropriate G36/G37 sequence
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2016-09-19 11:01:36 +00:00
|
|
|
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
|
2019-10-06 11:39:50 +00:00
|
|
|
void* aData = nullptr ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void PenTo( const wxPoint& pos, char plume ) override;
|
2014-10-19 20:20:16 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void Text( const wxPoint& aPos,
|
2017-02-20 16:57:41 +00:00
|
|
|
const COLOR4D aColor,
|
2016-09-19 11:01:36 +00:00
|
|
|
const wxString& aText,
|
|
|
|
double aOrient,
|
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold,
|
|
|
|
bool aMultilineAllowed = false,
|
|
|
|
void* aData = NULL ) override;
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
|
|
|
* Filled circular flashes are stored as apertures
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode, void* aData ) override;
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filled oval flashes are handled as aperture in the 90 degree positions only
|
|
|
|
*/
|
2013-05-05 07:17:48 +00:00
|
|
|
virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, double orient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode, void* aData ) override;
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
2016-02-10 16:02:40 +00:00
|
|
|
* Filled rect flashes are handled as aperture in the 0 90 180 or 270 degree orientation only
|
|
|
|
* and as polygon for other orientations
|
|
|
|
* TODO: always use flashed shapes (aperture macros)
|
2014-10-19 20:20:16 +00:00
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
|
2016-09-19 11:01:36 +00:00
|
|
|
double orient, EDA_DRAW_MODE_T trace_mode, void* aData ) override;
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2016-02-10 16:02:40 +00:00
|
|
|
/**
|
|
|
|
* Roundrect pad at the moment are not handled as aperture, since
|
|
|
|
* they require aperture macros
|
|
|
|
* TODO: always use flashed shapes (aperture macros)
|
|
|
|
*/
|
|
|
|
virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
int aCornerRadius, double aOrient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2016-02-10 16:02:40 +00:00
|
|
|
virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
SHAPE_POLY_SET* aPolygons,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
|
|
|
* Trapezoidal pad at the moment are *never* handled as aperture, since
|
|
|
|
* they require aperture macros
|
2016-02-10 16:02:40 +00:00
|
|
|
* TODO: always use flashed shapes (aperture macros)
|
2014-10-19 20:20:16 +00:00
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
2017-06-16 07:14:28 +00:00
|
|
|
double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2019-10-02 15:16:27 +00:00
|
|
|
virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount,
|
|
|
|
double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
|
|
|
|
2019-10-06 11:39:50 +00:00
|
|
|
/**
|
|
|
|
* Plot a Gerber region: similar to PlotPoly but plot only filled polygon,
|
|
|
|
* and add the TA.AperFunction if aData contains this attribute, and clear it
|
|
|
|
* after plotting
|
|
|
|
*/
|
|
|
|
void PlotGerberRegion( const std::vector< wxPoint >& aCornerList,
|
|
|
|
void * aData = NULL );
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
|
|
|
* Change the plot polarity and begin a new layer
|
|
|
|
* Used to 'scratch off' silk screen away from solder mask
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive ) override;
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
/**
|
|
|
|
* Function SetGerberCoordinatesFormat
|
|
|
|
* selection of Gerber units and resolution (number of digits in mantissa)
|
|
|
|
* @param aResolution = number of digits in mantissa of coordinate
|
|
|
|
* use 5 or 6 for mm and 6 or 7 for inches
|
|
|
|
* do not use value > 6 (mm) or > 7 (in) to avoid overflow
|
|
|
|
* @param aUseInches = true to use inches, false to use mm (default)
|
|
|
|
*
|
|
|
|
* Should be called only after SetViewport() is called
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false ) override;
|
2014-07-04 14:22:38 +00:00
|
|
|
|
2018-12-09 09:23:07 +00:00
|
|
|
void UseX2format( bool aEnable ) { m_useX2format = aEnable; }
|
2016-09-19 11:01:36 +00:00
|
|
|
void UseX2NetAttributes( bool aEnable ) { m_useNetAttributes = aEnable; }
|
|
|
|
|
|
|
|
/**
|
2018-07-08 12:12:38 +00:00
|
|
|
* calling this function allows one to define the beginning of a group
|
2016-09-19 11:01:36 +00:00
|
|
|
* of drawing items (used in X2 format with netlist attributes)
|
|
|
|
* @param aData can define any parameter
|
|
|
|
*/
|
|
|
|
virtual void StartBlock( void* aData ) override;
|
|
|
|
|
|
|
|
/**
|
2018-07-08 12:12:38 +00:00
|
|
|
* calling this function allows one to define the end of a group of drawing
|
|
|
|
* items the group is started by StartBlock()
|
2016-09-19 11:01:36 +00:00
|
|
|
* (used in X2 format with netlist attributes)
|
|
|
|
* @param aData can define any parameter
|
|
|
|
*/
|
|
|
|
virtual void EndBlock( void* aData ) override;
|
|
|
|
|
2019-10-06 11:39:50 +00:00
|
|
|
/** Remove (clear) all attributes from object attributes dictionary (TO. and TA commands)
|
|
|
|
* similar to clearNetAttribute(), this is an unconditional reset of TO. and TA. attributes
|
|
|
|
*/
|
|
|
|
void ClearAllAttributes();
|
|
|
|
|
2019-11-03 19:23:31 +00:00
|
|
|
/**
|
|
|
|
* @return a index to the aperture in aperture list which meets the size and type of tool
|
|
|
|
* if the aperture does not exist, it is created and entered in aperture list
|
|
|
|
* @param aSize = the size of tool
|
|
|
|
* @param aType = the type ( shape ) of tool
|
|
|
|
* @param aApertureAttribute = an aperture attribute of the tool (a tool can have onlu one attribute)
|
|
|
|
* 0 = no specific attribute
|
|
|
|
*/
|
|
|
|
int GetOrCreateAperture( const wxSize& aSize,
|
|
|
|
APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2020-03-19 11:53:52 +00:00
|
|
|
/** Plot a round rect (a round rect shape in fact) as a Gerber region
|
|
|
|
* using lines and arcs for corners
|
|
|
|
* @param aRectCenter is the center of the rectangle
|
|
|
|
* @param aSize is the size of the rectangle
|
|
|
|
* @param aCornerRadius is the radius of the corners
|
|
|
|
* @param aOrient is the rotation of the rectangle
|
|
|
|
* Note: only the G36 ... G37 region is created.
|
|
|
|
*/
|
|
|
|
void plotRoundRectAsRegion( const wxPoint& aRectCenter, const wxSize& aSize,
|
|
|
|
int aCornerRadius, double aOrient );
|
|
|
|
/**
|
|
|
|
* Plot a Gerber arc.
|
|
|
|
* if aPlotInRegion = true, the current pen position will not be
|
|
|
|
* initialized to the arc start position, and therefore the arc can be used
|
|
|
|
* to define a region outline item
|
|
|
|
* a line will be created from current ^position to arc start point
|
|
|
|
* if aPlotInRegion = false, the current pen position will be initialized
|
|
|
|
* to the arc start position, to plot an usual arc item
|
|
|
|
* The line thickness is not initialized in plotArc, and must be initialized
|
|
|
|
* before calling it if needed.
|
|
|
|
*/
|
|
|
|
void plotArc( const wxPoint& aCenter, double aStAngle, double aEndAngle,
|
|
|
|
int aRadius, bool aPlotInRegion );
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
/**
|
|
|
|
* Pick an existing aperture or create a new one, matching the
|
|
|
|
* size, type and attributes.
|
|
|
|
* write the DCode selection on gerber file
|
|
|
|
*/
|
|
|
|
void selectAperture( const wxSize& aSize, APERTURE::APERTURE_TYPE aType,
|
|
|
|
int aApertureAttribute );
|
2019-10-02 15:16:27 +00:00
|
|
|
/**
|
|
|
|
* Pick an existing aperture or create a new one, matching the
|
|
|
|
* aDiameter, aPolygonRotation, type and attributes.
|
|
|
|
* It apply only to apertures with type = AT_REGULAR_POLY3 to AT_REGULAR_POLY12
|
|
|
|
* write the DCode selection on gerber file
|
|
|
|
*/
|
|
|
|
void selectAperture( int aDiameter, double aPolygonRotation,
|
|
|
|
APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
|
2014-10-19 20:20:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Emit a D-Code record, using proper conversions
|
|
|
|
* to format a leading zero omitted gerber coordinate
|
|
|
|
* (for n decimal positions, see header generation in start_plot
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void emitDcode( const DPOINT& pt, int dcode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
/**
|
|
|
|
* print a Gerber net attribute object record.
|
|
|
|
* In a gerber file, a net attribute is owned by a graphic object
|
|
|
|
* formatNetAttribute must be called before creating the object
|
|
|
|
* @param aData contains the dato to format.
|
|
|
|
* the generated string depends on the type of netlist info
|
|
|
|
*/
|
|
|
|
void formatNetAttribute( GBR_NETLIST_METADATA* aData );
|
|
|
|
|
|
|
|
/**
|
2019-08-20 17:22:30 +00:00
|
|
|
* clear a Gerber net attribute record (clear object attribute dictionary)
|
|
|
|
* and output the clear object attribute dictionary command to gerber file
|
2019-10-06 11:39:50 +00:00
|
|
|
* has effect only if a net attribute is stored in m_objectAttributesDictionnary
|
2016-09-19 11:01:36 +00:00
|
|
|
*/
|
|
|
|
void clearNetAttribute();
|
|
|
|
|
2019-11-03 19:23:31 +00:00
|
|
|
// the attributes dictionary created/modifed by %TO, attached to objects, when they are created
|
|
|
|
// by D01, D03, G36/G37 commands
|
2016-09-19 11:01:36 +00:00
|
|
|
// standard attributes are .P, .C and .N
|
|
|
|
// this is used by gerber readers when creating a new object. Cleared by %TD command
|
|
|
|
// Note: m_objectAttributesDictionnary can store more than one attribute
|
|
|
|
// the string stores the line(s) actually written to the gerber file
|
|
|
|
// it can store a .P, .C or .N attribute, or 2 or 3 attributes, separated by a \n char (EOL)
|
|
|
|
std::string m_objectAttributesDictionnary;
|
|
|
|
|
|
|
|
// The last aperture attribute generated (only one aperture attribute can be set)
|
|
|
|
int m_apertureAttribute;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
FILE* workFile;
|
|
|
|
FILE* finalFile;
|
2010-12-11 18:40:39 +00:00
|
|
|
wxString m_workFilename;
|
2010-03-31 16:59:32 +00:00
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
/**
|
|
|
|
* Generate the table of D codes
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
void writeApertureList();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
std::vector<APERTURE> m_apertures; // The list of available apertures
|
|
|
|
int m_currentApertureIdx; // The index of the current aperture in m_apertures
|
|
|
|
|
|
|
|
bool m_gerberUnitInch; // true if the gerber units are inches, false for mm
|
|
|
|
int m_gerberUnitFmt; // number of digits in mantissa.
|
|
|
|
// usually 6 in Inches and 5 or 6 in mm
|
|
|
|
bool m_useX2format; // Add X2 file header attributes. If false, attributes
|
|
|
|
// will be added as comments.
|
|
|
|
bool m_useNetAttributes; // In recent gerber files, netlist info can be added.
|
|
|
|
// It will be added if this param is true, using X2 or
|
|
|
|
// X1 format
|
2009-06-28 16:50:42 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class DXF_PLOTTER : public PLOTTER
|
2009-06-30 10:43:20 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
public:
|
2020-03-26 11:02:59 +00:00
|
|
|
DXF_PLOTTER() : m_textAsLines( false )
|
2009-08-29 10:20:48 +00:00
|
|
|
{
|
2020-03-26 11:02:59 +00:00
|
|
|
m_textAsLines = true;
|
2017-02-20 17:48:27 +00:00
|
|
|
m_currentColor = COLOR4D::BLACK;
|
2019-12-28 00:55:11 +00:00
|
|
|
m_currentLineType = PLOT_DASH_TYPE::SOLID;
|
2019-12-20 14:11:39 +00:00
|
|
|
SetUnits( DXF_UNITS::INCHES );
|
2009-08-29 10:20:48 +00:00
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual PLOT_FORMAT GetPlotterType() const override
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_FORMAT::DXF;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
static wxString GetDefaultFileExtension()
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2012-09-15 12:13:03 +00:00
|
|
|
return wxString( wxT( "dxf" ) );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DXF handles NATIVE text emitting TEXT entities
|
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetTextMode( PLOT_TEXT_MODE mode ) override
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( mode != PLOT_TEXT_MODE::DEFAULT )
|
2020-03-26 11:02:59 +00:00
|
|
|
m_textAsLines = ( mode != PLOT_TEXT_MODE::NATIVE );
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool StartPlot() override;
|
|
|
|
virtual bool EndPlot() override;
|
2009-06-30 10:43:20 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// For now we don't use 'thick' primitives, so no line width
|
2016-09-19 11:01:36 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
|
2009-06-30 10:43:20 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
currentPenWidth = 0;
|
2010-12-12 02:29:33 +00:00
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
virtual void SetDash( PLOT_DASH_TYPE dashed ) override;
|
2011-04-20 08:13:21 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
virtual void SetColor( COLOR4D color ) override;
|
2011-08-31 14:59:20 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2016-09-24 18:53:15 +00:00
|
|
|
double aScale, bool aMirror ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2016-09-24 18:53:15 +00:00
|
|
|
int width = USE_DEFAULT_LINE_WIDTH ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2016-09-19 11:01:36 +00:00
|
|
|
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode, void* aData ) override;
|
2013-12-06 18:31:15 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle,
|
2016-09-24 18:53:15 +00:00
|
|
|
int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
|
|
|
|
virtual void PenTo( const wxPoint& pos, char plume ) override;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode, void* aData ) override;
|
2013-05-05 07:17:48 +00:00
|
|
|
virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, double orient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode, void* aData ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
|
2016-09-19 11:01:36 +00:00
|
|
|
double orient, EDA_DRAW_MODE_T trace_mode, void* aData ) override;
|
2016-02-10 16:02:40 +00:00
|
|
|
virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
int aCornerRadius, double aOrient,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2016-02-10 16:02:40 +00:00
|
|
|
virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
|
|
|
SHAPE_POLY_SET* aPolygons,
|
2016-09-19 11:01:36 +00:00
|
|
|
EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
2017-06-16 07:14:28 +00:00
|
|
|
double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2019-10-02 15:16:27 +00:00
|
|
|
virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount,
|
|
|
|
double aOrient, EDA_DRAW_MODE_T aTraceMode, void* aData ) override;
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
2017-02-20 16:57:41 +00:00
|
|
|
const COLOR4D aColor,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxString& aText,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aOrient,
|
2012-05-03 18:37:56 +00:00
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
2014-04-28 16:13:18 +00:00
|
|
|
bool aBold,
|
2016-09-19 11:01:36 +00:00
|
|
|
bool aMultilineAllowed = false,
|
|
|
|
void* aData = NULL ) override;
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2019-06-13 00:28:22 +00:00
|
|
|
|
2019-07-10 14:47:12 +00:00
|
|
|
// Must be in the same order as the drop-down list in the plot dialog inside pcbnew
|
2019-12-20 14:11:39 +00:00
|
|
|
enum class DXF_UNITS
|
2019-06-13 00:28:22 +00:00
|
|
|
{
|
2019-12-20 14:11:39 +00:00
|
|
|
INCHES = 0,
|
|
|
|
MILLIMETERS = 1
|
2019-06-13 00:28:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the units to use for plotting the DXF file.
|
|
|
|
*
|
|
|
|
* @param aUnit - The units to use
|
|
|
|
*/
|
2019-07-10 14:47:12 +00:00
|
|
|
void SetUnits( DXF_UNITS aUnit );
|
2019-06-13 00:28:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The units currently enabled for plotting
|
|
|
|
*
|
|
|
|
* @return The currently configured units
|
|
|
|
*/
|
2019-07-10 14:47:12 +00:00
|
|
|
DXF_UNITS GetUnits() const
|
2019-06-13 00:28:22 +00:00
|
|
|
{
|
|
|
|
return m_plotUnits;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the scale factor to apply to convert the device units to be in the
|
|
|
|
* currently set units.
|
|
|
|
*
|
|
|
|
* @return Scaling factor to apply for unit conversion
|
|
|
|
*/
|
|
|
|
double GetUnitScaling() const
|
|
|
|
{
|
|
|
|
return m_unitScalingFactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the correct value for the $MEASUREMENT field given the current units
|
|
|
|
*
|
|
|
|
* @return the $MEASUREMENT directive field value
|
|
|
|
*/
|
|
|
|
unsigned int GetMeasurementDirective() const
|
|
|
|
{
|
|
|
|
return m_measurementDirective;
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
protected:
|
2020-03-26 11:02:59 +00:00
|
|
|
bool m_textAsLines;
|
|
|
|
COLOR4D m_currentColor;
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_DASH_TYPE m_currentLineType;
|
2019-06-13 00:28:22 +00:00
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
DXF_UNITS m_plotUnits;
|
|
|
|
double m_unitScalingFactor;
|
|
|
|
unsigned int m_measurementDirective;
|
2009-06-30 10:43:20 +00:00
|
|
|
};
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
class TITLE_BLOCK;
|
2020-03-26 11:02:59 +00:00
|
|
|
|
|
|
|
void PlotWorkSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK& aTitleBlock,
|
|
|
|
const PAGE_INFO& aPageInfo, int aSheetNumber, int aNumberOfSheets,
|
|
|
|
const wxString &aSheetDesc, const wxString &aFilename,
|
|
|
|
COLOR4D aColor = COLOR4D::UNSPECIFIED );
|
2012-08-29 16:59:50 +00:00
|
|
|
|
|
|
|
/** Returns the default plot extension for a format
|
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
wxString GetDefaultPlotExtension( PLOT_FORMAT aFormat );
|
2012-08-29 16:59:50 +00:00
|
|
|
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
#endif // PLOT_COMMON_H_
|