Commit 44071acf authored by dickelbeck's avatar dickelbeck

Lorenzo's postscript fill patch for bugs 2003834 and 1956732

parent 0cdcd78b
...@@ -68,9 +68,25 @@ bool CloseFileHPGL( FILE* plot_file ) ...@@ -68,9 +68,25 @@ bool CloseFileHPGL( FILE* plot_file )
return TRUE; return TRUE;
} }
/************************************************************/
void PlotRectHPGL( wxPoint p1, wxPoint p2, int 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, PlotOutputFile );
Plume_HPGL( 'U' ); return;
}
/************************************************************/ /************************************************************/
void PlotCircle_HPGL( wxPoint centre, int diameter, int width ) void PlotCircleHPGL( wxPoint centre, int diameter, int fill, int width )
/************************************************************/ /************************************************************/
{ {
int rayon; int rayon;
...@@ -91,7 +107,7 @@ void PlotCircle_HPGL( wxPoint centre, int diameter, int width ) ...@@ -91,7 +107,7 @@ void PlotCircle_HPGL( wxPoint centre, int diameter, int width )
/********************************************************************/ /********************************************************************/
void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, int width ) void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, int fill, int width )
/********************************************************************/ /********************************************************************/
/* trace d'un arc de cercle: /* trace d'un arc de cercle:
......
...@@ -113,9 +113,20 @@ void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width ) ...@@ -113,9 +113,20 @@ void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width )
fprintf( PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y ); fprintf( PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y );
} }
/***************************************************************/
void PlotRectPS( wxPoint p1, wxPoint p2, int fill, int width )
/***************************************************************/
{
UserToDeviceCoordinate( p1 );
UserToDeviceCoordinate( p2 );
SetCurrentLineWidthPS( width );
fprintf( PlotOutputFile, "%d %d %d %d rect%d\n", p1.x, p1.y,
p2.x-p1.x, p2.y-p1.y, fill );
}
/******************************************************/ /******************************************************/
void PlotCircle_PS( wxPoint pos, int diametre, int width ) void PlotCirclePS( wxPoint pos, int diametre, int fill, int width )
/******************************************************/ /******************************************************/
{ {
int rayon; int rayon;
...@@ -128,13 +139,13 @@ void PlotCircle_PS( wxPoint pos, int diametre, int width ) ...@@ -128,13 +139,13 @@ void PlotCircle_PS( wxPoint pos, int diametre, int width )
rayon = 0; rayon = 0;
SetCurrentLineWidthPS( width ); SetCurrentLineWidthPS( width );
sprintf( Line, "newpath %d %d %d 0 360 arc stroke\n", pos.x, pos.y, rayon ); sprintf(Line, "%d %d %d cir%d\n", pos.x, pos.y, rayon, fill);
fputs( Line, PlotOutputFile ); fputs( Line, PlotOutputFile );
} }
/**************************************************************************************/ /**************************************************************************************/
void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int width ) void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int fill, int width )
/**************************************************************************************/ /**************************************************************************************/
/* Plot an arc: /* Plot an arc:
...@@ -152,11 +163,13 @@ void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int width ...@@ -152,11 +163,13 @@ void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int width
UserToDeviceCoordinate( centre ); UserToDeviceCoordinate( centre );
if( PlotOrientOptions == PLOT_MIROIR ) if( PlotOrientOptions == PLOT_MIROIR )
sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y,
(int) (rayon * XScale), (float) StAngle / 10, (float) EndAngle / 10 ); (int) (rayon * XScale), (float) StAngle / 10, (float) EndAngle / 10,
fill);
else else
sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y,
(int) (rayon * XScale), -(float) EndAngle / 10, -(float) StAngle / 10 ); (int) (rayon * XScale), -(float) EndAngle / 10, -(float) StAngle / 10,
fill);
// Undo internationalization printf (float x.y printed x,y) // Undo internationalization printf (float x.y printed x,y)
to_point( Line ); to_point( Line );
...@@ -197,11 +210,7 @@ void PlotPolyPS( int nb_segm, int* coord, int fill, int width ) ...@@ -197,11 +210,7 @@ void PlotPolyPS( int nb_segm, int* coord, int fill, int width )
} }
// Fermeture du polygone // Fermeture du polygone
if( fill ) fprintf(PlotOutputFile, "poly%d\n", fill);
fprintf( PlotOutputFile, "closepath " );
if( fill == 1 )
fprintf( PlotOutputFile, "fill " );
fprintf( PlotOutputFile, "stroke\n" );
} }
...@@ -260,7 +269,19 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, ...@@ -260,7 +269,19 @@ void PrintHeaderPS( FILE* file, const wxString& Creator,
" moveto\n", " moveto\n",
" lineto\n", " lineto\n",
" stroke\n", " stroke\n",
"} def\n", "} bind def\n",
"/cir0 { newpath 0 360 arc stroke } bind def\n",
"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/arc0 { newpath arc stroke } bind def\n",
"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill grestore stroke } bind def\n",
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill grestore stroke } bind def\n",
"/poly0 { stroke } bind def\n",
"/poly1 { closepath gsave fill grestore stroke } bind def\n",
"/poly2 { closepath gsave fill grestore stroke } bind def\n",
"/rect0 { rectstroke } bind def\n",
"/rect1 { rectfill } bind def\n",
"/rect2 { rectfill } bind def\n",
"gsave\n", "gsave\n",
"72 72 scale\t\t\t% Talk inches\n", "72 72 scale\t\t\t% Talk inches\n",
"1 setlinecap\n", "1 setlinecap\n",
......
...@@ -73,9 +73,24 @@ void SetCurrentLineWidth( int width ) ...@@ -73,9 +73,24 @@ void SetCurrentLineWidth( int width )
} }
} }
/*******************************************************************************/
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 centre, int StAngle, int EndAngle, int rayon, int width ) void PlotArc( wxPoint centre, int StAngle, int EndAngle, int rayon, int fill, int width )
/*******************************************************************************/ /*******************************************************************************/
/* trace d'un arc de cercle: /* trace d'un arc de cercle:
...@@ -87,28 +102,28 @@ void PlotArc( wxPoint centre, int StAngle, int EndAngle, int rayon, int width ) ...@@ -87,28 +102,28 @@ void PlotArc( wxPoint centre, int StAngle, int EndAngle, int rayon, int width )
switch( g_PlotFormat ) switch( g_PlotFormat )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
PlotArcHPGL( centre, StAngle, EndAngle, rayon, width ); PlotArcHPGL( centre, StAngle, EndAngle, rayon, fill, width );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
PlotArcPS( centre, StAngle, EndAngle, rayon, width ); PlotArcPS( centre, StAngle, EndAngle, rayon, fill, width );
break; break;
} }
} }
/*******************************************************/ /*******************************************************/
void PlotCercle( wxPoint pos, int diametre, int width ) void PlotCercle( wxPoint pos, int diametre, int fill, int width )
/*******************************************************/ /*******************************************************/
{ {
switch( g_PlotFormat ) switch( g_PlotFormat )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
PlotCircle_HPGL( pos, diametre, width ); PlotCircleHPGL( pos, diametre, fill, width );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
PlotCircle_PS( pos, diametre, width ); PlotCirclePS( pos, diametre, fill, width );
break; break;
} }
} }
...@@ -204,7 +219,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) ...@@ -204,7 +219,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
pos.y = PartY + TransMat[1][0] * Arc->m_Pos.x + pos.y = PartY + TransMat[1][0] * Arc->m_Pos.x +
TransMat[1][1] * Arc->m_Pos.y; TransMat[1][1] * Arc->m_Pos.y;
MapAngles( &t1, &t2, TransMat ); MapAngles( &t1, &t2, TransMat );
PlotArc( pos, t1, t2, Arc->m_Rayon, Arc->m_Width ); PlotArc( pos, t1, t2, Arc->m_Rayon, Arc->m_Fill, Arc->m_Width );
} }
break; break;
...@@ -215,7 +230,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) ...@@ -215,7 +230,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
TransMat[0][1] * Circle->m_Pos.y; TransMat[0][1] * Circle->m_Pos.y;
pos.y = PartY + TransMat[1][0] * Circle->m_Pos.x + pos.y = PartY + TransMat[1][0] * Circle->m_Pos.x +
TransMat[1][1] * Circle->m_Pos.y; TransMat[1][1] * Circle->m_Pos.y;
PlotCercle( pos, Circle->m_Rayon * 2, Circle->m_Width ); PlotCercle( pos, Circle->m_Rayon * 2, Circle->m_Fill, Circle->m_Width );
} }
break; break;
...@@ -251,12 +266,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) ...@@ -251,12 +266,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
y2 = PartY + TransMat[1][0] * Square->m_End.x y2 = PartY + TransMat[1][0] * Square->m_End.x
+ TransMat[1][1] * Square->m_End.y; + TransMat[1][1] * Square->m_End.y;
SetCurrentLineWidth( Square->m_Width ); PlotRect( wxPoint(x1, y1), wxPoint(x2, y2), Square->m_Fill, Square->m_Width );
Move_Plume( wxPoint( x1, y1 ), 'U' );
Move_Plume( wxPoint( x1, y2 ), 'D' );
Move_Plume( wxPoint( x2, y2 ), 'D' );
Move_Plume( wxPoint( x2, y1 ), 'D' );
Move_Plume( wxPoint( x1, y1 ), 'D' );
} }
break; break;
...@@ -469,8 +479,8 @@ static void PlotPinSymbol( int posX, int posY, int len, int orient, int Shape ) ...@@ -469,8 +479,8 @@ static void PlotPinSymbol( int posX, int posY, int len, int orient, int Shape )
if( Shape & INVERT ) if( Shape & INVERT )
{ {
PlotCercle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1, PlotCercle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1 ), MapY1 * INVERT_PIN_RADIUS + y1),
INVERT_PIN_RADIUS * 2 ); INVERT_PIN_RADIUS * 2,0 );
Move_Plume( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1, Move_Plume( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1 ), 'U' ); MapY1 * INVERT_PIN_RADIUS * 2 + y1 ), 'U' );
......
...@@ -677,7 +677,7 @@ void WinEDA_PlotHPGLFrame::Plot_1_Page_HPGL( const wxString& FullFileName, ...@@ -677,7 +677,7 @@ void WinEDA_PlotHPGLFrame::Plot_1_Page_HPGL( const wxString& FullFileName,
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) DrawList ) #define STRUCT ( (DrawJunctionStruct*) DrawList )
x1 = STRUCT->m_Pos.x; y1 = STRUCT->m_Pos.y; x1 = STRUCT->m_Pos.x; y1 = STRUCT->m_Pos.y;
PlotCercle( wxPoint( x1, y1 ), DRAWJUNCTION_SIZE * 2 ); PlotCercle( wxPoint( x1, y1 ), DRAWJUNCTION_SIZE * 2, 1 );
break; break;
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
......
...@@ -559,7 +559,7 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName, ...@@ -559,7 +559,7 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
#define STRUCT ( (DrawJunctionStruct*) DrawList ) #define STRUCT ( (DrawJunctionStruct*) DrawList )
if( g_PlotPSColorOpt ) if( g_PlotPSColorOpt )
SetColorMapPS( ReturnLayerColor( STRUCT->GetLayer() ) ); SetColorMapPS( ReturnLayerColor( STRUCT->GetLayer() ) );
PlotCercle( STRUCT->m_Pos, DRAWJUNCTION_SIZE ); PlotCercle( STRUCT->m_Pos, DRAWJUNCTION_SIZE, 1 );
break; break;
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
......
...@@ -290,7 +290,7 @@ int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly); ...@@ -290,7 +290,7 @@ int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly);
void SetCurrentLineWidth( int width); void SetCurrentLineWidth( int width);
void PlotArc(wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1); void PlotArc(wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1);
void PlotCercle(wxPoint centre, int diametre, int width = -1); void PlotCercle(wxPoint centre, int diametre, int fill, int width = -1);
void PlotPoly( int nb, int * coord, int fill, int width = -1); void PlotPoly( int nb, int * coord, int fill, int width = -1);
void PlotNoConnectStruct(DrawNoConnectStruct * Struct); void PlotNoConnectStruct(DrawNoConnectStruct * Struct);
......
...@@ -61,8 +61,9 @@ void InitPlotParametresPS( wxPoint offset, ...@@ -61,8 +61,9 @@ void InitPlotParametresPS( wxPoint offset,
double yscale, double yscale,
int orient = 0 ); int orient = 0 );
void SetDefaultLineWidthPS( int width ); void SetDefaultLineWidthPS( int width );
void PlotCircle_PS( wxPoint pos, int diametre, int width = -1 ); void PlotRectPS(wxPoint p1, wxPoint p2, int fill, int width = -1);
void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1 ); void PlotCirclePS( wxPoint pos, int diametre, int fill, int width = -1 );
void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int fill, int width = -1 );
// Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree // Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree
void PlotPolyPS( int nb_segm, int* coord, int fill, int width = -1 ); void PlotPolyPS( int nb_segm, int* coord, int fill, int width = -1 );
...@@ -84,8 +85,9 @@ void SetColorMapPS( int color ); ...@@ -84,8 +85,9 @@ void SetColorMapPS( int color );
void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient = 0 ); void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient = 0 );
bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num ); bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num );
bool CloseFileHPGL( FILE* plot_file ); bool CloseFileHPGL( FILE* plot_file );
void PlotCircle_HPGL( wxPoint centre, int diameter, int width = -1 ); void PlotCircleHPGL( wxPoint centre, int diameter, int fill, int width = -1 );
void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1 ); void PlotRectHPGL(wxPoint t1, wxPoint t2, int fill, int width = -1);
void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, int fill, int width = -1 );
void PlotPolyHPGL( int nb, int* coord, int fill, int width = -1 ); void PlotPolyHPGL( int nb, int* coord, int fill, int width = -1 );
void Move_Plume_HPGL( wxPoint pos, int plume ); void Move_Plume_HPGL( wxPoint pos, int plume );
void Plume_HPGL( int plume ); void Plume_HPGL( int plume );
......
...@@ -791,7 +791,7 @@ void PlotCircle( int format_plot, int thickness, wxPoint centre, int radius ) ...@@ -791,7 +791,7 @@ void PlotCircle( int format_plot, int thickness, wxPoint centre, int radius )
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
PlotCircle_PS( centre, radius * 2, thickness ); PlotCirclePS( centre, radius * 2, thickness, 0);
break; break;
} }
} }
...@@ -837,7 +837,7 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -837,7 +837,7 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
if( IsPostScript( format_plot ) ) if( IsPostScript( format_plot ) )
{ {
PlotArcPS( centre, start_angle, end_angle, radius, thickness ); PlotArcPS( centre, start_angle, end_angle, radius, thickness, 0 );
return; return;
} }
......
...@@ -543,8 +543,8 @@ void trace_1_pastille_OVALE_POST( wxPoint pos, wxSize size, int orient, int mode ...@@ -543,8 +543,8 @@ void trace_1_pastille_OVALE_POST( wxPoint pos, wxSize size, int orient, int mode
rayon = 1; rayon = 1;
if( rayon < w ) if( rayon < w )
w = rayon; w = rayon;
PlotArcPS( wxPoint( pos.x + x1, pos.y + y1 ), -orient, -orient + 1800, rayon, w ); PlotArcPS( wxPoint( pos.x + x1, pos.y + y1 ), -orient, -orient + 1800, rayon, w, 0);
PlotArcPS( wxPoint( pos.x + x0, pos.y + y0 ), -orient + 1800, -orient, rayon, w ); PlotArcPS( wxPoint( pos.x + x0, pos.y + y0 ), -orient + 1800, -orient, rayon, w, 0 );
x0 = -rayon; x0 = -rayon;
y0 = -delta / 2; y0 = -delta / 2;
......
...@@ -132,26 +132,10 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event ) ...@@ -132,26 +132,10 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
namespace DSN { namespace DSN {
struct POINT_PAIR
{
POINT start;
POINT end;
BOARD_ITEM* item; ///< the item which has these points, TRACK or DRAWSEGMENT
};
typedef std::vector<POINT_PAIR> POINT_PAIRS;
const KICAD_T SPECCTRA_DB::scanPADs[] = { TYPEPAD, EOT }; const KICAD_T SPECCTRA_DB::scanPADs[] = { TYPEPAD, EOT };
static inline void swap( POINT_PAIR& pair )
{
POINT temp = pair.start;
pair.start = pair.end;
pair.end = temp;
}
/** /**
* Function scale * Function scale
* converts a distance from kicad units to our reported specctra dsn units: * converts a distance from kicad units to our reported specctra dsn units:
......
...@@ -122,6 +122,15 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event ) ...@@ -122,6 +122,15 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
namespace DSN { namespace DSN {
/**
* Function scale
* converts a session file distance to Kicad units of deci-mils.
* @param distance The session file length to convert.
* @param aResolution The session UNIT_RES which holds the engineering unit
* specifier
* @return int - The Kicad length in deci-mils
*/
static int scale( double distance, UNIT_RES* aResolution ) static int scale( double distance, UNIT_RES* aResolution )
{ {
double resValue = aResolution->GetValue(); double resValue = aResolution->GetValue();
...@@ -152,7 +161,7 @@ static int scale( double distance, UNIT_RES* aResolution ) ...@@ -152,7 +161,7 @@ static int scale( double distance, UNIT_RES* aResolution )
// used within Kicad. // used within Kicad.
factor *= 10.0; factor *= 10.0;
int ret = (int) round(factor * distance / resValue); int ret = (int) round( factor * distance / resValue );
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment