Add patch from Lorenzo Marcantonio. Fix some warning issues, and zlib issue under Windows (zlib sources added)
This commit is contained in:
@@ -16,25 +16,34 @@
|
||||
#include <build_version.h>
|
||||
|
||||
|
||||
/**
|
||||
* Function set_viewport
|
||||
* Set the plot offset for the current plotting
|
||||
* @param aOffset = plot offset
|
||||
* @param aScale = coordinate scale (scale coefficient for coordinates)
|
||||
* @param aMirror - Mirror plot if true.
|
||||
*/
|
||||
void GERBER_PLOTTER::set_viewport( wxPoint aOffset, double aScale, bool aMirror )
|
||||
void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
double aScale, bool aMirror )
|
||||
{
|
||||
wxASSERT( !output_file );
|
||||
wxASSERT( !outputFile );
|
||||
wxASSERT( aMirror == false );
|
||||
plotMirror = false;
|
||||
plot_offset = aOffset;
|
||||
plotOffset = aOffset;
|
||||
wxASSERT( aScale == 1 );
|
||||
plot_scale = 1;
|
||||
device_scale = 1;
|
||||
set_default_line_width( 100 ); /* line thickness in 1 / 1000 inch */
|
||||
plotScale = 1;
|
||||
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
|
||||
/* We don't handle the filmbox, and it's more useful to keep the
|
||||
* origin at the origin */
|
||||
paperSize.x = 0;
|
||||
paperSize.y = 0;
|
||||
SetDefaultLineWidth( 100 * aIusPerDecimil ); // Arbitrary default
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit a D-Code record, using proper conversions
|
||||
* to format a leading zero omitted gerber coordinate
|
||||
* (for 4 decimal positions, see header generation in start_plot
|
||||
*/
|
||||
void GERBER_PLOTTER::emitDcode( const DPOINT& pt, int dcode )
|
||||
{
|
||||
|
||||
fprintf( outputFile, "X%dY%dD%02d*\n",
|
||||
int( pt.x ), int( pt.y ), dcode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function start_plot
|
||||
@@ -42,106 +51,102 @@ void GERBER_PLOTTER::set_viewport( wxPoint aOffset, double aScale, bool aMirror
|
||||
* initialize global variable g_Plot_PlotOutputFile
|
||||
* @param aFile: an opened file to write to
|
||||
*/
|
||||
bool GERBER_PLOTTER::start_plot( FILE* aFile )
|
||||
bool GERBER_PLOTTER::StartPlot( FILE* aFile )
|
||||
{
|
||||
wxASSERT( !output_file );
|
||||
final_file = aFile;
|
||||
wxASSERT( !outputFile );
|
||||
finalFile = aFile;
|
||||
|
||||
// Create a temporary filename to store gerber file
|
||||
// note tmpfile() does not work under Vista and W7 in user mode
|
||||
m_workFilename = filename + wxT(".tmp");
|
||||
work_file = wxFopen( m_workFilename, wxT( "wt" ));
|
||||
output_file = work_file;
|
||||
wxASSERT( output_file );
|
||||
workFile = wxFopen( m_workFilename, wxT( "wt" ));
|
||||
outputFile = workFile;
|
||||
wxASSERT( outputFile );
|
||||
|
||||
if( output_file == NULL )
|
||||
if( outputFile == NULL )
|
||||
return false;
|
||||
|
||||
wxString Title = creator + wxT( " " ) + GetBuildVersion();
|
||||
fprintf( output_file, "G04 (created by %s) date %s*\n",
|
||||
fprintf( outputFile, "G04 (created by %s) date %s*\n",
|
||||
TO_UTF8( Title ), TO_UTF8( DateAndTime() ) );
|
||||
|
||||
// Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
|
||||
fputs( "G01*\nG70*\nG90*\n", output_file );
|
||||
fputs( "%MOIN*%\n", output_file ); // set unites = INCHES
|
||||
/* Mass parameter: unit = INCHES */
|
||||
fputs( "%MOIN*%\n", outputFile );
|
||||
|
||||
/* Set gerber format to 3.4 */
|
||||
/* Set coordinate format to 3.4 absolute, leading zero omitted */
|
||||
fputs( "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n",
|
||||
output_file );
|
||||
outputFile );
|
||||
|
||||
fputs( "G04 APERTURE LIST*\n", output_file );
|
||||
/* Specify linear interpol (G01), unit = INCH (G70), abs format (G90) */
|
||||
fputs( "G01*\nG70*\nG90*\n", outputFile );
|
||||
fputs( "G04 APERTURE LIST*\n", outputFile );
|
||||
/* Select the default aperture */
|
||||
set_current_line_width( -1 );
|
||||
SetCurrentLineWidth( -1 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool GERBER_PLOTTER::end_plot()
|
||||
bool GERBER_PLOTTER::EndPlot()
|
||||
{
|
||||
char line[1024];
|
||||
wxString msg;
|
||||
|
||||
wxASSERT( output_file );
|
||||
wxASSERT( outputFile );
|
||||
|
||||
/* Outfile is actually a temporary file! */
|
||||
fputs( "M02*\n", output_file );
|
||||
fflush( output_file );
|
||||
/* Outfile is actually a temporary file i.e. workFile */
|
||||
fputs( "M02*\n", outputFile );
|
||||
fflush( outputFile );
|
||||
|
||||
// rewind( work_file ); // work_file == output_file !!!
|
||||
fclose( work_file );
|
||||
work_file = wxFopen( m_workFilename, wxT( "rt" ));
|
||||
wxASSERT( work_file );
|
||||
output_file = final_file;
|
||||
fclose( workFile );
|
||||
workFile = wxFopen( m_workFilename, wxT( "rt" ));
|
||||
wxASSERT( workFile );
|
||||
outputFile = finalFile;
|
||||
|
||||
// Placement of apertures in RS274X
|
||||
while( fgets( line, 1024, work_file ) )
|
||||
while( fgets( line, 1024, workFile ) )
|
||||
{
|
||||
fputs( line, output_file );
|
||||
fputs( line, outputFile );
|
||||
|
||||
if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
|
||||
{
|
||||
write_aperture_list();
|
||||
fputs( "G04 APERTURE END LIST*\n", output_file );
|
||||
writeApertureList();
|
||||
fputs( "G04 APERTURE END LIST*\n", outputFile );
|
||||
}
|
||||
}
|
||||
|
||||
fclose( work_file );
|
||||
fclose( final_file );
|
||||
fclose( workFile );
|
||||
fclose( finalFile );
|
||||
::wxRemoveFile( m_workFilename );
|
||||
output_file = 0;
|
||||
outputFile = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Set the default line width (in 1/1000 inch) for the current plotting
|
||||
*/
|
||||
void GERBER_PLOTTER::set_default_line_width( int width )
|
||||
void GERBER_PLOTTER::SetDefaultLineWidth( int width )
|
||||
{
|
||||
default_pen_width = width;
|
||||
current_aperture = apertures.end();
|
||||
defaultPenWidth = width;
|
||||
currentAperture = apertures.end();
|
||||
}
|
||||
|
||||
|
||||
/* Set the Current line width (in 1/1000 inch) for the next plot
|
||||
*/
|
||||
void GERBER_PLOTTER::set_current_line_width( int width )
|
||||
void GERBER_PLOTTER::SetCurrentLineWidth( int width )
|
||||
{
|
||||
int pen_width;
|
||||
|
||||
if( width > 0 )
|
||||
pen_width = width;
|
||||
else
|
||||
pen_width = default_pen_width;
|
||||
pen_width = defaultPenWidth;
|
||||
|
||||
select_aperture( wxSize( pen_width, pen_width ), APERTURE::Plotting );
|
||||
current_pen_width = pen_width;
|
||||
selectAperture( wxSize( pen_width, pen_width ), APERTURE::Plotting );
|
||||
currentPenWidth = pen_width;
|
||||
}
|
||||
|
||||
|
||||
std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize& size,
|
||||
APERTURE::Aperture_Type type )
|
||||
std::vector<APERTURE>::iterator GERBER_PLOTTER::getAperture( const wxSize& size,
|
||||
APERTURE::APERTURE_TYPE type )
|
||||
{
|
||||
int last_D_code = 9;
|
||||
|
||||
@@ -150,9 +155,9 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize&
|
||||
|
||||
while( tool != apertures.end() )
|
||||
{
|
||||
last_D_code = tool->D_code;
|
||||
last_D_code = tool->DCode;
|
||||
|
||||
if( (tool->type == type) && (tool->size == size) )
|
||||
if( (tool->Type == type) && (tool->Size == size) )
|
||||
return tool;
|
||||
|
||||
tool++;
|
||||
@@ -160,76 +165,78 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize&
|
||||
|
||||
// Allocate a new aperture
|
||||
APERTURE new_tool;
|
||||
new_tool.size = size;
|
||||
new_tool.type = type;
|
||||
new_tool.D_code = last_D_code + 1;
|
||||
new_tool.Size = size;
|
||||
new_tool.Type = type;
|
||||
new_tool.DCode = last_D_code + 1;
|
||||
apertures.push_back( new_tool );
|
||||
return apertures.end() - 1;
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::select_aperture( const wxSize& size,
|
||||
APERTURE::Aperture_Type type )
|
||||
void GERBER_PLOTTER::selectAperture( const wxSize& size,
|
||||
APERTURE::APERTURE_TYPE type )
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
wxASSERT( outputFile );
|
||||
|
||||
if( ( current_aperture == apertures.end() )
|
||||
|| ( current_aperture->type != type )
|
||||
|| ( current_aperture->size != size ) )
|
||||
if( ( currentAperture == apertures.end() )
|
||||
|| ( currentAperture->Type != type )
|
||||
|| ( currentAperture->Size != size ) )
|
||||
{
|
||||
/* Pick an existing aperture or create a new one */
|
||||
current_aperture = get_aperture( size, type );
|
||||
fprintf( output_file, "G54D%d*\n", current_aperture->D_code );
|
||||
currentAperture = getAperture( size, type );
|
||||
fprintf( outputFile, "G54D%d*\n", currentAperture->DCode );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Generate list of D_CODES.
|
||||
* Returns the number of D_Codes generated in RS274X format.
|
||||
/**
|
||||
* Generate the table of D codes
|
||||
*/
|
||||
void GERBER_PLOTTER::write_aperture_list()
|
||||
void GERBER_PLOTTER::writeApertureList()
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
wxASSERT( outputFile );
|
||||
char cbuf[1024];
|
||||
|
||||
/* Init : */
|
||||
for( std::vector<APERTURE>::iterator tool = apertures.begin();
|
||||
tool != apertures.end(); tool++ )
|
||||
{
|
||||
const float fscale = 0.0001f * plot_scale; // For 3.4 format
|
||||
char* text;
|
||||
const double fscale = 0.0001f * plotScale
|
||||
* iuPerDeviceUnit ; // For 3.4 format
|
||||
char* text = cbuf + sprintf( cbuf, "%%ADD%d", tool->DCode );
|
||||
|
||||
text = cbuf + sprintf( cbuf, "%%ADD%d", tool->D_code );
|
||||
|
||||
switch( tool->type )
|
||||
switch( tool->Type )
|
||||
{
|
||||
case APERTURE::Circle:
|
||||
sprintf( text, "C,%f*%%\n", tool->size.x * fscale );
|
||||
sprintf( text, "C,%g*%%\n", tool->Size.x * fscale );
|
||||
break;
|
||||
|
||||
case APERTURE::Rect:
|
||||
sprintf( text, "R,%fX%f*%%\n", tool->size.x * fscale,
|
||||
tool->size.y * fscale );
|
||||
sprintf( text, "R,%gX%g*%%\n",
|
||||
tool->Size.x * fscale,
|
||||
tool->Size.y * fscale );
|
||||
break;
|
||||
|
||||
case APERTURE::Plotting:
|
||||
sprintf( text, "C,%f*%%\n", tool->size.x * fscale );
|
||||
sprintf( text, "C,%g*%%\n", tool->Size.x * fscale );
|
||||
break;
|
||||
|
||||
case APERTURE::Oval:
|
||||
sprintf( text, "O,%fX%f*%%\n", tool->size.x * fscale, tool->size.y * fscale );
|
||||
sprintf( text, "O,%gX%g*%%\n",
|
||||
tool->Size.x * fscale,
|
||||
tool->Size.y * fscale );
|
||||
break;
|
||||
}
|
||||
|
||||
fputs( cbuf, output_file );
|
||||
fputs( cbuf, outputFile );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::pen_to( wxPoint aPos, char plume )
|
||||
void GERBER_PLOTTER::PenTo( const wxPoint& aPos, char plume )
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
user_to_device_coordinates( aPos );
|
||||
wxASSERT( outputFile );
|
||||
DPOINT pos_dev = userToDeviceCoordinates( aPos );
|
||||
|
||||
switch( plume )
|
||||
{
|
||||
@@ -237,21 +244,21 @@ void GERBER_PLOTTER::pen_to( wxPoint aPos, char plume )
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
fprintf( output_file, "X%5.5dY%5.5dD02*\n", aPos.x, aPos.y );
|
||||
emitDcode( pos_dev, 2 );
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
fprintf( output_file, "X%5.5dY%5.5dD01*\n", aPos.x, aPos.y );
|
||||
emitDcode( pos_dev, 1 );
|
||||
}
|
||||
|
||||
pen_state = plume;
|
||||
penState = plume;
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
|
||||
void GERBER_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
|
||||
int width )
|
||||
{
|
||||
static std::vector< wxPoint > cornerList;
|
||||
cornerList.clear();
|
||||
std::vector< wxPoint > cornerList;
|
||||
|
||||
// Build corners list
|
||||
cornerList.push_back( p1 );
|
||||
@@ -267,141 +274,98 @@ void GERBER_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function circle
|
||||
* writes a non filled circle to output file
|
||||
* Plot one circle as segments (6 to 16 depending on its radius
|
||||
* @param aCentre = center coordinates
|
||||
* @param aDiameter = diameter of the circle
|
||||
* @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR)
|
||||
* not used here: circles are always not filled the gerber. Filled circles are flashed
|
||||
* @param aWidth = line width
|
||||
*/
|
||||
void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int aWidth )
|
||||
void GERBER_PLOTTER::Circle( const wxPoint& aCentre, int aDiameter, FILL_T aFill,
|
||||
int aWidth )
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
wxASSERT( outputFile );
|
||||
wxPoint start, end;
|
||||
double radius = aDiameter / 2;
|
||||
const int delta = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */
|
||||
|
||||
start.x = aCentre.x + KiROUND( radius );
|
||||
start.y = aCentre.y;
|
||||
set_current_line_width( aWidth );
|
||||
move_to( start );
|
||||
SetCurrentLineWidth( aWidth );
|
||||
MoveTo( start );
|
||||
|
||||
for( int ii = delta; ii < 3600; ii += delta )
|
||||
{
|
||||
end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( (double)ii / 10.0 ) ) );
|
||||
end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( (double)ii / 10.0 ) ) );
|
||||
line_to( end );
|
||||
end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( ii / 10.0 ) ) );
|
||||
end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( ii / 10.0 ) ) );
|
||||
LineTo( end );
|
||||
}
|
||||
|
||||
finish_to( start );
|
||||
FinishTo( start );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function PlotPoly
|
||||
* writes a filled or not filled polyline to output file
|
||||
* @param aCornerList = buffer of corners coordinates
|
||||
* @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR)
|
||||
* @param aWidth = Width of the line to plot.
|
||||
/**
|
||||
* Gerber polygon: they can (and *should*) be filled with the
|
||||
* appropriate G36/G37 sequence (raster fills are deprecated)
|
||||
*/
|
||||
void GERBER_PLOTTER::PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth )
|
||||
void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList,
|
||||
FILL_T aFill, int aWidth )
|
||||
{
|
||||
if( aCornerList.size() <= 1 )
|
||||
return;
|
||||
|
||||
set_current_line_width( aWidth );
|
||||
SetCurrentLineWidth( aWidth );
|
||||
|
||||
if( aFill )
|
||||
fputs( "G36*\n", output_file );
|
||||
fputs( "G36*\n", outputFile );
|
||||
|
||||
move_to( aCornerList[0] );
|
||||
MoveTo( aCornerList[0] );
|
||||
|
||||
for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
|
||||
{
|
||||
line_to( aCornerList[ii] );
|
||||
LineTo( aCornerList[ii] );
|
||||
}
|
||||
|
||||
if( aFill )
|
||||
{
|
||||
finish_to( aCornerList[0] );
|
||||
fputs( "G37*\n", output_file );
|
||||
FinishTo( aCornerList[0] );
|
||||
fputs( "G37*\n", outputFile );
|
||||
}
|
||||
else
|
||||
{
|
||||
pen_finish();
|
||||
PenFinish();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function PlotImage
|
||||
* Only Postscript plotters can plot bitmaps
|
||||
* for plotters that cannot plot a bitmap, a rectangle is plotted
|
||||
* For GERBER_PLOTTER, draws a rectangle
|
||||
* 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)
|
||||
/**
|
||||
* Filled circular flashes are stored as apertures
|
||||
*/
|
||||
void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor )
|
||||
void GERBER_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
|
||||
EDA_DRAW_MODE_T trace_mode )
|
||||
{
|
||||
wxSize size;
|
||||
size.x = aImage.GetWidth();
|
||||
size.y = aImage.GetHeight();
|
||||
|
||||
size.x = KiROUND( size.x * aScaleFactor );
|
||||
size.y = KiROUND( size.y * 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 );
|
||||
|
||||
}
|
||||
|
||||
/* Function flash_pad_circle
|
||||
* Plot a circular pad or via at the user position pos
|
||||
*/
|
||||
void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre, EDA_DRAW_MODE_T trace_mode )
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
wxASSERT( outputFile );
|
||||
wxSize size( diametre, diametre );
|
||||
|
||||
switch( trace_mode )
|
||||
{
|
||||
case LINE:
|
||||
case SKETCH:
|
||||
set_current_line_width( -1 );
|
||||
circle( pos, diametre - current_pen_width, NO_FILL );
|
||||
SetCurrentLineWidth( -1 );
|
||||
Circle( pos, diametre - currentPenWidth, NO_FILL );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
user_to_device_coordinates( pos );
|
||||
select_aperture( size, APERTURE::Circle );
|
||||
fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
|
||||
DPOINT pos_dev = userToDeviceCoordinates( pos );
|
||||
selectAperture( size, APERTURE::Circle );
|
||||
emitDcode( pos_dev, 3 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Plot oval pad at position pos:
|
||||
* Dimensions dx, dy,
|
||||
* Orient Orient
|
||||
* For a vertical or horizontal orientation, the shape is flashed
|
||||
* For any orientation the shape is drawn as a segment
|
||||
/**
|
||||
* Filled oval flashes are handled as aperture in the 90 degree positions only
|
||||
*/
|
||||
void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
||||
EDA_DRAW_MODE_T trace_mode )
|
||||
void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int orient,
|
||||
EDA_DRAW_MODE_T trace_mode )
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
wxASSERT( outputFile );
|
||||
int x0, y0, x1, y1, delta;
|
||||
wxSize size( aSize );
|
||||
|
||||
/* Plot a flashed shape. */
|
||||
if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
|
||||
@@ -409,10 +373,10 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
||||
{
|
||||
if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
|
||||
EXCHG( size.x, size.y );
|
||||
|
||||
user_to_device_coordinates( pos );
|
||||
select_aperture( size, APERTURE::Oval );
|
||||
fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
|
||||
|
||||
DPOINT pos_dev = userToDeviceCoordinates( pos );
|
||||
selectAperture( size, APERTURE::Oval );
|
||||
emitDcode( pos_dev, 3 );
|
||||
}
|
||||
else /* Plot pad as a segment. */
|
||||
{
|
||||
@@ -428,6 +392,7 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
||||
|
||||
if( trace_mode == FILLED )
|
||||
{
|
||||
/* XXX to do: use an aperture macro to declare the rotated pad */
|
||||
/* The pad is reduced to an oval with dy > dx */
|
||||
delta = size.y - size.x;
|
||||
x0 = 0;
|
||||
@@ -436,104 +401,100 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
|
||||
y1 = delta / 2;
|
||||
RotatePoint( &x0, &y0, orient );
|
||||
RotatePoint( &x1, &y1, orient );
|
||||
thick_segment( wxPoint( pos.x + x0, pos.y + y0 ),
|
||||
ThickSegment( wxPoint( pos.x + x0, pos.y + y0 ),
|
||||
wxPoint( pos.x + x1, pos.y + y1 ),
|
||||
size.x, trace_mode );
|
||||
}
|
||||
else
|
||||
{
|
||||
sketch_oval( pos, size, orient, -1 );
|
||||
sketchOval( pos, size, orient, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Plot rectangular pad.
|
||||
* Gives its center, size, and orientation
|
||||
* For a vertical or horizontal shape, the shape is an aperture (Dcode) and
|
||||
* it is flashed.
|
||||
* For others shape the direction is plotted as a polygon.
|
||||
/**
|
||||
* Filled rect flashes are handled as aperture in the 90 degree positions only
|
||||
*/
|
||||
void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
|
||||
int orient, EDA_DRAW_MODE_T trace_mode )
|
||||
void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize,
|
||||
int orient, EDA_DRAW_MODE_T trace_mode )
|
||||
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
wxASSERT( outputFile );
|
||||
wxSize size( aSize );
|
||||
|
||||
/* Plot as flashed. */
|
||||
switch( orient )
|
||||
{
|
||||
case 900:
|
||||
case 2700: /* rotation of 90 degrees or 270 returns dimensions */
|
||||
EXCHG( size.x, size.y );
|
||||
case 2700: /* rotation of 90 degrees or 270 swaps dimensions */
|
||||
EXCHG( size.x, size.y );
|
||||
|
||||
// Pass through
|
||||
// Pass through
|
||||
case 0:
|
||||
case 1800:
|
||||
switch( trace_mode )
|
||||
{
|
||||
case LINE:
|
||||
case SKETCH:
|
||||
set_current_line_width( -1 );
|
||||
rect( wxPoint( pos.x - (size.x - current_pen_width) / 2,
|
||||
pos.y - (size.y - current_pen_width) / 2 ),
|
||||
wxPoint( pos.x + (size.x - current_pen_width) / 2,
|
||||
pos.y + (size.y - current_pen_width) / 2 ),
|
||||
NO_FILL );
|
||||
break;
|
||||
switch( trace_mode )
|
||||
{
|
||||
case LINE:
|
||||
case SKETCH:
|
||||
SetCurrentLineWidth( -1 );
|
||||
Rect( wxPoint( pos.x - (size.x - currentPenWidth) / 2,
|
||||
pos.y - (size.y - currentPenWidth) / 2 ),
|
||||
wxPoint( pos.x + (size.x - currentPenWidth) / 2,
|
||||
pos.y + (size.y - currentPenWidth) / 2 ),
|
||||
NO_FILL );
|
||||
break;
|
||||
|
||||
case FILLED:
|
||||
user_to_device_coordinates( pos );
|
||||
select_aperture( size, APERTURE::Rect );
|
||||
fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
|
||||
break;
|
||||
}
|
||||
case FILLED:
|
||||
DPOINT pos_dev = userToDeviceCoordinates( pos );
|
||||
selectAperture( size, APERTURE::Rect );
|
||||
emitDcode( pos_dev, 3 );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
default: // plot pad shape as polygon
|
||||
{
|
||||
// XXX to do: use an aperture macro to declare the rotated pad
|
||||
wxPoint coord[4];
|
||||
// coord[0] is assumed the lower left
|
||||
// coord[1] is assumed the upper left
|
||||
// coord[2] is assumed the upper right
|
||||
// coord[3] is assumed the lower right
|
||||
|
||||
default: /* plot pad shape as polygon */
|
||||
{
|
||||
wxPoint coord[4];
|
||||
// coord[0] is assumed the lower left
|
||||
// coord[1] is assumed the upper left
|
||||
// coord[2] is assumed the upper right
|
||||
// coord[3] is assumed the lower right
|
||||
/* Trace the outline. */
|
||||
coord[0].x = -size.x/2; // lower left
|
||||
coord[0].y = size.y/2;
|
||||
coord[1].x = -size.x/2; // upper left
|
||||
coord[1].y = -size.y/2;
|
||||
coord[2].x = size.x/2; // upper right
|
||||
coord[2].y = -size.y/2;
|
||||
coord[3].x = size.x/2; // lower right
|
||||
coord[3].y = size.y/2;
|
||||
|
||||
/* Trace the outline. */
|
||||
coord[0].x = -size.x/2; // lower left
|
||||
coord[0].y = size.y/2;
|
||||
coord[1].x = -size.x/2; // upper left
|
||||
coord[1].y = -size.y/2;
|
||||
coord[2].x = size.x/2; // upper right
|
||||
coord[2].y = -size.y/2;
|
||||
coord[3].x = size.x/2; //lower right
|
||||
coord[3].y = size.y/2;
|
||||
|
||||
flash_pad_trapez( pos, coord, orient, trace_mode );
|
||||
}
|
||||
break;
|
||||
FlashPadTrapez( pos, coord, orient, trace_mode );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Plot trapezoidal pad.
|
||||
* aPadPos is pad position, aCorners the corners positions of the basic shape
|
||||
* Orientation aPadOrient in 0.1 degrees
|
||||
* Plot mode = FILLED or SKETCH
|
||||
/**
|
||||
* Trapezoidal pad at the moment are *never* handled as aperture, since
|
||||
* they require aperture macros
|
||||
*/
|
||||
void GERBER_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
||||
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
|
||||
void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCorners,
|
||||
int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
|
||||
|
||||
{
|
||||
// XXX to do: use an aperture macro to declare the pad
|
||||
// polygon corners list
|
||||
static std::vector< wxPoint > cornerList;
|
||||
cornerList.clear();
|
||||
|
||||
std::vector< wxPoint > cornerList;
|
||||
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
cornerList.push_back( aCorners[ii] );
|
||||
|
||||
/* Draw the polygon and fill the interior as required. */
|
||||
// Draw the polygon and fill the interior as required
|
||||
for( unsigned ii = 0; ii < 4; ii++ )
|
||||
{
|
||||
RotatePoint( &cornerList[ii], aPadOrient );
|
||||
@@ -543,15 +504,19 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
|
||||
// Close the polygon
|
||||
cornerList.push_back( cornerList[0] );
|
||||
|
||||
set_current_line_width( -1 );
|
||||
SetCurrentLineWidth( -1 );
|
||||
PlotPoly( cornerList, aTrace_Mode==FILLED ? FILLED_SHAPE : NO_FILL );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the plot polarity and begin a new layer
|
||||
* Used to 'scratch off' silk screen away from solder mask
|
||||
*/
|
||||
void GERBER_PLOTTER::SetLayerPolarity( bool aPositive )
|
||||
{
|
||||
if( aPositive )
|
||||
fprintf( output_file, "%%LPD*%%\n" );
|
||||
fprintf( outputFile, "%%LPD*%%\n" );
|
||||
else
|
||||
fprintf( output_file, "%%LPC*%%\n" );
|
||||
fprintf( outputFile, "%%LPC*%%\n" );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user