7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 09:51:53 +00:00

Commit patch for plot functions from Lorenzo

This commit is contained in:
charras 2009-06-28 16:50:42 +00:00
parent ed71f4b772
commit 2a80117065
43 changed files with 3267 additions and 5017 deletions

View File

@ -329,7 +329,7 @@ bool EDA_TextStruct::TextHitTest( EDA_Rect& refArea )
void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_Colors aColor,
int aDrawMode,
GRFillMode aFillMode, EDA_Colors aAnchor_color )
GRTraceMode aFillMode, EDA_Colors aAnchor_color )
/***************************************************************/
/** Function Draw
@ -399,7 +399,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_Colors aColor,
int aDrawMode,
GRFillMode aFillMode, EDA_Colors aAnchor_color,
GRTraceMode aFillMode, EDA_Colors aAnchor_color,
wxString& aText, wxPoint aPos )
{
int width = m_Width;

View File

@ -14,129 +14,271 @@
/***************************************************************************/
void InitPlotParametresGERBER( wxPoint aOffset, double aXScale, double aYScale )
void Gerber_Plotter::set_viewport( wxPoint offset,
double aScale, int orient )
/***************************************************************************/
/** function InitPlotParametresGERBER
/** function set_viewport
* Set the plot offset for the current plotting
* @param aOffset = plot offset
* @param aXScale,aYScale = coordinate scale (scale coefficient for coordinates)
* @param aScale = coordinate scale (scale coefficient for coordinates)
*/
{
g_Plot_PlotOrientOptions = 0;
g_Plot_PlotOffset = aOffset;
g_Plot_XScale = aXScale;
g_Plot_YScale = aYScale;
g_Plot_DefaultPenWidth = 120; /* epaisseur du trait standard en 1/1000 pouce */
g_Plot_CurrentPenWidth = -1;
wxASSERT(!output_file);
wxASSERT(orient == 0);
plot_orient_options = 0;
plot_offset = offset;
wxASSERT(aScale == 1);
plot_scale = 1;
device_scale = 1;
set_default_line_width(100); /* epaisseur du trait standard en 1/1000 pouce */
}
/******************************************************************/
void Write_Header_GERBER( const wxString aTitle, FILE* aFile )
/******************************************************************/
/** Function Write_Header_GERBER
void Gerber_Plotter::start_plot( FILE *aFile )
/*****************************************************************/
/** Function start_plot
* Write GERBER header to file
* initialize global variable g_Plot_PlotOutputFile
* @param aTitle: the name of creator (comment)
* @param aFile: an opened file to write to
*/
{
char Line[1024];
g_Plot_PlotOutputFile = aFile;
wxASSERT(!output_file);
final_file = aFile;
work_file = tmpfile();
output_file = work_file;
DateAndTime( Line );
wxString Title = aTitle + wxT( " " ) + GetBuildVersion();
fprintf( g_Plot_PlotOutputFile, "G04 (created by %s) date %s*\n", CONV_TO_UTF8( Title ), Line );
wxString Title = creator + wxT( " " ) + GetBuildVersion();
fprintf( output_file, "G04 (created by %s) date %s*\n", CONV_TO_UTF8( Title ), Line );
// Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
fputs( "G01*\nG70*\nG90*\n", g_Plot_PlotOutputFile );
fputs( "%MOIN*%\n", g_Plot_PlotOutputFile ); // set unites = INCHES
fputs( "G01*\nG70*\nG90*\n", output_file );
fputs( "%MOIN*%\n", output_file ); // set unites = INCHES
/* Set gerber format to 3.4 */
fputs( "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n",
g_Plot_PlotOutputFile);
output_file);
fputs( "G04 APERTURE LIST*\n", g_Plot_PlotOutputFile );
fputs( "G04 APERTURE LIST*\n", output_file );
/* Select the default aperture */
set_current_line_width(-1);
}
/******************************************************************/
void Gerber_Plotter::end_plot( )
/*****************************************************************/
{
char line[1024];
wxString msg;
/**********************************************/
void LineTo_GERBER( wxPoint aPos, int aCommand )
/**********************************************/
/** Function LineTo_GERBER
* if aCommand = 'U' initialise the starting point of a line
* if aCommand = 'D' draw a line from the starting point, or last point to aPos
* @param aPos = end of the current line.
* @param aCommand = 'U' or 'D' or 'Z' (Pen up , no moving )
wxASSERT(output_file);
/* Outfile is actually a temporary file! */
fputs( "M02*\n", output_file );
fflush(output_file);
rewind( work_file ); // work_file == output_file !!!
output_file = final_file;
// Placement des Apertures en RS274X
while( fgets( line, 1024, work_file ) )
{
fputs( line, output_file );
if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
{
write_aperture_list();
fputs( "G04 APERTURE END LIST*\n", output_file );
}
}
fclose( work_file );
fclose( final_file );
output_file = 0;
}
/*************************************************************************************/
void Gerber_Plotter::set_default_line_width( int width )
/*************************************************************************************/
/* Set the default line width (in 1/1000 inch) for the current plotting
*/
{
static wxPoint LastPoint;
switch ( aCommand )
default_pen_width = width; // epaisseur du trait standard en 1/1000 pouce
current_aperture = apertures.end();
}
/***************************************/
void Gerber_Plotter::set_current_line_width( int width )
/***************************************/
/* Set the Current line width (in 1/1000 inch) for the next plot
*/
{
int pen_width;
if( width > 0 )
pen_width = width;
else
pen_width = default_pen_width;
select_aperture(wxSize(pen_width, pen_width), Aperture::Plotting);
current_pen_width = pen_width;
}
/******************************************************/
vector<Aperture>::iterator Gerber_Plotter::get_aperture(const wxSize &size,
Aperture::Aperture_Type type)
/******************************************************/
{
int last_D_code = 9;
// Search an existing aperture
vector<Aperture>::iterator tool = apertures.begin();
while (tool != apertures.end()) {
last_D_code = tool->D_code;
if ((tool->type == type)
&& (tool->size == size))
return tool;
tool++;
}
// Allocate a new aperture
Aperture new_tool;
new_tool.size = size;
new_tool.type = type;
new_tool.D_code = 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)
/******************************************************/
{
wxASSERT(output_file);
if ((current_aperture == apertures.end())
|| (current_aperture->type != type)
|| (current_aperture->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 );
}
}
/******************************************************/
void Gerber_Plotter::write_aperture_list( )
/******************************************************/
/* Genere la liste courante des D_CODES
* Retourne le nombre de D_Codes utilises
* Genere une sequence RS274X
*/
{
wxASSERT(output_file);
char cbuf[1024];
/* Init : */
for (vector<Aperture>::iterator tool=apertures.begin();
tool != apertures.end(); tool++)
{
const float fscale = 0.0001f * plot_scale; // For 3.4 format
char* text;
text = cbuf + sprintf( cbuf, "%%ADD%d", tool->D_code);
switch( tool->type )
{
case Aperture::Circle:
sprintf( text, "C,%f*%%\n", tool->size.x * fscale );
break;
case Aperture::Rect:
sprintf( text, "R,%fX%f*%%\n", tool->size.x * fscale,
tool->size.y * fscale );
break;
case Aperture::Plotting:
sprintf( text, "C,%f*%%\n", tool->size.x * fscale );
break;
case Aperture::Oval:
sprintf( text, "O,%fX%f*%%\n", tool->size.x * fscale,
tool->size.y * fscale );
break;
}
fputs( cbuf, output_file );
}
}
/**********************************************/
void Gerber_Plotter::pen_to( wxPoint aPos, char plume )
{
wxASSERT(output_file);
user_to_device_coordinates( aPos );
switch ( plume )
{
case 'Z':
return;
break;
case 'U':
fprintf( output_file, "X%5.5dY%5.5dD02*\n", aPos.x, aPos.y );
break;
case 'D':
PlotGERBERLine( LastPoint, aPos, g_Plot_CurrentPenWidth );
fprintf( output_file, "X%5.5dY%5.5dD01*\n", aPos.x, aPos.y );
}
LastPoint = aPos;
pen_state = plume;
}
/** Function PlotGERBERLine
* Plot a line
* the D_CODE **MUST** have already selected (this is just the line plot)
* @param aStartPos = starting point of the line
* @param aEndPos = ending point of the line
* @param aThickness = line thickness (not used here)
*/
void PlotGERBERLine( wxPoint aStartPos, wxPoint aEndPos, int aThickness )
/************************************************************/
void Gerber_Plotter::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/************************************************************/
{
UserToDeviceCoordinate( aStartPos );
UserToDeviceCoordinate( aEndPos );
fprintf( g_Plot_PlotOutputFile, "X%5.5dY%5.5dD02*\n", aStartPos.x, aStartPos.y );
fprintf( g_Plot_PlotOutputFile, "X%5.5dY%5.5dD01*\n", aEndPos.x, aEndPos.y );
wxASSERT(output_file);
int coord[10] = {
p1.x, p1.y,
p1.x, p2.y,
p2.x, p2.y,
p2.x, p1.y,
p1.x, p1.y
};
poly( 5, coord, fill, width);
}
/********************************************************************/
void PlotCircle_GERBER( wxPoint aCentre, int aRadius, int aWidth )
void Gerber_Plotter::circle( wxPoint pos, int diametre, FILL_T fill, int width )
/********************************************************************/
/** Function PlotCircle_GERBER
* writes a non filled circle to output file
* Plot one circle as segments (6 to 16 depending on its radius
* @param aCentre = centre coordintes
* @param aRadius = radius of the circle
* @param aWidth = line width (noc currently used, D_CODEs must be selected before)
* @param aWidth = line width
*/
{
int ii;
wxPoint start, end;
int delta; /* increment (in 0.1 degrees) to draw circles */
wxASSERT(output_file);
wxPoint start,end;
double aRadius = diametre / 2;
const int delta = 3600/32; /* increment (in 0.1 degrees) to draw circles */
delta = 3600/32; /* there are delta segments for draw a circle */
start.x = aCentre.x + aRadius;
start.y = aCentre.y;
for( ii = delta; ii < 3600; ii += delta )
start.x = pos.x + aRadius;
start.y = pos.y;
set_current_line_width(width);
move_to(start);
for(int ii = delta; ii < 3600; ii += delta )
{
end.x = aCentre.x + (int) (aRadius * fcosinus[ii]);
end.y = aCentre.y + (int) (aRadius * fsinus[ii]);
PlotGERBERLine( start, end, aWidth );
start = end;
end.x = pos.x + (int) (aRadius * fcosinus[ii]);
end.y = pos.y + (int) (aRadius * fsinus[ii]);
line_to(end);
}
end.x = aCentre.x + aRadius;
end.y = aCentre.y;
PlotGERBERLine( start, end, aWidth );
finish_to( start );
}
/***************************************************************/
void PlotFilledPolygon_GERBER( int aCornersCount, int* aCoord )
void Gerber_Plotter::poly( int nb_segm, int* coord, FILL_T fill, int width )
/***************************************************************/
/** Function PlotFilledPolygon_GERBER
* writes a filled polyline to output file
@ -144,59 +286,231 @@ void PlotFilledPolygon_GERBER( int aCornersCount, int* aCoord )
* @param aCoord = buffer of corners coordinates
*/
{
int ii;
wxASSERT(output_file);
wxPoint pos, startpos;
set_current_line_width(width);
fputs( "G36*\n", g_Plot_PlotOutputFile );
pos.x = *aCoord;
aCoord++;
pos.y = *aCoord;
aCoord++;
UserToDeviceCoordinate( pos );
startpos = pos;
fprintf( g_Plot_PlotOutputFile, "X%5.5dY%5.5dD02*\n", pos.x, pos.y );
for( ii = 1; ii < aCornersCount; ii++ )
if (fill)
fputs( "G36*\n", output_file );
startpos.x = *coord++;
startpos.y = *coord++;
move_to(startpos);
for(int ii = 1; ii < nb_segm; ii++ )
{
pos.x = *aCoord;
aCoord++;
pos.y = *aCoord;
aCoord++;
UserToDeviceCoordinate( pos );
fprintf( g_Plot_PlotOutputFile, "X%5.5dY%5.5dD01*\n", pos.x, pos.y );
pos.x = *coord++;
pos.y = *coord++;
line_to( pos );
}
if (fill)
{
finish_to(startpos);
fputs( "G37*\n", output_file );
}
else
{
pen_finish();
}
fprintf( g_Plot_PlotOutputFile, "X%5.5dY%5.5dD01*\n", startpos.x, startpos.y );
fputs( "G37*\n", g_Plot_PlotOutputFile );
}
/*******************************************************************/
void PlotPolygon_GERBER( int aCornersCount, int* aCoord, int aWidth )
/*******************************************************************/
/** Function PlotPolygon_GERBER
* writes a closed polyline (not a filled polygon) to output file
* @param aCornersCount = numer of corners
* @param aCoord = buffer of corners coordinates
* @param aWidth = line width (not currently used, D_CODEs must be selected before)
*/
void Gerber_Plotter::flash_pad_circle(wxPoint pos, int diametre,
GRTraceMode trace_mode)
/* Plot a circular pad or via at the user position pos
*/
{
wxPoint start, end, startpoint;
startpoint.x = *aCoord++;
startpoint.y = *aCoord++;
start = startpoint;
for( int ii = 0; ii < aCornersCount-1; ii++ )
wxASSERT(output_file);
wxSize size( diametre, diametre );
switch (trace_mode)
{
end.x = *aCoord;
aCoord++;
end.y = *aCoord;
aCoord++;
PlotGERBERLine(start, end, aWidth );
start = end;
case FILAIRE:
case SKETCH:
set_current_line_width(-1);
circle(pos, diametre-current_pen_width, 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 );
break;
}
if ( startpoint != end ) // Close poly
PlotGERBERLine(end, startpoint, aWidth );
}
void Gerber_Plotter::flash_pad_oval(wxPoint pos, wxSize size, int orient,
GRTraceMode trace_mode)
/* Trace 1 pastille PAD_OVAL en position pos_X,Y:
* dimensions dx, dy,
* orientation orient
* Pour une orientation verticale ou horizontale, la forme est flashee
* Pour une orientation quelconque la forme est tracee comme un segment
*/
{
wxASSERT(output_file);
int x0, y0, x1, y1, delta;
/* Trace de la forme flashee */
if(( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
&& trace_mode == FILLED)
{
if( orient == 900 || orient == 2700 ) /* orient tournee de 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 );
}
else /* Forme tracee comme un segment */
{
if( size.x > size.y )
{
EXCHG( size.x, size.y );
if( orient < 2700 )
orient += 900;
else
orient -= 2700;
}
if (trace_mode == FILLED)
{
/* la pastille est ramenee a une pastille ovale avec dy > dx */
delta = size.y - size.x;
x0 = 0;
y0 = -delta / 2;
x1 = 0;
y1 = delta / 2;
RotatePoint( &x0, &y0, orient );
RotatePoint( &x1, &y1, orient );
thick_segment( 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);
}
}
void Gerber_Plotter::flash_pad_rect(wxPoint pos, wxSize size,
int orient, GRTraceMode trace_mode)
/* Plot 1 rectangular pad
* donne par son centre, ses dimensions, et son orientation
* For a vertical or horizontal shape, the shape is an aperture (Dcode) and it is flashed
* For others orientations the shape is plotted as a polygon
*/
{
wxASSERT(output_file);
/* Trace de la forme flashee */
switch( orient )
{
case 900:
case 2700: /* la rotation de 90 ou 270 degres revient a permutter des dimensions */
EXCHG( size.x, size.y );
// Pass through
case 0:
case 1800:
switch (trace_mode) {
case FILAIRE:
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;
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;
}
break;
default: /* plot pad shape as polygon */
flash_pad_trapez( pos, size, wxSize( 0, 0 ), orient, trace_mode );
break;
}
}
void Gerber_Plotter::flash_pad_trapez(wxPoint pos, wxSize size, wxSize delta,
int orient, GRTraceMode trace_mode)
/* Trace 1 pad trapezoidal donne par :
* son centre pos.x,pos.y
* ses dimensions size.x et size.y
* les variations delta.x et delta.y ( 1 des deux au moins doit etre nulle)
* son orientation orient en 0.1 degres
* le mode de trace (FILLED, SKETCH, FILAIRE)
*
* Le trace n'est fait que pour un trapeze, c.a.d que delta.x ou delta.y
* = 0.
*
* les notation des sommets sont ( vis a vis de la table tracante )
*
* " 0 ------------- 3 "
* " . . "
* " . O . "
* " . . "
* " 1 ---- 2 "
*
*
* exemple de Disposition pour delta.y > 0, delta.x = 0
* " 1 ---- 2 "
* " . . "
* " . O . "
* " . . "
* " 0 ------------- 3 "
*
*
* exemple de Disposition pour delta.y = 0, delta.x > 0
* " 0 "
* " . . "
* " . . "
* " . 3 "
* " . . "
* " . O . "
* " . . "
* " . 2 "
* " . . "
* " . . "
* " 1 "
*/
{
wxASSERT(output_file);
int ii, jj;
int dx, dy;
wxPoint polygon[4]; /* polygon corners */
int coord[10];
int ddx, ddy;
/* calcul des dimensions optimales du spot choisi = 1/4 plus petite dim */
dx = size.x - abs( delta.y );
dy = size.y - abs( delta.x );
dx = size.x / 2;
dy = size.y / 2;
ddx = delta.x / 2;
ddy = delta.y / 2;
polygon[0].x = -dx - ddy;
polygon[0].y = +dy + ddx;
polygon[1].x = -dx + ddy;
polygon[1].y = -dy - ddx;
polygon[2].x = +dx - ddy;
polygon[2].y = -dy + ddx;
polygon[3].x = +dx + ddy;
polygon[3].y = +dy - ddx;
/* Dessin du polygone et Remplissage eventuel de l'interieur */
for( ii = 0, jj = 0; ii < 4; ii++ )
{
RotatePoint( &polygon[ii].x, &polygon[ii].y, orient );
coord[jj] = polygon[ii].x += pos.x;
jj++;
coord[jj] = polygon[ii].y += pos.y;
jj++;
}
coord[8]=coord[0];
coord[9]=coord[1];
set_current_line_width(-1);
poly( 5, coord, trace_mode==FILLED?FILLED_SHAPE:NO_FILL );
}

View File

@ -11,96 +11,189 @@
#include "macros.h"
#include "kicad_string.h"
/* parametre HPGL pour trace de cercle: */
#define CHORD_ANGLE 10
//Variables locales
void Move_Plume_HPGL( wxPoint pos, int plume );
void Plume_HPGL( int plume );
/* From decimils to plu */
const double SCALE_HPGL = 0.102041;
/***********************************************************************************/
void InitPlotParametresHPGL( wxPoint offset, double aXScale, double aYScale, int orient )
void HPGL_Plotter::set_viewport( wxPoint offset,
double aScale, int orient )
/***********************************************************************************/
/* Set the plot offset for the current plotting
* g_Plot_XScale,g_Plot_YScale = coordinate scale (scale coefficient for coordinates)
* device_g_Plot_XScale,device_g_Plot_YScale = device coordinate scale (i.e scale used by plot device)
*/
{
g_Plot_PlotOffset = offset;
g_Plot_XScale = aXScale;
g_Plot_YScale = aYScale;
g_Plot_DefaultPenWidth = 6; /* epaisseur du trait standard en 1/1000 pouce */
g_Plot_PlotOrientOptions = orient;
g_Plot_CurrentPenWidth = -1;
wxASSERT(!output_file);
plot_offset = offset;
plot_scale = aScale;
device_scale = SCALE_HPGL;
set_default_line_width(100); /* epaisseur du trait standard en 1/1000 pouce */
plot_orient_options = orient;
}
/*****************************************************************/
bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num )
void HPGL_Plotter::start_plot( FILE *fout )
/*****************************************************************/
{
char Line[256];
g_Plot_PlotOutputFile = plot_file;
g_Plot_PenState = 'U';
sprintf( Line, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_num );
fputs( Line, plot_file );
return TRUE;
wxASSERT(!output_file);
output_file = fout;
fprintf( output_file, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_number );
}
/**********************************/
bool CloseFileHPGL( FILE* plot_file )
void HPGL_Plotter::end_plot()
/**********************************/
{
fputs( "PU;PA;SP0;\n", plot_file );
fclose( plot_file );
return TRUE;
wxASSERT(output_file);
fputs( "PU;PA;SP0;\n", output_file );
fclose( output_file );
output_file = 0;
}
/************************************************************/
void PlotRectHPGL( wxPoint p1, wxPoint p2, bool fill, int width )
void HPGL_Plotter::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/************************************************************/
{
char Line[256];
UserToDeviceCoordinate( p1 );
UserToDeviceCoordinate( p2 );
Plume_HPGL( 'U' );
sprintf( Line, "PA %d,%d;EA %d,%d;\n", p1.x, p1.y, p2.x, p2.y );
fputs( Line, g_Plot_PlotOutputFile );
Plume_HPGL( 'U' ); return;
wxASSERT(output_file);
user_to_device_coordinates( p2 );
move_to(p1);
fprintf( output_file, "EA %d,%d;\n", p2.x, p2.y );
pen_finish();
}
/************************************************************/
void PlotCircleHPGL( wxPoint centre, int diameter, bool fill, int width )
void HPGL_Plotter::circle( wxPoint centre, int diameter, FILL_T fill, int width )
/************************************************************/
{
int rayon;
char Line[256];
wxASSERT(output_file);
double rayon = user_to_device_size(diameter / 2);
UserToDeviceCoordinate( centre );
rayon = (int) (diameter / 2 * g_Plot_XScale);
if( rayon < 0 )
rayon = 0;
Plume_HPGL( 'U' );
sprintf( Line, "PA %d,%d;CI %d,%d;\n", centre.x, centre.y, rayon, CHORD_ANGLE );
fputs( Line, g_Plot_PlotOutputFile );
Plume_HPGL( 'U' ); return;
if( rayon > 0 )
{
move_to(centre);
fprintf( output_file, "CI %g;\n", rayon);
pen_finish();
}
}
/*****************************************************/
void HPGL_Plotter::poly( int nb, int* coord, FILL_T fill, int width )
/*****************************************************/
/* Trace un polygone (ferme si rempli) en format HPGL
* coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli
*/
{
wxASSERT(output_file);
if( nb <= 1 )
return;
move_to( wxPoint( coord[0], coord[1] ) );
for(int ii = 1; ii < nb; ii++ )
line_to( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ) );
/* Fermeture eventuelle du polygone */
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();
}
/***************************/
void HPGL_Plotter::pen_control( int plume )
/***************************/
/* leve (plume = 'U') ou baisse (plume = 'D') la plume
*/
{
wxASSERT(output_file);
switch (plume) {
case 'U':
if( pen_state != 'U' )
{
fputs( "PU;", output_file );
pen_state = 'U';
}
break;
case 'D':
if( pen_state != 'D' )
{
fputs( "PD;", output_file );
pen_state = 'D';
}
break;
case 'Z':
fputs( "PU;", output_file );
pen_state = 'U';
pen_lastpos.x = -1;
pen_lastpos.y = -1;
break;
}
}
/**********************************************/
void HPGL_Plotter::pen_to( wxPoint pos, char plume )
/**********************************************/
/*
* deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
* en position x,y
* Unites en Unites DESSIN
* Si plume = 'Z' lever de plume sans deplacement
*/
{
wxASSERT(output_file);
if( plume == 'Z' )
{
pen_control( 'Z' );
return;
}
pen_control( plume );
user_to_device_coordinates( pos );
if (pen_lastpos != pos)
fprintf( output_file, "PA %d,%d;\n", pos.x, pos.y );
pen_lastpos = pos;
}
void HPGL_Plotter::set_dash( bool dashed )
{
wxASSERT(output_file);
if (dashed)
fputs("LI 2;\n", stderr);
else
fputs("LI;\n", stderr);
}
void HPGL_Plotter::thick_segment( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode)
/** Function Plot a filled segment (track)
* @param start = starting point
* @param end = ending point
* @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH ..
*/
{
wxASSERT(output_file);
wxPoint center;
wxSize size;
if( (pen_diameter >= width) || (tracemode == FILAIRE) ) /* just a line is Ok */
{
move_to( start );
finish_to( end );
}
else
segment_as_oval(start, end, width, tracemode);
}
/********************************************************************/
void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fill, int width )
void HPGL_Plotter::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width )
/********************************************************************/
/* trace d'un arc de cercle:
@ -112,7 +205,7 @@ void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fil
* ou PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle; PU;
*/
{
char Line[256];
wxASSERT(output_file);
wxPoint cmap; /* point de depart */
wxPoint cpos; /* centre */
float angle; /* angle de l'arc*/
@ -120,105 +213,320 @@ void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fil
if( rayon <= 0 )
return;
cpos = centre; UserToDeviceCoordinate( cpos );
cpos = centre;
user_to_device_coordinates( cpos );
if( g_Plot_PlotOrientOptions == PLOT_MIROIR )
{
EndAngle = -EndAngle;
StAngle = -StAngle;
EXCHG( StAngle, EndAngle );
}
if( plot_orient_options == PLOT_MIROIR )
angle = (StAngle - EndAngle) / 10.0;
else
angle = (EndAngle - StAngle) / 10.0;
/* Calcul des coord du point de depart : */
cmap.x = (int) ( centre.x + ( rayon * cos( StAngle * M_PI / 1800 ) ) );
cmap.y = (int) ( centre.y + ( rayon * sin( StAngle * M_PI / 1800 ) ) );
UserToDeviceCoordinate( cmap );
cmap.y = (int) ( centre.y - ( rayon * sin( StAngle * M_PI / 1800 ) ) );
user_to_device_coordinates( cmap );
Plume_HPGL( 'U' );
sprintf( Line, "PU;PA %d,%d;PD;AA %d,%d, ", cmap.x, cmap.y, cpos.x, cpos.y );
fputs( Line, g_Plot_PlotOutputFile );
sprintf( Line, "%f", -angle ); to_point( Line ); // Transforme , et . du separateur
fputs( Line, g_Plot_PlotOutputFile );
sprintf( Line, ", %d", CHORD_ANGLE ); fputs( Line, g_Plot_PlotOutputFile );
sprintf( Line, ";PU;\n" ); fputs( Line, g_Plot_PlotOutputFile );
Plume_HPGL( 'U' );
fprintf( output_file, "PU;PA %d,%d;PD;AA %d,%d, ", cmap.x, cmap.y, cpos.x, cpos.y );
fprintf( output_file, "%f", angle );
fprintf( output_file, ";PU;\n" );
pen_finish();
}
/*****************************************************/
void PlotPolyHPGL( int nb, int* coord, bool fill, int width )
/*****************************************************/
/* Trace un polygone (ferme si rempli) en format HPGL
* coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli
*/
/***********************************************************************************/
void HPGL_Plotter::flash_pad_oval( wxPoint pos, wxSize size, int orient,
GRTraceMode trace_mode )
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */
{
int ii;
wxASSERT(output_file);
int rayon, deltaxy, cx, cy;
if( nb <= 1 )
return;
Move_Plume_HPGL( wxPoint( coord[0], coord[1] ), 'U' );
for( ii = 1; ii < nb; ii++ )
/* la pastille est ramenee a une pastille ovale avec size.y > size.x
* ( ovale vertical en orientation 0 ) */
if( size.x > size.y )
{
Move_Plume_HPGL( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ), 'D' );
EXCHG( size.x, size.y ); orient += 900;
if( orient >= 3600 )
orient -= 3600;
}
/* Fermeture eventuelle du polygone */
if( fill )
deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */
rayon = size.x / 2;
if( trace_mode == FILLED )
{
ii = (nb - 1) * 2;
if( (coord[ii] != coord[0] ) || (coord[ii + 1] != coord[0]) )
Move_Plume_HPGL( wxPoint( coord[0], coord[1] ), 'D' );
flash_pad_rect( pos, wxSize( size.x, deltaxy+pen_diameter ),
orient, trace_mode );
cx = 0; cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
flash_pad_circle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode );
cx = 0; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
flash_pad_circle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode );
}
else /* Trace en mode SKETCH */
{
sketch_oval(pos, size, orient, pen_diameter);
}
Plume_HPGL( 'U' );
}
/*******************************************************************************/
void HPGL_Plotter::flash_pad_circle(wxPoint pos, int diametre,
GRTraceMode trace_mode)
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos */
{
wxASSERT(output_file);
int rayon, delta;
/**********************************************/
void Move_Plume_HPGL( wxPoint pos, int plume )
/**********************************************/
user_to_device_coordinates( pos );
delta = pen_diameter - pen_overlap;
rayon = diametre / 2;
if( trace_mode != FILAIRE )
{
rayon = (diametre - pen_diameter ) / 2;
}
if( rayon < 0 )
{
rayon = 0;
}
wxSize rsize( rayon, rayon );
user_to_device_size( rsize );
fprintf( output_file, "PA %d,%d;CI %d;\n", pos.x, pos.y, rsize.x );
if( trace_mode == FILLED ) /* Trace en mode Remplissage */
{
if( delta > 0 )
{
while( (rayon -= delta ) >= 0 )
{
rsize.x = rsize.y = rayon;
user_to_device_size( rsize );
fprintf( output_file, "PA %d,%d; CI %d;\n", pos.x, pos.y, rsize.x );
}
}
}
pen_finish();
return;
}
/**************************************************************************/
void HPGL_Plotter::flash_pad_rect(wxPoint pos, wxSize padsize,
int orient, GRTraceMode trace_mode)
/**************************************************************************/
/*
* deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
* en position x,y
* Unites en Unites DESSIN
* Si plume = 'Z' lever de plume sans deplacement
* Trace 1 pad rectangulaire vertical ou horizontal ( Pad rectangulaire )
* donne par son centre et ses dimensions X et Y
* Units are user units
*/
{
char Line[256];
wxASSERT(output_file);
wxSize size;
int delta;
int ox, oy, fx, fy;
if( plume == 'Z' )
size.x = padsize.x / 2; size.y = padsize.y / 2;
if( trace_mode != FILAIRE )
{
Plume_HPGL( 'U' );
size.x = (padsize.x - (int) pen_diameter) / 2;
size.y = (padsize.y - (int) pen_diameter) / 2;
}
if( size.x < 0 )
size.x = 0;
if( size.y < 0 )
size.y = 0;
/* Si une des dimensions est nulle, le trace se reduit a 1 trait */
if( size.x == 0 )
{
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;
}
if( size.y == 0 )
{
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 ) );
return;
}
Plume_HPGL( plume );
UserToDeviceCoordinate( pos );
sprintf( Line, "PA %d,%d;\n", pos.x, pos.y ); fputs( Line, g_Plot_PlotOutputFile );
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 ) );
if( trace_mode == FILLED )
{
/* Trace en mode Remplissage */
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 ) );
}
}
}
/***************************/
void Plume_HPGL( int plume )
/***************************/
/* leve (plume = 'U') ou baisse (plume = 'D') la plume
/*******************************************************************/
void HPGL_Plotter::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
int orient, GRTraceMode trace_mode )
/*******************************************************************/
/*
* Trace 1 pad trapezoidal donne par :
* son centre pos.x,pos.y
* ses dimensions dimX et dimY
* les variations deltaX et deltaY
* son orientation orient et 0.1 degres
* le mode de trace (FILLED, SKETCH, FILAIRE)
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY
* = 0.
*
* les notation des sommets sont ( vis a vis de la table tracante )
* 0 ------------- 3
* . .
* . .
* . .
* 1 --- 2
*/
{
if( plume == 'U' )
wxASSERT(output_file);
wxPoint polygone[4]; /* coord des sommets / centre du pad */
wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */
int moveX, moveY; /* variation de position plume selon axe X et Y , lors
* du remplissage du trapeze */
moveX = moveY = pen_diameter;
size.x /= 2; size.y /= 2;
delta.x /= 2; delta.y /= 2;
polygone[0].x = -size.x - delta.y; polygone[0].y = +size.y + delta.x;
polygone[1].x = -size.x + delta.y; polygone[1].y = -size.y - delta.x;
polygone[2].x = +size.x - delta.y; polygone[2].y = -size.y + delta.x;
polygone[3].x = +size.x + delta.y; polygone[3].y = +size.y - delta.x;
/* Trace du contour */
polygone[0].x += moveX; polygone[0].y -= moveY;
polygone[1].x += moveX; polygone[1].y += moveY;
polygone[2].x -= moveX; polygone[2].y += moveY;
polygone[3].x -= moveX; polygone[3].y -= moveY;
for(int ii = 0; ii < 4; ii++ )
{
if( g_Plot_PenState != 'U' )
fputs( "PU;", g_Plot_PlotOutputFile );
g_Plot_PenState = 'U';
coord[ii].x = polygone[ii].x + pos.x;
coord[ii].y = polygone[ii].y + pos.y;
RotatePoint( &coord[ii], pos, orient );
}
// Plot edge:
move_to( coord[0] );
line_to( coord[1] );
line_to( coord[2] );
line_to( coord[3] );
finish_to( coord[0] );
if( trace_mode == FILLED )
{
int jj;
/* Fill the shape */
moveX = moveY = pen_diameter - pen_overlap;
/* calcul de jj = hauteur du remplissage */
if( delta.y ) /* Trapeze horizontal */
{
jj = size.y - (int) ( pen_diameter + (2 * pen_overlap) );
}
else
{
if( g_Plot_PenState != 'D' )
fputs( "PD;", g_Plot_PlotOutputFile );
g_Plot_PenState = 'D';
jj = size.x - (int) ( pen_diameter + (2 * pen_overlap) );
}
/* Calcul de jj = nombre de segments a tracer pour le remplissage */
jj = jj / (int) (pen_diameter - pen_overlap);
/* Trace du contour */
for( ; jj > 0; jj-- )
{
polygone[0].x += moveX; polygone[0].y -= moveY;
polygone[1].x += moveX; polygone[1].y += moveY;
polygone[2].x -= moveX; polygone[2].y += moveY;
polygone[3].x -= moveX; polygone[3].y -= moveY;
/* Test de limitation de variation des dimensions :
* si les sommets se "croisent", il ne faut plus modifier les
* coordonnees correspondantes */
if( polygone[0].x > polygone[3].x )
{ /* croisement sur axe X des 2 sommets 0 et 3 */
polygone[0].x = polygone[3].x = 0;
}
if( polygone[1].x > polygone[2].x )
{ /* croisement sur axe X des 2 sommets 1 et 2 */
polygone[1].x = polygone[2].x = 0;
}
if( polygone[1].y > polygone[0].y )
{ /* croisement sur axe Y des 2 sommets 0 et 1 */
polygone[0].y = polygone[1].y = 0;
}
if( polygone[2].y > polygone[3].y )
{ /* croisement sur axe Y des 2 sommets 2 et 3 */
polygone[2].y = polygone[3].y = 0;
}
for(int ii = 0; ii < 4; ii++ )
{
coord[ii].x = polygone[ii].x + pos.x;
coord[ii].y = polygone[ii].y + pos.y;
RotatePoint( &coord[ii], pos, orient );
}
move_to( coord[0] );
line_to( coord[1] );
line_to( coord[2] );
line_to( coord[3] );
finish_to( coord[0] );
}
}
}

