2009-01-19 19:08:42 +00:00
|
|
|
/**
|
|
|
|
* Common plot library \n
|
|
|
|
* Plot settings, postscript plotting, gerber plotting.
|
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-01-23 04:33:36 +00:00
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <common.h> // PAGE_INFO
|
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 {
|
2008-03-22 05:55:06 +00:00
|
|
|
PLOT_FORMAT_HPGL,
|
|
|
|
PLOT_FORMAT_GERBER,
|
2009-06-30 10:43:20 +00:00
|
|
|
PLOT_FORMAT_POST,
|
|
|
|
PLOT_FORMAT_DXF
|
2008-03-22 05:55:06 +00:00
|
|
|
};
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
|
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:
|
2011-12-31 05:44:00 +00:00
|
|
|
PLOTTER( PlotFormat aPlotType );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
virtual ~PLOTTER()
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2010-12-12 02:29:33 +00:00
|
|
|
// Emergency cleanup
|
2009-06-28 16:50:42 +00:00
|
|
|
if( output_file )
|
|
|
|
{
|
|
|
|
fclose( output_file );
|
|
|
|
}
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function GetPlotterType
|
2009-08-29 10:20:48 +00:00
|
|
|
* @return the format of the plot file
|
|
|
|
*/
|
2011-12-31 05:44:00 +00:00
|
|
|
PlotFormat GetPlotterType() { return m_PlotType; }
|
2009-08-29 10:20:48 +00:00
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
virtual bool start_plot( FILE* fout ) = 0;
|
|
|
|
virtual bool end_plot() = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
|
|
|
virtual void set_negative( bool _negative )
|
|
|
|
{
|
|
|
|
negative_mode = _negative;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set_color_mode( bool _color_mode )
|
|
|
|
{
|
|
|
|
color_mode = _color_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool get_color_mode() const
|
|
|
|
{
|
|
|
|
return color_mode;
|
|
|
|
}
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
void SetPageSettings( const PAGE_INFO& aPageSettings );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
|
|
|
virtual void set_current_line_width( int width ) = 0;
|
|
|
|
virtual void set_default_line_width( int width ) = 0;
|
|
|
|
virtual void set_color( int color ) = 0;
|
|
|
|
virtual void set_dash( bool dashed ) = 0;
|
|
|
|
|
2012-01-07 06:02:38 +00:00
|
|
|
virtual int get_current_line_width()
|
|
|
|
{
|
|
|
|
return current_pen_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set_plot_width_adj( double width )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual double get_plot_width_adj()
|
|
|
|
{
|
|
|
|
return 0.;
|
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void set_creator( const wxString& _creator )
|
|
|
|
{
|
|
|
|
creator = _creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set_filename( const wxString& _filename )
|
|
|
|
{
|
|
|
|
filename = _filename;
|
|
|
|
}
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
/// Set the plot offset for the current plotting
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror ) = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Standard primitives
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill,
|
|
|
|
int width = -1 ) = 0;
|
|
|
|
virtual void circle( wxPoint pos, int diametre, FILL_T fill,
|
|
|
|
int width = -1 ) = 0;
|
|
|
|
virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
|
|
|
|
FILL_T fill, int width = -1 );
|
2011-04-20 08:13:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function PlotPoly
|
|
|
|
* @brief Draw a polygon ( filled or not )
|
|
|
|
* @param aCornerList = corners list
|
|
|
|
* @param aFill :if true : filled polygon
|
|
|
|
* @param aWidth = line width
|
|
|
|
*/
|
|
|
|
virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1 ) = 0;
|
|
|
|
|
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)
|
|
|
|
*/
|
|
|
|
virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor ) = 0;
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void thick_segment( wxPoint start, wxPoint end, int width,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void thick_arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
|
2012-01-03 17:14:17 +00:00
|
|
|
int width, EDA_DRAW_MODE_T tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void thick_rect( wxPoint p1, wxPoint p2, int width,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void thick_circle( wxPoint pos, int diametre, int width,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void pen_to( wxPoint pos, char plume ) = 0;
|
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Flash primitives
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode ) = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode ) = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
2012-01-03 17:14:17 +00:00
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode ) = 0;
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-09-13 11:51:09 +00:00
|
|
|
/** virtual function flash_pad_trapez
|
|
|
|
* flash a trapezoidal pad
|
|
|
|
* @param aPadPos = the position of the shape
|
|
|
|
* @param aCorners = the list of 4 corners positions, relative to the shape position, pad orientation 0
|
|
|
|
* @param aPadOrient = the rotation of the shape
|
|
|
|
* @param aTrace_Mode = FILLED or SKETCH
|
|
|
|
*/
|
|
|
|
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
2012-01-03 17:14:17 +00:00
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode ) = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Convenience functions
|
2009-06-28 16:50:42 +00:00
|
|
|
void move_to( wxPoint pos )
|
|
|
|
{
|
|
|
|
pen_to( pos, 'U' );
|
|
|
|
}
|
|
|
|
|
|
|
|
void line_to( wxPoint pos )
|
|
|
|
{
|
|
|
|
pen_to( pos, 'D' );
|
|
|
|
}
|
|
|
|
|
|
|
|
void finish_to( wxPoint pos )
|
|
|
|
{
|
|
|
|
pen_to( pos, 'D' );
|
|
|
|
pen_to( pos, 'Z' );
|
|
|
|
}
|
|
|
|
|
|
|
|
void pen_finish()
|
|
|
|
{
|
2010-12-12 02:29:33 +00:00
|
|
|
// Shortcut
|
2009-06-28 16:50:42 +00:00
|
|
|
pen_to( wxPoint( 0, 0 ), 'Z' );
|
|
|
|
}
|
|
|
|
|
|
|
|
void text( const wxPoint& aPos,
|
|
|
|
enum EDA_Colors aColor,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
2012-01-03 17:14:17 +00:00
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
2009-06-28 16:50:42 +00:00
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
void marker( const wxPoint& position, int diametre, int 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.
|
2010-12-12 02:29:33 +00:00
|
|
|
* @param aPositive is the layer polarity and true for positive.
|
2010-12-06 22:05:12 +00:00
|
|
|
*/
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive ) = 0;
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2010-12-12 02:29:33 +00:00
|
|
|
// These are marker subcomponents
|
2009-06-28 16:50:42 +00:00
|
|
|
void center_square( const wxPoint& position, int diametre, FILL_T fill );
|
|
|
|
void center_lozenge( const wxPoint& position, int diametre, FILL_T fill );
|
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Helper function for sketched filler segment
|
2009-06-28 16:50:42 +00:00
|
|
|
void segment_as_oval( wxPoint start, wxPoint end, int width,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
void sketch_oval( wxPoint pos, wxSize size, int orient, int width );
|
|
|
|
|
|
|
|
virtual void user_to_device_coordinates( wxPoint& pos );
|
|
|
|
virtual void user_to_device_size( wxSize& size );
|
|
|
|
virtual double user_to_device_size( double size );
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
PlotFormat m_PlotType;
|
|
|
|
|
|
|
|
/// Plot scale
|
2009-06-28 16:50:42 +00:00
|
|
|
double plot_scale;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
/// Device scale (from decimils to device units)
|
2009-06-28 16:50:42 +00:00
|
|
|
double device_scale;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
/// Plot offset (in decimils)
|
2009-06-28 16:50:42 +00:00
|
|
|
wxPoint plot_offset;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
/// Output file
|
2009-06-28 16:50:42 +00:00
|
|
|
FILE* output_file;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// Pen handling
|
2009-06-28 16:50:42 +00:00
|
|
|
bool color_mode, negative_mode;
|
|
|
|
int default_pen_width;
|
|
|
|
int current_pen_width;
|
|
|
|
char pen_state;
|
|
|
|
wxPoint pen_lastpos;
|
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;
|
2009-06-28 16:50:42 +00:00
|
|
|
wxSize paper_size;
|
|
|
|
};
|
|
|
|
|
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:
|
|
|
|
HPGL_PLOTTER() :
|
|
|
|
PLOTTER( PLOT_FORMAT_HPGL )
|
2009-08-29 10:20:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
virtual bool start_plot( FILE* fout );
|
|
|
|
virtual bool end_plot();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
// HPGL doesn't handle line thickness or color
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void set_current_line_width( int width )
|
|
|
|
{
|
2010-12-12 02:29:33 +00:00
|
|
|
// Handy override
|
2009-10-05 17:52:41 +00:00
|
|
|
current_pen_width = wxRound( pen_diameter );
|
2011-12-31 05:44:00 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void set_default_line_width( int width ) {};
|
|
|
|
virtual void set_dash( bool dashed );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void set_color( int color ) {};
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void set_pen_speed( int speed )
|
|
|
|
{
|
|
|
|
wxASSERT( output_file == 0 );
|
|
|
|
pen_speed = speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set_pen_number( int number )
|
|
|
|
{
|
|
|
|
wxASSERT( output_file == 0 );
|
|
|
|
pen_number = number;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set_pen_diameter( double diameter )
|
|
|
|
{
|
|
|
|
wxASSERT( output_file == 0 );
|
|
|
|
pen_diameter = diameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set_pen_overlap( double overlap )
|
|
|
|
{
|
|
|
|
wxASSERT( output_file == 0 );
|
|
|
|
pen_overlap = overlap;
|
|
|
|
}
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
|
|
|
|
virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2011-04-20 08:13:21 +00:00
|
|
|
/*
|
|
|
|
* Function PlotPoly
|
|
|
|
* Draw a polygon (filled or not) in HPGL format
|
|
|
|
* param aCornerList = corners list
|
|
|
|
* param aFill :if true : filled polygon
|
|
|
|
* param aWidth = line width
|
|
|
|
*/
|
|
|
|
virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1);
|
|
|
|
|
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
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void thick_segment( wxPoint start, wxPoint end, int width,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
|
|
|
|
FILL_T fill, int width = -1 );
|
|
|
|
virtual void pen_to( wxPoint pos, char plume );
|
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
2012-01-03 17:14:17 +00:00
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-09-13 11:51:09 +00:00
|
|
|
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
2012-01-03 17:14:17 +00:00
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive ) {}
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2010-12-11 18:40:39 +00:00
|
|
|
void pen_control( int plume );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
|
|
|
int pen_speed;
|
|
|
|
int pen_number;
|
|
|
|
double pen_diameter;
|
|
|
|
double pen_overlap;
|
|
|
|
};
|
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class PS_PLOTTER : public PLOTTER
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
public:
|
|
|
|
PS_PLOTTER() :
|
|
|
|
PLOTTER( PLOT_FORMAT_POST )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
plot_scale_adjX = 1;
|
|
|
|
plot_scale_adjY = 1;
|
|
|
|
}
|
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
virtual bool start_plot( FILE* fout );
|
|
|
|
virtual bool end_plot();
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void set_current_line_width( int width );
|
|
|
|
virtual void set_default_line_width( int width );
|
|
|
|
virtual void set_dash( bool dashed );
|
|
|
|
virtual void set_color( int color );
|
|
|
|
|
|
|
|
void set_scale_adjust( double scaleX, double scaleY )
|
|
|
|
{
|
|
|
|
plot_scale_adjX = scaleX;
|
|
|
|
plot_scale_adjY = scaleY;
|
|
|
|
}
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2012-01-07 21:49:24 +00:00
|
|
|
virtual void set_plot_width_adj( double width )
|
|
|
|
{
|
|
|
|
plot_width_adj = width;
|
|
|
|
}
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2012-01-07 21:49:24 +00:00
|
|
|
virtual double get_plot_width_adj()
|
|
|
|
{
|
|
|
|
return plot_width_adj;
|
|
|
|
}
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
|
|
|
|
virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
|
|
|
|
virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
|
|
|
|
FILL_T fill, int width = -1 );
|
2011-04-20 08:13:21 +00:00
|
|
|
/*
|
|
|
|
* Function PlotPoly
|
|
|
|
* Draw a polygon (filled or not) in POSTSCRIPT format
|
|
|
|
* param aCornerList = corners list
|
|
|
|
* param aFill :if true : filled polygon
|
|
|
|
* param aWidth = line width
|
|
|
|
*/
|
|
|
|
virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1);
|
|
|
|
|
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
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void pen_to( wxPoint pos, char plume );
|
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
2012-01-03 17:14:17 +00:00
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-09-13 11:51:09 +00:00
|
|
|
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
2012-01-03 17:14:17 +00:00
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive ) {}
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
|
|
|
double plot_scale_adjX, plot_scale_adjY;
|
2012-01-07 06:02:38 +00:00
|
|
|
double plot_width_adj;
|
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
|
|
|
{
|
|
|
|
enum Aperture_Type {
|
|
|
|
Circle = 1,
|
|
|
|
Rect = 2,
|
|
|
|
Plotting = 3,
|
|
|
|
Oval = 4
|
|
|
|
};
|
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
wxSize size; // horiz and Vert size
|
|
|
|
Aperture_Type type; // Type ( Line, rect , circulaire , ovale .. )
|
|
|
|
int D_code; // 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
|
|
|
|
* tool change? */
|
|
|
|
};
|
|
|
|
|
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:
|
|
|
|
GERBER_PLOTTER() :
|
|
|
|
PLOTTER( PLOT_FORMAT_GERBER )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
work_file = 0;
|
|
|
|
final_file = 0;
|
|
|
|
current_aperture = apertures.end();
|
|
|
|
}
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual bool start_plot( FILE* fout );
|
|
|
|
virtual bool end_plot();
|
|
|
|
virtual void set_current_line_width( int width );
|
|
|
|
virtual void set_default_line_width( int width );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
// RS274X has no dashing, nor colours
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void set_dash( bool dashed ) {};
|
|
|
|
virtual void set_color( int color ) {};
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
|
|
|
|
virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
|
|
|
|
virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
|
2011-04-20 08:13:21 +00:00
|
|
|
/*
|
|
|
|
* Function PlotPoly
|
|
|
|
* Draw a polygon (filled or not) in GERBER format
|
|
|
|
* param aCornerList = corners list
|
|
|
|
* param aFill :if true : filled polygon
|
|
|
|
* param aWidth = line width
|
|
|
|
*/
|
|
|
|
virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1);
|
|
|
|
|
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
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void pen_to( wxPoint pos, char plume );
|
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
2012-01-03 17:14:17 +00:00
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
2010-12-11 18:40:39 +00:00
|
|
|
|
|
|
|
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
2012-01-03 17:14:17 +00:00
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-06 22:05:12 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive );
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
protected:
|
2011-12-31 05:44:00 +00:00
|
|
|
void select_aperture( const wxSize& size, APERTURE::Aperture_Type type );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
std::vector<APERTURE>::iterator
|
|
|
|
get_aperture( const wxSize& size, APERTURE::Aperture_Type type );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
FILE* work_file, * final_file;
|
|
|
|
wxString m_workFilename;
|
2010-03-31 16:59:32 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
void write_aperture_list();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
std::vector<APERTURE> apertures;
|
|
|
|
std::vector<APERTURE>::iterator current_aperture;
|
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:
|
|
|
|
DXF_PLOTTER() :
|
|
|
|
PLOTTER( PLOT_FORMAT_DXF )
|
2009-08-29 10:20:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
virtual bool start_plot( FILE* fout );
|
|
|
|
virtual bool end_plot();
|
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
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void set_current_line_width( int width )
|
|
|
|
{
|
2010-12-12 02:29:33 +00:00
|
|
|
// Handy override
|
2009-06-30 10:43:20 +00:00
|
|
|
current_pen_width = 0;
|
2010-12-12 02:29:33 +00:00
|
|
|
}
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
virtual void set_default_line_width( int width )
|
2009-06-30 10:43:20 +00:00
|
|
|
{
|
2010-12-12 02:29:33 +00:00
|
|
|
// DXF lines are infinitesimal
|
2009-08-29 10:20:48 +00:00
|
|
|
default_pen_width = 0;
|
2010-12-12 02:29:33 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void set_dash( bool dashed );
|
|
|
|
|
|
|
|
virtual void set_color( int color );
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
|
|
|
|
virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
|
2011-04-20 08:13:21 +00:00
|
|
|
/*
|
|
|
|
* Function PlotPoly
|
|
|
|
* Draw a polygon (filled or not) in DXF format
|
|
|
|
* param aCornerList = corners list
|
|
|
|
* param aFill :if true : filled polygon
|
|
|
|
* param aWidth = line width
|
|
|
|
*/
|
|
|
|
virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1 );
|
|
|
|
|
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
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
|
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void thick_segment( wxPoint start, wxPoint end, int width,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T tracemode );
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
|
|
|
|
FILL_T fill, int width = -1 );
|
|
|
|
virtual void pen_to( wxPoint pos, char plume );
|
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_DRAW_MODE_T trace_mode );
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
2012-01-03 17:14:17 +00:00
|
|
|
int orient, EDA_DRAW_MODE_T trace_mode );
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-09-13 11:51:09 +00:00
|
|
|
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
2012-01-03 17:14:17 +00:00
|
|
|
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
|
2009-06-30 10:43:20 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
virtual void SetLayerPolarity( bool aPositive ) {}
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
protected:
|
2009-08-29 10:20:48 +00:00
|
|
|
int current_color;
|
2009-06-30 10:43:20 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
#endif // PLOT_COMMON_H_
|