Commit 3e477651 authored by charras's avatar charras

finishing work on hpgl plotting functions

parent f9642fd4
/************/ /************/
/* pcbplot.h*/ /* pcbplot.h*/
/************/ /************/
#ifndef PCBPLOT_H #ifndef PCBPLOT_H
#define PCBPLOT_H #define PCBPLOT_H
...@@ -36,7 +36,7 @@ eda_global int g_Plot_Mode // = FILAIRE, FILL or SKETCH ...@@ -36,7 +36,7 @@ eda_global int g_Plot_Mode // = FILAIRE, FILL or SKETCH
= FILLED = FILLED
#endif #endif
; ;
eda_global bool Plot_Set_MIROIR ; eda_global bool Plot_Set_MIROIR;
eda_global bool Sel_Rotate_Window; eda_global bool Sel_Rotate_Window;
eda_global bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille eda_global bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille
eda_global int g_PlotPSColorOpt; // True for color Postscript output eda_global int g_PlotPSColorOpt; // True for color Postscript output
...@@ -66,11 +66,11 @@ eda_global bool PlotPadsOnSilkLayer /* Plot pads sur couche serigraphie */ ...@@ -66,11 +66,11 @@ eda_global bool PlotPadsOnSilkLayer /* Plot pads sur couche serigraphie */
#endif #endif
; ;
eda_global bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la eda_global bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la
couche ( utile pour serigraphie) */ * couche ( utile pour serigraphie) */
/* Variables utiles */ /* Variables utiles */
eda_global FILE * dest; eda_global FILE* dest;
/* Gestion des plumes en plot format HPGL */ /* Gestion des plumes en plot format HPGL */
eda_global int g_HPGL_Pen_Num /* num de plume a charger */ eda_global int g_HPGL_Pen_Num /* num de plume a charger */
...@@ -87,11 +87,11 @@ eda_global int g_HPGL_Pen_Diam; /* diametre en mils */ ...@@ -87,11 +87,11 @@ eda_global int g_HPGL_Pen_Diam; /* diametre en mils */
eda_global int g_HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */ eda_global int g_HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */
/* Gestion des cadrages et echelles de trace */ /* Gestion des cadrages et echelles de trace */
eda_global float Scale_X, Scale_Y ; /* coeff d'agrandissement en X et Y demandes */ eda_global float Scale_X, Scale_Y; /* coeff d'agrandissement en X et Y demandes */
eda_global wxPoint g_PlotOffset; /* Offset de trace modifies par l'echelle */ eda_global wxPoint g_PlotOffset; /* Offset de trace modifies par l'echelle */
eda_global int g_PlotLine_Width; /* Largeur du trait en mode filaire (utilise en serigraphie, eda_global int g_PlotLine_Width; /* Largeur du trait en mode filaire (utilise en serigraphie,
pour traces en mode sketch et filaire) */ * pour traces en mode sketch et filaire) */
eda_global int g_PlotFormat /* id for plot format (see enum PlotFormat in plot_common.h) */ eda_global int g_PlotFormat /* id for plot format (see enum PlotFormat in plot_common.h) */
#ifdef MAIN #ifdef MAIN
...@@ -99,9 +99,9 @@ eda_global int g_PlotFormat /* id for plot format (see enum PlotFormat in plot_ ...@@ -99,9 +99,9 @@ eda_global int g_PlotFormat /* id for plot format (see enum PlotFormat in plot_
#endif #endif
; ;
eda_global int g_PlotOrient; /* numero de code de l'orientation du trace ( voir eda_global int g_PlotOrient; /* numero de code de l'orientation du trace ( voir
defines precedents): * defines precedents):
0 = normal * 0 = normal
PLOT_MIROIR = MIROIR * PLOT_MIROIR = MIROIR
*/ */
eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee
#ifdef MAIN #ifdef MAIN
...@@ -111,14 +111,14 @@ eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee ...@@ -111,14 +111,14 @@ eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee
eda_global int g_DrillShapeOpt eda_global int g_DrillShapeOpt
#ifdef MAIN #ifdef MAIN
= 1 // 0 = no drill mark, 1 = small mark, 2 = real drill = 1 // 0 = no drill mark, 1 = small mark, 2 = real drill
#endif #endif
; ;
/*************************************/ /*************************************/
/* Constantes utiles en trace GERBER */ /* Constantes utiles en trace GERBER */
/*************************************/ /*************************************/
/* codes de type de forme d'outils */ /* codes de type de forme d'outils */
#define GERB_CIRCLE 1 #define GERB_CIRCLE 1
...@@ -128,56 +128,64 @@ eda_global int g_DrillShapeOpt ...@@ -128,56 +128,64 @@ eda_global int g_DrillShapeOpt
#define GERB_DONUT 5 #define GERB_DONUT 5
/* PLOT_RTN.CC */ /* PLOT_RTN.CC */
void PlotTextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer); void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer );
/* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules,
prepare les parametres de trace de texte */
void PlotArc(int format_plot, wxPoint centre, int start_angle,int end_angle,
int rayon,int width);
void PlotCircle(int format_plot,int width, wxPoint centre, int rayon);
void PlotFilledPolygon(int format_plot, int nbpoints, int * coord);
void PlotPolygon(int format_plot, int nbpoints, int * coord, int width);
void PlotDrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer ); /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules,
* prepare les parametres de trace de texte */
void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
int rayon, int width );
void PlotCircle( int format_plot, int width, wxPoint centre, int rayon );
void PlotFilledPolygon( int format_plot, int nbpoints, int* coord );
void PlotPolygon( int format_plot, int nbpoints, int* coord, int width );
void PlotCotation( COTATION * Cotation, int format_plot,int masque_layer ); void PlotDrawSegment( DRAWSEGMENT* PtSegm, int format_plot, int masque_layer );
void PlotMirePcb( MIREPCB* PtMire, int format_plot,int masque_layer ); void PlotCotation( COTATION* Cotation, int format_plot, int masque_layer );
void Plot_1_EdgeModule(int format_plot, EDGE_MODULE * PtEdge); void PlotMirePcb( MIREPCB* PtMire, int format_plot, int masque_layer );
void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat); void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge );
void PlotFilledAreas( ZONE_CONTAINER* aZone, int aFormat );
/* PLOTGERB.CPP */ /* PLOTGERB.CPP */
void SelectD_CODE_For_LineDraw( int aSize ); void SelectD_CODE_For_LineDraw( int aSize );
void trace_1_contour_GERBER(wxPoint pos, wxSize size, wxSize delta, void trace_1_contour_GERBER( wxPoint pos, wxSize size, wxSize delta,
int penwidth, int orient); int penwidth, int orient );
/* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque
donne par son centre, ses dimensions, /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque
ses variations, l'epaisseur du trait et son orientation orient */ * donne par son centre, ses dimensions,
* ses variations, l'epaisseur du trait et son orientation orient */
/* PLOTHPGL.CC */ /* PLOTHPGL.CPP */
void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1,
int hauteur);
void trace_1_pad_TRAPEZE_HPGL(wxPoint padpos, wxSize size,wxSize delta, /** Function Plot a filled segment (track)
int orient,int modetrace); * @param aStart = starting point
* @param aEnd = ending point
* @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH ..
* @return true if Ok, false if aWidth > pen size (the segment is always plotted)
*/
bool Plot_Filled_Segment_HPGL( wxPoint aStart, wxPoint aEnd, int aWidth, GRFillMode aPlotMode );
void trace_1_pastille_RONDE_HPGL(wxPoint padpos, int diametre,int modetrace) ; void trace_1_pad_TRAPEZE_HPGL( wxPoint padpos, wxSize size, wxSize delta,
void trace_1_pastille_OVALE_HPGL(wxPoint padpos, wxSize size, int orient, int modetrace); int orient, int modetrace );
void PlotRectangularPad_HPGL(wxPoint padpos, wxSize padsize, int orient,int modetrace);
void trace_1_pastille_RONDE_HPGL( wxPoint padpos, int diametre, int modetrace );
void trace_1_pastille_OVALE_HPGL( wxPoint padpos, wxSize size, int orient, int modetrace );
void PlotRectangularPad_HPGL( wxPoint padpos, wxSize padsize, int orient, int modetrace );
/**************/ /**************/
/* PLOTPS.CPP */ /* PLOTPS.CPP */
/**************/ /**************/
void trace_1_pastille_OVALE_POST(wxPoint centre, wxSize size, int orient, int modetrace); void trace_1_pastille_OVALE_POST( wxPoint centre, wxSize size, int orient, int modetrace );
void trace_1_pastille_RONDE_POST(wxPoint centre, int diametre, int modetrace); void trace_1_pastille_RONDE_POST( wxPoint centre, int diametre, int modetrace );
void trace_1_pad_rectangulaire_POST(wxPoint centre, wxSize size,int orient, void trace_1_pad_rectangulaire_POST( wxPoint centre, wxSize size, int orient,
int modetrace); int modetrace );
void trace_1_contour_POST(wxPoint centre, wxSize size, wxSize delta, void trace_1_contour_POST( wxPoint centre, wxSize size, wxSize delta,
int dim_trait, int orient); int dim_trait, int orient );
void trace_1_pad_TRAPEZE_POST(wxPoint centre, wxSize size, wxSize delta, void trace_1_pad_TRAPEZE_POST( wxPoint centre, wxSize size, wxSize delta,
int orient,int modetrace); int orient, int modetrace );
#endif /* #define PCBPLOT_H */ #endif /* #define PCBPLOT_H */
...@@ -107,6 +107,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -107,6 +107,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
trace_1_pastille_RONDE_POST( pos, size.x, FILAIRE ); trace_1_pastille_RONDE_POST( pos, size.x, FILAIRE );
break; break;
} }
break; break;
case PAD_OVAL: case PAD_OVAL:
...@@ -129,6 +130,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -129,6 +130,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
pt_pad->m_Orient, FILAIRE ); pt_pad->m_Orient, FILAIRE );
break; break;
} }
break; break;
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
...@@ -156,6 +158,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -156,6 +158,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
FILAIRE ); FILAIRE );
break; break;
} }
break; break;
} }
...@@ -179,6 +182,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -179,6 +182,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
(int) pt_pad->m_Orient, FILAIRE ); (int) pt_pad->m_Orient, FILAIRE );
break; break;
} }
break; break;
} }
} }
...@@ -200,7 +204,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -200,7 +204,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
wxString errMsg; wxString errMsg;
errMsg.Printf( errMsg.Printf(
_("Your BOARD has a bad layer number of %u for module\n %s's \"reference\" text."), _( "Your BOARD has a bad layer number of %u for module\n %s's \"reference\" text." ),
textLayer, Module->GetReference().GetData() ); textLayer, Module->GetReference().GetData() );
DisplayError( this, errMsg ); DisplayError( this, errMsg );
goto exit; goto exit;
...@@ -220,7 +224,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -220,7 +224,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
wxString errMsg; wxString errMsg;
errMsg.Printf( errMsg.Printf(
_("Your BOARD has a bad layer number of %u for module\n %s's \"value\" text."), _( "Your BOARD has a bad layer number of %u for module\n %s's \"value\" text." ),
textLayer, Module->GetReference().GetData() ); textLayer, Module->GetReference().GetData() );
DisplayError( this, errMsg ); DisplayError( this, errMsg );
goto exit; goto exit;
...@@ -260,13 +264,14 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -260,13 +264,14 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
wxString errMsg; wxString errMsg;
errMsg.Printf( errMsg.Printf(
_("Your BOARD has a bad layer number of %u for module\n %s's \"module text\" text of %s."), _(
"Your BOARD has a bad layer number of %u for module\n %s's \"module text\" text of %s." ),
textLayer, Module->GetReference().GetData(), pt_texte->m_Text.GetData() ); textLayer, Module->GetReference().GetData(), pt_texte->m_Text.GetData() );
DisplayError( this, errMsg ); DisplayError( this, errMsg );
goto exit; goto exit;
} }
if( !( (1<<textLayer) & masque_layer ) ) if( !( (1 << textLayer) & masque_layer ) )
continue; continue;
PlotTextModule( pt_texte, format_plot ); PlotTextModule( pt_texte, format_plot );
...@@ -276,10 +281,10 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -276,10 +281,10 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
/* Plot filled ares */ /* Plot filled ares */
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii); ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii );
if( ( (1 << edge_zone->GetLayer()) & masque_layer ) == 0 ) if( ( ( 1 << edge_zone->GetLayer() ) & masque_layer ) == 0 )
continue; continue;
PlotFilledAreas(edge_zone, format_plot); PlotFilledAreas( edge_zone, format_plot );
} }
exit: exit:
...@@ -311,7 +316,7 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot ) ...@@ -311,7 +316,7 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot )
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw( thickness );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
...@@ -473,7 +478,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -473,7 +478,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
if( g_Plot_Mode == FILAIRE ) if( g_Plot_Mode == FILAIRE )
{ {
thickness = g_PlotLine_Width; thickness = g_PlotLine_Width;
wxLogDebug( wxT("changing edgemodule thickness to g_PlotLine_Width") ); wxLogDebug( wxT( "changing edgemodule thickness to g_PlotLine_Width" ) );
} }
pos = PtEdge->m_Start; pos = PtEdge->m_Start;
...@@ -487,12 +492,12 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -487,12 +492,12 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw( thickness );
PlotGERBERLine( pos, end, thickness ); PlotGERBERLine( pos, end, thickness );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_segment_HPGL( pos.x, pos.y, end.x, end.y, thickness ); Plot_Filled_Segment_HPGL( pos, end, thickness, (GRFillMode)g_Plot_Mode );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
...@@ -582,7 +587,7 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer ) ...@@ -582,7 +587,7 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer )
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw( thickness );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
...@@ -602,10 +607,11 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer ) ...@@ -602,10 +607,11 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer )
/*********************************************************/ /*********************************************************/
void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat ) void PlotFilledAreas( ZONE_CONTAINER* aZone, int aFormat )
/*********************************************************/ /*********************************************************/
/* Plot areas (given by .m_FilledPolysList member) in a zone /* Plot areas (given by .m_FilledPolysList member) in a zone
*/ */
{ {
static int* CornersBuffer = NULL; static int* CornersBuffer = NULL;
static unsigned CornersBufferSize = 0; static unsigned CornersBufferSize = 0;
...@@ -615,6 +621,8 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat ) ...@@ -615,6 +621,8 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat )
return; return;
// We need a buffer to store corners coordinates: // We need a buffer to store corners coordinates:
imax++; // provide room to sore an extra coordinte to close the ploygon
if( CornersBuffer == NULL ) if( CornersBuffer == NULL )
{ {
CornersBufferSize = imax * 4; CornersBufferSize = imax * 4;
...@@ -627,6 +635,8 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat ) ...@@ -627,6 +635,8 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat )
CornersBuffer = (int*) realloc( CornersBuffer, CornersBufferSize * sizeof(int) ); CornersBuffer = (int*) realloc( CornersBuffer, CornersBufferSize * sizeof(int) );
} }
imax--;
// Plot all filled areas // Plot all filled areas
int corners_count = 0; int corners_count = 0;
for( unsigned ic = 0, ii = 0; ic < imax; ic++ ) for( unsigned ic = 0, ii = 0; ic < imax; ic++ )
...@@ -635,11 +645,21 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat ) ...@@ -635,11 +645,21 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat )
CornersBuffer[ii++] = corner->x; CornersBuffer[ii++] = corner->x;
CornersBuffer[ii++] = corner->y; CornersBuffer[ii++] = corner->y;
corners_count++; corners_count++;
if( corner->end_contour ) if( corner->end_contour ) // Plot the current filled area outline
{ // Plot the current filled area {
if( aZone->m_FillMode == 0) // We are using solid polygons (if != 0: using segments in m_Zone) // First, close the outline
if( CornersBuffer[0] != CornersBuffer[ii - 2] || CornersBuffer[1] !=
CornersBuffer[ii - 1] )
{
CornersBuffer[ii++] = CornersBuffer[0];
CornersBuffer[ii] = CornersBuffer[1];
corners_count++;
}
// Plot the current filled area outline
if( aZone->m_FillMode == 0 ) // We are using solid polygons (if != 0: using segments in m_Zone)
PlotFilledPolygon( aFormat, corners_count, CornersBuffer ); PlotFilledPolygon( aFormat, corners_count, CornersBuffer );
if ( aZone->m_ZoneMinThickness > 0 ) if( aZone->m_ZoneMinThickness > 0 )
PlotPolygon( aFormat, corners_count, CornersBuffer, aZone->m_ZoneMinThickness ); PlotPolygon( aFormat, corners_count, CornersBuffer, aZone->m_ZoneMinThickness );
corners_count = 0; corners_count = 0;
ii = 0; ii = 0;
...@@ -647,6 +667,7 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat ) ...@@ -647,6 +667,7 @@ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat )
} }
} }
/******************************************************************************/ /******************************************************************************/
void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer ) void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer )
/******************************************************************************/ /******************************************************************************/
...@@ -686,7 +707,7 @@ void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer ) ...@@ -686,7 +707,7 @@ void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer )
switch( Format ) switch( Format )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw( thickness );
if( pt_segm->m_Shape == S_CIRCLE ) if( pt_segm->m_Shape == S_CIRCLE )
PlotCircle( PLOT_FORMAT_GERBER, thickness, start, radius ); PlotCircle( PLOT_FORMAT_GERBER, thickness, start, radius );
else if( pt_segm->m_Shape == S_ARC ) else if( pt_segm->m_Shape == S_ARC )
...@@ -702,7 +723,7 @@ void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer ) ...@@ -702,7 +723,7 @@ void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer )
else if( pt_segm->m_Shape == S_ARC ) else if( pt_segm->m_Shape == S_ARC )
PlotArc( PLOT_FORMAT_HPGL, start, StAngle, EndAngle, radius, thickness ); PlotArc( PLOT_FORMAT_HPGL, start, StAngle, EndAngle, radius, thickness );
else else
trace_1_segment_HPGL( start.x, start.y, end.x, end.y, thickness ); Plot_Filled_Segment_HPGL( start, end, thickness, (GRFillMode)g_Plot_Mode );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
...@@ -726,7 +747,7 @@ void PlotCircle( int format_plot, int thickness, wxPoint centre, int radius ) ...@@ -726,7 +747,7 @@ void PlotCircle( int format_plot, int thickness, wxPoint centre, int radius )
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw( thickness );
PlotCircle_GERBER( centre, radius, thickness ); PlotCircle_GERBER( centre, radius, thickness );
break; break;
...@@ -762,20 +783,44 @@ void PlotFilledPolygon( int format_plot, int nbpoints, int* coord ) ...@@ -762,20 +783,44 @@ void PlotFilledPolygon( int format_plot, int nbpoints, int* coord )
} }
} }
/**********************************************************************/ /**********************************************************************/
void PlotPolygon( int format_plot, int nbpoints, int* coord, int width ) void PlotPolygon( int format_plot, int nbpoints, int* coord, int width )
/**********************************************************************/ /**********************************************************************/
/* plot a polygon */
/* plot a non filled polygon
*/
{ {
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(width); SelectD_CODE_For_LineDraw( width );
PlotPolygon_GERBER( nbpoints, coord, width ); PlotPolygon_GERBER( nbpoints, coord, width );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
PlotPolyHPGL( nbpoints, coord, false, width ); {
// Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units,
// with plot scale (if Scale is 2, pen diametre is always g_HPGL_Pen_Diam
// so apparent pen diam is real pen diam / Scale
int pen_diam = (int) round( (g_HPGL_Pen_Diam * U_PCB) / Scale_X ); // Assume Scale_X # Scale_Y
wxString msg;
if( pen_diam >= width )
PlotPolyHPGL( nbpoints, coord, false, width ); // PlotPolyHPGL does not handle width
else
{
wxPoint start, end;
start.x = *coord++;
start.y = *coord++;
for( int ii = 1; ii < nbpoints; ii++ )
{
end.x = *coord++;
end.y = *coord++;
Plot_Filled_Segment_HPGL( start, end, width, (GRFillMode)g_Plot_Mode );
start = end;
}
}
}
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
...@@ -826,8 +871,8 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -826,8 +871,8 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
RotatePoint( &ox, &oy, start_angle ); RotatePoint( &ox, &oy, start_angle );
if ( format_plot == PLOT_FORMAT_GERBER ) if( format_plot == PLOT_FORMAT_GERBER )
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw( thickness );
delta = 120; /* un cercle sera trace en 3600/delta = 30 segments / cercle*/ delta = 120; /* un cercle sera trace en 3600/delta = 30 segments / cercle*/
for( ii = start_angle + delta; ii < end_angle; ii += delta ) for( ii = start_angle + delta; ii < end_angle; ii += delta )
...@@ -845,11 +890,9 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -845,11 +890,9 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_segment_HPGL( centre.x + ox, Plot_Filled_Segment_HPGL( wxPoint(centre.x + ox, centre.y + oy),
centre.y + oy, wxPoint(centre.x + fx, centre.y + fy),
centre.x + fx, thickness, (GRFillMode)g_Plot_Mode );
centre.y + fy,
thickness );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
...@@ -873,11 +916,9 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -873,11 +916,9 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_segment_HPGL( centre.x + ox, Plot_Filled_Segment_HPGL( wxPoint(centre.x + ox, centre.y + oy),
centre.y + oy, wxPoint(centre.x + fx, centre.y + fy),
centre.x + fx, thickness, (GRFillMode)g_Plot_Mode );
centre.y + fy,
thickness );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
......
...@@ -70,7 +70,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) ...@@ -70,7 +70,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer )
return; return;
} }
SetLocaleTo_C_standard( ); SetLocaleTo_C_standard();
Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN ); Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN );
...@@ -186,7 +186,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) ...@@ -186,7 +186,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer )
/* fin */ /* fin */
CloseFileHPGL( dest ); CloseFileHPGL( dest );
SetLocaleTo_Default( ); SetLocaleTo_Default();
} }
...@@ -346,78 +346,86 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, ...@@ -346,78 +346,86 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer,
if( pts->Type() == TYPE_VIA ) if( pts->Type() == TYPE_VIA )
continue; continue;
if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) )
continue; Plot_Filled_Segment_HPGL( pts->m_Start, pts->m_End, pts->m_Width, (GRFillMode)g_Plot_Mode );
size.x = size.y = pts->m_Width;
start = pts->m_Start;
end = pts->m_End;
if( size.x > pen_diam ) /* c.a.d si largeur piste > diam plume */
trace_1_pastille_RONDE_HPGL( start, size.x, modetrace );
/* Trace d'un segment de piste */
trace_1_segment_HPGL( start.x, start.y, end.x, end.y, size.x );
/* Complement de Trace en mode Remplissage */
if( (g_Plot_Mode == FILLED) && (pen_diam <= size.x ) )
{
while( ( size.x -= (int) ( (pen_rayon - pen_recouvrement) * 2 ) ) > 0 )
{
trace_1_segment_HPGL( start.x, start.y, end.x, end.y,
MAX( size.x, pen_diam ) );
}
}
if( size.x > pen_diam )
trace_1_pastille_RONDE_HPGL( end, size.x, modetrace );
} }
/* trace des segments pistes et zones */ /* trace des segments pistes et zones */
for( pts = m_Pcb->m_Zone; pts != NULL; pts = pts->Next() ) for( pts = m_Pcb->m_Zone; pts != NULL; pts = pts->Next() )
{ {
if( g_TabOneLayerMask[pts->GetLayer()] & masque_layer ) if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) )
Plot_Filled_Segment_HPGL( pts->m_Start, pts->m_End, pts->m_Width, (GRFillMode)g_Plot_Mode );
}
/* Plot filled ares */
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
size.x = size.y = pts->m_Width; ZONE_CONTAINER* zone = m_Pcb->GetArea( ii );
start = pts->m_Start; if( ( ( 1 << zone->GetLayer() ) & masque_layer ) == 0 )
end = pts->m_End; continue;
PlotFilledAreas( zone, PLOT_FORMAT_HPGL );
}
}
if( size.x > pen_diam ) /* c.a.d si largeur piste > diam plume */
trace_1_pastille_RONDE_HPGL( start, size.x, modetrace );
/* Trace d'un segment de piste */ /*********************************************************************************************/
trace_1_segment_HPGL( start.x, start.y, end.x, end.y, size.x ); bool Plot_Filled_Segment_HPGL( wxPoint aStart, wxPoint aEnd, int aWidth, GRFillMode aPlotMode )
/* Complement de Trace en mode Remplissage */ /*********************************************************************************************/
if( (g_Plot_Mode == FILLED) && (pen_diam <= size.x ) )
{ /** Function Plot a filled segment (track)
while( ( size.x -= (int) ( (pen_rayon - pen_recouvrement) * 2 ) ) > 0 ) * @param aStart = starting point
* @param aEnd = ending point
* @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH ..
* @return true if Ok, false if aWidth > pen size (the segment is always plotted)
*/
{
wxPoint center;
wxSize size;
int orient;
if( (pen_diam >= aWidth) || (g_Plot_Mode == FILAIRE) ) /* just a line is Ok */
{ {
trace_1_segment_HPGL( start.x, start.y, end.x, end.y, Move_Plume_HPGL( aStart, 'U' );
MAX( size.x, pen_diam ) ); Move_Plume_HPGL( aEnd, 'D' );
} Plume_HPGL( 'U' );
return pen_diam <= aWidth;;
} }
if( size.x > pen_diam ) // A segment is like an oval pal, so use trace_1_pastille_OVALE_HPGL to do the work.
trace_1_pastille_RONDE_HPGL( end, size.x, modetrace ); center.x = (aStart.x + aEnd.x) / 2;
} center.y = (aStart.y + aEnd.y) / 2;
}
size.x = aEnd.x - aStart.x;
size.y = aEnd.y - aStart.y;
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) ) + aWidth; // module.
size.y = aWidth;
trace_1_pastille_OVALE_HPGL( center, size, orient, aPlotMode );
return pen_diam <= aWidth;
} }
/************************************************************************************/ /************************************************************************************/
void trace_1_pastille_OVALE_HPGL( wxPoint pos, wxSize size, int orient, int modetrace ) void trace_1_pastille_OVALE_HPGL( wxPoint pos, wxSize size, int aOrient, int modetrace )
/************************************************************************************/ /************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */ /* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */
{ {
int rayon, deltaxy, cx, cy; int rayon, deltaxy, cx, cy;
int trace_orient = orient;
/* la pastille est ramenee a une pastille ovale avec size.y > size.x /* la pastille est ramenee a une pastille ovale avec size.y > size.x
* ( ovale vertical en orientation 0 ) */ * ( ovale vertical en orientation 0 ) */
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); trace_orient += 900; EXCHG( size.x, size.y ); aOrient += 900;
if( orient >= 3600 ) if( aOrient >= 3600 )
trace_orient -= 3600; aOrient -= 3600;
} }
deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */ deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */
rayon = size.x / 2; rayon = size.x / 2;
...@@ -425,41 +433,41 @@ void trace_1_pastille_OVALE_HPGL( wxPoint pos, wxSize size, int orient, int mode ...@@ -425,41 +433,41 @@ void trace_1_pastille_OVALE_HPGL( wxPoint pos, wxSize size, int orient, int mode
if( modetrace == FILLED ) if( modetrace == FILLED )
{ {
PlotRectangularPad_HPGL( pos, wxSize( size.x, deltaxy ), PlotRectangularPad_HPGL( pos, wxSize( size.x, deltaxy ),
orient, modetrace ); aOrient, modetrace );
cx = 0; cy = deltaxy / 2; cx = 0; cy = deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
trace_1_pastille_RONDE_HPGL( wxPoint( cx + pos.x, cy + pos.y ), size.x, modetrace ); trace_1_pastille_RONDE_HPGL( wxPoint( cx + pos.x, cy + pos.y ), size.x, modetrace );
Plume_HPGL( 'U' ); Plume_HPGL( 'U' );
cx = 0; cy = -deltaxy / 2; cx = 0; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
trace_1_pastille_RONDE_HPGL( wxPoint( cx + pos.x, cy + pos.y ), size.x, modetrace ); trace_1_pastille_RONDE_HPGL( wxPoint( cx + pos.x, cy + pos.y ), size.x, modetrace );
} }
else /* Trace en mode FILAIRE */ else /* Trace en mode SKETCH */
{ {
cx = -rayon; cy = -deltaxy / 2; cx = -rayon; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'U' ); Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'U' );
cx = -rayon; cy = deltaxy / 2; cx = -rayon; cy = deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'D' ); Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'D' );
cx = rayon; cy = -deltaxy / 2; cx = rayon; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'U' ); Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'U' );
cx = rayon; cy = deltaxy / 2; cx = rayon; cy = deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'D' ); Move_Plume_HPGL( wxPoint( cx + pos.x, cy + pos.y ), 'D' );
Plume_HPGL( 'U' ); Plume_HPGL( 'U' );
cx = 0; cy = -deltaxy / 2; cx = 0; cy = deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
PlotArc( PLOT_FORMAT_HPGL, wxPoint( cx + pos.x, cy + pos.y ), PlotArc( PLOT_FORMAT_HPGL, wxPoint( cx + pos.x, cy + pos.y ),
trace_orient, trace_orient + 1800, -aOrient, -aOrient - 1800,
size.x / 2, pen_diam ); size.x / 2, pen_diam );
cx = 0; cy = deltaxy / 2; cx = 0; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, trace_orient ); RotatePoint( &cx, &cy, aOrient );
PlotArc( PLOT_FORMAT_HPGL, wxPoint( cx + pos.x, cy + pos.y ), PlotArc( PLOT_FORMAT_HPGL, wxPoint( cx + pos.x, cy + pos.y ),
trace_orient + 1800, trace_orient, -aOrient - 1800, -aOrient,
size.x / 2, pen_diam ); size.x / 2, pen_diam );
} }
...@@ -648,7 +656,7 @@ void trace_1_pad_TRAPEZE_HPGL( wxPoint padpos, wxSize size, wxSize delta, ...@@ -648,7 +656,7 @@ void trace_1_pad_TRAPEZE_HPGL( wxPoint padpos, wxSize size, wxSize delta,
wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */ wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */
float fangle; /* angle d'inclinaison des cotes du trapeze */ float fangle; /* angle d'inclinaison des cotes du trapeze */
int rayon; /* rayon de la plume */ int rayon; /* rayon de la plume */
int moveX, moveY;/* variation de position plume selon axe X et Y , lors int moveX, moveY; /* variation de position plume selon axe X et Y , lors
* du remplissage du trapeze */ * du remplissage du trapeze */
rayon = (int) pen_rayon; if( modetrace == FILAIRE ) rayon = (int) pen_rayon; if( modetrace == FILAIRE )
...@@ -761,119 +769,3 @@ void trace_1_pad_TRAPEZE_HPGL( wxPoint padpos, wxSize size, wxSize delta, ...@@ -761,119 +769,3 @@ void trace_1_pad_TRAPEZE_HPGL( wxPoint padpos, wxSize size, wxSize delta,
Plume_HPGL( 'U' ); Plume_HPGL( 'U' );
} }
/********************************************************************/
void trace_1_segment_HPGL( int pos_X0, int pos_Y0, int pos_X1, int pos_Y1,
int epaisseur )
/********************************************************************/
/* Trace 1 rectangle donne par son axe et son epaisseur (piste rectangulaire)
* en mode SKETCH
*/
{
float alpha; /* angle de l'axe du rectangle */
wxSize size; /* coord relatives a l'origine du segment de sa fin */
int dh; /* demi epaisseur du segment compte tenu de la
* largeur de la plume */
int dx_rot; /* coord du segment en repere modifie ( size.y_rot etant nul )*/
float sin_alpha, cos_alpha;
size.x = pos_X1 - pos_X0; size.y = pos_Y1 - pos_Y0;
dh = (epaisseur - (int) pen_diam ) / 2;
if( dh < 0 )
{
dh = 0; s_Nb_Plot_Errors++;
}
if( (dh == 0) || (g_Plot_Mode == FILAIRE) ) /* Le trace se reduit a 1 trait */
{
Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 ), 'U' );
Move_Plume_HPGL( wxPoint( pos_X1, pos_Y1 ), 'D' );
Plume_HPGL( 'U' );
return;
}
if( size.x < 0 )
{
EXCHG( pos_X0, pos_X1 ); EXCHG( pos_Y0, pos_Y1 );
size.y = -size.y; size.x = -size.x;
}
if( size.y == 0 ) /* segment horizontal */
{
Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 - dh ), 'U' );
Move_Plume_HPGL( wxPoint( pos_X1, pos_Y1 - dh ), 'D' );
Move_Plume_HPGL( wxPoint( pos_X1, pos_Y1 + dh ), 'D' );
Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 + dh ), 'D' );
Move_Plume_HPGL( wxPoint( pos_X0, pos_Y0 - dh ), 'D' );
}
else if( size.x == 0 ) /* vertical */
{
if( size.y < 0 )
dh = -dh;
Move_Plume_HPGL( wxPoint( pos_X0 - dh, pos_Y0 ), 'U' );
Move_Plume_HPGL( wxPoint( pos_X1 - dh, pos_Y1 ), 'D' );
Move_Plume_HPGL( wxPoint( pos_X1 + dh, pos_Y1 ), 'D' );
Move_Plume_HPGL( wxPoint( pos_X0 + dh, pos_Y0 ), 'D' );
Move_Plume_HPGL( wxPoint( pos_X0 - dh, pos_Y0 ), 'D' );
}
else /* piste inclinee */
{
/* On calcule les coord des extremites du rectangle dans le repere
* a axe x confondu avec l'axe du rect. puis on revient dans le repere
* de trace par 2 rotations inverses
* coord : xrot = x*cos + y*sin
* yrot = y*cos - x*sin
*
* avec ici yrot = 0 puisque le segment est horizontal dans le nouveau repere
* Transformee inverse :
* coord : x = xrot*cos - yrot*sin
* y = yrot*cos + xrot*sin
*/
int dx0, dy0, dx1, dy1;
if( size.x == size.y ) /* alpah = 45 degre */
{
sin_alpha = cos_alpha = 0.70711;
}
else if( size.x == -size.y ) /* alpah = -45 degre */
{
cos_alpha = 0.70711; sin_alpha = -0.70711;
}
else
{
alpha = atan2( (double) size.y, (double) size.x );
sin_alpha = sin( alpha );
cos_alpha = cos( alpha );
}
dx_rot = (int) (size.x * cos_alpha + size.y * sin_alpha);
/* size.y_rot = (int)(size.y * cos_alpha - size.x * sin_alpha) ; doit etre NULL */
/* calcul du point de coord 0,-dh */
dx0 = (int) ( dh * sin_alpha);
dy0 = (int) (-dh * cos_alpha );
Move_Plume_HPGL( wxPoint( pos_X0 + dx0, pos_Y0 + dy0 ), 'U' );
/* calcul du point de coord size.xrot,-dh */
dx1 = (int) (dx_rot * cos_alpha + dh * sin_alpha);
dy1 = (int) (-dh * cos_alpha + dx_rot * sin_alpha );
Move_Plume_HPGL( wxPoint( pos_X0 + dx1, pos_Y0 + dy1 ), 'D' );
/* calcul du point de coord size.xrot,+dh */
dx1 = (int) (dx_rot * cos_alpha - dh * sin_alpha);
dy1 = (int) (dh * cos_alpha + dx_rot * sin_alpha );
Move_Plume_HPGL( wxPoint( pos_X0 + dx1, pos_Y0 + dy1 ), 'D' );
/* calcul du point de coord 0,+dh */
dx1 = (int) ( -dh * sin_alpha);
dy1 = (int) (dh * cos_alpha );
Move_Plume_HPGL( wxPoint( pos_X0 + dx1, pos_Y0 + dy1 ), 'D' );
/* retour au point de depart */
Move_Plume_HPGL( wxPoint( pos_X0 + dx0, pos_Y0 + dy0 ), 'D' );
}
Plume_HPGL( 'U' );
}
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