View File

@ -11,65 +11,57 @@
#include "macros.h"
#include "kicad_string.h"
// Locales
static Ki_PageDescr* SheetPS;
/*************************************************************************************/
void InitPlotParametresPS( wxPoint offset, Ki_PageDescr* sheet,
double aXScale, double aYScale, int orient )
void PS_Plotter::set_viewport( wxPoint offset,
double aScale, int orient )
/*************************************************************************************/
/* Set the plot offset for the current plotting
* g_Plot_XScale,g_Plot_YScale = coordinate scale (scale coefficient for coordinates)
* device_g_Plot_XScale,device_g_Plot_YScale = device coordinate scale (i.e scale used by plot device)
*/
/* Set the plot offset for the current plotting */
{
g_Plot_PlotOrientOptions = orient;
g_Plot_PlotOffset = offset;
SheetPS = sheet;
g_Plot_XScale = aXScale;
g_Plot_YScale = aYScale;
g_Plot_CurrentPenWidth = -1;
g_Plot_PenState = 'Z';
wxASSERT(!output_file);
plot_orient_options = orient;
plot_offset = offset;
plot_scale = aScale;
device_scale = 1; /* PS references in decimils */
set_default_line_width(100); /* epaisseur du trait standard en 1/1000 pouce */
}
/*************************************************************************************/
void SetDefaultLineWidthPS( int width )
void PS_Plotter::set_default_line_width( int width )
/*************************************************************************************/
/* Set the default line width (in 1/1000 inch) for the current plotting
*/
{
g_Plot_DefaultPenWidth = width; // epaisseur du trait standard en 1/1000 pouce
g_Plot_CurrentPenWidth = -1;
default_pen_width = width; // epaisseur du trait standard en 1/1000 pouce
current_pen_width = -1;
}
/***************************************/
void SetCurrentLineWidthPS( int width )
void PS_Plotter::set_current_line_width( int width )
/***************************************/
/* Set the Current line width (in 1/1000 inch) for the next plot
*/
{
wxASSERT(output_file);
int pen_width;
if( width > 0 )
if( width >= 0 )
pen_width = width;
else
pen_width = g_Plot_DefaultPenWidth;
pen_width = default_pen_width;
if( pen_width != g_Plot_CurrentPenWidth )
fprintf( g_Plot_PlotOutputFile, "%d setlinewidth\n", (int) (g_Plot_XScale * pen_width) );
if( pen_width != current_pen_width )
fprintf( output_file, "%g setlinewidth\n",
user_to_device_size(pen_width));
g_Plot_CurrentPenWidth = pen_width;
current_pen_width = pen_width;
}
/******************************/
void SetColorMapPS( int color )
void PS_Plotter::set_color( int color )
/******************************/
/* Print the postscript set color command:
@ -79,97 +71,92 @@ void SetColorMapPS( int color )
* color = color index in ColorRefs[]
*/
{
char Line[1024];
sprintf( Line, "%.3f %.3f %.3f setrgbcolor\n",
(float) ColorRefs[color].m_Red / 255,
(float) ColorRefs[color].m_Green / 255,
(float) ColorRefs[color].m_Blue / 255 );
to_point( Line );
fputs( Line, g_Plot_PlotOutputFile );
wxASSERT(output_file);
if ((color >= 0 && color_mode)
|| (color == BLACK)
|| (color == WHITE))
{
if (negative_mode)
fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
(double) 1.0-ColorRefs[color].m_Red / 255,
(double) 1.0-ColorRefs[color].m_Green / 255,
(double) 1.0-ColorRefs[color].m_Blue / 255 );
else
fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
(double) ColorRefs[color].m_Red / 255,
(double) ColorRefs[color].m_Green / 255,
(double) ColorRefs[color].m_Blue / 255 );
}
}
/***************************************************************/
void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width )
/***************************************************************/
/* Plot 1 segment like a track segment
*/
void PS_Plotter::set_dash( bool dashed )
{
UserToDeviceCoordinate( start );
UserToDeviceCoordinate( end );
SetCurrentLineWidthPS( width );
fprintf( g_Plot_PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y );
wxASSERT(output_file);
if (dashed)
fputs("dashedline\n", stderr);
else
fputs("solidline\n", stderr);
}
/***************************************************************/
void PlotRectPS( wxPoint p1, wxPoint p2, bool fill, int width )
void PS_Plotter::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/***************************************************************/
{
UserToDeviceCoordinate( p1 );
UserToDeviceCoordinate( p2 );
user_to_device_coordinates( p1 );
user_to_device_coordinates( p2 );
SetCurrentLineWidthPS( width );
fprintf( g_Plot_PlotOutputFile, "%d %d %d %d rect%d\n", p1.x, p1.y,
set_current_line_width( width );
fprintf( output_file, "%d %d %d %d rect%d\n", p1.x, p1.y,
p2.x-p1.x, p2.y-p1.y, fill );
}
/******************************************************/
void PlotCirclePS( wxPoint pos, int diametre, bool fill, int width )
void PS_Plotter::circle( wxPoint pos, int diametre, FILL_T fill, int width )
/******************************************************/
{
int rayon;
char Line[256];
wxASSERT(output_file);
user_to_device_coordinates( pos );
double rayon = user_to_device_size(diametre / 2.0);
UserToDeviceCoordinate( pos );
rayon = (int) (g_Plot_XScale * diametre / 2);
if( rayon < 1 )
rayon = 1;
if( rayon < 0 )
rayon = 0;
SetCurrentLineWidthPS( width );
sprintf(Line, "%d %d %d cir%d\n", pos.x, pos.y, rayon, fill);
fputs( Line, g_Plot_PlotOutputFile );
set_current_line_width( width );
fprintf(output_file, "%d %d %g cir%d\n", pos.x, pos.y, rayon, fill);
}
/**************************************************************************************/
void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fill, int width )
void PS_Plotter::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width )
/**************************************************************************************/
/* Plot an arc:
* StAngle, EndAngle = start and end arc in 0.1 degree
*/
{
char Line[256];
wxASSERT(output_file);
if( rayon <= 0 )
return;
SetCurrentLineWidthPS( width );
set_current_line_width( width );
// Calcul des coord du point de depart :
UserToDeviceCoordinate( centre );
if( g_Plot_PlotOrientOptions == PLOT_MIROIR )
sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y,
(int) (rayon * g_Plot_XScale), (float) StAngle / 10, (float) EndAngle / 10,
user_to_device_coordinates( centre );
rayon = user_to_device_size(rayon);
if( plot_orient_options == PLOT_MIROIR )
fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
rayon, (double) -EndAngle / 10, (double) -StAngle / 10,
fill);
else
sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y,
(int) (rayon * g_Plot_XScale), -(float) EndAngle / 10, -(float) StAngle / 10,
fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
rayon, (double) StAngle / 10, (double) EndAngle / 10,
fill);
// Undo internationalization printf (float x.y printed x,y)
to_point( Line );
fputs( Line, g_Plot_PlotOutputFile );
}
/*****************************************************************/
void PlotPolyPS( int nb_segm, int* coord, bool fill, int width )
void PS_Plotter::poly( int nb_segm, int* coord, FILL_T fill, int width )
/*****************************************************************/
/* Draw a polygon ( a filled polygon if fill == 1 ) in POSTSCRIPT format
@ -179,62 +166,63 @@ void PlotPolyPS( int nb_segm, int* coord, bool fill, int width )
* @param width = line width
*/
{
int ii;
wxASSERT(output_file);
wxPoint pos;
if( nb_segm <= 1 )
return;
SetCurrentLineWidthPS( width );
set_current_line_width( width );
pos.x = coord[0];
pos.y = coord[1];
UserToDeviceCoordinate( pos );
fprintf( g_Plot_PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y );
user_to_device_coordinates( pos );
fprintf( output_file, "newpath\n%d %d moveto\n", pos.x, pos.y );
for( ii = 1; ii < nb_segm; ii++ )
for(int ii = 1; ii < nb_segm; ii++ )
{
pos.x = coord[2 * ii];
pos.y = coord[2 * ii + 1];
UserToDeviceCoordinate( pos );
fprintf( g_Plot_PlotOutputFile, "%d %d lineto\n", pos.x, pos.y );
user_to_device_coordinates( pos );
fprintf( output_file, "%d %d lineto\n", pos.x, pos.y );
}
// Fermeture du polygone
fprintf(g_Plot_PlotOutputFile, "poly%d\n", fill);
fprintf(output_file, "poly%d\n", fill);
}
/*************************************/
void LineTo_PS( wxPoint pos, int plume )
void PS_Plotter::pen_to( wxPoint pos, char plume )
/*************************************/
/* Routine to draw to a new position
*/
{
char Line[256];
wxASSERT(output_file);
if( plume == 'Z' ) {
if (g_Plot_PenState != 'Z') {
fputs( "stroke\n", g_Plot_PlotOutputFile );
g_Plot_PenState = 'Z';
if (pen_state != 'Z') {
fputs( "stroke\n", output_file );
pen_state = 'Z';
pen_lastpos.x = -1;
pen_lastpos.y = -1;
}
return;
}
UserToDeviceCoordinate( pos );
if (g_Plot_PenState == 'Z') {
fputs( "newpath\n", g_Plot_PlotOutputFile );
user_to_device_coordinates( pos );
if (pen_state == 'Z') {
fputs( "newpath\n", output_file );
}
sprintf( Line, "%d %d %sto\n", pos.x, pos.y, (plume=='D')?"line":"move" );
fputs( Line, g_Plot_PlotOutputFile );
g_Plot_PenState = plume;
if (pen_state != plume || pos != pen_lastpos)
fprintf( output_file, "%d %d %sto\n", pos.x, pos.y, (plume=='D')?"line":"move" );
pen_state = plume;
pen_lastpos = pos;
}
/***********************************************************/
void PrintHeaderPS( FILE* file, const wxString& Creator,
const wxString& FileName, int PageCount,
int BBox[4], int PaperOrientation )
void PS_Plotter::start_plot( FILE *fout)
/***********************************************************/
/* The code within this function (and the CloseFilePS function)
@ -246,18 +234,14 @@ void PrintHeaderPS( FILE* file, const wxString& Creator,
* http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf
*
*
* The PageCount and PaperOrientation parameters have been provided to
* respectively cater for the production of multiple-page postscript
* files, and postscript files having either a portrait orientation
* or a landscape orientation.
*
* BBox is the boundary box (position and size of the "client rectangle"
* for drawings (page - margins) in mils (0.001 inch)
*/
{
wxASSERT(!output_file);
wxString msg;
char Line[1024];
output_file = fout;
static const char* PSMacro[] = {
"/line {\n",
" newpath\n",
@ -279,48 +263,37 @@ void PrintHeaderPS( FILE* file, const wxString& Creator,
"/rect2 { rectfill } bind def\n",
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
"/dashedline { [50 50] 0 setdash } bind def\n",
"/solidline { [] 0 setdash } bind def\n",
"gsave\n",
"72 72 scale\t\t\t% Talk inches\n",
"0.0072 0.0072 scale\n", // Configure postscript for decimils
"linemode1\n",
NULL
};
const double MIL_TO_INCH = 0.001;
int ii;
const double DECIMIL_TO_INCH = 0.0001;
time_t time1970 = time( NULL );
g_Plot_PlotOutputFile = file;
fputs( "%!PS-Adobe-3.0\n", output_file ); // Print header
fputs( "%!PS-Adobe-3.0\n", g_Plot_PlotOutputFile ); // Print header
sprintf( Line, "%%%%Creator: %s\n", CONV_TO_UTF8( Creator ) );
fputs( Line, g_Plot_PlotOutputFile );
fprintf( output_file, "%%%%Creator: %s\n", CONV_TO_UTF8( creator ) );
// A "newline" character ("\n") is not included in the following string,
// because it is provided by the ctime() function.
sprintf( Line, "%%%%CreationDate: %s", ctime( &time1970 ) );
fputs( Line, g_Plot_PlotOutputFile );
fprintf( output_file, "%%%%CreationDate: %s", ctime( &time1970 ) );
fprintf( output_file, "%%%%Title: %s\n", CONV_TO_UTF8( filename ) );
fprintf( output_file, "%%%%Pages: 1\n");
fprintf( output_file, "%%%%PageOrder: Ascend\n" );
sprintf( Line, "%%%%Title: %s\n", CONV_TO_UTF8( FileName ) );
fputs( Line, g_Plot_PlotOutputFile );
sprintf( Line, "%%%%Pages: %d\n", PageCount );
fputs( Line, g_Plot_PlotOutputFile );
sprintf( Line, "%%%%PageOrder: Ascend\n" );
fputs( Line, g_Plot_PlotOutputFile );
// Print boundary box en 1/72 pouce, box is in mils
const double CONV_SCALE = MIL_TO_INCH * 72;
// Print boundary box en 1/72 pouce, box is in decimils
const double CONV_SCALE = DECIMIL_TO_INCH * 72;
// The coordinates of the lower left corner of the boundary
// box need to be "rounded down", but the coordinates of its
// upper right corner need to be "rounded up" instead.
sprintf( Line, "%%%%BoundingBox: %d %d %d %d\n",
(int) floor( (BBox[1] * CONV_SCALE) ), (int) floor( (BBox[0] * CONV_SCALE) ),
(int) ceil( (BBox[3] * CONV_SCALE) ), (int) ceil( (BBox[2] * CONV_SCALE) ) );
fputs( Line, g_Plot_PlotOutputFile );
fprintf( output_file, "%%%%BoundingBox: 0 0 %d %d\n",
(int) ceil( paper_size.y * CONV_SCALE),
(int) ceil( paper_size.x * CONV_SCALE));
// Specify the size of the sheet and the name associated with that size.
// (If the "User size" option has been selected for the sheet size,
@ -334,27 +307,20 @@ void PrintHeaderPS( FILE* file, const wxString& Creator,
//
// (NOTE: m_Size.y is *supposed* to be listed before m_Size.x;
// the order in which they are specified is not wrong!)
if( SheetPS->m_Name.Cmp( wxT( "User" ) ) == 0 )
sprintf( Line, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
wxRound( SheetPS->m_Size.y * CONV_SCALE ),
wxRound( SheetPS->m_Size.x * CONV_SCALE ) );
if( sheet->m_Name.Cmp( wxT( "User" ) ) == 0 )
fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
wxRound( sheet->m_Size.y * CONV_SCALE ),
wxRound( sheet->m_Size.x * CONV_SCALE ) );
else // ( if SheetPS->m_Name does not equal "User" )
sprintf( Line, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
CONV_TO_UTF8( SheetPS->m_Name ),
wxRound( SheetPS->m_Size.y * CONV_SCALE ),
wxRound( SheetPS->m_Size.x * CONV_SCALE ) );
fputs( Line, g_Plot_PlotOutputFile );
else // ( if sheet->m_Name does not equal "User" )
fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
CONV_TO_UTF8( sheet->m_Name ),
wxRound( sheet->m_Size.y * CONV_SCALE ),
wxRound( sheet->m_Size.x * CONV_SCALE ) );
if( PaperOrientation == wxPORTRAIT )
sprintf( Line, "%%%%Orientation: Portrait\n" );
else
sprintf( Line, "%%%%Orientation: Landscape\n" );
fprintf( output_file, "%%%%Orientation: Landscape\n" );
fputs( Line, g_Plot_PlotOutputFile );
sprintf( Line, "%%%%EndComments\n" );
fputs( Line, g_Plot_PlotOutputFile );
fprintf( output_file, "%%%%EndComments\n" );
// Now specify various other details.
@ -362,46 +328,208 @@ void PrintHeaderPS( FILE* file, const wxString& Creator,
// PSMacro[]) to highlight that it has been provided to ensure that the
// contents of the postscript file comply with the details specified
// within the Document Structuring Convention.
sprintf( Line, "%%%%Page: 1 1\n" );
fputs( Line, g_Plot_PlotOutputFile );
fprintf( output_file, "%%%%Page: 1 1\n" );
for( ii = 0; PSMacro[ii] != NULL; ii++ )
for(int ii = 0; PSMacro[ii] != NULL; ii++ )
{
fputs( PSMacro[ii], g_Plot_PlotOutputFile );
fputs( PSMacro[ii], output_file );
}
if( PaperOrientation == wxLANDSCAPE )
sprintf( Line, "%f %f translate 90 rotate\n",
(float) BBox[3] * MIL_TO_INCH, (float) BBox[0] * MIL_TO_INCH );
// (If support for creating postscript files with a portrait orientation
// is ever provided, determine whether it would be necessary to provide
// an "else" command and then an appropriate "sprintf" command here.)
fprintf( output_file, "%d 0 translate 90 rotate\n", paper_size.y);
// compensation internationalisation printf (float x.y généré x,y)
to_point( Line );
fputs( Line, g_Plot_PlotOutputFile );
sprintf( Line, "%f %f scale\t\t%% Move to User coordinates\n",
g_Plot_XScale, g_Plot_YScale );
to_point( Line );
fputs( Line, g_Plot_PlotOutputFile );
// Apply the scale adjustments
if (plot_scale_adjX != 1.0 || plot_scale_adjY != 1.0)
fprintf( output_file, "%g %g scale\n",
plot_scale_adjX, plot_scale_adjY);
// Set default line width ( g_Plot_DefaultPenWidth is in user units )
fprintf( g_Plot_PlotOutputFile, "%d setlinewidth\n", g_Plot_DefaultPenWidth );
fprintf( output_file, "%g setlinewidth\n",
user_to_device_size(default_pen_width) );
}
/******************************************/
bool CloseFilePS( FILE* plot_file )
void PS_Plotter::end_plot()
/******************************************/
{
fputs( "showpage\n", plot_file );
fputs( "grestore\n", plot_file );
fputs( "%%EOF\n", plot_file );
fclose( plot_file );
return TRUE;
wxASSERT(output_file);
fputs( "showpage\ngrestore\n%%EOF\n", output_file );
fclose( output_file );
output_file = 0;
}
/***********************************************************************************/
void PS_Plotter::flash_pad_oval( wxPoint pos, wxSize size, int orient,
GRTraceMode modetrace )
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y:
* dimensions dx,dy,
* orientation orient
* La forme est tracee comme un segment
*/
{
wxASSERT(output_file);
int x0, y0, x1, y1, delta;
// la pastille est ramenee a une pastille ovale avec dy > dx
if( size.x > size.y )
{
EXCHG( size.x, size.y );
orient += 900;
if( orient >= 3600 )
orient -= 3600;
}
delta = size.y - size.x ;
x0 = 0;
y0 = -delta / 2;
x1 = 0;
y1 = delta / 2;
RotatePoint( &x0, &y0, orient );
RotatePoint( &x1, &y1, orient );
if( modetrace == FILLED )
thick_segment( wxPoint( pos.x + x0, pos.y + y0 ),
wxPoint( pos.x + x1, pos.y + y1 ), size.x, modetrace );
else
sketch_oval(pos, size, orient, -1);
}
/*******************************************************************************/
void PS_Plotter::flash_pad_circle(wxPoint pos, int diametre,
GRTraceMode modetrace)
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos_X,Y
*/
{
wxASSERT(output_file);
if( modetrace == FILLED )
{
set_current_line_width( 0 );
circle(pos, diametre, FILLED_SHAPE);
}
else
{
set_current_line_width(-1);
int w = current_pen_width;
circle(pos, diametre-2*w, NO_FILL);
}
}
/**************************************************************************/
void PS_Plotter::flash_pad_rect(wxPoint pos, wxSize size,
int orient, GRTraceMode trace_mode)
/**************************************************************************/
/*
* Trace 1 pad rectangulaire d'orientation quelconque
* donne par son centre, ses dimensions,
* et son orientation orient
*/
{
wxASSERT(output_file);
set_current_line_width(-1);
int w = current_pen_width;
size.x -= w;
if( size.x < 1 )
size.x = 1;
size.y -= w;
if( size.y < 1 )
size.y = 1;
int dx = size.x / 2;
int dy = size.y / 2;
int coord[10] = {
pos.x - dx, pos.y + dy,
pos.x - dx, pos.y - dy,
pos.x + dx, pos.y - dy,
pos.x + dx, pos.y + dy,
0, 0
};
for(int ii = 0; ii < 4; ii++ )
{
RotatePoint( &coord[ii*2], &coord[ii*2+1], pos.x, pos.y, orient );
}
coord[8] = coord[0];
coord[9] = coord[1];
poly(5, coord, trace_mode==FILLED?FILLED_SHAPE:NO_FILL);
}
/*******************************************************************/
void PS_Plotter::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
int orient, GRTraceMode modetrace )
/*******************************************************************/
/*
* Trace 1 pad trapezoidal donne par :
* son centre centre
* ses dimensions size
* les variations delta ( 1 des deux au moins doit etre nulle)
* son orientation orient en 0.1 degres
* le mode de trace (FILLED, SKETCH, FILAIRE)
*
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY
* = 0.
*
* les notation des sommets sont ( vis a vis de la table tracante )
*
* " 0 ------------- 3 "
* " . . "
* " . O . "
* " . . "
* " 1 ---- 2 "
*
*
* exemple de Disposition pour deltaY > 0, deltaX = 0
* " 1 ---- 2 "
* " . . "
* " . O . "
* " . . "
* " 0 ------------- 3 "
*
*
* exemple de Disposition pour deltaY = 0, deltaX > 0
* " 0 "
* " . . "
* " . . "
* " . 3 "
* " . . "
* " . O . "
* " . . "
* " . 2 "
* " . . "
* " . . "
* " 1 "
*/
{
wxASSERT(output_file);
set_current_line_width(-1);
int w = current_pen_width;
int dx, dy;
int ddx, ddy;
dx = (size.x-w) / 2;
dy = (size.y-w) / 2;
ddx = delta.x / 2;
ddy = delta.y / 2;
int coord[10] = {
-dx - ddy, +dy + ddx,
-dx + ddy, -dy - ddx,
+dx - ddy, -dy + ddx,
+dx + ddy, +dy - ddx,
0, 0
};
for(int ii = 0; ii < 4; ii++ )
{
RotatePoint( &coord[ii*2], &coord[ii*2+1], orient );
coord[ii*2] += centre.x;
coord[ii*2+1] += centre.y;
}
poly(5, coord, modetrace==FILLED?FILLED_SHAPE:NO_FILL);
}

View File

@ -14,52 +14,8 @@
#include "class_base_screen.h"
#include "drawtxt.h"
// Variables partagees avec Common plot Postscript et HPLG Routines
wxPoint g_Plot_PlotOffset;
FILE* g_Plot_PlotOutputFile;
double g_Plot_XScale, g_Plot_YScale;
int g_Plot_DefaultPenWidth;
int g_Plot_CurrentPenWidth = -1;
int g_Plot_PlotOrientOptions, g_Plot_PenState;
/*************************/
void ForcePenReinit()
/*************************/
/* set the flag g_Plot_CurrentPenWidth to -1 in order to force a pen width redefinition
* for the next draw command
*/
{
g_Plot_CurrentPenWidth = -1;
}
/**********************************************/
void SetPlotScale( double aXScale, double aYScale )
/**********************************************/
/* Set the plot scale for the current plotting)
*/
{
g_Plot_XScale = aXScale;
g_Plot_YScale = aYScale;
}
/*********************************/
void Setg_Plot_PlotOffset( wxPoint offset )
/*********************************/
/* Set the plot offset for the current plotting)
*/
{
g_Plot_PlotOffset = offset;
}
/**************************************************************************/
void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
void WinEDA_DrawFrame::PlotWorkSheet( Plotter *plotter, BASE_SCREEN* screen )
/**************************************************************************/
/* Plot sheet references
@ -68,40 +24,21 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
{
#define WSTEXTSIZE 50 // Text size in mils
Ki_PageDescr* Sheet = screen->m_CurrentSheetDesc;
int ii, jj, xg, yg, ipas, gxpas, gypas;
int xg, yg, ipas, gxpas, gypas;
wxSize PageSize;
wxPoint pos, ref;
EDA_Colors color;
Ki_WorkSheetData* WsItem;
int conv_unit = screen->GetInternalUnits() / 1000; /* Scale to convert dimension in 1/1000 in into internal units
* (1/1000 inc for EESchema, 1/10000 for pcbnew */
wxString msg;
wxSize text_size;
void (*FctPlume)( wxPoint pos, int state );
int UpperLimit = VARIABLE_BLOCK_START_POSITION;
bool italic = false;
bool bold = false;
bool thickness = 0; //@todo : use current pen
switch( format_plot )
{
case PLOT_FORMAT_POST:
FctPlume = LineTo_PS;
break;
case PLOT_FORMAT_HPGL:
FctPlume = Move_Plume_HPGL;
break;
case PLOT_FORMAT_GERBER:
FctPlume = LineTo_GERBER;
break;
default:
return;
}
color = BLACK;
plotter->set_color(color);
PageSize.x = Sheet->m_Size.x;
PageSize.y = Sheet->m_Size.y;
@ -113,31 +50,30 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
yg = (PageSize.y - Sheet->m_BottomMargin) * conv_unit; /* lower right corner */
#if defined(KICAD_GOST)
FctPlume(ref,'U');
plotter->move_to( ref );
pos.x = xg; pos.y = ref.y;
FctPlume(pos,'D');
plotter->line_to( pos );
pos.x = xg; pos.y = yg;
FctPlume(pos,'D');
plotter->line_to( pos );
pos.x = ref.x; pos.y = yg;
FctPlume( pos,'D' );
FctPlume(ref,'D');
FctPlume(ref,'Z');
plotter->line_to( pos );
plotter->finish_to( ref );
#else
for( ii = 0; ii < 2; ii++ )
for( unsigned ii = 0; ii < 2; ii++ )
{
FctPlume( ref, 'U' );
plotter->move_to( ref );
pos.x = xg; pos.y = ref.y;
FctPlume( pos, 'D' );
plotter->line_to( pos );
pos.x = xg; pos.y = yg;
FctPlume( pos, 'D' );
plotter->line_to( pos );
pos.x = ref.x; pos.y = yg;
FctPlume( pos, 'D' );
FctPlume( ref, 'D' );
ref.x += GRID_REF_W * conv_unit; ref.y += GRID_REF_W * conv_unit;
xg -= GRID_REF_W * conv_unit; yg -= GRID_REF_W * conv_unit;
plotter->line_to( pos );
plotter->finish_to( ref );
ref.x += GRID_REF_W * conv_unit;
ref.y += GRID_REF_W * conv_unit;
xg -= GRID_REF_W * conv_unit;
yg -= GRID_REF_W * conv_unit;
}
FctPlume(ref,'Z');
#endif
/* trace des reperes */
@ -150,7 +86,9 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
yg = (PageSize.y - Sheet->m_BottomMargin); /* lower right corner in 1/1000 inch */
#if defined(KICAD_GOST)
for ( WsItem = &WS_Segm1_LU; WsItem != NULL; WsItem = WsItem->Pnext )
for ( Ki_WorkSheetData* WsItem = &WS_Segm1_LU;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = (ref.x - WsItem->m_Posx) * conv_unit;
pos.y = (yg - WsItem->m_Posy) * conv_unit;
@ -161,22 +99,22 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
break;
case WS_PODPIS_LU:
if(WsItem->m_Legende) msg = WsItem->m_Legende;
PlotGraphicText(format_plot, pos, color,
plotter->text( pos, color,
msg, TEXT_ORIENT_VERT, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, false );
break;
case WS_SEGMENT_LU:
FctPlume(pos, 'U');
plotter->move_to(pos);
pos.x = (ref.x - WsItem->m_Endx) * conv_unit;
pos.y = (yg - WsItem->m_Endy) * conv_unit;
FctPlume(pos, 'D');
FctPlume(ref,'Z');
plotter->finish_to(pos);
break;
}
}
for ( WsItem = &WS_Segm1_LT; WsItem != NULL; WsItem = WsItem->Pnext )
for ( Ki_WorkSheetData* WsItem = &WS_Segm1_LT;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = (ref.x + WsItem->m_Posx) * conv_unit;
pos.y = (ref.y + WsItem->m_Posy) * conv_unit;
@ -184,11 +122,10 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
switch( WsItem->m_Type )
{
case WS_SEGMENT_LT:
FctPlume(pos, 'U');
plotter->move_to(pos);
pos.x = (ref.x + WsItem->m_Endx) * conv_unit;
pos.y = (ref.y + WsItem->m_Endy) * conv_unit;
FctPlume(pos, 'D');
FctPlume(ref,'Z');
plotter->finish_to(pos);
break;
}
}
@ -197,20 +134,19 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
/* Trace des reperes selon l'axe X */
ipas = (xg - ref.x) / PAS_REF;
gxpas = ( xg - ref.x) / ipas;
for( ii = ref.x + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- )
for(int ii = ref.x + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- )
{
msg.Empty(); msg << jj;
if( ii < xg - PAS_REF / 2 )
{
pos.x = ii * conv_unit; pos.y = ref.y * conv_unit;
FctPlume( pos, 'U' );
plotter->move_to(pos);
pos.x = ii * conv_unit; pos.y = (ref.y + GRID_REF_W) * conv_unit;
FctPlume( pos, 'D' );
FctPlume(ref,'Z');
plotter->finish_to(pos);
}
pos.x = (ii - gxpas / 2) * conv_unit;
pos.y = (ref.y + GRID_REF_W / 2) * conv_unit;
PlotGraphicText( format_plot, pos, color,
plotter->text( pos, color,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
@ -218,14 +154,13 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
if( ii < xg - PAS_REF / 2 )
{
pos.x = ii * conv_unit; pos.y = yg * conv_unit;
FctPlume( pos, 'U' );
plotter->move_to( pos);
pos.x = ii * conv_unit; pos.y = (yg - GRID_REF_W) * conv_unit;
FctPlume( pos, 'D' );
FctPlume(ref,'Z');
plotter->finish_to(pos);
}
pos.x = (ii - gxpas / 2) * conv_unit;
pos.y = (yg - GRID_REF_W / 2) * conv_unit;
PlotGraphicText( format_plot, pos, color,
plotter->text( pos, color,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
@ -234,7 +169,7 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
/* Trace des reperes selon l'axe Y */
ipas = (yg - ref.y) / PAS_REF;
gypas = ( yg - ref.y) / ipas;
for( ii = ref.y + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- )
for( int ii = ref.y + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- )
{
if( jj < 26 )
msg.Printf( wxT( "%c" ), jj + 'A' );
@ -243,14 +178,13 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
if( ii < yg - PAS_REF / 2 )
{
pos.x = ref.x * conv_unit; pos.y = ii * conv_unit;
FctPlume( pos, 'U' );
plotter->move_to(pos);
pos.x = (ref.x + GRID_REF_W) * conv_unit; pos.y = ii * conv_unit;
FctPlume( pos, 'D' );
FctPlume(ref,'Z');
plotter->finish_to(pos);
}
pos.x = (ref.x + GRID_REF_W / 2) * conv_unit;
pos.y = (ii - gypas / 2) * conv_unit;
PlotGraphicText( format_plot, pos, color,
plotter->text( pos, color,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
@ -258,14 +192,13 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
if( ii < yg - PAS_REF / 2 )
{
pos.x = xg * conv_unit; pos.y = ii * conv_unit;
FctPlume( pos, 'U' );
plotter->move_to(pos);
pos.x = (xg - GRID_REF_W) * conv_unit; pos.y = ii * conv_unit;
FctPlume( pos, 'D' );
FctPlume(ref,'Z');
plotter->finish_to(pos);
}
pos.x = (xg - GRID_REF_W / 2) * conv_unit;
pos.y = (ii - gypas / 2) * conv_unit;
PlotGraphicText( format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
}
@ -279,7 +212,9 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
ref.y = PageSize.y - Sheet->m_BottomMargin;
if (screen->m_ScreenNumber == 1)
{
for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext )
for(Ki_WorkSheetData* WsItem = &WS_Date;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = (ref.x - WsItem->m_Posx) * conv_unit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
@ -294,7 +229,7 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
break;
case WS_PODPIS:
if(WsItem->m_Legende) msg = WsItem->m_Legende;
PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size,
plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ,text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
break;
@ -303,14 +238,14 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
case WS_IDENTSHEET:
if(WsItem->m_Legende) msg = WsItem->m_Legende;
msg << screen->m_ScreenNumber;
PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size,
plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ,text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
break;
case WS_SHEETS:
if(WsItem->m_Legende) msg = WsItem->m_Legende;
msg << screen->m_NumberOfScreen;
PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
break;
@ -329,16 +264,17 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
case WS_UPPER_SEGMENT:
case WS_LEFT_SEGMENT:
case WS_SEGMENT:
FctPlume(pos, 'U');
plot->move_to(pos);
pos.x = (ref.x - WsItem->m_Endx) * conv_unit;
pos.y = (ref.y - WsItem->m_Endy) * conv_unit;
FctPlume(pos, 'D');
FctPlume(ref,'Z');
plot->finish_to(pos);
break;
}
}
} else {
for( WsItem = &WS_CADRE_D; WsItem != NULL; WsItem = WsItem->Pnext )
for(Ki_WorkSheetData* WsItem = &WS_CADRE_D;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = (ref.x - WsItem->m_Posx) * conv_unit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
@ -349,24 +285,23 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
/* Begin list number > 1 */
case WS_PODPIS_D:
if(WsItem->m_Legende) msg = WsItem->m_Legende;
PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
break;
case WS_IDENTSHEET_D:
if(WsItem->m_Legende) msg = WsItem->m_Legende;
msg << screen->m_ScreenNumber;
PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false );
break;
case WS_LEFT_SEGMENT_D:
case WS_SEGMENT_D:
FctPlume(pos, 'U');
plot->move_to(pos);
pos.x = (ref.x - WsItem->m_Endx) * conv_unit;
pos.y = (ref.y - WsItem->m_Endy) * conv_unit;
FctPlume(pos, 'D');
FctPlume(ref,'Z');
plot->finish_to(pos);
break;
}
}
@ -375,7 +310,9 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
ref.x = PageSize.x - GRID_REF_W - Sheet->m_RightMargin;
ref.y = PageSize.y - GRID_REF_W - Sheet->m_BottomMargin;
for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext )
for (Ki_WorkSheetData* WsItem = &WS_Date;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = (ref.x - WsItem->m_Posx) * conv_unit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
@ -472,63 +409,393 @@ void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
wxPoint auxpos;
auxpos.x = (ref.x - WsItem->m_Endx) * conv_unit;;
auxpos.y = (ref.y - WsItem->m_Endy) * conv_unit;;
FctPlume( pos, 'U' );
FctPlume( auxpos, 'D' );
FctPlume(ref,'Z');
plotter->move_to( pos );
plotter->finish_to( auxpos );
}
break;
}
if( !msg.IsEmpty() )
{
PlotGraphicText( format_plot, pos, color,
plotter->text( pos, color,
msg.GetData(), TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, bold );
}
}
#endif
switch( format_plot )
{
case PLOT_FORMAT_HPGL:
Plume_HPGL( 'U' );
break;
case PLOT_FORMAT_POST:
break;
}
}
/******************************************/
void UserToDeviceCoordinate( wxPoint& pos )
void Plotter::user_to_device_coordinates( wxPoint& pos )
/******************************************/
/* modifie les coord pos.x et pos.y pour le trace selon l'orientation,
* l'echelle, les offsets de trace */
{
pos.x = (int) (pos.x * g_Plot_XScale);
pos.y = (int) (pos.y * g_Plot_YScale);
pos.x = (int) ((pos.x - plot_offset.x) * plot_scale * device_scale);
if (plot_orient_options == PLOT_MIROIR)
pos.y = (int) ((pos.y - plot_offset.y) * plot_scale * device_scale);
else
pos.y = (int) ((paper_size.y - (pos.y - plot_offset.y) * plot_scale) * device_scale);
}
switch( g_Plot_PlotOrientOptions ) /* Calcul du cadrage */
/********************************************************************/
void Plotter::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width )
/********************************************************************/
/* Generic arc rendered as a polyline */
{
wxPoint start, end;
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);
/* Please NOTE the different sign due to Y-axis flip */
alpha = StAngle/1800.0*M_PI;
start.x = centre.x + (int) (rayon * cos(-alpha));
start.y = centre.y + (int) (rayon * sin(-alpha));
move_to(start);
for(int ii = StAngle+delta; ii < EndAngle; ii += delta )
{
default:
pos.x -= g_Plot_PlotOffset.x; pos.y = g_Plot_PlotOffset.y - pos.y;
alpha = ii/1800.0*M_PI;
end.x = centre.x + (int) (rayon * cos(-alpha));
end.y = centre.y + (int) (rayon * sin(-alpha));
line_to(end);
}
alpha = EndAngle/1800.0*M_PI;
end.x = centre.x + (int) (rayon * cos(-alpha));
end.y = centre.y + (int) (rayon * sin(-alpha));
finish_to( end );
}
/************************************/
void Plotter::user_to_device_size( wxSize& size )
/************************************/
/* modifie les dimension size.x et size.y pour le trace selon l'echelle */
{
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 rayon = diametre / 2.8284;
int coord[10] = {
position.x+rayon, position.y+rayon,
position.x+rayon, position.y-rayon,
position.x-rayon, position.y-rayon,
position.x-rayon, position.y+rayon,
position.x+rayon, position.y+rayon
};
if (fill)
{
poly(4, coord, fill);
}
else
{
poly(5, coord, fill);
}
}
/************************************************************************************/
void Plotter::center_lozenge( const wxPoint& position, int diametre, FILL_T fill)
/************************************************************************************/
{
int rayon = diametre / 2;
int coord[10] = {
position.x, position.y+rayon,
position.x+rayon, position.y,
position.x, position.y-rayon,
position.x-rayon, position.y,
position.x, position.y+rayon,
};
if (fill)
{
poly(4, coord, fill);
}
else
{
poly(5, coord, fill);
}
}
/************************************************************************************/
void Plotter::marker( const wxPoint& position, int diametre, int aShapeId)
/************************************************************************************/
/* Trace un motif de numero de forme aShapeId, aux coord x0, y0.
* x0, y0 = coordonnees tables
* diametre = diametre (coord table) du trou
* aShapeId = index ( permet de generer des formes caract )
*/
{
int rayon = diametre / 2;
int x0, y0;
x0 = position.x; y0 = position.y;
switch( aShapeId )
{
case 0: /* vias : forme en X */
move_to( wxPoint( x0 - rayon, y0 - rayon ) );
line_to( wxPoint( x0 + rayon, y0 + rayon ) );
move_to( wxPoint( x0 + rayon, y0 - rayon ) );
finish_to( wxPoint( x0 - rayon, y0 + rayon ) );
break;
case PLOT_MIROIR:
pos.x -= g_Plot_PlotOffset.x; pos.y = -g_Plot_PlotOffset.y + pos.y;
case 1: /* Cercle */
circle(position, diametre, NO_FILL);
break;
case 2: /* forme en + */
move_to( wxPoint( x0, y0 - rayon ) );
line_to( wxPoint( x0, y0 + rayon ) );
move_to( wxPoint( x0 + rayon, y0 ) );
finish_to( wxPoint( x0 - rayon, y0 ) );
break;
case 3: /* forme en X cercle */
circle(position, diametre, NO_FILL);
move_to( wxPoint( x0 - rayon, y0 - rayon ) );
line_to( wxPoint( x0 + rayon, y0 + rayon ) );
move_to( wxPoint( x0 + rayon, y0 - rayon ) );
finish_to( wxPoint( x0 - rayon, y0 + rayon ) );
break;
case 4: /* forme en cercle barre de - */
circle(position, diametre, NO_FILL);
move_to( wxPoint( x0 - rayon, y0 ) );
finish_to( wxPoint( x0 + rayon, y0 ) );
break;
case 5: /* forme en cercle barre de | */
circle(position, diametre, NO_FILL);
move_to( wxPoint( x0, y0 - rayon ) );
finish_to( wxPoint( x0, y0 + rayon ) );
break;
case 6: /* forme en carre */
center_square(position, diametre, NO_FILL);
break;
case 7: /* forme en losange */
center_lozenge(position, diametre, NO_FILL);
break;
case 8: /* forme en carre barre par un X*/
center_square(position, diametre, NO_FILL);
move_to( wxPoint( x0 - rayon, y0 - rayon ) );
line_to( wxPoint( x0 + rayon, y0 + rayon ) );
move_to( wxPoint( x0 + rayon, y0 - rayon ) );
finish_to( wxPoint( x0 - rayon, y0 + rayon ) );
break;
case 9: /* forme en losange barre par un +*/
center_lozenge(position, diametre, NO_FILL);
move_to( wxPoint( x0, y0 - rayon ) );
line_to( wxPoint( x0, y0 + rayon ) );
move_to( wxPoint( x0 + rayon, y0 ) );
finish_to( wxPoint( x0 - rayon, y0 ) );
break;
case 10: /* forme en carre barre par un '/' */
center_square(position, diametre, NO_FILL);
move_to( wxPoint( x0 - rayon, y0 - rayon ) );
finish_to( wxPoint( x0 + rayon, y0 + rayon ) );
break;
case 11: /* forme en losange barre par un |*/
center_lozenge(position, diametre, NO_FILL);
move_to( wxPoint( x0, y0 - rayon ) );
finish_to( wxPoint( x0, y0 + rayon ) );
break;
case 12: /* forme en losange barre par un -*/
center_lozenge(position, diametre, NO_FILL);
move_to( wxPoint( x0 - rayon, y0 ) );
finish_to( wxPoint( x0 + rayon, y0 ) );
break;
default:
circle(position, diametre, NO_FILL);
break;
}
}
/************************************/
void UserToDeviceSize( wxSize& size )
/************************************/
/* modifie les dimension size.x et size.y pour le trace selon l'echelle */
/***************************************************************/
void Plotter::segment_as_oval( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode)
/***************************************************************/
{
size.x = (int) (size.x * g_Plot_XScale);
size.y = (int) (size.y * g_Plot_YScale);
/* Convert a thick segment and plot it as an oval */
wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2);
wxSize size( end.x - start.x, end.y - start.y);
int orient;
if ( size.y == 0 )
orient = 0;
else if ( size.x == 0 )
orient = 900;
else orient = - (int) (atan2( (double)size.y, (double)size.x ) * 1800.0 / M_PI);
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 );
}
/***************************************************************/
void Plotter::sketch_oval(wxPoint pos, wxSize size, int orient,
int width)
/***************************************************************/
{
set_current_line_width(width);
width = current_pen_width;
int rayon, deltaxy, cx, cy;
if( size.x > size.y )
{
EXCHG( size.x, size.y ); orient += 900;
if( orient >= 3600 )
orient -= 3600;
}
deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */
rayon = (size.x-width) / 2;
cx = -rayon; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
move_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = -rayon; cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = rayon; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
move_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = rayon; cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = 0; cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
arc( wxPoint( cx + pos.x, cy + pos.y ),
orient + 1800 , orient + 3600,
rayon, NO_FILL);
cx = 0; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
arc( wxPoint( cx + pos.x, cy + pos.y ),
orient, orient + 1800,
rayon, NO_FILL );
}
/***************************************************************/
void Plotter::thick_segment( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode )
/***************************************************************/
/* Plot 1 segment like a track segment
*/
{
switch (tracemode)
{
case FILLED:
case FILAIRE:
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 rayon,
int width, GRTraceMode tracemode )
{
switch (tracemode)
{
case FILAIRE:
set_current_line_width(-1);
arc(centre, StAngle, EndAngle, rayon, NO_FILL,-1);
break;
case FILLED:
arc(centre, StAngle, EndAngle, rayon,NO_FILL, width);
break;
case SKETCH:
set_current_line_width(-1);
arc(centre, StAngle, EndAngle, rayon-(width-current_pen_width)/2,NO_FILL, -1);
arc(centre, StAngle, EndAngle, rayon+(width-current_pen_width)/2,NO_FILL, -1);
break;
}
}
void Plotter::thick_rect( wxPoint p1, wxPoint p2, int width,
GRTraceMode tracemode)
{
switch (tracemode)
{
case FILAIRE:
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,
GRTraceMode tracemode)
{
switch (tracemode)
{
case FILAIRE:
circle(pos, diametre,NO_FILL, -1);
break;
case FILLED:
circle(pos, diametre,NO_FILL, width);
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);
break;
}
}
/*************************************************************************************/
void Plotter::set_paper_size(Ki_PageDescr* asheet)
/*************************************************************************************/
{
wxASSERT(!output_file);
sheet = asheet;
// Sheets are in mils, plotter works with decimils
paper_size.x = sheet->m_Size.x * 10;
paper_size.y = sheet->m_Size.y * 10;
}

View File

@ -19,6 +19,7 @@
#define EDA_DRAWBASE
#include "hershey_fonts.h"
#include "plot_common.h"
/* factor used to calculate actual size of shapes from hershey fonts (could be adjusted depending on the font name)
* Its value is choosen in order to have letters like M, P .. vertical size equal to the vertical char size parameter
@ -170,9 +171,19 @@ static void DrawGraphicTextPline(
bool sketch_mode,
int point_count,
wxPoint* coord,
void (* aCallback)( int x0, int y0, int xf, int yf ) )
void (* aCallback)(int x0, int y0, int xf, int yf ),
Plotter *plotter )
{
if( aCallback )
if( plotter )
{
plotter->move_to(coord[0]);
for( int ik = 1; ik < point_count; ik++ )
{
plotter->line_to( coord[ik] );
}
plotter->pen_finish();
}
else if (aCallback)
{
for( int ik = 0; ik < (point_count - 1); ik++ )
{
@ -216,8 +227,6 @@ static int overbar_position( int size_v, int thickness )
* Use a value min(aSize.x, aSize.y) / 5 for a bold text
* @param aItalic = true to simulate an italic font
* @param aBold = true to use a bold font. Useful only with default width value (aWidth = 0)
* @param aCallback() = function called (if non null) to draw each segment.
* used to draw 3D texts or for plotting, NULL for normal drawings
*/
/****************************************************************************************************/
void DrawGraphicText( WinEDA_DrawPanel* aPanel,
@ -232,13 +241,14 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int aWidth,
bool aItalic,
bool aBold,
void (* aCallback)( int x0, int y0, int xf, int yf ) )
void (* aCallback)( int x0, int y0, int xf, int yf ),
Plotter *plotter )
/****************************************************************************************************/
{
int char_count, AsciiCode;
int AsciiCode;
int x0, y0;
int size_h, size_v;
int ptr;
unsigned ptr;
int dx, dy; // Draw coordinate for segments to draw. also used in some other calculation
wxPoint current_char_pos; // Draw coordinates for the current char
wxPoint overbar_pos; // Start point for the current overbar
@ -270,7 +280,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
if( size_h < 0 ) // text is mirrored using size.x < 0 (mirror / Y axis)
italic_reverse = true;
char_count = NegableTextLength( aText );
unsigned char_count = NegableTextLength( aText );
if( char_count == 0 )
return;
@ -351,8 +361,14 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
RotatePoint( &current_char_pos, aPos, aOrient );
RotatePoint( &end, aPos, aOrient );
if( aCallback )
if( plotter ) {
plotter->move_to(current_char_pos);
plotter->finish_to( end );
}
else if (aCallback)
{
aCallback( current_char_pos.x, current_char_pos.y, end.x, end.y );
}
else
GRLine( &aPanel->m_ClipBox, aDC,
current_char_pos.x, current_char_pos.y, end.x, end.y, aWidth, aColor );
@ -401,7 +417,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
coord[1] = overbar_pos;
/* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback );
sketch_mode, 2, coord, aCallback, plotter );
}
continue; /* Skip ~ processing */
}
@ -439,7 +455,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
if( aWidth <= 1 )
aWidth = 0;
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, point_count, coord, aCallback );
sketch_mode, point_count, coord,
aCallback, plotter );
}
point_count = 0;
}
@ -481,54 +498,11 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
coord[1] = overbar_pos;
/* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback );
sketch_mode, 2, coord, aCallback, plotter );
}
}
/* functions used to plot texts, using DrawGraphicText() with a call back function */
static void (*MovePenFct)( wxPoint pos, int state ); // a pointer to actual plot function (HPGL, PS, ..)
static bool s_Plotbegin; // Flag to init plot
/*
* The call back function
*/
/****************************************************************/
static void s_Callback_plot( int x0, int y0, int xf, int yf )
/****************************************************************/
{
static wxPoint PenLastPos;
wxPoint pstart;
pstart.x = x0;
pstart.y = y0;
wxPoint pend;
pend.x = xf;
pend.y = yf;
if( s_Plotbegin ) // First segment to plot
{
MovePenFct( pstart, 'U' );
MovePenFct( pend, 'D' );
s_Plotbegin = false;
}
else
{
if( PenLastPos == pstart ) // this is a next segment in a polyline
{
MovePenFct( pend, 'D' );
}
else // New segment to plot
{
MovePenFct( pstart, 'U' );
MovePenFct( pend, 'D' );
}
}
PenLastPos = pend;
}
/** Function PlotGraphicText
* same as DrawGraphicText, but plot graphic text insteed of draw it
* @param aFormat_plot = plot format (PLOT_FORMAT_POST, PLOT_FORMAT_HPGL, PLOT_FORMAT_GERBER)
@ -546,8 +520,7 @@ static void s_Callback_plot( int x0, int y0, int xf, int yf )
* @param aBold = true to use a bold font Useful only with default width value (aWidth = 0)
*/
/******************************************************************************************/
void PlotGraphicText( int aFormat_plot,
const wxPoint& aPos,
void Plotter::text( const wxPoint& aPos,
enum EDA_Colors aColor,
const wxString& aText,
int aOrient,
@ -562,45 +535,22 @@ void PlotGraphicText( int aFormat_plot,
if( aWidth == 0 && aBold ) // Use default values if aWidth == 0
aWidth = GetPenSizeForBold( MIN( aSize.x, aSize.y ) );
#ifdef CLIP_PEN // made by draw and plot functions
if ( aWidth >= 0 )
aWidth = Clamp_Text_PenSize( aWidth, aSize, aBold );
else
aWidth = - Clamp_Text_PenSize( -aWidth, aSize, aBold );
#endif
// Initialise the actual function used to plot lines:
switch( aFormat_plot )
{
case PLOT_FORMAT_POST:
MovePenFct = LineTo_PS;
SetCurrentLineWidthPS( aWidth );
break;
set_current_line_width( aWidth );
case PLOT_FORMAT_HPGL:
MovePenFct = Move_Plume_HPGL;
break;
case PLOT_FORMAT_GERBER:
MovePenFct = LineTo_GERBER;
/* Gerber tool has to be set outside... */
break;
if( aColor >= 0 )
set_color( aColor );
default:
return;
}
if( aColor >= 0 && IsPostScript( aFormat_plot ) )
SetColorMapPS( aColor );
s_Plotbegin = true;
DrawGraphicText( NULL, NULL, aPos, aColor, aText,
aOrient, aSize,
aH_justify, aV_justify,
aWidth, aItalic,
aBold,
s_Callback_plot );
/* end text : pen UP ,no move */
MovePenFct( wxPoint( 0, 0 ), 'Z' );
NULL,
this );
}

View File

@ -704,7 +704,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
* If TextInside then the text is been put inside (moving from x1, y1 in *
* the opposite direction to x2,y2), otherwise all is drawn outside. *
*****************************************************************************/
void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
void LibDrawPin::PlotPinTexts( Plotter *plotter,
wxPoint& pin_pos,
int orient,
int TextInside,
bool DrawPinNum,
@ -716,12 +717,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
EDA_Colors NameColor, NumColor;
wxSize PinNameSize = wxSize( m_PinNameSize, m_PinNameSize );
wxSize PinNumSize = wxSize( m_PinNumSize, m_PinNumSize );
bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST)
&& g_PlotPSColorOpt;
/* Get the num and name colors */
NameColor = (EDA_Colors) ( plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1 );
NumColor = (EDA_Colors) ( plot_color ? ReturnLayerColor( LAYER_PINNUM ) : -1 );
NameColor = ReturnLayerColor( LAYER_PINNAM );
NumColor = ReturnLayerColor( LAYER_PINNUM );
/* Create the pin num string */
ReturnPinStringNum( StringPinNum );
@ -754,7 +753,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
if( orient == PIN_RIGHT )
{
x = x1 + TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ), NameColor,
plotter->text( wxPoint( x, y1 ), NameColor,
m_PinName,
TEXT_ORIENT_HORIZ,
PinNameSize,
@ -766,7 +765,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
{
x = x1 - TextInside;
if( DrawPinName )
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ),
plotter->text( wxPoint( x, y1 ),
NameColor, m_PinName, TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
@ -775,8 +774,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
}
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat,
wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
plotter->text( wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
@ -792,7 +790,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
y = y1 + TextInside;
if( DrawPinName )
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor,
plotter->text( wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
@ -800,8 +798,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
aWidth, false, false );
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat,
wxPoint( x1 - TXTMARGE,
plotter->text( wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
@ -815,7 +812,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
y = y1 - TextInside;
if( DrawPinName )
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor,
plotter->text( wxPoint( x1, y ), NameColor,
m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT,
@ -823,8 +820,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
aWidth, false, false );
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat,
wxPoint( x1 - TXTMARGE,
plotter->text( wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
@ -843,8 +839,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
if( DrawPinName )
{
x = (x1 + pin_pos.x) / 2;
PlotGraphicText( g_PlotFormat, wxPoint( x,
y1 - TXTMARGE ),
plotter->text( wxPoint( x, y1 - TXTMARGE ),
NameColor, m_PinName,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
@ -854,7 +849,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
if( DrawPinNum )
{
x = (x1 + pin_pos.x) / 2;
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 + TXTMARGE ),
plotter->text( wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
@ -867,8 +862,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
if( DrawPinName )
{
y = (y1 + pin_pos.y) / 2;
PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE,
y ),
plotter->text( wxPoint( x1 - TXTMARGE, y ),
NameColor, m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
@ -878,9 +872,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat,
wxPoint( x1 + TXTMARGE,
(y1 + pin_pos.y) / 2 ),
plotter->text( wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,

View File

@ -26,21 +26,6 @@
#define IEEE_SYMBOL_PIN_DIM 40 /* Dim of special pin symbol. */
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.
*/
enum FILL_T {
NO_FILL, // Poly, Square, Circle, Arc = option No Fill
FILLED_SHAPE, /* Poly, Square, Circle, Arc = option Fill
* with current color ("Solid shape") */
FILLED_WITH_BG_BODYCOLOR, /* Poly, Square, Circle, Arc = option Fill
* with background body color, translucent
* (texts inside this shape can be seen)
* not filled in B&W mode when plotting or
* printing */
};
/**
* Enum ElectricPinType
@ -290,7 +275,8 @@ public:
wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum,
bool DrawPinName, int Color, int DrawMode );
void PlotPinTexts( wxPoint& pin_pos,
void PlotPinTexts( Plotter *plotter,
wxPoint& pin_pos,
int orient,
int TextInside,
bool DrawPinNum,

View File

@ -403,10 +403,6 @@ PARAM_CFG_ARRAY& WinEDA_SchematicFrame::GetConfigurationSettings( void )
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGrid" ),
&g_GridColor,
DARKDARKGRAY ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Pltmarg" ),
&g_PlotMargin,
300, 0, 10000 ) );
return m_configSettings;
}

View File

@ -45,8 +45,6 @@ SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Block Save)
// Gestion d'options
bool g_HVLines = true; // Bool: force H or V directions (Wires, Bus ..)
int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp)
struct EESchemaVariables g_EESchemaVar;
/* Variables globales pour Libview */
@ -65,11 +63,6 @@ int g_LastTextOrient = TEXT_ORIENT_HORIZ;
bool g_FlDrawSpecificUnit = FALSE;
bool g_FlDrawSpecificConvert = TRUE;
int g_PlotFormat; /* flag = TYPE_HPGL, TYPE_PS... */
int g_PlotMargin; /* Marge pour traces du cartouche */
double g_PlotScaleX;
double g_PlotScaleY; /* coeff d'echelle de trace en unites table tracante */
HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
//SCH_SCREEN * ScreenSch;

View File

@ -117,9 +117,6 @@ extern SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Bloc
// Gestion d'options
extern bool g_HVLines;
extern int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp)
// Gestion de diverses variables, options... devant etre memorisees mais
// Remises a 0 lors d'un rechargement de projetc
struct EESchemaVariables
@ -152,11 +149,6 @@ extern bool g_FlDrawSpecificConvert;
/* Gestion des trace sur table tracante */
extern int g_PlotFormat; /* flag = TYPE_HPGL, TYPE_PS... */
extern int g_PlotMargin; /* Marge pour traces du cartouche */
extern double g_PlotScaleX, g_PlotScaleY; /* coeff d'echelle de trace en unites table tracante */
/* For HPGL plotting: Pen caract : */
struct HPGL_Pen_Descr_Struct
{

View File

@ -17,156 +17,17 @@
#include "protos.h"
/* Local Variables : */
static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* Struct );
static void PlotTextField( SCH_COMPONENT* DrawLibItem,
static void Plot_Hierarchical_PIN_Sheet(Plotter *plotter,
Hierarchical_PIN_Sheet_Struct* Struct );
static void PlotTextField(Plotter *plotter, SCH_COMPONENT* DrawLibItem,
int FieldNumber, int IsMulti, int DrawMode );
static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape );
static void PlotPinSymbol(Plotter *plotter, const wxPoint& pos,
int len, int orient, int Shape );
/***/
/* Defines for filling polygons in plot polygon functions */
#define FILL true
#define NOFILL false
/* routine de lever ou baisser de plume.
* si plume = 'U' les traces suivants se feront plume levee
* si plume = 'D' les traces suivants se feront plume levee
*/
void Plume( int plume )
{
switch( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
Plume_HPGL( plume );
break;
case PLOT_FORMAT_POST:
LineTo_PS( wxPoint(0,0), plume );
break;
}
}
/* routine de deplacement de plume de plume.
*/
void Move_Plume( wxPoint pos, int plume )
{
switch( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
Move_Plume_HPGL( pos, plume );
break;
case PLOT_FORMAT_POST:
LineTo_PS( pos, plume );
break;
}
}
void SetCurrentLineWidth( int width )
{
switch( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
break;
case PLOT_FORMAT_POST:
SetCurrentLineWidthPS( width );
break;
}
}
/*******************************************************************************/
void PlotRect( wxPoint p1, wxPoint p2, int fill, int width )
/*******************************************************************************/
{
switch( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
PlotRectHPGL( p1, p2, fill, width );
break;
case PLOT_FORMAT_POST:
PlotRectPS( p1, p2, fill, width );
break;
}
}
/*****************************************************************************************/
void PlotArc( wxPoint aCentre, int aStAngle, int aEndAngle, int aRadius, bool aFill, int aWidth )
/*****************************************************************************************/
/** Function PlotArc
* Plot an arc:
* @param aCentre = Arc centre
* @param aStAngle = begining of arc in 0.1 degrees
* @param aEndAngle = end of arc in 0.1 degrees
* @param aRadius = Arc radius
* @param aFill = fill option
* @param aWidth = Tickness of outlines
*/
{
switch( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
PlotArcHPGL( aCentre, aStAngle, aEndAngle, aRadius, aFill, aWidth );
break;
case PLOT_FORMAT_POST:
PlotArcPS( aCentre, aStAngle, aEndAngle, aRadius, aFill, aWidth );
break;
}
}
/*****************************************************************/
void PlotCercle( wxPoint pos, int diametre, bool fill, int width )
/*****************************************************************/
{
switch( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
PlotCircleHPGL( pos, diametre, fill, width );
break;
case PLOT_FORMAT_POST:
PlotCirclePS( pos, diametre, fill, width );
break;
}
}
/******************************************************************/
void PlotPoly( int nb, int* coord, bool fill, int width )
/******************************************************************/
/* Trace un polygone ferme
* coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli
*/
{
if( nb <= 1 )
return;
switch( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
PlotPolyHPGL( nb, coord, fill, width );
break;
case PLOT_FORMAT_POST:
PlotPolyPS( nb, coord, fill, width );
break;
}
}
/**********************************************************/
void PlotNoConnectStruct( DrawNoConnectStruct* Struct )
static void PlotNoConnectStruct(Plotter *plotter, DrawNoConnectStruct* Struct )
/**********************************************************/
/* Routine de dessin des symboles de "No Connexion" ..
@ -177,22 +38,20 @@ void PlotNoConnectStruct( DrawNoConnectStruct* Struct )
pX = Struct->m_Pos.x; pY = Struct->m_Pos.y;
SetCurrentLineWidth( -1 );
Move_Plume( wxPoint( pX - DELTA, pY - DELTA ), 'U' );
Move_Plume( wxPoint( pX + DELTA, pY + DELTA ), 'D' );
Move_Plume( wxPoint( pX + DELTA, pY - DELTA ), 'U' );
Move_Plume( wxPoint( pX - DELTA, pY + DELTA ), 'D' );
Plume( 'Z' );
plotter->set_current_line_width( -1 );
plotter->move_to( wxPoint( pX - DELTA, pY - DELTA ) );
plotter->finish_to( wxPoint( pX + DELTA, pY + DELTA ) );
plotter->move_to( wxPoint( pX + DELTA, pY - DELTA ) );
plotter->finish_to( wxPoint( pX - DELTA, pY + DELTA ) );
}
/*************************************************/
void PlotLibPart( SCH_COMPONENT* DrawLibItem )
static void PlotLibPart(Plotter *plotter, SCH_COMPONENT* DrawLibItem )
/*************************************************/
/* Polt a component */
{
int ii, t1, t2, * Poly, orient;
LibEDA_BaseStruct* DEntry;
EDA_LibComponentStruct* Entry;
int TransMat[2][2], Multi, convert;
EDA_Colors CharColor = UNSPECIFIED_COLOR;
@ -206,7 +65,8 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
Multi = DrawLibItem->m_Multi;
convert = DrawLibItem->m_Convert;
for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() )
for(LibEDA_BaseStruct* DEntry = Entry->m_Drawings;
DEntry != NULL; DEntry = DEntry->Next() )
{
/* Elimination des elements non relatifs a l'unite */
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) )
@ -214,12 +74,8 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
continue;
Plume( 'U' );
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
draw_bgfill = true;
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
draw_bgfill = plotter->get_color_mode();
switch( DEntry->Type() )
{
@ -231,16 +87,15 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
MapAngles( &t1, &t2, TransMat );
if( draw_bgfill && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotArc( pos, t1, t2, Arc->m_Rayon, true, 0 );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->arc( pos, t1, t2, Arc->m_Rayon, FILLED_SHAPE, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotArc( pos,
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->arc( pos,
t1,
t2,
Arc->m_Rayon,
Arc->m_Fill == FILLED_SHAPE ? true : false,
Arc->m_Fill,
Arc->m_Width );
}
break;
@ -251,14 +106,13 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
pos = TransformCoordinate( TransMat, Circle->m_Pos ) + DrawLibItem->m_Pos;
if( draw_bgfill && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotCercle( pos, Circle->m_Rayon * 2, true, 0 );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->circle( pos, Circle->m_Rayon * 2, FILLED_SHAPE, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotCercle( pos,
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->circle( pos,
Circle->m_Rayon * 2,
Circle->m_Fill == FILLED_SHAPE ? true : false,
Circle->m_Fill,
Circle->m_Width );
}
break;
@ -271,11 +125,11 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
* transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0);
pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos;
SetCurrentLineWidth( -1 );
plotter->set_current_line_width( -1 );
int thickness = (Text->m_Width == 0) ? g_DrawDefaultLineThickness : Text->m_Width;
thickness = Clamp_Text_PenSize( thickness, Text->m_Size, Text->m_Bold );
PlotGraphicText( g_PlotFormat, pos, CharColor,
plotter->text( pos, CharColor,
Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
Text->m_Size,
@ -293,12 +147,11 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
if( draw_bgfill && Square->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotRect( pos, end, true, 0 );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotRect( pos, end, Square->m_Fill == FILLED_SHAPE ? true : false, Square->m_Width );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->rect( pos, end, Square->m_Fill, Square->m_Width );
}
break;
@ -314,9 +167,9 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
pos = TransformCoordinate( TransMat, Pin->m_Pos ) + DrawLibItem->m_Pos;
/* Dessin de la pin et du symbole special associe */
PlotPinSymbol( pos, Pin->m_PinLen, orient, Pin->m_PinShape );
PlotPinSymbol(plotter, pos, Pin->m_PinLen, orient, Pin->m_PinShape );
int thickness = g_DrawDefaultLineThickness;
Pin->PlotPinTexts( pos, orient,
Pin->PlotPinTexts( plotter, pos, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
thickness );
@ -327,7 +180,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->GetCornerCount() );
for( ii = 0; ii < (int) polyline->GetCornerCount(); ii++ )
for(ii = 0; ii < (int) polyline->GetCornerCount(); ii++ )
{
pos = polyline->m_PolyPoints[ii];
pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
@ -337,12 +190,11 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
if( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotPoly( ii, Poly, true, 0 );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->poly( ii, Poly, FILLED_WITH_BG_BODYCOLOR, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotPoly( ii, Poly, polyline->m_Fill == FILLED_SHAPE ? true : false, polyline->m_Width );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->poly( ii, Poly, polyline->m_Fill, polyline->m_Width );
MyFree( Poly );
}
break;
@ -361,12 +213,11 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
if( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
PlotPoly( ii, Poly, true, 0 );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->poly( ii, Poly, FILLED_WITH_BG_BODYCOLOR, 0 );
}
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_DEVICE ) );
PlotPoly( ii, Poly, polyline->m_Fill == FILLED_SHAPE ? true : false, polyline->m_Width );
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->poly( ii, Poly, polyline->m_Fill, polyline->m_Width );
MyFree( Poly );
}
@ -375,7 +226,6 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
}
/* Fin Switch */
Plume( 'U' );
}
/* Fin Boucle de dessin */
@ -388,23 +238,23 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
if( (Entry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE) == 0 )
{
if( Entry->m_UnitCount > 1 )
PlotTextField( DrawLibItem, REFERENCE, 1, 0 );
PlotTextField(plotter, DrawLibItem, REFERENCE, 1, 0 );
else
PlotTextField( DrawLibItem, REFERENCE, 0, 0 );
PlotTextField(plotter, DrawLibItem, REFERENCE, 0, 0 );
}
if( (Entry->m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 )
PlotTextField( DrawLibItem, VALUE, 0, 0 );
PlotTextField(plotter, DrawLibItem, VALUE, 0, 0 );
for( ii = 2; ii < NUMBER_OF_FIELDS; ii++ )
{
PlotTextField( DrawLibItem, ii, 0, 0 );
PlotTextField(plotter, DrawLibItem, ii, 0, 0 );
}
}
/*************************************************************/
static void PlotTextField( SCH_COMPONENT* DrawLibItem,
static void PlotTextField( Plotter *plotter, SCH_COMPONENT* DrawLibItem,
int FieldNumber, int IsMulti, int DrawMode )
/**************************************************************/
@ -424,7 +274,6 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
int orient;
EDA_Colors color = UNSPECIFIED_COLOR;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor( field->GetLayer() );
DrawMode = 0; /* Unused */
@ -521,11 +370,11 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
int thickness = (field->m_Width == 0) ? g_DrawDefaultLineThickness : field->m_Width;
thickness = Clamp_Text_PenSize( thickness, field->m_Size, field->m_Bold );
SetCurrentLineWidth( thickness );
plotter->set_current_line_width( thickness );
if( !IsMulti || (FieldNumber != REFERENCE) )
{
PlotGraphicText( g_PlotFormat, textpos, color, field->m_Text,
plotter->text( textpos, color, field->m_Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
field->m_Size,
hjustify, vjustify,
@ -544,7 +393,7 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
unit_id = 'A' - 1 + DrawLibItem->m_Multi;
#endif
Text.Append( unit_id );
PlotGraphicText( g_PlotFormat, textpos, color, Text,
plotter->text( textpos, color, Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
field->m_Size, hjustify, vjustify,
thickness, field->m_Italic, field->m_Bold );
@ -553,7 +402,8 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
/**************************************************************************/
static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape )
static void PlotPinSymbol(Plotter *plotter, const wxPoint& pos,
int len, int orient, int Shape )
/**************************************************************************/
/* Trace la pin du symbole en cours de trace
@ -564,10 +414,9 @@ static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape )
color = ReturnLayerColor( LAYER_PIN );
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( color );
plotter->set_color( color );
SetCurrentLineWidth( -1 );
plotter->set_current_line_width( -1 );
MapX1 = MapY1 = 0; x1 = pos.x; y1 = pos.y;
@ -592,35 +441,35 @@ static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape )
if( Shape & INVERT )
{
PlotCercle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
plotter->circle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1 ),
INVERT_PIN_RADIUS * 2, // diameter
false, // fill
NO_FILL, // fill
-1 ); // width
Move_Plume( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1 ), 'U' );
Move_Plume( pos, 'D' );
plotter->move_to( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1 ));
plotter->finish_to( pos );
}
else
{
Move_Plume( wxPoint( x1, y1 ), 'U' );
Move_Plume( pos, 'D' );
plotter->move_to( wxPoint( x1, y1 ) );
plotter->finish_to( pos );
}
if( Shape & CLOCK )
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
Move_Plume( wxPoint( x1, y1 + CLOCK_PIN_DIM ), 'U' );
Move_Plume( wxPoint( x1 - MapX1 * CLOCK_PIN_DIM, y1 ), 'D' );
Move_Plume( wxPoint( x1, y1 - CLOCK_PIN_DIM ), 'D' );
plotter->move_to( wxPoint( x1, y1 + CLOCK_PIN_DIM ) );
plotter->line_to( wxPoint( x1 - MapX1 * CLOCK_PIN_DIM, y1 ) );
plotter->finish_to( wxPoint( x1, y1 - CLOCK_PIN_DIM ) );
}
else /* MapX1 = 0 */
{
Move_Plume( wxPoint( x1 + CLOCK_PIN_DIM, y1 ), 'U' );
Move_Plume( wxPoint( x1, y1 - MapY1 * CLOCK_PIN_DIM ), 'D' );
Move_Plume( wxPoint( x1 - CLOCK_PIN_DIM, y1 ), 'D' );
plotter->move_to( wxPoint( x1 + CLOCK_PIN_DIM, y1 ) );
plotter->line_to( wxPoint( x1, y1 - MapY1 * CLOCK_PIN_DIM ) );
plotter->finish_to( wxPoint( x1 - CLOCK_PIN_DIM, y1 ) );
}
}
@ -628,17 +477,17 @@ static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape )
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
Move_Plume( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ), 'U' );
Move_Plume( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM ), 'D' );
Move_Plume( wxPoint( x1, y1 ), 'D' );
plotter->move_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
plotter->line_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM ) );
plotter->finish_to( wxPoint( x1, y1 ) );
}
else /* MapX1 = 0 */
{
Move_Plume( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ), 'U' );
Move_Plume( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ), 'D' );
Move_Plume( wxPoint( x1, y1 ), 'D' );
plotter->move_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
plotter->line_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
plotter->finish_to( wxPoint( x1, y1 ) );
}
}
@ -647,21 +496,20 @@ static void PlotPinSymbol( const wxPoint& pos, int len, int orient, int Shape )
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
Move_Plume( wxPoint( x1, y1 - IEEE_SYMBOL_PIN_DIM ), 'U' );
Move_Plume( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ), 'D' );
plotter->move_to( wxPoint( x1, y1 - IEEE_SYMBOL_PIN_DIM ) );
plotter->finish_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
}
else /* MapX1 = 0 */
{
Move_Plume( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM, y1 ), 'U' );
Move_Plume( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ), 'D' );
plotter->move_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM, y1 ) );
plotter->finish_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
}
}
Plume( 'Z' );
}
/*******************************************/
void PlotTextStruct( EDA_BaseStruct* Struct )
static void PlotTextStruct(Plotter *plotter, EDA_BaseStruct* Struct )
/*******************************************/
/*
@ -685,13 +533,12 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
SCH_TEXT* schText = (SCH_TEXT*) Struct;
EDA_Colors color = UNSPECIFIED_COLOR;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor( schText->m_Layer );
wxPoint textpos = schText->m_Pos + schText->GetSchematicTextOffset();
int thickness = (schText->m_Width == 0) ? g_DrawDefaultLineThickness : schText->m_Width;
thickness = Clamp_Text_PenSize( thickness, schText->m_Size, schText->m_Bold );
SetCurrentLineWidth( thickness );
plotter->set_current_line_width( thickness );
if( schText->m_MultilineAllowed )
{
@ -705,7 +552,7 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
PlotGraphicText( g_PlotFormat, pos,
plotter->text( pos,
color, txt, schText->m_Orient, schText->m_Size,
schText->m_HJustify, schText->m_VJustify,
thickness, schText->m_Italic, schText->m_Bold );
@ -716,7 +563,7 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
}
else
PlotGraphicText( g_PlotFormat, textpos,
plotter->text( textpos,
color, schText->m_Text, schText->m_Orient, schText->m_Size,
schText->m_HJustify, schText->m_VJustify,
thickness, schText->m_Italic, schText->m_Bold );
@ -725,18 +572,19 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
if( Struct->Type() == TYPE_SCH_GLOBALLABEL )
{
( (SCH_GLOBALLABEL*) Struct )->CreateGraphicShape( Poly, schText->m_Pos );
PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
plotter->poly( Poly.size(), &Poly[0].x, NO_FILL );
}
if( Struct->Type() == TYPE_SCH_HIERLABEL )
{
( (SCH_HIERLABEL*) Struct )->CreateGraphicShape( Poly, schText->m_Pos );
PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
plotter->poly( Poly.size(), &Poly[0].x, NO_FILL );
}
}
/*****************************************************************************************/
static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarchical_PIN )
static void Plot_Hierarchical_PIN_Sheet(Plotter *plotter,
Hierarchical_PIN_Sheet_Struct* aHierarchical_PIN )
/****************************************************************************************/
/* Plot a Hierarchical_PIN_Sheet
@ -747,7 +595,6 @@ static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarc
static std::vector <wxPoint> Poly;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
txtcolor = ReturnLayerColor( aHierarchical_PIN->GetLayer() );
posx = aHierarchical_PIN->m_Pos.x;
@ -767,9 +614,9 @@ static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarc
int thickness = (aHierarchical_PIN->m_Width == 0) ? g_DrawDefaultLineThickness : aHierarchical_PIN->m_Width;
thickness = Clamp_Text_PenSize( thickness, aHierarchical_PIN->m_Size, aHierarchical_PIN->m_Bold );
SetCurrentLineWidth( thickness );
plotter->set_current_line_width( thickness );
PlotGraphicText( g_PlotFormat, wxPoint( tposx, posy ), txtcolor,
plotter->text( wxPoint( tposx, posy ), txtcolor,
aHierarchical_PIN->m_Text, TEXT_ORIENT_HORIZ, wxSize( size, size ),
side, GR_TEXT_VJUSTIFY_CENTER,
thickness, aHierarchical_PIN->m_Italic, aHierarchical_PIN->m_Bold );
@ -777,12 +624,12 @@ static void Plot_Hierarchical_PIN_Sheet( Hierarchical_PIN_Sheet_Struct* aHierarc
/* Draw the associated graphic symbol */
aHierarchical_PIN->CreateGraphicShape( Poly, aHierarchical_PIN->m_Pos );
PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
plotter->poly( Poly.size(), &Poly[0].x, NO_FILL );
}
/*************************************************/
void PlotSheetStruct( DrawSheetStruct* Struct )
static void PlotSheetStruct(Plotter *plotter, DrawSheetStruct* Struct )
/*************************************************/
/* Routine de dessin du bloc type hierarchie */
{
@ -792,25 +639,22 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
wxString Text;
wxPoint pos;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( Struct->m_Layer ) );
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
int thickness = g_DrawDefaultLineThickness;
SetCurrentLineWidth( thickness );
plotter->set_current_line_width( thickness );
Move_Plume( Struct->m_Pos, 'U' );
plotter->move_to( Struct->m_Pos );
pos = Struct->m_Pos; pos.x += Struct->m_Size.x;
Move_Plume( pos, 'D' );
plotter->line_to( pos );
pos.y += Struct->m_Size.y;
Move_Plume( pos, 'D' );
plotter->line_to( pos );
pos = Struct->m_Pos; pos.y += Struct->m_Size.y;
Move_Plume( pos, 'D' );
Move_Plume( Struct->m_Pos, 'D' );
Plume( 'Z' );
plotter->line_to( pos );
plotter->finish_to( Struct->m_Pos );
/* Draw texts: SheetName */
Text = Struct->m_SheetName;
@ -819,11 +663,10 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
thickness = g_DrawDefaultLineThickness;
thickness = Clamp_Text_PenSize( thickness, size, false );
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_SHEETNAME ) );
plotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) );
bool italic = false;
PlotGraphicText( g_PlotFormat, pos, txtcolor,
plotter->text( pos, txtcolor,
Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, false );
@ -834,11 +677,9 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
thickness = g_DrawDefaultLineThickness;
thickness = Clamp_Text_PenSize( thickness, size, false );
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_SHEETFILENAME ) );
plotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
PlotGraphicText( g_PlotFormat,
wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 ),
plotter->text( wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 ),
txtcolor,
Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
@ -846,12 +687,121 @@ void PlotSheetStruct( DrawSheetStruct* Struct )
/* Draw texts : SheetLabel */
SheetLabelStruct = Struct->m_Label;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( Struct->m_Layer ) );
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
while( SheetLabelStruct != NULL )
{
Plot_Hierarchical_PIN_Sheet( SheetLabelStruct );
Plot_Hierarchical_PIN_Sheet(plotter, SheetLabelStruct );
SheetLabelStruct = SheetLabelStruct->Next();
}
}
/*************************************************/
void PlotDrawlist(Plotter *plotter, SCH_ITEM* drawlist )
/*************************************************/
{
while( drawlist ) /* tracage */
{
SCH_COMPONENT* DrawLibItem;
int layer;
wxPoint StartPos, EndPos;
switch( drawlist->Type() )
{
case DRAW_BUSENTRY_STRUCT_TYPE: /* Struct Raccord et Segment sont identiques */
#undef STRUCT
#define STRUCT ( (DrawBusEntryStruct*) drawlist )
StartPos = STRUCT->m_Pos;
EndPos = STRUCT->m_End();
layer = STRUCT->GetLayer();
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) drawlist )
if( drawlist->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{
StartPos = STRUCT->m_Start;
EndPos = STRUCT->m_End;
layer = STRUCT->GetLayer();
}
plotter->set_color( ReturnLayerColor( layer ) );
switch( layer )
{
case LAYER_NOTES: /* Trace en pointilles */
plotter->set_current_line_width( g_DrawDefaultLineThickness );
plotter->set_dash(true);
plotter->move_to( StartPos );
plotter->finish_to( EndPos );
plotter->set_dash(false);
break;
case LAYER_BUS: /* Trait large */
{
int thickness = wxRound( g_DrawDefaultLineThickness * 2 );
if ( thickness < 3 ) thickness = 3;
/* We NEED it to be thick, even on HPGL */
plotter->thick_segment(StartPos, EndPos, thickness, FILLED);
plotter->set_current_line_width( g_DrawDefaultLineThickness );
}
break;
default:
plotter->set_current_line_width( g_DrawDefaultLineThickness );
plotter->move_to( StartPos );
plotter->finish_to( EndPos );
break;
}
break;
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) drawlist )
plotter->set_color( ReturnLayerColor( STRUCT->GetLayer() ) );
plotter->circle( STRUCT->m_Pos, DRAWJUNCTION_SIZE, FILLED_SHAPE );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
PlotTextStruct(plotter, drawlist );
break;
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) drawlist;
PlotLibPart(plotter, DrawLibItem );
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
case DRAW_MARKER_STRUCT_TYPE:
break;
case DRAW_SHEET_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawSheetStruct*) drawlist )
PlotSheetStruct(plotter, STRUCT );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) drawlist )
plotter->set_color( ReturnLayerColor( LAYER_NOCONNECT ) );
PlotNoConnectStruct(plotter, STRUCT );
break;
default:
break;
}
drawlist = drawlist->Next();
}
}

