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
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
/* Shared Config keys for plot and print */ /* Shared Config keys for plot and print */
#define OPTKEY_PLOT_LINEWIDTH_VALUE wxT( "PlotLineWidth" ) #define OPTKEY_PLOT_LINEWIDTH_VALUE wxT( "PlotLineWidth" )
#define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" ) #define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" )
#define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" ) #define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" )
#define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" ) #define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" ) #define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
/* Constantes de conversion d'unites */ /* Constantes de conversion d'unites */
/* coeff de conversion dim en 0.1 mil -> dim en unite PS: (unite PS = pouce) */ /* coeff de conversion dim en 0.1 mil -> dim en unite PS: (unite PS = pouce) */
...@@ -24,23 +24,23 @@ ...@@ -24,23 +24,23 @@
#define SCALE_HPGL 0.102041 #define SCALE_HPGL 0.102041
/* Options : */ /* Options : */
eda_global bool g_Exclude_Edges_Pcb // True to exclude contents of Edges Pcb layer eda_global bool g_Exclude_Edges_Pcb // True to exclude contents of Edges Pcb layer
#ifdef MAIN #ifdef MAIN
= FALSE = FALSE
#endif #endif
; ;
eda_global bool g_Plot_Frame_Ref; // True to plot/print frame references eda_global bool g_Plot_Frame_Ref; // True to plot/print frame references
eda_global bool g_DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask) eda_global bool g_DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask)
eda_global int g_Plot_Mode // = FILAIRE, FILL or SKETCH eda_global int g_Plot_Mode // = FILAIRE, FILL or SKETCH
#ifdef MAIN #ifdef MAIN
= 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
eda_global bool g_Plot_PS_Negative; // True to create a negative board ps plot eda_global bool g_Plot_PS_Negative; // True to create a negative board ps plot
/* Autorisation de trace des divers items en serigraphie */ /* Autorisation de trace des divers items en serigraphie */
...@@ -60,50 +60,50 @@ eda_global bool Sel_Texte_Divers ...@@ -60,50 +60,50 @@ eda_global bool Sel_Texte_Divers
#endif #endif
; ;
eda_global bool Sel_Texte_Invisible; eda_global bool Sel_Texte_Invisible;
eda_global bool PlotPadsOnSilkLayer /* Plot pads sur couche serigraphie */ eda_global bool PlotPadsOnSilkLayer /* Plot pads sur couche serigraphie */
#ifdef MAIN #ifdef MAIN
= TRUE = TRUE
#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 */
#ifdef MAIN #ifdef MAIN
= 1 = 1
#endif #endif
; ;
eda_global int g_HPGL_Pen_Speed /* vitesse en cm/s */ eda_global int g_HPGL_Pen_Speed /* vitesse en cm/s */
#ifdef MAIN #ifdef MAIN
= 40 = 40
#endif #endif
; ;
eda_global int g_HPGL_Pen_Diam; /* diametre en mils */ 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
= PLOT_FORMAT_GERBER = PLOT_FORMAT_GERBER
#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
= 1 = 1
#endif #endif
...@@ -111,73 +111,81 @@ eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee ...@@ -111,73 +111,81 @@ 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
#define GERB_RECT 2 #define GERB_RECT 2
#define GERB_LINE 3 #define GERB_LINE 3
#define GERB_OVALE 4 #define GERB_OVALE 4
#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,8 +204,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -200,8 +204,8 @@ 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,8 +224,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -220,8 +224,8 @@ 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."), _(
textLayer, Module->GetReference().GetData(), pt_texte->m_Text.GetData() ); "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() );
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:
...@@ -306,27 +311,27 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot ) ...@@ -306,27 +311,27 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot )
thickness = g_PlotLine_Width; thickness = g_PlotLine_Width;
if( pt_texte->m_Mirror ) if( pt_texte->m_Mirror )
size.x = -size.x; // Text is mirrored size.x = -size.x; // Text is mirrored
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:
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
SetCurrentLineWidthPS( thickness ); SetCurrentLineWidthPS( thickness );
break; break;
} }
PlotGraphicText( format_plot, pos, BLACK, PlotGraphicText( format_plot, pos, BLACK,
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic ); thickness, pt_texte->m_Italic );
} }
...@@ -402,7 +407,7 @@ void PlotMirePcb( MIREPCB* Mire, int format_plot, int masque_layer ) ...@@ -402,7 +407,7 @@ void PlotMirePcb( MIREPCB* Mire, int format_plot, int masque_layer )
DrawTmp->m_Shape = S_SEGMENT; DrawTmp->m_Shape = S_SEGMENT;
/* Trace des 2 traits */ /* Trace des 2 traits */
radius = Mire->m_Size / 2; radius = Mire->m_Size / 2;
dx1 = radius, dy1 = 0; dx2 = 0, dy2 = radius; dx1 = radius, dy1 = 0; dx2 = 0, dy2 = radius;
if( Mire->m_Shape ) /* Forme X */ if( Mire->m_Shape ) /* Forme X */
{ {
...@@ -428,8 +433,8 @@ void Plot_Edges_Modules( BOARD* pcb, int format_plot, int masque_layer ) ...@@ -428,8 +433,8 @@ void Plot_Edges_Modules( BOARD* pcb, int format_plot, int masque_layer )
/**********************************************************************/ /**********************************************************************/
/* Trace les contours des modules */ /* Trace les contours des modules */
{ {
int nb_items; /* Pour affichage activite: nbr modules traites */ int nb_items; /* Pour affichage activite: nbr modules traites */
wxString msg; wxString msg;
nb_items = 0; nb_items = 0;
for( MODULE* module = pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
...@@ -458,11 +463,11 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -458,11 +463,11 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
/**************************************************************/ /**************************************************************/
/* Trace les contours des modules */ /* Trace les contours des modules */
{ {
int type_trace; /* forme a tracer (segment, cercle) */ int type_trace; /* forme a tracer (segment, cercle) */
int thickness; /* thickness des segments */ int thickness; /* thickness des segments */
int radius; /* radius des cercles a tracer */ int radius; /* radius des cercles a tracer */
int StAngle, EndAngle; int StAngle, EndAngle;
wxPoint pos, end; /* Coord des segments a tracer */ wxPoint pos, end; /* Coord des segments a tracer */
if( PtEdge->Type() != TYPE_EDGE_MODULE ) if( PtEdge->Type() != TYPE_EDGE_MODULE )
return; return;
...@@ -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:
...@@ -508,7 +513,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -508,7 +513,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
break; break;
case S_ARC: case S_ARC:
radius = (int) hypot( (double) (end.x - pos.x), (double) (end.y - pos.y) ); radius = (int) hypot( (double) (end.x - pos.x), (double) (end.y - pos.y) );
StAngle = ArcTangente( end.y - pos.y, end.x - pos.x ); StAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
EndAngle = StAngle + PtEdge->m_Angle; EndAngle = StAngle + PtEdge->m_Angle;
if( StAngle > EndAngle ) if( StAngle > EndAngle )
...@@ -517,40 +522,40 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -517,40 +522,40 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
break; break;
case S_POLYGON: case S_POLYGON:
{ {
// We must compute true coordinates from m_PolyList // We must compute true coordinates from m_PolyList
// which are relative to module position, orientation 0 // which are relative to module position, orientation 0
MODULE* Module = NULL; MODULE* Module = NULL;
if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) ) if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) )
Module = (MODULE*) PtEdge->GetParent(); Module = (MODULE*) PtEdge->GetParent();
int* ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyPoints.size() * sizeof(int) );
int* ptr = ptr_base;
int* source = (int*) &PtEdge->m_PolyPoints[0];
for( unsigned ii = 0; ii < PtEdge->m_PolyPoints.size(); ii++ ) int* ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyPoints.size() * sizeof(int) );
{ int* ptr = ptr_base;
int x = *source++;
int y = *source++;
if( Module ) int* source = (int*) &PtEdge->m_PolyPoints[0];
{
RotatePoint( &x, &y, Module->m_Orient );
x += Module->m_Pos.x;
y += Module->m_Pos.y;
}
x += PtEdge->m_Start0.x; for( unsigned ii = 0; ii < PtEdge->m_PolyPoints.size(); ii++ )
y += PtEdge->m_Start0.y; {
int x = *source++;
int y = *source++;
*ptr++ = x; if( Module )
*ptr++ = y; {
RotatePoint( &x, &y, Module->m_Orient );
x += Module->m_Pos.x;
y += Module->m_Pos.y;
} }
PlotFilledPolygon( format_plot, PtEdge->m_PolyPoints.size(), ptr_base ); x += PtEdge->m_Start0.x;
free( ptr_base ); y += PtEdge->m_Start0.y;
*ptr++ = x;
*ptr++ = y;
} }
PlotFilledPolygon( format_plot, PtEdge->m_PolyPoints.size(), ptr_base );
free( ptr_base );
}
break; break;
} }
} }
...@@ -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:
...@@ -594,27 +599,30 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer ) ...@@ -594,27 +599,30 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer )
} }
PlotGraphicText( format_plot, pos, BLACK, PlotGraphicText( format_plot, pos, BLACK,
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic ); thickness, pt_texte->m_Italic );
} }
/*********************************************************/ /*********************************************************/
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;
unsigned imax = aZone->m_FilledPolysList.size(); unsigned imax = aZone->m_FilledPolysList.size();
if( imax == 0 ) // Nothing to draw if( imax == 0 ) // Nothing to draw
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 )
/******************************************************************************/ /******************************************************************************/
...@@ -676,7 +697,7 @@ void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer ) ...@@ -676,7 +697,7 @@ void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer )
if( pt_segm->m_Shape == S_ARC ) if( pt_segm->m_Shape == S_ARC )
{ {
radius = (int) hypot( (double) (end.x - start.x), (double) (end.y - start.y) ); radius = (int) hypot( (double) (end.x - start.x), (double) (end.y - start.y) );
StAngle = ArcTangente( end.y - start.y, end.x - start.x ); StAngle = ArcTangente( end.y - start.y, end.x - start.x );
EndAngle = StAngle + pt_segm->m_Angle; EndAngle = StAngle + pt_segm->m_Angle;
if( StAngle > EndAngle ) if( StAngle > EndAngle )
...@@ -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:
...@@ -814,9 +859,9 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -814,9 +859,9 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
/* Correction pour petits cercles par rapport a l'thickness du trait */ /* Correction pour petits cercles par rapport a l'thickness du trait */
if( radius < (thickness * 10) ) if( radius < (thickness * 10) )
delta = 225; /* 16 segm pour 360 deg */ delta = 225; /* 16 segm pour 360 deg */
if( radius < (thickness * 5) ) if( radius < (thickness * 5) )
delta = 300; /* 12 segm pour 360 deg */ delta = 300; /* 12 segm pour 360 deg */
if( start_angle > end_angle ) if( start_angle > end_angle )
end_angle += 3600; end_angle += 3600;
...@@ -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 )
...@@ -840,16 +885,14 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -840,16 +885,14 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
PlotGERBERLine( wxPoint( centre.x + ox, centre.y + oy ), PlotGERBERLine( wxPoint( centre.x + ox, centre.y + oy ),
wxPoint( centre.x + fx, centre.y + fy ), thickness ); wxPoint( centre.x + fx, centre.y + fy ), thickness );
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 );
...@@ -101,7 +101,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) ...@@ -101,7 +101,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer )
BoardCenter.y = (int) (BoardCenter.y * scale_y); BoardCenter.y = (int) (BoardCenter.y * scale_y);
if( g_PlotScaleOpt != 1 ) if( g_PlotScaleOpt != 1 )
Center = TRUE; // Echelle != 1 Center = TRUE; // Echelle != 1
/* Calcul du cadrage */ /* Calcul du cadrage */
marge = (int) (marge * SCALE_HPGL); marge = (int) (marge * SCALE_HPGL);
...@@ -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) )
Plot_Filled_Segment_HPGL( pts->m_Start, pts->m_End, pts->m_Width, (GRFillMode)g_Plot_Mode );
}
/* trace des segments pistes et zones */
for( pts = m_Pcb->m_Zone; pts != NULL; pts = pts->Next() )
{
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++ )
{
ZONE_CONTAINER* zone = m_Pcb->GetArea( ii );
if( ( ( 1 << zone->GetLayer() ) & masque_layer ) == 0 )
continue; continue;
PlotFilledAreas( zone, PLOT_FORMAT_HPGL );
}
}
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 ); bool Plot_Filled_Segment_HPGL( wxPoint aStart, wxPoint aEnd, int aWidth, GRFillMode aPlotMode )
/*********************************************************************************************/
/* Trace d'un segment de piste */ /** Function Plot a filled segment (track)
trace_1_segment_HPGL( start.x, start.y, end.x, end.y, size.x ); * @param aStart = starting point
/* Complement de Trace en mode Remplissage */ * @param aEnd = ending point
if( (g_Plot_Mode == FILLED) && (pen_diam <= size.x ) ) * @param aWidth = segment width (thickness)
{ * @param aPlotMode = FILLED, SKETCH ..
while( ( size.x -= (int) ( (pen_rayon - pen_recouvrement) * 2 ) ) > 0 ) * @return true if Ok, false if aWidth > pen size (the segment is always plotted)
{ */
trace_1_segment_HPGL( start.x, start.y, end.x, end.y, {
MAX( size.x, pen_diam ) ); wxPoint center;
} wxSize size;
} int orient;
if( size.x > pen_diam ) if( (pen_diam >= aWidth) || (g_Plot_Mode == FILAIRE) ) /* just a line is Ok */
trace_1_pastille_RONDE_HPGL( end, size.x, modetrace ); {
Move_Plume_HPGL( aStart, 'U' );
Move_Plume_HPGL( aEnd, 'D' );
Plume_HPGL( 'U' );
return pen_diam <= aWidth;;
} }
/* trace des segments pistes et zones */ // A segment is like an oval pal, so use trace_1_pastille_OVALE_HPGL to do the work.
for( pts = m_Pcb->m_Zone; pts != NULL; pts = pts->Next() ) center.x = (aStart.x + aEnd.x) / 2;
{ center.y = (aStart.y + aEnd.y) / 2;
if( g_TabOneLayerMask[pts->GetLayer()] & masque_layer )
{
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 */ size.x = aEnd.x - aStart.x;
trace_1_pastille_RONDE_HPGL( start, size.x, modetrace ); 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 d'un segment de piste */ trace_1_pastille_OVALE_HPGL( center, size, orient, aPlotMode );
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 ) return pen_diam <= aWidth;
trace_1_pastille_RONDE_HPGL( end, size.x, modetrace );
}
}
} }
/************************************************************************************/ /************************************************************************************/
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 );
} }
...@@ -473,7 +481,7 @@ void trace_1_pastille_RONDE_HPGL( wxPoint pos, int diametre, int modetrace ) ...@@ -473,7 +481,7 @@ void trace_1_pastille_RONDE_HPGL( wxPoint pos, int diametre, int modetrace )
/* Trace 1 pastille RONDE (via,pad rond) en position pos */ /* Trace 1 pastille RONDE (via,pad rond) en position pos */
{ {
char cbuf[1024]; char cbuf[1024];
int rayon, delta; int rayon, delta;
UserToDeviceCoordinate( pos ); UserToDeviceCoordinate( pos );
...@@ -648,8 +656,8 @@ void trace_1_pad_TRAPEZE_HPGL( wxPoint padpos, wxSize size, wxSize delta, ...@@ -648,8 +656,8 @@ 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 )
rayon = 0; rayon = 0;
...@@ -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