2009-11-23 15:16:50 +00:00
|
|
|
/************************************/
|
2008-03-22 05:55:06 +00:00
|
|
|
/* Kicad: Common plot HPGL Routines */
|
2009-11-23 15:16:50 +00:00
|
|
|
/************************************/
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "trigo.h"
|
|
|
|
#include "wxstruct.h"
|
|
|
|
#include "base_struct.h"
|
|
|
|
#include "plot_common.h"
|
|
|
|
#include "macros.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "kicad_string.h"
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* HPGL scale factor. */
|
2009-06-28 16:50:42 +00:00
|
|
|
const double SCALE_HPGL = 0.102041;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Set the plot offset for the current plotting
|
2008-03-22 05:55:06 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HPGL_PLOTTER::set_viewport( wxPoint offset, double aScale, int orient )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( !output_file );
|
|
|
|
plot_offset = offset;
|
|
|
|
plot_scale = aScale;
|
2009-06-28 16:50:42 +00:00
|
|
|
device_scale = SCALE_HPGL;
|
2009-11-23 15:16:50 +00:00
|
|
|
set_default_line_width( 100 ); /* default line width in 1 / 1000 inch */
|
2009-06-28 16:50:42 +00:00
|
|
|
plot_orient_options = orient;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
bool HPGL_PLOTTER::start_plot( FILE* fout )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( !output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
output_file = fout;
|
|
|
|
fprintf( output_file, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_number );
|
2010-03-31 16:59:32 +00:00
|
|
|
return true;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
bool HPGL_PLOTTER::end_plot()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
fputs( "PU;PA;SP0;\n", output_file );
|
|
|
|
fclose( output_file );
|
2010-03-31 16:59:32 +00:00
|
|
|
output_file = NULL;
|
|
|
|
return true;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
void HPGL_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
user_to_device_coordinates( p2 );
|
2009-11-23 15:16:50 +00:00
|
|
|
move_to( p1 );
|
2009-06-28 16:50:42 +00:00
|
|
|
fprintf( output_file, "EA %d,%d;\n", p2.x, p2.y );
|
|
|
|
pen_finish();
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
void HPGL_PLOTTER::circle( wxPoint centre,
|
|
|
|
int diameter,
|
|
|
|
FILL_T fill,
|
|
|
|
int width )
|
2008-06-30 13:47:55 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
|
|
|
double rayon = user_to_device_size( diameter / 2 );
|
2008-06-30 13:47:55 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( rayon > 0 )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
move_to( centre );
|
|
|
|
fprintf( output_file, "CI %g;\n", rayon );
|
|
|
|
pen_finish();
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-30 13:47:55 +00:00
|
|
|
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Plot a polygon (closed if completed) in HPGL
|
|
|
|
* Coord = coord table tops
|
|
|
|
* Nb = number of coord (coord 1 = 2 elements: X and Y table)
|
|
|
|
* Fill: if! = 0 filled polygon
|
2009-06-28 16:50:42 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HPGL_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
if( nb <= 1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
move_to( wxPoint( coord[0], coord[1] ) );
|
2009-11-23 15:16:50 +00:00
|
|
|
for( int ii = 1; ii < nb; ii++ )
|
2009-06-28 16:50:42 +00:00
|
|
|
line_to( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ) );
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Close polygon if filled. */
|
2009-06-28 16:50:42 +00:00
|
|
|
if( fill )
|
|
|
|
{
|
|
|
|
int ii = (nb - 1) * 2;
|
|
|
|
if( (coord[ii] != coord[0] ) || (coord[ii + 1] != coord[1]) )
|
|
|
|
line_to( wxPoint( coord[0], coord[1] ) );
|
|
|
|
}
|
|
|
|
pen_finish();
|
2008-06-30 13:47:55 +00:00
|
|
|
}
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Set pen up ('U') or down ('D').
|
2009-06-28 16:50:42 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HPGL_PLOTTER::pen_control( int plume )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
|
|
|
switch( plume )
|
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
case 'U':
|
|
|
|
if( pen_state != 'U' )
|
2009-11-23 15:16:50 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
fputs( "PU;", output_file );
|
2009-11-23 15:16:50 +00:00
|
|
|
pen_state = 'U';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
case 'D':
|
2009-08-29 10:20:48 +00:00
|
|
|
if( pen_state != 'D' )
|
2009-11-23 15:16:50 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
fputs( "PD;", output_file );
|
2009-11-23 15:16:50 +00:00
|
|
|
pen_state = 'D';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
case 'Z':
|
2009-11-23 15:16:50 +00:00
|
|
|
fputs( "PU;", output_file );
|
|
|
|
pen_state = 'U';
|
|
|
|
pen_lastpos.x = -1;
|
|
|
|
pen_lastpos.y = -1;
|
|
|
|
break;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
/*
|
2009-11-23 15:16:50 +00:00
|
|
|
* Move the pen to position with pen up or down.
|
|
|
|
* At position x, y
|
|
|
|
* Unit to unit DRAWING
|
|
|
|
* If pen = 'Z' without changing pen during move.
|
2009-06-28 16:50:42 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HPGL_PLOTTER::pen_to( wxPoint pos, char plume )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
if( plume == 'Z' )
|
|
|
|
{
|
|
|
|
pen_control( 'Z' );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pen_control( plume );
|
|
|
|
user_to_device_coordinates( pos );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
if( pen_lastpos != pos )
|
|
|
|
fprintf( output_file, "PA %d,%d;\n", pos.x, pos.y );
|
2009-06-28 16:50:42 +00:00
|
|
|
pen_lastpos = pos;
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
void HPGL_PLOTTER::set_dash( bool dashed )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
|
|
|
if( dashed )
|
|
|
|
fputs( "LI 2;\n", stderr );
|
2009-06-28 16:50:42 +00:00
|
|
|
else
|
2009-11-23 15:16:50 +00:00
|
|
|
fputs( "LI;\n", stderr );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function Plot a filled segment (track)
|
2009-06-28 16:50:42 +00:00
|
|
|
* @param start = starting point
|
|
|
|
* @param end = ending point
|
|
|
|
* @param aWidth = segment width (thickness)
|
|
|
|
* @param aPlotMode = FILLED, SKETCH ..
|
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HPGL_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
|
|
|
|
GRTraceMode tracemode )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
wxPoint center;
|
|
|
|
wxSize size;
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
if( (pen_diameter >= width) || (tracemode == FILAIRE) ) /* just a line is
|
|
|
|
* Ok */
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
move_to( start );
|
|
|
|
finish_to( end );
|
|
|
|
}
|
|
|
|
else
|
2009-11-23 15:16:50 +00:00
|
|
|
segment_as_oval( start, end, width, tracemode );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
/* Plot an arc:
|
|
|
|
* Center = center coord
|
|
|
|
* Stangl, endAngle = angle of beginning and end
|
|
|
|
* Radius = radius of the arc
|
|
|
|
* Command
|
|
|
|
* PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, NbSegm; PU;
|
|
|
|
* Or PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, PU;
|
2008-03-22 05:55:06 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HPGL_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
|
|
|
|
FILL_T fill, int width )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
|
|
|
wxPoint cmap;
|
|
|
|
wxPoint cpos;
|
|
|
|
float angle;
|
2008-03-22 05:55:06 +00:00
|
|
|
|
|
|
|
if( rayon <= 0 )
|
|
|
|
return;
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
cpos = centre;
|
2009-06-28 16:50:42 +00:00
|
|
|
user_to_device_coordinates( cpos );
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( plot_orient_options == PLOT_MIROIR )
|
2009-11-23 15:16:50 +00:00
|
|
|
angle = (StAngle - EndAngle) / 10.0;
|
2009-06-28 16:50:42 +00:00
|
|
|
else
|
2009-11-23 15:16:50 +00:00
|
|
|
angle = (EndAngle - StAngle) / 10.0;
|
|
|
|
/* Calculate start point, */
|
2008-03-22 05:55:06 +00:00
|
|
|
cmap.x = (int) ( centre.x + ( rayon * cos( StAngle * M_PI / 1800 ) ) );
|
2009-06-28 16:50:42 +00:00
|
|
|
cmap.y = (int) ( centre.y - ( rayon * sin( StAngle * M_PI / 1800 ) ) );
|
|
|
|
user_to_device_coordinates( cmap );
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
fprintf( output_file,
|
|
|
|
"PU;PA %d,%d;PD;AA %d,%d, ",
|
|
|
|
cmap.x,
|
|
|
|
cmap.y,
|
|
|
|
cpos.x,
|
|
|
|
cpos.y );
|
2009-08-29 10:20:48 +00:00
|
|
|
fprintf( output_file, "%f", angle );
|
2009-06-28 16:50:42 +00:00
|
|
|
fprintf( output_file, ";PU;\n" );
|
|
|
|
pen_finish();
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
/* Plot oval pad.
|
|
|
|
*/
|
2009-08-29 10:20:48 +00:00
|
|
|
void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
2009-11-23 15:16:50 +00:00
|
|
|
GRTraceMode trace_mode )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
int rayon, deltaxy, cx, cy;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* The pad is reduced to an oval with size.y > size.x
|
|
|
|
* (Oval vertical orientation 0)
|
|
|
|
*/
|
2009-06-28 16:50:42 +00:00
|
|
|
if( size.x > size.y )
|
|
|
|
{
|
|
|
|
EXCHG( size.x, size.y ); orient += 900;
|
|
|
|
if( orient >= 3600 )
|
|
|
|
orient -= 3600;
|
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
deltaxy = size.y - size.x; /* distance between centers of the oval */
|
2009-06-28 16:50:42 +00:00
|
|
|
rayon = size.x / 2;
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( trace_mode == FILLED )
|
|
|
|
{
|
2009-10-26 19:00:46 +00:00
|
|
|
flash_pad_rect( pos, wxSize( size.x, deltaxy + wxRound( pen_diameter ) ),
|
2009-11-23 15:16:50 +00:00
|
|
|
orient, trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
cx = 0; cy = deltaxy / 2;
|
|
|
|
RotatePoint( &cx, &cy, orient );
|
2009-11-23 15:16:50 +00:00
|
|
|
flash_pad_circle( wxPoint( cx + pos.x,
|
|
|
|
cy + pos.y ), size.x, trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
cx = 0; cy = -deltaxy / 2;
|
|
|
|
RotatePoint( &cx, &cy, orient );
|
2009-11-23 15:16:50 +00:00
|
|
|
flash_pad_circle( wxPoint( cx + pos.x,
|
|
|
|
cy + pos.y ), size.x, trace_mode );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
else /* Plot in SKETCH mode. */
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
sketch_oval( pos, size, orient, wxRound( pen_diameter ) );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
/* Plot round pad or via.
|
|
|
|
*/
|
|
|
|
void HPGL_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
|
|
|
|
GRTraceMode trace_mode )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
|
|
|
int rayon, delta;
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
user_to_device_coordinates( pos );
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
delta = wxRound( pen_diameter - pen_overlap );
|
2009-06-28 16:50:42 +00:00
|
|
|
rayon = diametre / 2;
|
|
|
|
if( trace_mode != FILAIRE )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
rayon = ( diametre - wxRound( pen_diameter ) ) / 2;
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( rayon < 0 )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
rayon = 0;
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
2009-06-28 16:50:42 +00:00
|
|
|
wxSize rsize( rayon, rayon );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
user_to_device_size( rsize );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
fprintf( output_file, "PA %d,%d;CI %d;\n", pos.x, pos.y, rsize.x );
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
if( trace_mode == FILLED ) /* Plot in filled mode. */
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
if( delta > 0 )
|
|
|
|
{
|
|
|
|
while( (rayon -= delta ) >= 0 )
|
|
|
|
{
|
|
|
|
rsize.x = rsize.y = rayon;
|
|
|
|
user_to_device_size( rsize );
|
2009-11-23 15:16:50 +00:00
|
|
|
fprintf( output_file,
|
|
|
|
"PA %d,%d; CI %d;\n",
|
|
|
|
pos.x,
|
|
|
|
pos.y,
|
|
|
|
rsize.x );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pen_finish();
|
|
|
|
return;
|
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/*
|
2009-11-23 15:16:50 +00:00
|
|
|
* Plot rectangular pad vertical or horizontal.
|
|
|
|
* Gives its center and its dimensions X and Y
|
|
|
|
* Units are user units
|
2008-03-22 05:55:06 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HPGL_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
|
|
|
|
int orient, GRTraceMode trace_mode )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2009-06-28 16:50:42 +00:00
|
|
|
wxSize size;
|
|
|
|
int delta;
|
|
|
|
int ox, oy, fx, fy;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
size.x = padsize.x / 2;
|
|
|
|
size.y = padsize.y / 2;
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( trace_mode != FILAIRE )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
size.x = (padsize.x - (int) pen_diameter) / 2;
|
|
|
|
size.y = (padsize.y - (int) pen_diameter) / 2;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( size.x < 0 )
|
2009-11-23 15:16:50 +00:00
|
|
|
size.x = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
if( size.y < 0 )
|
2009-11-23 15:16:50 +00:00
|
|
|
size.y = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* If a dimension is zero, the trace is reduced to 1 line. */
|
2009-06-28 16:50:42 +00:00
|
|
|
if( size.x == 0 )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
ox = pos.x;
|
|
|
|
oy = pos.y - size.y;
|
|
|
|
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
|
|
|
|
fx = pos.x;
|
|
|
|
fy = pos.y + size.y;
|
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
move_to( wxPoint( ox, oy ) );
|
|
|
|
finish_to( wxPoint( fx, fy ) );
|
|
|
|
return;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
if( size.y == 0 )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
ox = pos.x - size.x;
|
|
|
|
oy = pos.y;
|
|
|
|
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
|
|
|
|
fx = pos.x + size.x;
|
|
|
|
fy = pos.y;
|
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
move_to( wxPoint( ox, oy ) );
|
|
|
|
finish_to( wxPoint( fx, fy ) );
|
2008-03-22 05:55:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
ox = pos.x - size.x;
|
|
|
|
oy = pos.y - size.y;
|
2009-06-28 16:50:42 +00:00
|
|
|
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
|
|
|
|
move_to( wxPoint( ox, oy ) );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
fx = pos.x - size.x;
|
|
|
|
fy = pos.y + size.y;
|
2009-06-28 16:50:42 +00:00
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
line_to( wxPoint( fx, fy ) );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
fx = pos.x + size.x;
|
|
|
|
fy = pos.y + size.y;
|
2009-06-28 16:50:42 +00:00
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
line_to( wxPoint( fx, fy ) );
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
fx = pos.x + size.x;
|
|
|
|
fy = pos.y - size.y;
|
2009-06-28 16:50:42 +00:00
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
line_to( wxPoint( fx, fy ) );
|
|
|
|
|
|
|
|
finish_to( wxPoint( ox, oy ) );
|
|
|
|
|
|
|
|
if( trace_mode == FILLED )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Plot in filled mode. */
|
|
|
|
delta = (int) (pen_diameter - pen_overlap);
|
|
|
|
|
|
|
|
if( delta > 0 )
|
|
|
|
while( (size.x > 0) && (size.y > 0) )
|
|
|
|
{
|
|
|
|
size.x -= delta;
|
|
|
|
size.y -= delta;
|
|
|
|
|
|
|
|
if( size.x < 0 )
|
|
|
|
size.x = 0;
|
|
|
|
if( size.y < 0 )
|
|
|
|
size.y = 0;
|
|
|
|
|
|
|
|
ox = pos.x - size.x;
|
|
|
|
oy = pos.y - size.y;
|
|
|
|
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
|
|
|
|
move_to( wxPoint( ox, oy ) );
|
|
|
|
|
|
|
|
fx = pos.x - size.x;
|
|
|
|
fy = pos.y + size.y;
|
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
line_to( wxPoint( fx, fy ) );
|
|
|
|
|
|
|
|
fx = pos.x + size.x;
|
|
|
|
fy = pos.y + size.y;
|
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
line_to( wxPoint( fx, fy ) );
|
|
|
|
|
|
|
|
fx = pos.x + size.x;
|
|
|
|
fy = pos.y - size.y;
|
|
|
|
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
|
|
|
|
line_to( wxPoint( fx, fy ) );
|
|
|
|
|
|
|
|
finish_to( wxPoint( ox, oy ) );
|
|
|
|
}
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
/* Plot trapezoidal pad.
|
2010-09-13 11:51:09 +00:00
|
|
|
* aPadPos is pad position, aCorners the corners position of the basic shape
|
|
|
|
* Orientation aPadOrient in 0.1 degrees
|
|
|
|
* Plot mode FILLED or SKETCH
|
2008-03-22 05:55:06 +00:00
|
|
|
*/
|
2010-09-13 11:51:09 +00:00
|
|
|
void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
|
|
|
int aPadOrient, GRTraceMode aTrace_Mode )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
wxASSERT( output_file );
|
2010-09-13 11:51:09 +00:00
|
|
|
wxPoint polygone[4]; // coordinates of corners relatives to the pad
|
|
|
|
wxPoint coord[4]; // absolute coordinates of corners (coordinates in plotter space)
|
|
|
|
int move;
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2010-09-13 11:51:09 +00:00
|
|
|
move = wxRound( pen_diameter );
|
|
|
|
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
polygone[ii] = aCorners[ii];
|
|
|
|
|
|
|
|
// polygone[0] is assumed the lower left
|
|
|
|
// polygone[1] is assumed the upper left
|
|
|
|
// polygone[2] is assumed the upper right
|
|
|
|
// polygone[3] is assumed the lower right
|
|
|
|
|
|
|
|
// Plot the outline:
|
2009-11-23 15:16:50 +00:00
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2010-09-13 11:51:09 +00:00
|
|
|
coord[ii] = polygone[ii];
|
|
|
|
RotatePoint( &coord[ii], aPadOrient );
|
|
|
|
coord[ii] += aPadPos;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
move_to( coord[0] );
|
|
|
|
line_to( coord[1] );
|
|
|
|
line_to( coord[2] );
|
|
|
|
line_to( coord[3] );
|
|
|
|
finish_to( coord[0] );
|
|
|
|
|
2010-09-13 11:51:09 +00:00
|
|
|
// Fill shape:
|
|
|
|
if( aTrace_Mode == FILLED )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2010-09-13 11:51:09 +00:00
|
|
|
// TODO: replace this par the HPGL plot polygon.
|
2009-11-23 15:16:50 +00:00
|
|
|
int jj;
|
|
|
|
/* Fill the shape */
|
2010-09-13 11:51:09 +00:00
|
|
|
move = wxRound( pen_diameter - pen_overlap );
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Calculate fill height. */
|
|
|
|
|
2010-09-13 11:51:09 +00:00
|
|
|
if( polygone[0].y == polygone[3].y ) /* Horizontal */
|
2009-11-23 15:16:50 +00:00
|
|
|
{
|
2010-09-13 11:51:09 +00:00
|
|
|
jj = polygone[3].y - (int) ( pen_diameter + ( 2 * pen_overlap ) );
|
2009-11-23 15:16:50 +00:00
|
|
|
}
|
2010-09-13 11:51:09 +00:00
|
|
|
else // vertical
|
2009-11-23 15:16:50 +00:00
|
|
|
{
|
2010-09-13 11:51:09 +00:00
|
|
|
jj = polygone[3].x - (int) ( pen_diameter + ( 2 * pen_overlap ) );
|
2009-11-23 15:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculation of dd = number of segments was traced to fill. */
|
|
|
|
jj = jj / (int) ( pen_diameter - pen_overlap );
|
|
|
|
|
|
|
|
/* Trace the outline. */
|
|
|
|
for( ; jj > 0; jj-- )
|
|
|
|
{
|
2010-09-13 11:51:09 +00:00
|
|
|
polygone[0].x += move;
|
|
|
|
polygone[0].y -= move;
|
|
|
|
polygone[1].x += move;
|
|
|
|
polygone[1].y += move;
|
|
|
|
polygone[2].x -= move;
|
|
|
|
polygone[2].y += move;
|
|
|
|
polygone[3].x -= move;
|
|
|
|
polygone[3].y -= move;
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
/* Test for crossed vertexes. */
|
|
|
|
if( polygone[0].x > polygone[3].x ) /* X axis intersection on
|
|
|
|
*vertexes 0 and 3 */
|
|
|
|
{
|
|
|
|
polygone[0].x = polygone[3].x = 0;
|
|
|
|
}
|
|
|
|
if( polygone[1].x > polygone[2].x ) /* X axis intersection on
|
|
|
|
*vertexes 1 and 2 */
|
|
|
|
{
|
|
|
|
polygone[1].x = polygone[2].x = 0;
|
|
|
|
}
|
|
|
|
if( polygone[1].y > polygone[0].y ) /* Y axis intersection on
|
|
|
|
*vertexes 0 and 1 */
|
|
|
|
{
|
|
|
|
polygone[0].y = polygone[1].y = 0;
|
|
|
|
}
|
|
|
|
if( polygone[2].y > polygone[3].y ) /* Y axis intersection on
|
|
|
|
*vertexes 2 and 3 */
|
|
|
|
{
|
|
|
|
polygone[2].y = polygone[3].y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
{
|
2010-09-13 11:51:09 +00:00
|
|
|
coord[ii] = polygone[ii];
|
|
|
|
RotatePoint( &coord[ii], aPadOrient );
|
|
|
|
coord[ii] += aPadPos;
|
2009-11-23 15:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
move_to( coord[0] );
|
|
|
|
line_to( coord[1] );
|
|
|
|
line_to( coord[2] );
|
|
|
|
line_to( coord[3] );
|
|
|
|
finish_to( coord[0] );
|
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|