View File

@ -28,24 +28,14 @@
#include "general.h"
#include "worksheet.h"
#include "plot_common.h"
#include "protos.h"
/* coeff de conversion dim en 1 mil -> dim en unite HPGL: */
#define SCALE_HPGL 1.02041
#include "plothpgl.h"
////@begin XPM images
////@end XPM images
extern void Move_Plume( wxPoint pos, int plume );
extern void Plume( int plume );
/* Variables locales : */
FILE* PlotOutput; /* exportee dans printps.cc */
static double Scale_X = 1;
static double Scale_Y = 1;
int HPGL_SizeSelect;
enum PageFormatReq {
@ -519,9 +509,6 @@ void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL( int Select_PlotAll, int HPGL_She
Ki_PageDescr* PlotSheet;
wxSize SheetSize;
wxPoint SheetOffset, PlotOffset;
int margin;
g_PlotFormat = PLOT_FORMAT_HPGL;
/* When printing all pages, the printed page is not the current page.
* In complex hierarchies, we must setup references and others parameters in the printed SCH_SCREEN
@ -532,7 +519,7 @@ void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL( int Select_PlotAll, int HPGL_She
sheetpath = SheetList.GetFirst();
DrawSheetPath list;
for( ; ; )
while (true)
{
if( Select_PlotAll )
{
@ -547,31 +534,27 @@ void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL( int Select_PlotAll, int HPGL_She
screen = schframe->m_CurrentSheet->LastScreen();
ActiveScreen = screen;
}
else // Should not occur
else // Should not happen
return;
sheetpath = SheetList.GetNext();
}
ReturnSheetDims( screen, SheetSize, SheetOffset );
/* Calcul des echelles de conversion */
g_PlotScaleX = Scale_X * SCALE_HPGL;
g_PlotScaleY = Scale_Y * SCALE_HPGL;
margin = 400; // Margin in mils
if (HPGL_SheetSize)
PlotSheet = Plot_sheet_list[HPGL_SheetSize];
else
PlotSheet = screen->m_CurrentSheetDesc;
g_PlotScaleX = g_PlotScaleX * (SheetSize.x - 2 * margin) / PlotSheet->m_Size.x;
g_PlotScaleY = g_PlotScaleY * (SheetSize.y - 2 * margin) / PlotSheet->m_Size.y;
/* 10x because eeschema works in mils, not decimils */
double plot_scale = 10 * (double)PlotSheet->m_Size.x / (double)SheetSize.x;
/* calcul des offsets */
PlotOffset.x = -(int) ( SheetOffset.x * SCALE_HPGL );
PlotOffset.y = (int) ( (SheetOffset.y + SheetSize.y) * SCALE_HPGL );
PlotOffset.x -= (int) ( margin * SCALE_HPGL );
PlotOffset.y += (int) ( margin * SCALE_HPGL );
PlotOffset.x = -SheetOffset.x;
PlotOffset.y = -SheetOffset.y;
PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" );
SetLocaleTo_C_standard();
InitPlotParametresHPGL( PlotOffset, g_PlotScaleX, g_PlotScaleY );
Plot_1_Page_HPGL( PlotFileName, screen );
Plot_1_Page_HPGL( PlotFileName, screen, PlotSheet, PlotOffset, plot_scale );
SetLocaleTo_Default();
if( !Select_PlotAll )
@ -586,152 +569,54 @@ void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL( int Select_PlotAll, int HPGL_She
/**************************************************************************/
void WinEDA_PlotHPGLFrame::Plot_1_Page_HPGL( const wxString& FullFileName,
BASE_SCREEN* screen )
void WinEDA_PlotHPGLFrame::Plot_1_Page_HPGL( const wxString& FileName,
SCH_SCREEN* screen,
Ki_PageDescr* sheet,
wxPoint &offset,
double plot_scale)
/**************************************************************************/
/* Trace en format HPGL. d'une feuille de dessin
* 1 unite HPGL = 0.98 mils ( 1 mil = 1.02041 unite HPGL ) .
*/
{
EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem;
int x1 = 0, y1 = 0, x2 = 0, y2 = 0, layer;
wxString msg;
PlotOutput = wxFopen( FullFileName, wxT( "wt" ) );
if( PlotOutput == 0 )
FILE *output_file = wxFopen( FileName, wxT( "wt" ) );
if( output_file == NULL )
{
msg = _( "Unable to create " ) + FullFileName;
DisplayError( this, msg ); return;
msg = wxT( "\n** " );
msg += _( "Unable to create " ) + FileName + wxT( " **\n\n" );
m_MsgBox->AppendText( msg );
wxBell();
return;
}
msg = _( "Plot " ) + FullFileName + wxT( "\n" );
SetLocaleTo_C_standard();
msg.Printf( _( "Plot: %s\n" ), FileName.GetData() );
m_MsgBox->AppendText( msg );
HPGL_Plotter *plotter = new HPGL_Plotter();
plotter->set_paper_size(sheet);
plotter->set_viewport( offset, plot_scale, 0);
plotter->set_default_line_width( g_DrawDefaultLineThickness );
/* Init : */
PrintHeaderHPGL( PlotOutput, g_HPGL_Pen_Descr.m_Pen_Speed, g_HPGL_Pen_Descr.m_Pen_Num );
plotter->set_creator(wxT("EESchema-HPGL"));
plotter->set_filename(FileName);
plotter->set_pen_speed(g_HPGL_Pen_Descr.m_Pen_Speed);
plotter->set_pen_number(g_HPGL_Pen_Descr.m_Pen_Num);
plotter->set_pen_diameter(g_HPGL_Pen_Descr.m_Pen_Diam);
plotter->set_pen_overlap(g_HPGL_Pen_Descr.m_Pen_Diam/2);
plotter->start_plot( output_file );
m_Parent->PlotWorkSheet( PLOT_FORMAT_HPGL, screen );
plotter->set_color( BLACK );
m_Parent->PlotWorkSheet( plotter, screen );
DrawList = screen->EEDrawList;
while( DrawList ) /* tracage */
{
Plume( 'U' );
layer = LAYER_NOTES;
switch( DrawList->Type() )
{
case DRAW_BUSENTRY_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawBusEntryStruct*) DrawList )
x1 = STRUCT->m_Pos.x; y1 = STRUCT->m_Pos.y;
x2 = STRUCT->m_End().x; y2 = STRUCT->m_End().y;
layer = STRUCT->GetLayer();
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) DrawList )
if( DrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{
x1 = STRUCT->m_Start.x; y1 = STRUCT->m_Start.y;
x2 = STRUCT->m_End.x; y2 = STRUCT->m_End.y;
layer = STRUCT->GetLayer();
}
switch( layer )
{
case LAYER_NOTES: /* Trace en pointilles */
Move_Plume( wxPoint( x1, y1 ), 'U' );
fprintf( PlotOutput, "LT 2;\n" );
Move_Plume( wxPoint( x2, y2 ), 'D' );
fprintf( PlotOutput, "LT;\n" );
break;
case LAYER_BUS: /* Trait large */
{
int deltaX = 0, deltaY = 0; double angle;
if( (x2 - x1) == 0 )
deltaX = 8;
else if( (y2 - y1) == 0 )
deltaY = 8;
else
{
angle = atan2( (double) ( x2 - x1 ), (double) ( y1 - y2 ) );
deltaX = (int) ( 8 * sin( angle ) );
deltaY = (int) ( 8 * cos( angle ) );
}
Move_Plume( wxPoint( x1 + deltaX, y1 - deltaY ), 'U' );
Move_Plume( wxPoint( x1 - deltaX, y1 + deltaY ), 'D' );
Move_Plume( wxPoint( x2 - deltaX, y2 + deltaY ), 'D' );
Move_Plume( wxPoint( x2 + deltaX, y2 - deltaY ), 'D' );
Move_Plume( wxPoint( x1 + deltaX, y1 - deltaY ), 'D' );
}
break;
default:
Move_Plume( wxPoint( x1, y1 ), 'U' );
Move_Plume( wxPoint( x2, y2 ), 'D' );
break;
}
break;
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) DrawList )
x1 = STRUCT->m_Pos.x; y1 = STRUCT->m_Pos.y;
PlotCercle( wxPoint( x1, y1 ), DRAWJUNCTION_SIZE * 2, true );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
PlotTextStruct( DrawList );
break;
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawList;
PlotLibPart( DrawLibItem );
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
case DRAW_MARKER_STRUCT_TYPE:
break;
case DRAW_SHEET_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawSheetStruct*) DrawList )
PlotSheetStruct( STRUCT );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) DrawList )
PlotNoConnectStruct( STRUCT );
break;
default:
break;
}
Plume( 'U' );
DrawList = DrawList->Next();
}
PlotDrawlist(plotter, screen->EEDrawList);
/* fin */
CloseFileHPGL( PlotOutput );
}
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
m_MsgBox->AppendText( wxT( "Ok\n" ) );
}
/*!
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX

View File

@ -132,7 +132,8 @@ public:
void SetPenWidth(wxSpinEvent& event);
void SetPenSpeed(wxSpinEvent& event);
void SetPenNum(wxSpinEvent& event);
void Plot_1_Page_HPGL(const wxString & FullFileName,BASE_SCREEN * screen);
void Plot_1_Page_HPGL(const wxString &FileName, SCH_SCREEN * screen,
Ki_PageDescr* paper, wxPoint& offset, double scale);
void Plot_Schematic_HPGL(int Select_PlotAll, int HPGL_SheetSize);
void ReturnSheetDims( BASE_SCREEN * screen, wxSize & SheetSize, wxPoint & SheetOffset);
void SetPageOffsetValue();

View File

@ -18,8 +18,8 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
@ -27,28 +27,16 @@
#include "plot_common.h"
#include "protos.h"
// coeff de conversion dim en 1 mil -> dim en unite PS:
const double SCALE_PS = 0.001;
extern void Move_Plume( wxPoint pos, int plume );
extern void Plume( int plume );
enum PageFormatReq {
PAGE_SIZE_AUTO,
PAGE_SIZE_A4,
PAGE_SIZE_A
};
/* Variables locales : */
static int PS_SizeSelect = PAGE_SIZE_AUTO;
extern FILE* PlotOutput;
static bool Plot_Sheet_Ref = TRUE;
////@begin includes
////@end includes
#include "plotps.h"
////@begin XPM images
@ -116,6 +104,7 @@ WinEDA_PlotPSFrame::WinEDA_PlotPSFrame( WinEDA_DrawFrame* parent,
long style )
{
m_Parent = parent;
PlotPSColorOpt = false;
Create( parent, id, caption, pos, size, style );
}
@ -223,7 +212,7 @@ void WinEDA_PlotPSFrame::CreateControls()
// Set validators
m_SizeOption->SetValidator( wxGenericValidator(& PS_SizeSelect) );
m_PlotPSColorOption->SetValidator( wxGenericValidator(& g_PlotPSColorOpt) );
m_PlotPSColorOption->SetValidator( wxGenericValidator(& PlotPSColorOpt) );
m_Plot_Sheet_Ref->SetValidator( wxGenericValidator(& Plot_Sheet_Ref) );
////@end WinEDA_PlotPSFrame content construction
@ -318,7 +307,7 @@ void WinEDA_PlotPSFrame::InitOptVars()
/*****************************************/
{
Plot_Sheet_Ref = m_Plot_Sheet_Ref->GetValue();
g_PlotPSColorOpt = m_PlotPSColorOption->GetSelection();
PlotPSColorOpt = m_PlotPSColorOption->GetSelection();
PS_SizeSelect = m_SizeOption->GetSelection();
g_DrawDefaultLineThickness = m_DefaultLineSizeCtrl->GetValue();
if( g_DrawDefaultLineThickness < 1 )
@ -335,12 +324,9 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
SCH_SCREEN* oldscreen = screen;
DrawSheetPath* sheetpath, *oldsheetpath = schframe->GetSheet();
wxString PlotFileName;
Ki_PageDescr* PlotSheet, * RealSheet;
int BBox[4];
Ki_PageDescr* PlotSheet, *RealSheet;
wxPoint plot_offset;
g_PlotFormat = PLOT_FORMAT_POST;
/* When printing all pages, the printed page is not the current page.
* In complex hierarchies, we must setup references and others parameters in the printed SCH_SCREEN
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
@ -350,7 +336,7 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
sheetpath = SheetList.GetFirst();
DrawSheetPath list;
for( ; ; )
while (true)
{
if( AllPages )
{
@ -370,28 +356,30 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
sheetpath = SheetList.GetNext();
}
PlotSheet = screen->m_CurrentSheetDesc;
RealSheet = &g_Sheet_A4;
if( pagesize == PAGE_SIZE_AUTO )
RealSheet = PlotSheet;
else if( pagesize == PAGE_SIZE_A )
switch (pagesize)
{
case PAGE_SIZE_A:
RealSheet = &g_Sheet_A;
break;
case PAGE_SIZE_A4:
RealSheet = &g_Sheet_A4;
break;
case PAGE_SIZE_AUTO:
default:
RealSheet = PlotSheet;
break;
}
/* Calculate plot bouding box in 1/1000 inch */
BBox[0] = BBox[1] = g_PlotMargin; // Plot margin in 1/1000 inch
BBox[2] = RealSheet->m_Size.x - g_PlotMargin;
BBox[3] = RealSheet->m_Size.y - g_PlotMargin;
/* Calculate pcbnew to PS conversion scale */
g_PlotScaleX = SCALE_PS * (float) (BBox[2] - BBox[0]) / PlotSheet->m_Size.x;
g_PlotScaleY = SCALE_PS * (float) (BBox[3] - BBox[1]) / PlotSheet->m_Size.y;
double scalex = (double) RealSheet->m_Size.x / PlotSheet->m_Size.x;
double scaley = (double) RealSheet->m_Size.y / PlotSheet->m_Size.y;
double scale = 10 * MIN(scalex, scaley);
plot_offset.x = 0;
plot_offset.y = PlotSheet->m_Size.y;
plot_offset.y = 0;
PlotFileName = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".ps" );
PlotOneSheetPS( PlotFileName, screen, RealSheet, BBox, plot_offset );
PlotOneSheetPS( PlotFileName, screen, RealSheet, plot_offset, scale );
if( !AllPages )
break;
@ -408,163 +396,51 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
SCH_SCREEN* screen,
Ki_PageDescr* sheet,
int BBox[4],
wxPoint plot_offset )
wxPoint plot_offset,
double scale)
/*****************************************************************************************/
/* Trace en format PS. d'une feuille de dessin
*/
{
wxString Line;
SCH_ITEM* DrawList;
SCH_COMPONENT* DrawLibItem;
int layer;
wxPoint StartPos, EndPos;
wxString msg;
PlotOutput = wxFopen( FileName, wxT( "wt" ) );
if( PlotOutput == NULL )
FILE *output_file = wxFopen( FileName, wxT( "wt" ) );
if( output_file == NULL )
{
Line = wxT( "\n** " );
Line += _( "Unable to create " ) + FileName + wxT( " **\n\n" );
m_MsgBox->AppendText( Line );
msg = wxT( "\n** " );
msg += _( "Unable to create " ) + FileName + wxT( " **\n\n" );
m_MsgBox->AppendText( msg );
wxBell();
return;
}
SetLocaleTo_C_standard();
Line.Printf( _( "Plot: %s\n" ), FileName.GetData() );
m_MsgBox->AppendText( Line );
msg.Printf( _( "Plot: %s\n" ), FileName.GetData() );
m_MsgBox->AppendText( msg );
InitPlotParametresPS( plot_offset, sheet, g_PlotScaleX, g_PlotScaleY );
SetDefaultLineWidthPS( g_DrawDefaultLineThickness );
PS_Plotter *plotter = new PS_Plotter();
plotter->set_paper_size(sheet);
plotter->set_viewport( plot_offset, scale, 0);
plotter->set_default_line_width( g_DrawDefaultLineThickness );
plotter->set_color_mode(PlotPSColorOpt);
/* Init : */
PrintHeaderPS( PlotOutput, wxT( "EESchema-PS" ), FileName, 1, BBox, wxLANDSCAPE );
InitPlotParametresPS( plot_offset, sheet, 1.0, 1.0 );
plotter->set_creator(wxT("EESchema-PS"));
plotter->set_filename(FileName);
plotter->start_plot(output_file);
if( m_Plot_Sheet_Ref->GetValue() )
{
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS( BLACK );
m_Parent->PlotWorkSheet( PLOT_FORMAT_POST, screen );
}
DrawList = screen->EEDrawList;
while( DrawList ) /* tracage */
{
layer = LAYER_NOTES;
switch( DrawList->Type() )
{
case DRAW_BUSENTRY_STRUCT_TYPE: /* Struct Raccord et Segment sont identiques */
#undef STRUCT
#define STRUCT ( (DrawBusEntryStruct*) DrawList )
StartPos = STRUCT->m_Pos;
EndPos = STRUCT->m_End();
layer = STRUCT->GetLayer();
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) DrawList )
if( DrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
if( Plot_Sheet_Ref )
{
StartPos = STRUCT->m_Start;
EndPos = STRUCT->m_End;
layer = STRUCT->GetLayer();
}
if( g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( layer ) );
switch( layer )
{
case LAYER_NOTES: /* Trace en pointilles */
SetCurrentLineWidth( g_DrawDefaultLineThickness );
fprintf( PlotOutput, "[50 50] 0 setdash\n" );
Move_Plume( StartPos, 'U' );
Move_Plume( EndPos, 'D' );
Plume( 'Z' );
fprintf( PlotOutput, "[] 0 setdash\n" );
break;
case LAYER_BUS: /* Trait large */
{
int thickness = wxRound( g_DrawDefaultLineThickness * 1.4 );
if ( thickness < 3 ) thickness = 3;
SetCurrentLineWidth( thickness );
fprintf( PlotOutput, "%d setlinewidth\n", thickness );
Move_Plume( StartPos, 'U' );
Move_Plume( EndPos, 'D' );
Plume( 'Z' );
SetCurrentLineWidth( g_DrawDefaultLineThickness );
fprintf( PlotOutput, "%d setlinewidth\n", g_DrawDefaultLineThickness );
}
break;
default:
SetCurrentLineWidth( g_DrawDefaultLineThickness );
Move_Plume( StartPos, 'U' );
Move_Plume( EndPos, 'D' );
Plume( 'Z' );
break;
}
break;
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) DrawList )
if( g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( STRUCT->GetLayer() ) );
PlotCercle( STRUCT->m_Pos, DRAWJUNCTION_SIZE, 1 );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
PlotTextStruct( DrawList );
break;
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawList;
PlotLibPart( DrawLibItem );
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
case DRAW_MARKER_STRUCT_TYPE:
break;
case DRAW_SHEET_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawSheetStruct*) DrawList )
PlotSheetStruct( STRUCT );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) DrawList )
if( g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( LAYER_NOCONNECT ) );
PlotNoConnectStruct( STRUCT );
break;
default:
break;
plotter->set_color( BLACK );
m_Parent->PlotWorkSheet( plotter, screen );
}
DrawList = DrawList->Next();
}
PlotDrawlist(plotter, screen->EEDrawList);
/* fin */
CloseFilePS( PlotOutput );
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
m_MsgBox->AppendText( wxT( "Ok\n" ) );

