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>
|
2012-05-03 18:37:56 +00:00
|
|
|
#include <vector2d.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <common.h> // PAGE_INFO
|
2012-04-12 21:31:31 +00:00
|
|
|
#include <eda_text.h> // FILL_T
|
2010-10-08 20:40:57 +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
|
|
|
*/
|
2009-06-28 16:50:42 +00:00
|
|
|
enum PlotFormat {
|
2012-09-15 12:13:03 +00:00
|
|
|
PLOT_FIRST_FORMAT = 0,
|
|
|
|
PLOT_FORMAT_HPGL = PLOT_FIRST_FORMAT,
|
2008-03-22 05:55:06 +00:00
|
|
|
PLOT_FORMAT_GERBER,
|
2009-06-30 10:43:20 +00:00
|
|
|
PLOT_FORMAT_POST,
|
2012-05-03 18:37:56 +00:00
|
|
|
PLOT_FORMAT_DXF,
|
2012-09-15 12:13:03 +00:00
|
|
|
PLOT_FORMAT_PDF,
|
|
|
|
PLOT_FORMAT_SVG,
|
|
|
|
PLOT_LAST_FORMAT = PLOT_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
|
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
|
|
|
*/
|
2012-08-29 16:59:50 +00:00
|
|
|
enum PlotTextMode {
|
|
|
|
PLOTTEXTMODE_STROKE,
|
|
|
|
PLOTTEXTMODE_NATIVE,
|
|
|
|
PLOTTEXTMODE_PHANTOM
|
2012-05-03 18:37:56 +00:00
|
|
|
};
|
2011-12-22 21:57:50 +00:00
|
|
|
|
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:
|
2012-08-29 16:59:50 +00:00
|
|
|
static const int DEFAULT_LINE_WIDTH = -1;
|
|
|
|
|
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
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual PlotFormat 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
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetNegative( bool _negative )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
negativeMode = _negative;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetColorMode( bool _color_mode )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
colorMode = _color_mode;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
bool GetColorMode() const
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
return colorMode;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetPageSettings( const PAGE_INFO& aPageSettings );
|
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
|
|
|
|
*/
|
|
|
|
virtual void SetCurrentLineWidth( int width ) = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/**
|
|
|
|
* Set the default line width. Used at the beginning and when a width
|
2012-08-29 16:59:50 +00:00
|
|
|
* of -1 (DEFAULT_LINE_WIDTH) is requested.
|
2012-05-03 18:37:56 +00:00
|
|
|
* @param width is specified in IUs
|
|
|
|
*/
|
|
|
|
virtual void SetDefaultLineWidth( int width ) = 0;
|
|
|
|
|
|
|
|
virtual int GetCurrentLineWidth() const
|
2012-01-07 06:02:38 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
return currentPenWidth;
|
2012-01-07 06:02:38 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetColor( EDA_COLOR_T color ) = 0;
|
|
|
|
|
|
|
|
virtual void SetDash( bool dashed ) = 0;
|
|
|
|
|
|
|
|
virtual void SetCreator( const wxString& _creator )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
creator = _creator;
|
|
|
|
}
|
|
|
|
|
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; }
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
// Low level primitives
|
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH ) = 0;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH ) = 0;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T fill, int width = DEFAULT_LINE_WIDTH );
|
2011-04-20 08:13:21 +00:00
|
|
|
|
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 )
|
|
|
|
* @param aCornerList = corners list
|
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
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill,
|
2013-02-06 15:21:37 +00:00
|
|
|
int aWidth = DEFAULT_LINE_WIDTH ) = 0;
|
2011-04-20 08:13:21 +00:00
|
|
|
|
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,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void ThickArc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
|
|
|
|
int width, EDA_DRAW_MODE_T tracemode );
|
|
|
|
virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
|
|
|
|
EDA_DRAW_MODE_T tracemode );
|
|
|
|
virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
|
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Flash primitives
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode ) = 0;
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
|
|
|
|
EDA_DRAW_MODE_T trace_mode ) = 0;
|
|
|
|
virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
|
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode ) = 0;
|
2010-12-11 18:40:39 +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
|
|
|
|
* @param aTrace_Mode = FILLED or SKETCH
|
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode ) = 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
|
|
|
|
*/
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
|
|
|
enum EDA_COLOR_T aColor,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold );
|
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;
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
virtual void SetTextMode( PlotTextMode mode )
|
|
|
|
{
|
2013-02-06 15:21:37 +00:00
|
|
|
// NOP for most plotters
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2010-12-12 02:29:33 +00:00
|
|
|
// These are marker subcomponents
|
2012-05-03 18:37:56 +00:00
|
|
|
void markerCircle( const wxPoint& pos, int radius );
|
|
|
|
void markerHBar( const wxPoint& pos, int radius );
|
|
|
|
void markerSlash( const wxPoint& pos, int radius );
|
|
|
|
void markerBackSlash( const wxPoint& pos, int radius );
|
|
|
|
void markerVBar( const wxPoint& pos, int radius );
|
|
|
|
void markerSquare( const wxPoint& position, int radius );
|
|
|
|
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
|
2012-05-03 18:37:56 +00:00
|
|
|
void segmentAsOval( const wxPoint& start, const wxPoint& end, int width,
|
|
|
|
EDA_DRAW_MODE_T tracemode );
|
|
|
|
void sketchOval( const wxPoint& pos, const wxSize& size, int orient,
|
|
|
|
int width );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
// Coordinate and scaling conversion functions
|
|
|
|
virtual DPOINT userToDeviceCoordinates( const wxPoint& pos );
|
|
|
|
virtual DPOINT userToDeviceSize( const wxSize& size );
|
|
|
|
virtual double userToDeviceSize( double size );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
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
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
/* Device scale (how many IUs in a decimil - always); it's a double
|
|
|
|
* 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;
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/// Device scale (from IUs to device units - usually decimils)
|
|
|
|
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
|
|
|
|
|
|
|
/// 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
|
2012-09-15 12:13:03 +00:00
|
|
|
bool colorMode; /// true to plot in color, false to plot in black and white
|
|
|
|
bool negativeMode; /// true to generate a negative image (PS mode mainly)
|
2012-05-03 18:37:56 +00:00
|
|
|
int defaultPenWidth;
|
|
|
|
int currentPenWidth;
|
|
|
|
/// Current pen state: 'U', 'D' or 'Z' (see PenTo)
|
|
|
|
char penState;
|
|
|
|
/// Last pen positions; set to -1,-1 when the pen is at rest
|
|
|
|
wxPoint penLastpos;
|
2010-12-11 18:40:39 +00:00
|
|
|
bool plotMirror;
|
2009-06-28 16:50:42 +00:00
|
|
|
wxString creator;
|
|
|
|
wxString filename;
|
2011-12-22 21:57:50 +00:00
|
|
|
PAGE_INFO pageInfo;
|
2012-05-03 18:37:56 +00:00
|
|
|
/// Paper size in IU - not in mils
|
|
|
|
wxSize paperSize;
|
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
|
|
|
|
|
|
|
virtual PlotFormat GetPlotterType() const
|
2009-08-29 10:20:48 +00:00
|
|
|
{
|
2012-09-28 17:47:41 +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
|
|
|
}
|
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
virtual bool StartPlot();
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual bool EndPlot();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/// HPGL doesn't handle line thickness or color
|
|
|
|
virtual void SetCurrentLineWidth( int width )
|
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
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetDefaultLineWidth( int width ) {};
|
|
|
|
virtual void SetDash( bool dashed );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetColor( EDA_COLOR_T color ) {};
|
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
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetPenDiameter( double diameter )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
penDiameter = diameter;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetPenOverlap( double overlap )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
penOverlap = overlap;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2013-02-06 15:21:37 +00:00
|
|
|
double aScale, bool aMirror );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2013-02-06 15:21:37 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH);
|
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,
|
|
|
|
EDA_DRAW_MODE_T tracemode );
|
|
|
|
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T fill, int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PenTo( const wxPoint& pos, char plume );
|
|
|
|
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
|
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
|
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
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;
|
|
|
|
double penOverlap;
|
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:
|
2012-09-24 06:39:59 +00:00
|
|
|
PSLIKE_PLOTTER() : plotScaleAdjX( 1 ), plotScaleAdjY( 1 ),
|
2012-08-29 16:59:50 +00:00
|
|
|
m_textMode( PLOTTEXTMODE_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
|
|
|
*/
|
2012-08-29 16:59:50 +00:00
|
|
|
virtual void SetTextMode( PlotTextMode mode )
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2012-08-29 16:59:50 +00:00
|
|
|
m_textMode = mode;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetDefaultLineWidth( int width );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
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
|
|
|
|
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
|
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
|
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
|
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
|
|
|
|
|
|
|
/** 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
|
|
|
*/
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetColor( EDA_COLOR_T color );
|
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,
|
|
|
|
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 );
|
|
|
|
void fputsPostscriptString(FILE *fout, const wxString& txt);
|
|
|
|
|
|
|
|
/// 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
|
2012-08-29 16:59:50 +00:00
|
|
|
PlotTextMode 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()
|
|
|
|
{
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual PlotFormat GetPlotterType() const
|
|
|
|
{
|
2012-09-15 12:13:03 +00:00
|
|
|
return PLOT_FORMAT_POST;
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
virtual bool StartPlot();
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual bool EndPlot();
|
|
|
|
virtual void SetCurrentLineWidth( int width );
|
|
|
|
virtual void SetDash( bool dashed );
|
|
|
|
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2013-02-06 15:21:37 +00:00
|
|
|
double aScale, bool aMirror );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle,
|
2013-02-06 15:21:37 +00:00
|
|
|
int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
|
|
|
|
double aScaleFactor );
|
|
|
|
|
|
|
|
virtual void PenTo( const wxPoint& pos, char plume );
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
|
|
|
enum EDA_COLOR_T aColor,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold );
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void emitSetRGBColor( double r, double g, double b );
|
|
|
|
};
|
|
|
|
|
|
|
|
class PDF_PLOTTER : public PSLIKE_PLOTTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PDF_PLOTTER() : pageStreamHandle( 0 ), workFile( NULL )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual PlotFormat GetPlotterType() const
|
|
|
|
{
|
2012-09-15 12:13:03 +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
|
|
|
|
*/
|
|
|
|
virtual bool OpenFile( const wxString& aFullFilename );
|
|
|
|
|
|
|
|
virtual bool StartPlot();
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual bool EndPlot();
|
|
|
|
virtual void StartPage();
|
|
|
|
virtual void ClosePage();
|
|
|
|
virtual void SetCurrentLineWidth( int width );
|
|
|
|
virtual void SetDash( bool dashed );
|
|
|
|
|
|
|
|
/** PDF can have multiple pages, so SetPageSettings can be called
|
|
|
|
* with the outputFile open (but not inside a page stream!) */
|
|
|
|
virtual void SetPageSettings( const PAGE_INFO& aPageSettings );
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2013-02-06 15:21:37 +00:00
|
|
|
double aScale, bool aMirror );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle,
|
2013-02-06 15:21:37 +00:00
|
|
|
int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH);
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PenTo( const wxPoint& pos, char plume );
|
|
|
|
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
|
|
|
enum EDA_COLOR_T aColor,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold );
|
|
|
|
|
|
|
|
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
|
|
|
|
double aScaleFactor );
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void emitSetRGBColor( double r, double g, double b );
|
|
|
|
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" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual PlotFormat GetPlotterType() const
|
|
|
|
{
|
|
|
|
return PLOT_FORMAT_SVG;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetColor( EDA_COLOR_T color );
|
2012-10-13 18:54:33 +00:00
|
|
|
virtual bool StartPlot();
|
2012-09-15 12:13:03 +00:00
|
|
|
virtual bool EndPlot();
|
|
|
|
virtual void SetCurrentLineWidth( int width );
|
|
|
|
virtual void SetDash( bool dashed );
|
|
|
|
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2013-02-06 15:21:37 +00:00
|
|
|
double aScale, bool aMirror );
|
2012-09-15 12:13:03 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
|
|
|
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle,
|
2013-02-06 15:21:37 +00:00
|
|
|
int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
|
|
|
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
|
|
|
|
|
|
|
|
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
|
|
|
|
double aScaleFactor );
|
|
|
|
|
|
|
|
virtual void PenTo( const wxPoint& pos, char plume );
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
|
|
|
enum EDA_COLOR_T aColor,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function emitSetRGBColor()
|
|
|
|
* initialize m_pen_rgb_color from reduced values r, g ,b
|
|
|
|
* ( reduced values are 0.0 to 1.0 )
|
|
|
|
*/
|
|
|
|
virtual void emitSetRGBColor( double r, double g, double b );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function setSVGPlotStyle()
|
|
|
|
* output the string which define pen and brush color, shape, transparence
|
|
|
|
*/
|
|
|
|
void setSVGPlotStyle();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function setFillMode()
|
|
|
|
* prepare parameters for setSVGPlotStyle()
|
|
|
|
*/
|
|
|
|
void setFillMode( FILL_T fill );
|
|
|
|
};
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
/* Class to handle a D_CODE when plotting a board : */
|
|
|
|
#define FIRST_DCODE_VALUE 10 // D_CODE < 10 is a command, D_CODE >= 10 is a tool
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
struct APERTURE
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
enum APERTURE_TYPE {
|
2009-06-28 16:50:42 +00:00
|
|
|
Circle = 1,
|
|
|
|
Rect = 2,
|
|
|
|
Plotting = 3,
|
|
|
|
Oval = 4
|
|
|
|
};
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
wxSize Size; // horiz and Vert size
|
|
|
|
APERTURE_TYPE Type; // Type ( Line, rect , circulaire , ovale .. )
|
|
|
|
int DCode; // code number ( >= 10 );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
|
|
|
/* Trivia question: WHY Gerber decided to use D instead of the usual T for
|
2012-05-03 18:37:56 +00:00
|
|
|
* tool change? */
|
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:
|
2012-05-03 18:37:56 +00:00
|
|
|
GERBER_PLOTTER()
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
workFile = 0;
|
|
|
|
finalFile = 0;
|
|
|
|
currentAperture = apertures.end();
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual PlotFormat GetPlotterType() const
|
|
|
|
{
|
2012-09-15 12:13:03 +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()
|
|
|
|
{
|
2012-09-15 12:13:03 +00:00
|
|
|
return wxString( wxT( "pho" ) );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
virtual bool StartPlot();
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual bool EndPlot();
|
|
|
|
virtual void SetCurrentLineWidth( int width );
|
|
|
|
virtual void SetDefaultLineWidth( int width );
|
2011-08-31 14:59:20 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
// RS274X has no dashing, nor colours
|
|
|
|
virtual void SetDash( bool dashed ) {};
|
|
|
|
virtual void SetColor( EDA_COLOR_T color ) {};
|
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2013-02-06 15:21:37 +00:00
|
|
|
double aScale, bool aMirror );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-07-15 17:28:52 +00:00
|
|
|
virtual void Arc( const wxPoint& aCenter, int aStAngle, int aEndAngle, int aRadius,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
|
|
|
|
virtual void PenTo( const wxPoint& pos, char plume );
|
|
|
|
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
|
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
|
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive );
|
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 selectAperture( const wxSize& size, APERTURE::APERTURE_TYPE type );
|
|
|
|
void emitDcode( const DPOINT& pt, int dcode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
std::vector<APERTURE>::iterator
|
2013-02-06 15:21:37 +00:00
|
|
|
getAperture( const wxSize& size, APERTURE::APERTURE_TYPE type );
|
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
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
void writeApertureList();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
std::vector<APERTURE> apertures;
|
2012-05-03 18:37:56 +00:00
|
|
|
std::vector<APERTURE>::iterator currentAperture;
|
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:
|
2012-05-03 18:37:56 +00:00
|
|
|
DXF_PLOTTER() : textAsLines( false )
|
2009-08-29 10:20:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual PlotFormat GetPlotterType() const
|
|
|
|
{
|
2012-09-15 12:13:03 +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
|
|
|
|
*/
|
|
|
|
virtual void SetTextMode( PlotTextMode mode )
|
|
|
|
{
|
|
|
|
textAsLines = ( mode != PLOTTEXTMODE_NATIVE );
|
2012-05-03 18:37:56 +00:00
|
|
|
}
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
virtual bool StartPlot();
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual bool EndPlot();
|
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
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetCurrentLineWidth( int width )
|
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
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetDefaultLineWidth( int width )
|
2009-06-30 10:43:20 +00:00
|
|
|
{
|
2010-12-12 02:29:33 +00:00
|
|
|
// DXF lines are infinitesimal
|
2012-05-03 18:37:56 +00:00
|
|
|
defaultPenWidth = 0;
|
2010-12-12 02:29:33 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetDash( bool dashed );
|
2011-04-20 08:13:21 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetColor( EDA_COLOR_T color );
|
2011-08-31 14:59:20 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
2013-02-06 15:21:37 +00:00
|
|
|
double aScale, bool aMirror );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
|
2012-08-29 16:59:50 +00:00
|
|
|
int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
|
|
|
|
EDA_DRAW_MODE_T tracemode );
|
|
|
|
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
|
2012-08-29 16:59:50 +00:00
|
|
|
FILL_T fill, int width = DEFAULT_LINE_WIDTH );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void PenTo( const wxPoint& pos, char plume );
|
|
|
|
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2012-05-03 18:37:56 +00:00
|
|
|
virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
|
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
|
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
|
|
|
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
|
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
|
|
|
|
|
|
|
virtual void Text( const wxPoint& aPos,
|
|
|
|
enum EDA_COLOR_T aColor,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold );
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
protected:
|
2012-05-03 18:37:56 +00:00
|
|
|
bool textAsLines;
|
|
|
|
int currentColor;
|
2009-06-30 10:43:20 +00:00
|
|
|
};
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
class TITLE_BLOCK;
|
|
|
|
void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
|
|
|
|
const PAGE_INFO& aPageInfo,
|
|
|
|
int aSheetNumber, int aNumberOfSheets,
|
|
|
|
const wxString &aSheetDesc,
|
|
|
|
const wxString &aFilename );
|
|
|
|
|
|
|
|
/** Returns the default plot extension for a format
|
|
|
|
*/
|
|
|
|
wxString GetDefaultPlotExtension( PlotFormat aFormat );
|
|
|
|
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
#endif // PLOT_COMMON_H_
|