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
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
#ifndef __INCLUDE__PLOT_COMMON_H__
|
|
|
|
#define __INCLUDE__PLOT_COMMON_H__ 1
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
#include <vector>
|
|
|
|
#include "drawtxt.h"
|
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
/**
|
|
|
|
* Enum PlotFormat
|
|
|
|
* must be kept in order of the radio buttons in the plot panel/window.
|
|
|
|
*/
|
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
|
|
|
};
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
const int PLOT_MIROIR = 1;
|
2008-03-22 05:55:06 +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:
|
2009-08-29 10:20:48 +00:00
|
|
|
PlotFormat m_PlotType; // type of plot
|
|
|
|
public:
|
|
|
|
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
|
|
|
{
|
|
|
|
/* Emergency cleanup */
|
|
|
|
if( output_file )
|
|
|
|
{
|
|
|
|
fclose( output_file );
|
|
|
|
}
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
/** function GetPlotterType()
|
|
|
|
* @return the format of the plot file
|
|
|
|
*/
|
|
|
|
PlotFormat GetPlotterType()
|
|
|
|
{ return m_PlotType; }
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void start_plot( FILE* fout ) = 0;
|
|
|
|
virtual void end_plot() = 0;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void set_paper_size( Ki_PageDescr* sheet );
|
|
|
|
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;
|
|
|
|
|
|
|
|
virtual void set_creator( const wxString& _creator )
|
|
|
|
{
|
|
|
|
creator = _creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void set_filename( const wxString& _filename )
|
|
|
|
{
|
|
|
|
filename = _filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void set_viewport( wxPoint offset,
|
|
|
|
double scale, int orient ) = 0;
|
|
|
|
|
|
|
|
/* Standard primitives */
|
|
|
|
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 );
|
|
|
|
virtual void poly( int nb_segm, int* coord, FILL_T fill,
|
|
|
|
int width = -1 ) = 0;
|
|
|
|
virtual void thick_segment( wxPoint start, wxPoint end, int width,
|
|
|
|
GRTraceMode tracemode );
|
|
|
|
virtual void thick_arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
|
|
|
|
int width, GRTraceMode tracemode );
|
|
|
|
virtual void thick_rect( wxPoint p1, wxPoint p2, int width,
|
|
|
|
GRTraceMode tracemode );
|
|
|
|
virtual void thick_circle( wxPoint pos, int diametre, int width,
|
|
|
|
GRTraceMode tracemode );
|
|
|
|
virtual void pen_to( wxPoint pos, char plume ) = 0;
|
|
|
|
|
|
|
|
/* Flash primitives */
|
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
|
|
|
GRTraceMode trace_mode ) = 0;
|
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
|
|
|
GRTraceMode trace_mode ) = 0;
|
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
|
|
|
int orient, GRTraceMode trace_mode ) = 0;
|
|
|
|
virtual void flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
|
|
|
|
int orient, GRTraceMode trace_mode ) = 0;
|
|
|
|
|
|
|
|
/* Convenience functions */
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
/* Shortcut */
|
|
|
|
pen_to( wxPoint( 0, 0 ), 'Z' );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void text( const wxPoint& aPos,
|
|
|
|
enum EDA_Colors aColor,
|
|
|
|
const wxString& aText,
|
|
|
|
int aOrient,
|
|
|
|
const wxSize& aSize,
|
|
|
|
enum GRTextHorizJustifyType aH_justify,
|
|
|
|
enum GRTextVertJustifyType aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold );
|
|
|
|
void marker( const wxPoint& position, int diametre, int aShapeId );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/* These are marker subcomponents */
|
|
|
|
void center_square( const wxPoint& position, int diametre, FILL_T fill );
|
|
|
|
void center_lozenge( const wxPoint& position, int diametre, FILL_T fill );
|
|
|
|
|
|
|
|
/* Helper function for sketched filler segment */
|
|
|
|
void segment_as_oval( wxPoint start, wxPoint end, int width,
|
|
|
|
GRTraceMode tracemode );
|
|
|
|
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 );
|
|
|
|
|
|
|
|
/* Plot scale */
|
|
|
|
double plot_scale;
|
|
|
|
/* Device scale (from decimils to device units) */
|
|
|
|
double device_scale;
|
|
|
|
/* Plot offset (in decimils) */
|
|
|
|
wxPoint plot_offset;
|
|
|
|
/* Output file */
|
|
|
|
FILE* output_file;
|
|
|
|
/* Pen handling */
|
|
|
|
bool color_mode, negative_mode;
|
|
|
|
int default_pen_width;
|
|
|
|
int current_pen_width;
|
|
|
|
char pen_state;
|
|
|
|
wxPoint pen_lastpos;
|
|
|
|
/* Other stuff */
|
|
|
|
int plot_orient_options; /* For now, mirror plot */
|
|
|
|
wxString creator;
|
|
|
|
wxString filename;
|
|
|
|
Ki_PageDescr* sheet;
|
|
|
|
wxSize paper_size;
|
|
|
|
};
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class HPGL_PLOTTER : public PLOTTER
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-08-29 10:20:48 +00:00
|
|
|
HPGL_PLOTTER() : PLOTTER(PLOT_FORMAT_HPGL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
virtual void start_plot( FILE* fout );
|
|
|
|
virtual void end_plot();
|
|
|
|
|
|
|
|
/* HPGL doesn't handle line thickness or color */
|
|
|
|
virtual void set_current_line_width( int width )
|
|
|
|
{
|
|
|
|
/* Handy override */
|
2009-10-05 17:52:41 +00:00
|
|
|
current_pen_width = wxRound( pen_diameter );
|
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 ) {};
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void set_viewport( wxPoint offset,
|
|
|
|
double scale, int orient );
|
|
|
|
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 poly( int nb_segm, int* coord, FILL_T fill, int width = -1 );
|
|
|
|
virtual void thick_segment( wxPoint start, wxPoint end, int width,
|
|
|
|
GRTraceMode tracemode );
|
|
|
|
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,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void pen_control( int plume );
|
|
|
|
|
|
|
|
int pen_speed;
|
|
|
|
int pen_number;
|
|
|
|
double pen_diameter;
|
|
|
|
double pen_overlap;
|
|
|
|
};
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class PS_PLOTTER : public PLOTTER
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-08-29 10:20:48 +00:00
|
|
|
PS_PLOTTER() : PLOTTER(PLOT_FORMAT_POST)
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
plot_scale_adjX = 1;
|
|
|
|
plot_scale_adjY = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void start_plot( FILE* fout );
|
|
|
|
virtual void end_plot();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void set_viewport( wxPoint offset,
|
|
|
|
double scale, int orient );
|
|
|
|
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 );
|
|
|
|
virtual void poly( int nb_segm, int* coord, FILL_T fill, int width = -1 );
|
|
|
|
virtual void pen_to( wxPoint pos, char plume );
|
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
double plot_scale_adjX, plot_scale_adjY;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
};
|
|
|
|
|
|
|
|
wxSize size; /* horiz and Vert size*/
|
|
|
|
Aperture_Type type; /* Type ( Line, rect , circulaire , ovale .. ) */
|
|
|
|
int D_code; /* code number ( >= 10 ); */
|
|
|
|
|
|
|
|
/* Trivia question: WHY Gerber decided to use D instead of the usual T for
|
|
|
|
* tool change? */
|
|
|
|
};
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class GERBER_PLOTTER : public PLOTTER
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-08-29 10:20:48 +00:00
|
|
|
GERBER_PLOTTER() : PLOTTER(PLOT_FORMAT_GERBER)
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
work_file = 0;
|
|
|
|
final_file = 0;
|
|
|
|
current_aperture = apertures.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
virtual void start_plot( FILE* fout );
|
|
|
|
virtual void 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
|
|
|
|
|
|
|
/* RS274X has no dashing, nor colours */
|
|
|
|
virtual void set_dash( bool dashed ) {};
|
|
|
|
virtual void set_color( int color ) {};
|
2009-08-29 10:20:48 +00:00
|
|
|
virtual void set_viewport( wxPoint offset,
|
|
|
|
double scale, int orient );
|
|
|
|
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 poly( int nb_segm, int* coord, FILL_T fill, int width = -1 );
|
|
|
|
virtual void pen_to( wxPoint pos, char plume );
|
|
|
|
virtual void flash_pad_circle( wxPoint pos, int diametre,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
|
|
|
protected:
|
2009-08-29 10:20:48 +00:00
|
|
|
void select_aperture( const wxSize& size,
|
|
|
|
APERTURE::Aperture_Type type );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
std::vector<APERTURE>::iterator get_aperture( const wxSize& size,
|
|
|
|
APERTURE::Aperture_Type type );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
FILE* work_file, * final_file;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
class DXF_PLOTTER : public PLOTTER
|
2009-06-30 10:43:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-08-29 10:20:48 +00:00
|
|
|
DXF_PLOTTER() : PLOTTER(PLOT_FORMAT_DXF)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
virtual void start_plot( FILE* fout );
|
|
|
|
virtual void end_plot();
|
|
|
|
|
|
|
|
/* For now we don't use 'thick' primitives, so no line width */
|
|
|
|
virtual void set_current_line_width( int width )
|
|
|
|
{
|
|
|
|
/* Handy override */
|
|
|
|
current_pen_width = 0;
|
|
|
|
};
|
2009-08-29 10:20:48 +00:00
|
|
|
virtual void set_default_line_width( int width )
|
2009-06-30 10:43:20 +00:00
|
|
|
{
|
2009-08-29 10:20:48 +00:00
|
|
|
/* DXF lines are infinitesimal */
|
|
|
|
default_pen_width = 0;
|
2009-06-30 10:43:20 +00:00
|
|
|
};
|
|
|
|
virtual void set_dash( bool dashed );
|
|
|
|
|
|
|
|
virtual void set_color( int color );
|
|
|
|
|
|
|
|
virtual void set_viewport( wxPoint offset,
|
|
|
|
double scale, int orient );
|
|
|
|
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 poly( int nb_segm, int* coord, FILL_T fill, int width = -1 );
|
|
|
|
virtual void thick_segment( wxPoint start, wxPoint end, int width,
|
|
|
|
GRTraceMode tracemode );
|
|
|
|
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,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
|
|
|
GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_rect( wxPoint pos, wxSize size,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
|
|
|
virtual void flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
|
|
|
|
int orient, GRTraceMode trace_mode );
|
|
|
|
|
|
|
|
protected:
|
2009-08-29 10:20:48 +00:00
|
|
|
int current_color;
|
2009-06-30 10:43:20 +00:00
|
|
|
};
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
#endif /* __INCLUDE__PLOT_COMMON_H__ */
|