View File

@ -106,7 +106,8 @@ public:
void InitOptVars();
void CreatePSFile(int AllPages, int pagesize);
void PlotOneSheetPS(const wxString & FileName,
SCH_SCREEN * screen, Ki_PageDescr * sheet, int BBox[4], wxPoint plot_offset);
SCH_SCREEN * screen, Ki_PageDescr * sheet,
wxPoint plot_offset, double scale);
/// Should we show tooltips?
static bool ShowToolTips();
@ -121,6 +122,7 @@ public:
////@end WinEDA_PlotPSFrame member variables
WinEDA_DrawFrame * m_Parent;
WinEDA_ValueCtrl * m_DefaultLineSizeCtrl;
int PlotPSColorOpt;
};
#endif

View File

@ -244,18 +244,7 @@ int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly);
/************/
/* PLOT.CPP */
/************/
void SetCurrentLineWidth( int width);
void PlotArc(wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1);
void PlotCercle(wxPoint centre, int diametre, bool fill, int width = -1);
void PlotPoly( int nb, int * coord, bool fill, int width = -1);
void PlotNoConnectStruct(DrawNoConnectStruct * Struct);
void PlotLibPart( SCH_COMPONENT *DrawLibItem );
/* Genere le trace d'un composant */
void PlotSheetStruct(DrawSheetStruct *Struct);
/* Routine de dessin du bloc type hierarchie */
void PlotTextStruct(EDA_BaseStruct *Struct);
void PlotDrawlist(Plotter *plotter, SCH_ITEM* drawlist );
/***************/
/* DELSHEET.CPP */

