Add patch from Lorenzo Marcantonio. Fix some warning issues, and zlib issue under Windows (zlib sources added)
This commit is contained in:
+356
-267
@@ -1,13 +1,17 @@
|
||||
/******************************************
|
||||
* class_plotter.cpp
|
||||
* the class PLOTTER handle basic functions to plot schematic and boards
|
||||
* with different plot formats.
|
||||
* currently formats are:*
|
||||
* HPGL
|
||||
* POSTSCRIPT
|
||||
* GERBER
|
||||
* DXF
|
||||
******************************************/
|
||||
/**
|
||||
* @file class_plotter.cpp
|
||||
* @brief KiCad: Base of all the plot routines
|
||||
* the class PLOTTER handle basic functions to plot schematic and boards
|
||||
* with different plot formats.
|
||||
*
|
||||
* There are currently engines for:
|
||||
* HPGL
|
||||
* POSTSCRIPT
|
||||
* GERBER
|
||||
* DXF
|
||||
* an SVG 'plot' is also provided along with the 'print' function by wx, but
|
||||
* is not handled here.
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
|
||||
@@ -21,112 +25,152 @@
|
||||
#include <class_base_screen.h>
|
||||
#include <drawtxt.h>
|
||||
|
||||
PLOTTER::PLOTTER( PlotFormat aPlotType )
|
||||
PLOTTER::PLOTTER( )
|
||||
{
|
||||
m_PlotType = aPlotType;
|
||||
plot_scale = 1;
|
||||
default_pen_width = 0;
|
||||
current_pen_width = -1; /* To-be-set marker */
|
||||
pen_state = 'Z'; /* End-of-path idle */
|
||||
plotMirror = 0; /* Mirror flag */
|
||||
output_file = 0;
|
||||
color_mode = false; /* Start as a BW plot */
|
||||
negative_mode = false;
|
||||
plotScale = 1;
|
||||
defaultPenWidth = 0;
|
||||
currentPenWidth = -1; // To-be-set marker
|
||||
penState = 'Z'; // End-of-path idle
|
||||
plotMirror = 0; // Mirror flag
|
||||
outputFile = 0;
|
||||
colorMode = false; // Starts as a BW plot
|
||||
negativeMode = false;
|
||||
}
|
||||
|
||||
|
||||
/* Modifies coordinates pos.x and pos.y trace according to the orientation,
|
||||
* scale factor, and offsets trace
|
||||
/**
|
||||
* Modifies coordinates according to the orientation,
|
||||
* scale factor, and offsets trace. Also convert from a wxPoint to DPOINT,
|
||||
* since some output engines needs floating point coordinates.
|
||||
*/
|
||||
void PLOTTER::user_to_device_coordinates( wxPoint& pos )
|
||||
DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& pos )
|
||||
{
|
||||
pos.x = (int) ( (pos.x - plot_offset.x) * plot_scale * device_scale );
|
||||
double x = (pos.x - plotOffset.x) * plotScale * iuPerDeviceUnit;
|
||||
double y;
|
||||
|
||||
if( plotMirror )
|
||||
pos.y = (int) ( ( pos.y - plot_offset.y ) * plot_scale * device_scale );
|
||||
y = ( pos.y - plotOffset.y ) * plotScale * iuPerDeviceUnit ;
|
||||
else
|
||||
pos.y = (int) ( ( paper_size.y - ( pos.y - plot_offset.y )
|
||||
* plot_scale ) * device_scale );
|
||||
y = ( paperSize.y - ( pos.y - plotOffset.y )
|
||||
* plotScale ) * iuPerDeviceUnit ;
|
||||
return DPOINT( x, y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies size according to the plotter scale factors
|
||||
* (wxSize version, returns a DPOINT)
|
||||
*/
|
||||
DPOINT PLOTTER::userToDeviceSize( const wxSize& size )
|
||||
{
|
||||
return DPOINT( size.x * plotScale * iuPerDeviceUnit,
|
||||
size.y * plotScale * iuPerDeviceUnit );
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies size according to the plotter scale factors
|
||||
* (simple double version)
|
||||
*/
|
||||
double PLOTTER::userToDeviceSize( double size )
|
||||
{
|
||||
return size * plotScale * iuPerDeviceUnit;
|
||||
}
|
||||
|
||||
|
||||
/* Generic arc rendered as a polyline */
|
||||
void PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
|
||||
/**
|
||||
* Generic fallback: arc rendered as a polyline
|
||||
*/
|
||||
void PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int radius,
|
||||
FILL_T fill, int width )
|
||||
{
|
||||
wxPoint start, end;
|
||||
const int delta = 50; /* increment (in 0.1 degrees) to draw circles */
|
||||
const int delta = 50; // increment (in 0.1 degrees) to draw circles
|
||||
double alpha;
|
||||
|
||||
if( StAngle > EndAngle )
|
||||
EXCHG( StAngle, EndAngle );
|
||||
|
||||
set_current_line_width( width );
|
||||
SetCurrentLineWidth( width );
|
||||
/* Please NOTE the different sign due to Y-axis flip */
|
||||
alpha = StAngle / 1800.0 * M_PI;
|
||||
alpha = DEG2RAD( StAngle / 10.0 );
|
||||
start.x = centre.x + (int) ( radius * cos( -alpha ) );
|
||||
start.y = centre.y + (int) ( radius * sin( -alpha ) );
|
||||
move_to( start );
|
||||
MoveTo( start );
|
||||
for( int ii = StAngle + delta; ii < EndAngle; ii += delta )
|
||||
{
|
||||
alpha = ii / 1800.0 * M_PI;
|
||||
alpha = DEG2RAD( ii / 10.0 );
|
||||
end.x = centre.x + (int) ( radius * cos( -alpha ) );
|
||||
end.y = centre.y + (int) ( radius * sin( -alpha ) );
|
||||
line_to( end );
|
||||
LineTo( end );
|
||||
}
|
||||
|
||||
alpha = EndAngle / 1800.0 * M_PI;
|
||||
alpha = DEG2RAD( EndAngle / 10.0 );
|
||||
end.x = centre.x + (int) ( radius * cos( -alpha ) );
|
||||
end.y = centre.y + (int) ( radius * sin( -alpha ) );
|
||||
finish_to( end );
|
||||
FinishTo( end );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback: if it doesn't handle bitmaps, we plot a rectangle
|
||||
*/
|
||||
void PLOTTER::PlotImage(const wxImage & aImage, const wxPoint& aPos,
|
||||
double aScaleFactor )
|
||||
{
|
||||
wxSize size( aImage.GetWidth() * aScaleFactor,
|
||||
aImage.GetHeight() * aScaleFactor );
|
||||
|
||||
wxPoint start = aPos;
|
||||
start.x -= size.x / 2;
|
||||
start.y -= size.y / 2;
|
||||
|
||||
wxPoint end = start;
|
||||
end.x += size.x;
|
||||
end.y += size.y;
|
||||
|
||||
Rect( start, end, NO_FILL );
|
||||
}
|
||||
|
||||
|
||||
/* Modifies size size.x and size.y trace according to the scale factor. */
|
||||
void PLOTTER::user_to_device_size( wxSize& size )
|
||||
/**
|
||||
* Plot a square centered on the position. Building block for markers
|
||||
*/
|
||||
void PLOTTER::markerSquare( const wxPoint& position, int radius )
|
||||
{
|
||||
size.x = (int) ( size.x * plot_scale * device_scale );
|
||||
size.y = (int) ( size.y * plot_scale * device_scale );
|
||||
}
|
||||
|
||||
|
||||
double PLOTTER::user_to_device_size( double size )
|
||||
{
|
||||
return size * plot_scale * device_scale;
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill )
|
||||
{
|
||||
int radius = KiROUND( diametre / 2.8284 );
|
||||
static std::vector< wxPoint > corner_list;
|
||||
corner_list.clear();
|
||||
double r = KiROUND( radius / 1.4142 );
|
||||
std::vector< wxPoint > corner_list;
|
||||
wxPoint corner;
|
||||
corner.x = position.x + radius;
|
||||
corner.y = position.y + radius;
|
||||
corner.x = position.x + r;
|
||||
corner.y = position.y + r;
|
||||
corner_list.push_back( corner );
|
||||
corner.x = position.x + radius;
|
||||
corner.y = position.y - radius;
|
||||
corner.x = position.x + r;
|
||||
corner.y = position.y - r;
|
||||
corner_list.push_back( corner );
|
||||
corner.x = position.x - radius;
|
||||
corner.y = position.y - radius;
|
||||
corner.x = position.x - r;
|
||||
corner.y = position.y - r;
|
||||
corner_list.push_back( corner );
|
||||
corner.x = position.x - radius;
|
||||
corner.y = position.y + radius;
|
||||
corner.x = position.x - r;
|
||||
corner.y = position.y + r;
|
||||
corner_list.push_back( corner );
|
||||
corner.x = position.x + radius;
|
||||
corner.y = position.y + radius;
|
||||
corner.x = position.x + r;
|
||||
corner.y = position.y + r;
|
||||
corner_list.push_back( corner );
|
||||
|
||||
PlotPoly( corner_list, fill );
|
||||
PlotPoly( corner_list, NO_FILL );
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::center_lozenge( const wxPoint& position, int diametre, FILL_T fill )
|
||||
/**
|
||||
* Plot a circle centered on the position. Building block for markers
|
||||
*/
|
||||
void PLOTTER::markerCircle( const wxPoint& position, int radius )
|
||||
{
|
||||
int radius = diametre / 2;
|
||||
static std::vector< wxPoint > corner_list;
|
||||
corner_list.clear();
|
||||
Circle( position, radius * 2, NO_FILL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plot a lozenge centered on the position. Building block for markers
|
||||
*/
|
||||
void PLOTTER::markerLozenge( const wxPoint& position, int radius )
|
||||
{
|
||||
std::vector< wxPoint > corner_list;
|
||||
wxPoint corner;
|
||||
corner.x = position.x;
|
||||
corner.y = position.y + radius;
|
||||
@@ -144,115 +188,163 @@ void PLOTTER::center_lozenge( const wxPoint& position, int diametre, FILL_T fill
|
||||
corner.y = position.y + radius;
|
||||
corner_list.push_back( corner );
|
||||
|
||||
PlotPoly( corner_list, fill );
|
||||
PlotPoly( corner_list, NO_FILL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plot a - bar centered on the position. Building block for markers
|
||||
*/
|
||||
void PLOTTER::markerHBar( const wxPoint& pos, int radius )
|
||||
{
|
||||
MoveTo( wxPoint( pos.x - radius, pos.y ) );
|
||||
FinishTo( wxPoint( pos.x + radius, pos.y ) );
|
||||
}
|
||||
|
||||
/* Draw a pattern shape number aShapeId, to coord x0, y0.
|
||||
/**
|
||||
* Plot a / bar centered on the position. Building block for markers
|
||||
*/
|
||||
void PLOTTER::markerSlash( const wxPoint& pos, int radius )
|
||||
{
|
||||
MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
|
||||
FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plot a \ bar centered on the position. Building block for markers
|
||||
*/
|
||||
void PLOTTER::markerBackSlash( const wxPoint& pos, int radius )
|
||||
{
|
||||
MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
|
||||
FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plot a | bar centered on the position. Building block for markers
|
||||
*/
|
||||
void PLOTTER::markerVBar( const wxPoint& pos, int radius )
|
||||
{
|
||||
MoveTo( wxPoint( pos.x, pos.y - radius ) );
|
||||
FinishTo( wxPoint( pos.x, pos.y + radius ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a pattern shape number aShapeId, to coord x0, y0.
|
||||
* x0, y0 = coordinates tables
|
||||
* Diameter diameter = (coord table) hole
|
||||
* AShapeId = index (used to generate forms characters)
|
||||
*/
|
||||
void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId )
|
||||
void PLOTTER::Marker( const wxPoint& position, int diametre, unsigned aShapeId )
|
||||
{
|
||||
int radius = diametre / 2;
|
||||
|
||||
int x0, y0;
|
||||
|
||||
x0 = position.x; y0 = position.y;
|
||||
|
||||
switch( aShapeId )
|
||||
/* Marker are composed by a series of 'parts' superimposed; not every
|
||||
combination make sense, obviously. Since they are used in order I
|
||||
tried to keep the uglier/more complex constructions at the end.
|
||||
Also I avoided the |/ |\ -/ -\ construction because they're *very*
|
||||
ugly... if needed they could be added anyway... I'd like to see
|
||||
a board with more than 58 drilling/slotting tools!
|
||||
If Visual C++ supported the 0b literals they would be optimally
|
||||
and easily encoded as an integer array. We have to do with octal */
|
||||
static const unsigned char marker_patterns[MARKER_COUNT] = {
|
||||
// Bit order: O Square Lozenge - | \ /
|
||||
// First choice: simple shapes
|
||||
0003, // X
|
||||
0100, // O
|
||||
0014, // +
|
||||
0040, // Sq
|
||||
0020, // Lz
|
||||
// Two simple shapes
|
||||
0103, // X O
|
||||
0017, // X +
|
||||
0043, // X Sq
|
||||
0023, // X Lz
|
||||
0114, // O +
|
||||
0140, // O Sq
|
||||
0120, // O Lz
|
||||
0054, // + Sq
|
||||
0034, // + Lz
|
||||
0060, // Sq Lz
|
||||
// Three simple shapes
|
||||
0117, // X O +
|
||||
0143, // X O Sq
|
||||
0123, // X O Lz
|
||||
0057, // X + Sq
|
||||
0037, // X + Lz
|
||||
0063, // X Sq Lz
|
||||
0154, // O + Sq
|
||||
0134, // O + Lz
|
||||
0074, // + Sq Lz
|
||||
// Four simple shapes
|
||||
0174, // O Sq Lz +
|
||||
0163, // X O Sq Lz
|
||||
0157, // X O Sq +
|
||||
0137, // X O Lz +
|
||||
0077, // X Sq Lz +
|
||||
// This draws *everything *
|
||||
0177, // X O Sq Lz +
|
||||
// Here we use the single bars... so the cross is forbidden
|
||||
0110, // O -
|
||||
0104, // O |
|
||||
0101, // O /
|
||||
0050, // Sq -
|
||||
0044, // Sq |
|
||||
0041, // Sq /
|
||||
0030, // Lz -
|
||||
0024, // Lz |
|
||||
0021, // Lz /
|
||||
0150, // O Sq -
|
||||
0144, // O Sq |
|
||||
0141, // O Sq /
|
||||
0130, // O Lz -
|
||||
0124, // O Lz |
|
||||
0121, // O Lz /
|
||||
0070, // Sq Lz -
|
||||
0064, // Sq Lz |
|
||||
0061, // Sq Lz /
|
||||
0170, // O Sq Lz -
|
||||
0164, // O Sq Lz |
|
||||
0161, // O Sq Lz /
|
||||
// Last resort: the backlash component (easy to confound)
|
||||
0102, // \ O
|
||||
0042, // \ Sq
|
||||
0022, // \ Lz
|
||||
0142, // \ O Sq
|
||||
0122, // \ O Lz
|
||||
0062, // \ Sq Lz
|
||||
0162 // \ O Sq Lz
|
||||
};
|
||||
if( aShapeId >= MARKER_COUNT )
|
||||
{
|
||||
case 0: /* vias : X shape */
|
||||
move_to( wxPoint( x0 - radius, y0 - radius ) );
|
||||
line_to( wxPoint( x0 + radius, y0 + radius ) );
|
||||
move_to( wxPoint( x0 + radius, y0 - radius ) );
|
||||
finish_to( wxPoint( x0 - radius, y0 + radius ) );
|
||||
break;
|
||||
|
||||
case 1: /* Circle */
|
||||
circle( position, diametre, NO_FILL );
|
||||
break;
|
||||
|
||||
case 2: /* + shape */
|
||||
move_to( wxPoint( x0, y0 - radius ) );
|
||||
line_to( wxPoint( x0, y0 + radius ) );
|
||||
move_to( wxPoint( x0 + radius, y0 ) );
|
||||
finish_to( wxPoint( x0 - radius, y0 ) );
|
||||
break;
|
||||
|
||||
case 3: /* X shape in circle */
|
||||
circle( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0 - radius, y0 - radius ) );
|
||||
line_to( wxPoint( x0 + radius, y0 + radius ) );
|
||||
move_to( wxPoint( x0 + radius, y0 - radius ) );
|
||||
finish_to( wxPoint( x0 - radius, y0 + radius ) );
|
||||
break;
|
||||
|
||||
case 4: /* circle with bar - shape */
|
||||
circle( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0 - radius, y0 ) );
|
||||
finish_to( wxPoint( x0 + radius, y0 ) );
|
||||
break;
|
||||
|
||||
case 5: /* circle with bar | shape */
|
||||
circle( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0, y0 - radius ) );
|
||||
finish_to( wxPoint( x0, y0 + radius ) );
|
||||
break;
|
||||
|
||||
case 6: /* square */
|
||||
center_square( position, diametre, NO_FILL );
|
||||
break;
|
||||
|
||||
case 7: /* diamond */
|
||||
center_lozenge( position, diametre, NO_FILL );
|
||||
break;
|
||||
|
||||
case 8: /* square with an X*/
|
||||
center_square( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0 - radius, y0 - radius ) );
|
||||
line_to( wxPoint( x0 + radius, y0 + radius ) );
|
||||
move_to( wxPoint( x0 + radius, y0 - radius ) );
|
||||
finish_to( wxPoint( x0 - radius, y0 + radius ) );
|
||||
break;
|
||||
|
||||
case 9: /* diamond with a +*/
|
||||
center_lozenge( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0, y0 - radius ) );
|
||||
line_to( wxPoint( x0, y0 + radius ) );
|
||||
move_to( wxPoint( x0 + radius, y0 ) );
|
||||
finish_to( wxPoint( x0 - radius, y0 ) );
|
||||
break;
|
||||
|
||||
case 10: /* square with a '/' */
|
||||
center_square( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0 - radius, y0 - radius ) );
|
||||
finish_to( wxPoint( x0 + radius, y0 + radius ) );
|
||||
break;
|
||||
|
||||
case 11: /* square with a |*/
|
||||
center_lozenge( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0, y0 - radius ) );
|
||||
finish_to( wxPoint( x0, y0 + radius ) );
|
||||
break;
|
||||
|
||||
case 12: /* square with a -*/
|
||||
center_lozenge( position, diametre, NO_FILL );
|
||||
move_to( wxPoint( x0 - radius, y0 ) );
|
||||
finish_to( wxPoint( x0 + radius, y0 ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
circle( position, diametre, NO_FILL );
|
||||
break;
|
||||
// Fallback shape
|
||||
markerCircle( position, radius );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Decode the pattern and draw the corresponding parts
|
||||
unsigned char pat = marker_patterns[aShapeId];
|
||||
if( pat & 0001 )
|
||||
markerSlash( position, radius );
|
||||
if( pat & 0002 )
|
||||
markerBackSlash( position, radius );
|
||||
if( pat & 0004 )
|
||||
markerVBar( position, radius );
|
||||
if( pat & 0010 )
|
||||
markerHBar( position, radius );
|
||||
if( pat & 0020 )
|
||||
markerLozenge( position, radius );
|
||||
if( pat & 0040 )
|
||||
markerSquare( position, radius );
|
||||
if( pat & 0100 )
|
||||
markerCircle( position, radius );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Convert a thick segment and plot it as an oval */
|
||||
void PLOTTER::segment_as_oval( wxPoint start, wxPoint end, int width,
|
||||
EDA_DRAW_MODE_T tracemode )
|
||||
/**
|
||||
* Convert a thick segment and plot it as an oval
|
||||
*/
|
||||
void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width,
|
||||
EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
|
||||
wxSize size( end.x - start.x, end.y - start.y );
|
||||
@@ -263,22 +355,22 @@ void PLOTTER::segment_as_oval( wxPoint start, wxPoint end, int width,
|
||||
else if( size.x == 0 )
|
||||
orient = 900;
|
||||
else
|
||||
orient = -(int) ( atan2( (double) size.y,
|
||||
(double) size.x ) * 1800.0 / M_PI );
|
||||
orient = -(int) ( RAD2DEG( atan2( size.y, size.x ) ) * 10.0 );
|
||||
size.x = (int) sqrt( ( (double) size.x * size.x )
|
||||
+ ( (double) size.y * size.y ) ) + width;
|
||||
size.y = width;
|
||||
|
||||
flash_pad_oval( center, size, orient, tracemode );
|
||||
FlashPadOval( center, size, orient, tracemode );
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::sketch_oval( wxPoint pos, wxSize size, int orient,
|
||||
int width )
|
||||
void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, int orient,
|
||||
int width )
|
||||
{
|
||||
set_current_line_width( width );
|
||||
width = current_pen_width;
|
||||
SetCurrentLineWidth( width );
|
||||
width = currentPenWidth;
|
||||
int radius, deltaxy, cx, cy;
|
||||
wxSize size( aSize );
|
||||
|
||||
if( size.x > size.y )
|
||||
{
|
||||
@@ -293,31 +385,31 @@ void PLOTTER::sketch_oval( wxPoint pos, wxSize size, int orient,
|
||||
cx = -radius;
|
||||
cy = -deltaxy / 2;
|
||||
RotatePoint( &cx, &cy, orient );
|
||||
move_to( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
cx = -radius;
|
||||
cy = deltaxy / 2;
|
||||
RotatePoint( &cx, &cy, orient );
|
||||
finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
|
||||
cx = radius;
|
||||
cy = -deltaxy / 2;
|
||||
RotatePoint( &cx, &cy, orient );
|
||||
move_to( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
cx = radius;
|
||||
cy = deltaxy / 2;
|
||||
RotatePoint( &cx, &cy, orient );
|
||||
finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
|
||||
|
||||
cx = 0;
|
||||
cy = deltaxy / 2;
|
||||
RotatePoint( &cx, &cy, orient );
|
||||
arc( wxPoint( cx + pos.x, cy + pos.y ),
|
||||
Arc( wxPoint( cx + pos.x, cy + pos.y ),
|
||||
orient + 1800, orient + 3600,
|
||||
radius, NO_FILL );
|
||||
cx = 0;
|
||||
cy = -deltaxy / 2;
|
||||
RotatePoint( &cx, &cy, orient );
|
||||
arc( wxPoint( cx + pos.x, cy + pos.y ),
|
||||
Arc( wxPoint( cx + pos.x, cy + pos.y ),
|
||||
orient, orient + 1800,
|
||||
radius, NO_FILL );
|
||||
}
|
||||
@@ -325,98 +417,98 @@ void PLOTTER::sketch_oval( wxPoint pos, wxSize size, int orient,
|
||||
|
||||
/* Plot 1 segment like a track segment
|
||||
*/
|
||||
void PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
|
||||
EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
switch( tracemode )
|
||||
{
|
||||
case FILLED:
|
||||
case LINE:
|
||||
set_current_line_width( tracemode==FILLED ? width : -1 );
|
||||
move_to( start );
|
||||
finish_to( end );
|
||||
break;
|
||||
|
||||
case SKETCH:
|
||||
set_current_line_width( -1 );
|
||||
segment_as_oval( start, end, width, tracemode );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::thick_arc( wxPoint centre, int StAngle, int EndAngle, int radius,
|
||||
int width, EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
switch( tracemode )
|
||||
{
|
||||
case LINE:
|
||||
set_current_line_width( -1 );
|
||||
arc( centre, StAngle, EndAngle, radius, NO_FILL, -1 );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
|
||||
break;
|
||||
|
||||
case SKETCH:
|
||||
set_current_line_width( -1 );
|
||||
arc( centre, StAngle, EndAngle,
|
||||
radius - ( width - current_pen_width ) / 2, NO_FILL, -1 );
|
||||
arc( centre, StAngle, EndAngle,
|
||||
radius + ( width - current_pen_width ) / 2, NO_FILL, -1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::thick_rect( wxPoint p1, wxPoint p2, int width,
|
||||
EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
switch( tracemode )
|
||||
{
|
||||
case LINE:
|
||||
rect( p1, p2, NO_FILL, -1 );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
rect( p1, p2, NO_FILL, width );
|
||||
break;
|
||||
|
||||
case SKETCH:
|
||||
set_current_line_width( -1 );
|
||||
p1.x -= (width - current_pen_width) / 2;
|
||||
p1.y -= (width - current_pen_width) / 2;
|
||||
p2.x += (width - current_pen_width) / 2;
|
||||
p2.y += (width - current_pen_width) / 2;
|
||||
rect( p1, p2, NO_FILL, -1 );
|
||||
p1.x += (width - current_pen_width);
|
||||
p1.y += (width - current_pen_width);
|
||||
p2.x -= (width - current_pen_width);
|
||||
p2.y -= (width - current_pen_width);
|
||||
rect( p1, p2, NO_FILL, -1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::thick_circle( wxPoint pos, int diametre, int width,
|
||||
void PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, int width,
|
||||
EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
switch( tracemode )
|
||||
{
|
||||
case LINE:
|
||||
circle( pos, diametre, NO_FILL, -1 );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
circle( pos, diametre, NO_FILL, width );
|
||||
case LINE:
|
||||
SetCurrentLineWidth( tracemode==FILLED ? width : -1 );
|
||||
MoveTo( start );
|
||||
FinishTo( end );
|
||||
break;
|
||||
|
||||
case SKETCH:
|
||||
set_current_line_width( -1 );
|
||||
circle( pos, diametre - width + current_pen_width, NO_FILL, -1 );
|
||||
circle( pos, diametre + width - current_pen_width, NO_FILL, -1 );
|
||||
SetCurrentLineWidth( -1 );
|
||||
segmentAsOval( start, end, width, tracemode );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::ThickArc( const wxPoint& centre, int StAngle, int EndAngle, int radius,
|
||||
int width, EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
switch( tracemode )
|
||||
{
|
||||
case LINE:
|
||||
SetCurrentLineWidth( -1 );
|
||||
Arc( centre, StAngle, EndAngle, radius, NO_FILL, -1 );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
Arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
|
||||
break;
|
||||
|
||||
case SKETCH:
|
||||
SetCurrentLineWidth( -1 );
|
||||
Arc( centre, StAngle, EndAngle,
|
||||
radius - ( width - currentPenWidth ) / 2, NO_FILL, -1 );
|
||||
Arc( centre, StAngle, EndAngle,
|
||||
radius + ( width - currentPenWidth ) / 2, NO_FILL, -1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
|
||||
EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
switch( tracemode )
|
||||
{
|
||||
case LINE:
|
||||
Rect( p1, p2, NO_FILL, -1 );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
Rect( p1, p2, NO_FILL, width );
|
||||
break;
|
||||
|
||||
case SKETCH:
|
||||
SetCurrentLineWidth( -1 );
|
||||
wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2,
|
||||
p1.y - (width - currentPenWidth) / 2 );
|
||||
wxPoint offsetp2( p2.x + (width - currentPenWidth) / 2,
|
||||
p2.y + (width - currentPenWidth) / 2 );
|
||||
Rect( offsetp1, offsetp2, NO_FILL, -1 );
|
||||
offsetp1.x += (width - currentPenWidth);
|
||||
offsetp1.y += (width - currentPenWidth);
|
||||
offsetp2.x -= (width - currentPenWidth);
|
||||
offsetp2.y -= (width - currentPenWidth);
|
||||
Rect( offsetp1, offsetp2, NO_FILL, -1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width,
|
||||
EDA_DRAW_MODE_T tracemode )
|
||||
{
|
||||
switch( tracemode )
|
||||
{
|
||||
case LINE:
|
||||
Circle( pos, diametre, NO_FILL, -1 );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
Circle( pos, diametre, NO_FILL, width );
|
||||
break;
|
||||
|
||||
case SKETCH:
|
||||
SetCurrentLineWidth( -1 );
|
||||
Circle( pos, diametre - width + currentPenWidth, NO_FILL, -1 );
|
||||
Circle( pos, diametre + width - currentPenWidth, NO_FILL, -1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -424,10 +516,7 @@ void PLOTTER::thick_circle( wxPoint pos, int diametre, int width,
|
||||
|
||||
void PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings )
|
||||
{
|
||||
wxASSERT( !output_file );
|
||||
wxASSERT( !outputFile );
|
||||
pageInfo = aPageSettings;
|
||||
|
||||
// PAGE_INFO is in mils, plotter works with deci-mils
|
||||
paper_size = pageInfo.GetSizeMils() * 10;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user