View File

@ -342,38 +342,6 @@ static PARAM_CFG_SETCOLOR ColorDCodesCfg
WHITE /* Valeur par defaut */
);
static PARAM_CFG_INT HPGLpenNumCfg
(
wxT("HPGLnum"), /* identification */
&g_HPGL_Pen_Num, /* Adresse du parametre */
1, /* Valeur par defaut */
1, 16 /* Valeurs extremes */
);
static PARAM_CFG_INT HPGLdiamCfg
(
wxT("HPGdiam"), /* identification */
&g_HPGL_Pen_Diam, /* Adresse du parametre */
15, /* Valeur par defaut */
0,0xFFFF /* Valeurs extremes */
);
static PARAM_CFG_INT HPGLspeedCfg
(
wxT("HPGLSpd"), /* identification */
&g_HPGL_Pen_Speed, /* Adresse du parametre */
25, /* Valeur par defaut */
0,100 /* Valeurs extremes */
);
static PARAM_CFG_INT HPGLrecouvrementCfg
(
wxT("HPGLrec"), /* identification */
&g_HPGL_Pen_Recouvrement, /* Adresse du parametre */
2, /* Valeur par defaut */
0, 100 /* Valeurs extremes */
);
static PARAM_CFG_INT GERBERSpotMiniCfg
(
wxT("GERBmin"), /* identification */

View File

@ -10,6 +10,12 @@
#include "pcbplot.h"
#include "protos.h"
/* The group of plot options - sadly global XXX */
PCB_Plot_Options g_pcb_plot_options;
/* variables locale : */
/* Routines Locales */
@ -24,7 +30,3 @@ void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event)
// frame->ShowModal(); frame->Destroy();
}
void Plume(int state)
{
}

View File

@ -12,5 +12,41 @@
#define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
/* Plot Options : */
struct PCB_Plot_Options {
bool Exclude_Edges_Pcb;
int PlotLine_Width;
bool Plot_Frame_Ref; // True to plot/print frame references
bool DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask)
int Plot_Mode;
bool Plot_Set_MIROIR;
bool Sel_Rotate_Window;
int HPGL_Pen_Num;
int HPGL_Pen_Speed;
int HPGL_Pen_Diam;
int HPGL_Pen_Recouvrement;
bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille
int PlotPSColorOpt; // True for color Postscript output
bool Plot_PS_Negative; // True to create a negative board ps plot
/* Autorisation de trace des divers items en serigraphie */
bool Sel_Texte_Reference;
bool Sel_Texte_Valeur;
bool Sel_Texte_Divers;
bool Sel_Texte_Invisible;
bool PlotPadsOnSilkLayer;
bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la
couche ( utile pour serigraphie) */
/* id for plot format (see enum PlotFormat in plot_common.h) */
int PlotFormat;
int PlotOrient;
int PlotScaleOpt;
int DrillShapeOpt;
double Scale_X;
double Scale_Y;
};
extern PCB_Plot_Options g_pcb_plot_options;
#endif // ifndef PCBPLOT_H

View File

@ -472,12 +472,27 @@ enum GRTextVertJustifyType {
};
/* Options to show solid segments (segments, texts...) */
enum GRFillMode {
enum GRTraceMode {
FILAIRE = 0, // segments are drawn as lines
FILLED, // normal mode: segments have thickness
SKETCH // skect mode: segments have thickness, but are not filled
};
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.
*/
enum FILL_T {
NO_FILL, // Poly, Square, Circle, Arc = option No Fill
FILLED_SHAPE, /* Poly, Square, Circle, Arc = option Fill
* with current color ("Solid shape") */
FILLED_WITH_BG_BODYCOLOR, /* Poly, Square, Circle, Arc = option Fill
* with background body color, translucent
* (texts inside this shape can be seen)
* not filled in B&W mode when plotting or
* printing */
};
#define DEFAULT_SIZE_TEXT 60 /* default text height (in mils or 1/1000") */
@ -516,12 +531,12 @@ public:
* @param aOffset = draw offset (usually (0,0))
* @param EDA_Colors aColor = text color
* @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
* @param GRFillMode aDisplay_mode = FILAIRE, FILLED or SKETCH
* @param GRTraceMode aDisplay_mode = FILAIRE, FILLED or SKETCH
* @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ).
*/
void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_Colors aColor,
int aDrawMode, GRFillMode aDisplay_mode = FILAIRE,
int aDrawMode, GRTraceMode aDisplay_mode = FILAIRE,
EDA_Colors aAnchor_color = UNSPECIFIED_COLOR );
private:
@ -540,7 +555,7 @@ private:
*/
void DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_Colors aColor,
int aDrawMode, GRFillMode aFillMode,
int aDrawMode, GRTraceMode aFillMode,
EDA_Colors aAnchor_color, wxString& aText,
wxPoint aPos );
public:

View File

@ -7,21 +7,24 @@
#ifndef __INCLUDE__DRAWTXT_H__
#define __INCLUDE__DRAWTXT_H__ 1
#include "base_struct.h"
class WinEDA_DrawPanel;
class Plotter;
/** Function Clamp_Text_PenSize
*As a rule, pen width should not be >1/4em, otherwise the character
* will be cluttered up in its own fatness
* The pen width max is aSize/4 for bold texts, and aSize/6 for normal texts
* The "best" pen width is aSize/5 for bold texts,
* so the clamp is consistant with bold option.
* @param aPenSize = the pen size to clamp
* @param aSize the char size (height or width, od its wxSize)
* @param aBold = true if text accept bold pen size
* @return the max pen size allowed
*/
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold = true);
int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold = true);
* will be cluttered up in its own fatness
* The pen width max is aSize/4 for bold texts, and aSize/6 for normal texts
* The "best" pen width is aSize/5 for bold texts,
* so the clamp is consistant with bold option.
* @param aPenSize = the pen size to clamp
* @param aSize the char size (height or width, od its wxSize)
* @param aBold = true if text accept bold pen size
* @return the max pen size allowed
*/
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold = true );
int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold = true );
/** Function GetPensizeForBold
* @return the "best" value for a pen size to draw/plot a bold text
@ -33,7 +36,7 @@ int GetPenSizeForBold( int aTextSize );
* @return the X size of the graphic text
* the full X size is ReturnGraphicTextWidth + the thickness of graphic lines
*/
int ReturnGraphicTextWidth(const wxString& aText, int size_h, bool italic, bool bold );
int ReturnGraphicTextWidth( const wxString& aText, int size_h, bool italic, bool bold );
/** Function NegableTextLength
* Return the text length of a negable string, excluding the ~ markers */
@ -70,34 +73,8 @@ void DrawGraphicText( WinEDA_DrawPanel * aPanel,
int aWidth,
bool aItalic,
bool aBold,
void (*aCallback)( int x0, int y0, int xf, int yf ) = NULL );
/** Function PlotGraphicText
* same as DrawGraphicText, but plot graphic text insteed of draw it
* @param aFormat_plot = plot format (PLOT_FORMAT_POST, PLOT_FORMAT_HPGL, PLOT_FORMAT_GERBER)
* @param aPos = text position (according to aH_justify, aV_justify)
* @param aColor (enum EDA_Colors) = text color
* @param aText = text to draw
* @param aOrient = angle in 0.1 degree
* @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
* @param aH_justify = horizontal justification (Left, center, right)
* @param aV_justify = vertical justification (bottom, center, top)
* @param aWidth = line width (pen width) (default = 0)
* if width < 0 : draw segments in sketch mode, width = abs(width)
* @param aItalic = true to simulate an italic font
* @param aBold = true to use a bold font
*/
void PlotGraphicText( int aFormat_plot,
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 (*aCallback)( int x0, int y0, int xf, int yf ) = NULL,
Plotter * plotter = NULL );
#endif /* __INCLUDE__DRAWTXT_H__ */

View File

@ -69,24 +69,4 @@ extern wxString g_Current_PadName; // Last used pad name (pad num)
extern D_PAD g_Pad_Master;
/* Gestion des plumes en plot format HPGL */
extern int g_HPGL_Pen_Num;
extern int g_HPGL_Pen_Speed;
extern int g_HPGL_Pen_Diam;
extern int g_HPGL_Pen_Recouvrement;
extern float Scale_X;
extern float Scale_Y;
extern wxPoint g_PlotOffset;
extern int g_PlotLine_Width;
extern int g_PlotFormat;
extern int g_PlotOrient;
/* id for plot format (see enum PlotFormat in plot_common.h) */
extern int g_PlotScaleOpt;
extern int g_DrillShapeOpt;
#endif /* __PCBCOMMON_H__ */

View File

@ -1,193 +1,384 @@
/**
* Common plot library \n
* Plot settings, postscript plotting, gerber plotting.
*
*
* @file plot_common.h
*/
#ifndef __INCLUDE__PLOT_COMMON_H__
#define __INCLUDE__PLOT_COMMON_H__ 1
#include <vector>
using namespace std;
#include "drawtxt.h"
/**
* Enum PlotFormat
* must be kept in order of the radio buttons in the plot panel/window.
*/
enum
PlotFormat
{
enum PlotFormat {
PLOT_FORMAT_HPGL,
PLOT_FORMAT_GERBER,
PLOT_FORMAT_POST
};
static inline bool IsPostScript( int aFormat )
{
return aFormat == PLOT_FORMAT_POST;
}
const int PLOT_MIROIR = 1;
// Variables used in Common plot functions
extern wxPoint g_Plot_PlotOffset;
extern FILE* g_Plot_PlotOutputFile;
extern double g_Plot_XScale, g_Plot_YScale;
extern int g_Plot_DefaultPenWidth, g_Plot_CurrentPenWidth;
extern int g_Plot_PlotOrientOptions, g_Plot_PenState;
class Plotter
{
public:
Plotter()
{
plot_scale = 1;
default_pen_width = 0;
current_pen_width = -1; /* To-be-set marker */
pen_state = 'Z'; /* End-of-path idle */
plot_orient_options = 0; /* Mirror flag */
output_file = 0;
color_mode = false; /* Start as a BW plot */
negative_mode = false;
sheet = NULL;
}
/*******************************/
/* common_plot_functions.cpp */
/*******************************/
void SetPlotScale( double aXScale, double aYScale ); // Set the plot scale for the current plotting)
void Setg_Plot_PlotOffset( wxPoint offset ); // Set the plot offset for the current plotting)
void InitPlotParametresGERBER( wxPoint offset, double aXScale, double aYScale );
// void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ); now a member of WinEDA_DrawFrame
void UserToDeviceCoordinate( wxPoint& pos );
// modifie les coord pos.x et pos.y pour le trace selon l'orientation, l'echelle, les offsets de trace
void UserToDeviceSize( wxSize& size );
// modifie les dimension size.x et size.y pour le trace selon l'echelle
void ForcePenReinit();
// set the flag g_Plot_CurrentPenWidth to -1 in order
// to force a pen width redefinition for the next draw command
virtual ~Plotter()
{
/* Emergency cleanup */
if( output_file )
{
fclose( output_file );
}
}
/*******************************/
/* common_plotPS_functions.cpp */
/*******************************/
void SetCurrentLineWidthPS( int width );
void InitPlotParametresPS( wxPoint offset,
Ki_PageDescr* sheet,
double aXScale,
double aYScale,
int orient = 0 );
void SetDefaultLineWidthPS( int width );
void PlotRectPS( wxPoint p1, wxPoint p2, bool fill, int width = -1 );
void PlotCirclePS( wxPoint pos, int diametre, bool fill, int width = -1 );
void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fill, int width = -1 );
virtual void start_plot( FILE* fout ) = 0;
virtual void end_plot() = 0;
// Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree
void PlotPolyPS( int nb_segm, int* coord, bool fill, int width = -1 );
void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width );
void LineTo_PS( wxPoint pos, int plume );
void PrintHeaderPS( FILE* file,
const wxString& Creator,
const wxString& FileName,
int PageCount,
int BBox[4],
int PaperOrientation );
bool CloseFilePS( FILE* plot_file );
void SetColorMapPS( int color );
virtual void set_negative( bool _negative )
{
negative_mode = _negative;
}
/*********************************/
/* common_plotHPGL_functions.cpp */
/*********************************/
void InitPlotParametresHPGL( wxPoint offset,
double aXScale,
double aYScale,
int orient = 0 );
bool PrintHeaderHPGL( FILE* plot_file,
int pen_speed,
int pen_num );
bool CloseFileHPGL( FILE* plot_file );
void PlotCircleHPGL( wxPoint centre,
int diameter,
bool fill,
int width = -1 );
void PlotRectHPGL( wxPoint t1,
wxPoint t2,
bool fill,
int width = -1 );
void PlotArcHPGL( wxPoint centre,
int StAngle,
int EndAngle,
int rayon,
bool fill,
int width = -1 );
virtual void set_color_mode( bool _color_mode )
{
color_mode = _color_mode;
}
void PlotPolyHPGL( int nb,
int* coord,
bool fill,
int width = -1 );
void Move_Plume_HPGL( wxPoint pos,
int plume );
void Plume_HPGL( int plume );
bool get_color_mode() const
{
return color_mode;
}
/*********************************/
/* common_plotGERBER_functions.cpp */
/*********************************/
/** Function InitPlotParametresGERBER
* Set the plot offset for the current plotting
* @param aOffset = plot offset
* @param aXScale,aYScale = coordinate scale (scale coefficient for coordinates)
*/
void InitPlotParametresGERBER( wxPoint aOffset,
double aXScale,
double aYScale );
/** Function Write_Header_GERBER
* Write GERBER header to file
* initialize global variable g_Plot_PlotOutputFile
* @param aTitle: the name of creator (comment)
* @param aFile: an opened file to write to
*/
void Write_Header_GERBER( const wxString aTitle,
FILE* aFile );
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;
/** Function LineTo_GERBER
* if aCommand = 'U' initialise the starting point of a line
* if aCommand = 'D' draw a line from the starting point, or last point to aPos
* @param aPos = end of the current line.
* @param aCommand = 'U' or 'D' or 'Z' (Pen up , no moving )
*/
void LineTo_GERBER( wxPoint aPos,
int aCommand );
virtual void set_creator( const wxString& _creator )
{
creator = _creator;
}
/** Function PlotGERBERLine
* Plot a line
* @param aStartPos = starting point of the line
* @param aEndPos = ending point of the line
* @param aThickness = line thickness
*/
void PlotGERBERLine( wxPoint aStartPos,
wxPoint aEndPos,
int aThickness );
/** Function PlotCircle_GERBER
* writes a non filled circle to output file
* Plot one circle as segments (6 to 16 depending on its radius
* @param aCentre = centre coordintes
* @param aRadius = radius of the circle
* @param aWidth = line width (noc currently used, D_CODEs must be selected before)
*/
void PlotCircle_GERBER( wxPoint aCentre,
int aRadius,
int aWidth );
virtual void set_filename( const wxString& _filename )
{
filename = _filename;
}
/** Function PlotPolygon_GERBER
* writes a closed polyline (not a filled polygon) to output file
* @param aCornersCount = numer of corners
* @param aCoord = buffer of corners coordinates
* @param aWidth = line width (noc currently used, D_CODEs must be selected before)
*/
void PlotPolygon_GERBER( int aCornersCount,
int* aCoord,
int aWidth );
/** Function PlotFilledPolygon_GERBER
* writes a filled polyline to output file
* @param aCornersCount = numer of corners
* @param aCoord = buffer of corners coordinates
*/
void PlotFilledPolygon_GERBER( int aCornersCount,
int* aCoord );
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;
};
class HPGL_Plotter : public Plotter
{
public:
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 */
current_pen_width = pen_diameter;
};
virtual void set_default_line_width( int width ) {};
virtual void set_dash( bool dashed );
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;
};
class PS_Plotter : public Plotter
{
public:
PS_Plotter()
{
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
struct Aperture
{
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? */
};
class Gerber_Plotter : public Plotter
{
public:
Gerber_Plotter()
{
work_file = 0;
final_file = 0;
current_aperture = apertures.end();
}
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 );
/* RS274X has no dashing, nor colours */
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 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 select_aperture( const wxSize& size, Aperture::Aperture_Type type );
vector<Aperture>::iterator get_aperture( const wxSize& size,
Aperture::Aperture_Type type );
FILE* work_file, * final_file;
void write_aperture_list();
vector<Aperture> apertures;
vector<Aperture>::iterator current_aperture;
};
#endif /* __INCLUDE__PLOT_COMMON_H__ */

View File

@ -295,17 +295,20 @@ public:
// Plotting
void ToPlotter( wxCommandEvent& event );
void Plot_Serigraphie( int format_plot, FILE* File, int masque_layer );
void Genere_GERBER( const wxString& FullFileName, int Layer,
bool PlotOriginIsAuxAxis );
void Genere_HPGL( const wxString& FullFileName, int Layer );
void Genere_PS( const wxString& FullFileName, int Layer, bool useA4 );
void Plot_Layer_HPGL( FILE* File, int masque_layer,
int garde, int tracevia, int modetrace );
void Plot_Layer_GERBER( FILE* File, int masque_layer,
int garde, int tracevia );
void Plot_Layer_PS( FILE* File, int masque_layer,
int garde, int tracevia, int modetrace );
bool PlotOriginIsAuxAxis,
GRTraceMode trace_mode );
void Genere_HPGL( const wxString& FullFileName, int Layer,
GRTraceMode trace_mode);
void Genere_PS( const wxString& FullFileName, int Layer,
bool useA4, GRTraceMode trace_mode );
void Plot_Layer(Plotter *plotter, int Layer, GRTraceMode trace_mode );
void Plot_Standard_Layer( Plotter *plotter, int masque_layer,
int garde, bool trace_via,
GRTraceMode trace_mode );
void Plot_Serigraphie( Plotter *plotter, int masque_layer,
GRTraceMode trace_mode);
void PlotDrillMark(Plotter *plotter, GRTraceMode trace_mode );
/* Block operations: */
/**
@ -872,12 +875,12 @@ public:
void Genere_GERBER( const wxString& FullFileName, int Layers );
void Genere_PS( const wxString& FullFileName, int Layers );
void Plot_Layer_HPGL( FILE* File, int masque_layer,
int garde, int tracevia, int modetrace );
int garde, bool trace_via, GRTraceMode trace_mode );
void Plot_Layer_GERBER( FILE* File, int masque_layer,
int garde, int tracevia );
int garde, bool trace_via, GRTraceMode trace_mode );
int Gen_D_CODE_File( const wxString& Name_File );
void Plot_Layer_PS( FILE* File, int masque_layer,
int garde, int tracevia, int modetrace );
int garde, bool trace_via, GRTraceMode trace_mode );
void Files_io( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event );

Some files were not shown because too many files have changed in this diff Show More