Commit 86885a7a authored by dickelbeck's avatar dickelbeck

dodge seg fault, caused by a bad layer number

parent af80a3cb
/*********************************************************/ /*********************************************************/
/* Routines de trace: fonction communes aux diff formats */ /* Routines de trace: fonction communes aux diff formats */
/*********************************************************/ /*********************************************************/
/* Fichier PLOT_RTN.CPP*/ /* Fichier PLOT_RTN.CPP*/
...@@ -19,26 +19,25 @@ ...@@ -19,26 +19,25 @@
/* Fonctions locales */ /* Fonctions locales */
static void Plot_Edges_Modules(BOARD * pcb, int format_plot, int masque_layer); static void Plot_Edges_Modules( BOARD* pcb, int format_plot, int masque_layer );
static void PlotTextModule(TEXTE_MODULE * pt_texte); static void PlotTextModule( TEXTE_MODULE* pt_texte );
/**********************************************************/ /**********************************************************/
void WinEDA_BasePcbFrame::Plot_Serigraphie(int format_plot, void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
FILE * File, int masque_layer) FILE* File, int masque_layer )
/***********************************************************/ /***********************************************************/
/* Genere le trace des couches type serigraphie, en format HPGL ou GERBER*/ /* Genere le trace des couches type serigraphie, en format HPGL ou GERBER*/
{ {
wxPoint pos, shape_pos; wxPoint pos, shape_pos;
wxSize size; wxSize size;
bool trace_val, trace_ref; bool trace_val, trace_ref;
MODULE* Module; MODULE* Module;
D_PAD * pt_pad; D_PAD* pt_pad;
TEXTE_MODULE * pt_texte; TEXTE_MODULE* pt_texte;
EDA_BaseStruct * PtStruct; EDA_BaseStruct* PtStruct;
wxString msg; wxString msg;
/* Trace du contour du PCB et des Elements du type Drawings Pcb */ /* Trace du contour du PCB et des Elements du type Drawings Pcb */
PtStruct = m_Pcb->m_Drawings; PtStruct = m_Pcb->m_Drawings;
...@@ -48,22 +47,26 @@ wxString msg; ...@@ -48,22 +47,26 @@ wxString msg;
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format_plot, masque_layer ); PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format_plot, masque_layer );
// (Following line has been superceded by new commands elsewhere.) // (Following line has been superceded by new commands elsewhere.)
// EDGE_LAYER | masque_layer ); // EDGE_LAYER | masque_layer );
break; break;
case TYPETEXTE: case TYPETEXTE:
PlotTextePcb( (TEXTE_PCB*) PtStruct,format_plot, masque_layer ); PlotTextePcb( (TEXTE_PCB*) PtStruct, format_plot, masque_layer );
// EDGE_LAYER | masque_layer ); // EDGE_LAYER | masque_layer );
break; break;
case TYPECOTATION: case TYPECOTATION:
PlotCotation( (COTATION*) PtStruct, format_plot, masque_layer ); PlotCotation( (COTATION*) PtStruct, format_plot, masque_layer );
// EDGE_LAYER | masque_layer ); // EDGE_LAYER | masque_layer );
break; break;
case TYPEMIRE: case TYPEMIRE:
PlotMirePcb( (MIREPCB*) PtStruct, format_plot, masque_layer ); PlotMirePcb( (MIREPCB*) PtStruct, format_plot, masque_layer );
// EDGE_LAYER | masque_layer ); // EDGE_LAYER | masque_layer );
break; break;
...@@ -71,191 +74,215 @@ wxString msg; ...@@ -71,191 +74,215 @@ wxString msg;
break; break;
default: default:
DisplayError(this, wxT("Plot_Serigraphie() error: unexpected Type()")); DisplayError( this, wxT( "Plot_Serigraphie() error: unexpected Type()" ) );
break; break;
} }
} }
/* trace des contours des MODULES : */ /* trace des contours des MODULES : */
Plot_Edges_Modules(m_Pcb, format_plot, masque_layer); Plot_Edges_Modules( m_Pcb, format_plot, masque_layer );
/* Trace des MODULES : PADS */ /* Trace des MODULES : PADS */
if(PlotPadsOnSilkLayer || Plot_Pads_All_Layers) if( PlotPadsOnSilkLayer || Plot_Pads_All_Layers )
{ {
nb_items = 0 ; nb_items = 0;
Affiche_1_Parametre(this, 56, wxT("Pads"),wxEmptyString,GREEN) ; Affiche_1_Parametre( this, 56, wxT( "Pads" ), wxEmptyString, GREEN );
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL ; Module = (MODULE *) Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
pt_pad = (D_PAD *) Module->m_Pads; pt_pad = (D_PAD*) Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD *) pt_pad->Pnext) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
/* Tst si layer OK */ /* Tst si layer OK */
if( (pt_pad->m_Masque_Layer & masque_layer) == 0) if( (pt_pad->m_Masque_Layer & masque_layer) == 0 )
{ {
if( ! Plot_Pads_All_Layers ) continue; if( !Plot_Pads_All_Layers )
continue;
} }
shape_pos = pt_pad->ReturnShapePos(); shape_pos = pt_pad->ReturnShapePos();
pos = shape_pos; size = pt_pad->m_Size; pos = shape_pos; size = pt_pad->m_Size;
switch( pt_pad->m_PadShape & 0x7F ) switch( pt_pad->m_PadShape & 0x7F )
{ {
case CIRCLE : case CIRCLE:
switch ( format_plot )
switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
PlotCircle(PLOT_FORMAT_GERBER, PlotCircle( PLOT_FORMAT_GERBER,
g_PlotLine_Width ,pos, size.x / 2); g_PlotLine_Width, pos, size.x / 2 );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_pastille_RONDE_HPGL(pos, size.x ,FILAIRE); trace_1_pastille_RONDE_HPGL( pos, size.x, FILAIRE );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
trace_1_pastille_RONDE_POST(pos, size.x ,FILAIRE); trace_1_pastille_RONDE_POST( pos, size.x, FILAIRE );
break; break;
} }
break ;
case OVALE : break;
switch ( format_plot )
case OVALE:
switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
trace_1_contour_GERBER(pos, size, wxSize(0,0), trace_1_contour_GERBER( pos, size, wxSize( 0, 0 ),
g_PlotLine_Width, g_PlotLine_Width,
pt_pad->m_Orient); pt_pad->m_Orient );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_pastille_OVALE_HPGL(pos,size, trace_1_pastille_OVALE_HPGL( pos, size,
pt_pad->m_Orient,FILAIRE) ; pt_pad->m_Orient, FILAIRE );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
trace_1_pastille_OVALE_POST(pos,size, trace_1_pastille_OVALE_POST( pos, size,
pt_pad->m_Orient,FILAIRE) ; pt_pad->m_Orient, FILAIRE );
break; break;
} }
break ;
case TRAPEZE : break;
case TRAPEZE:
{ {
wxSize delta; wxSize delta;
delta = pt_pad->m_DeltaSize; delta = pt_pad->m_DeltaSize;
switch ( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
trace_1_contour_GERBER(pos, size, delta, trace_1_contour_GERBER( pos, size, delta,
g_PlotLine_Width, g_PlotLine_Width,
(int)pt_pad->m_Orient); (int) pt_pad->m_Orient );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_pad_TRAPEZE_HPGL(pos,size, trace_1_pad_TRAPEZE_HPGL( pos, size,
delta, (int)pt_pad->m_Orient, delta, (int) pt_pad->m_Orient,
FILAIRE) ; FILAIRE );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
trace_1_pad_TRAPEZE_POST(pos,size, trace_1_pad_TRAPEZE_POST( pos, size,
delta, (int)pt_pad->m_Orient, delta, (int) pt_pad->m_Orient,
FILAIRE) ; FILAIRE );
break; break;
} }
break ;
break;
} }
case RECT : case RECT:
default: default:
switch ( format_plot )
switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
trace_1_contour_GERBER(pos, size, wxSize(0,0), trace_1_contour_GERBER( pos, size, wxSize( 0, 0 ),
g_PlotLine_Width, g_PlotLine_Width,
(int)pt_pad->m_Orient); (int) pt_pad->m_Orient );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
PlotRectangularPad_HPGL(pos,size, pt_pad->m_Orient,FILAIRE) ; PlotRectangularPad_HPGL( pos, size, pt_pad->m_Orient, FILAIRE );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
trace_1_pad_rectangulaire_POST(pos,size, trace_1_pad_rectangulaire_POST( pos, size,
(int)pt_pad->m_Orient,FILAIRE) ; (int) pt_pad->m_Orient, FILAIRE );
break; break;
} }
break ;
break;
} }
nb_items++; msg.Printf( wxT("%d"),nb_items) ;
Affiche_1_Parametre(this, 56,wxEmptyString,msg,GREEN) ; nb_items++; msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre( this, 56, wxEmptyString, msg, GREEN );
} }
} }
} /* Fin Sequence de trace des Pads */ } /* Fin Sequence de trace des Pads */
/* Trace Textes MODULES */ /* Trace Textes MODULES */
nb_items = 0; Affiche_1_Parametre(this, 64, wxT("TxtMod"),wxEmptyString,LIGHTBLUE) ; nb_items = 0; Affiche_1_Parametre( this, 64, wxT( "TxtMod" ), wxEmptyString, LIGHTBLUE );
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL ; Module = (MODULE *) Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
/* Analyse des autorisations de trace pour les textes VALEUR et REF */ /* Analyse des autorisations de trace pour les textes VALEUR et REF */
trace_val = Sel_Texte_Valeur; trace_val = Sel_Texte_Valeur;
trace_ref = Sel_Texte_Reference; // les 2 autorisations de tracer sont donnees trace_ref = Sel_Texte_Reference; // les 2 autorisations de tracer sont donnees
if( (g_TabOneLayerMask[Module->m_Reference->GetLayer()] & masque_layer) == 0) TEXTE_MODULE* text = Module->m_Reference;
int textLayer = text->GetLayer();
wxASSERT( (unsigned) textLayer < 32 );
if( ( (1 << textLayer) & masque_layer ) == 0 )
trace_ref = FALSE; trace_ref = FALSE;
if(Module->m_Reference->m_NoShow && !Sel_Texte_Invisible)
if( text->m_NoShow && !Sel_Texte_Invisible )
trace_ref = FALSE; trace_ref = FALSE;
if( (g_TabOneLayerMask[Module->m_Value->GetLayer()] & masque_layer) == 0) text = Module->m_Value;
textLayer = text->GetLayer();
wxASSERT( (unsigned) textLayer < 32 );
if( ( (1 << textLayer) & masque_layer ) == 0 )
trace_val = FALSE; trace_val = FALSE;
if(Module->m_Value->m_NoShow && !Sel_Texte_Invisible)
if( text->m_NoShow && !Sel_Texte_Invisible )
trace_val = FALSE; trace_val = FALSE;
/* Trace effectif des textes */ /* Trace effectif des textes */
if( trace_ref ) if( trace_ref )
{ {
PlotTextModule(Module->m_Reference); PlotTextModule( Module->m_Reference );
nb_items++ ; nb_items++;
msg.Printf( wxT("%d"),nb_items) ; msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre(this, 64,wxEmptyString,msg,LIGHTBLUE) ; Affiche_1_Parametre( this, 64, wxEmptyString, msg, LIGHTBLUE );
} }
if( trace_val ) if( trace_val )
{ {
PlotTextModule(Module->m_Value); PlotTextModule( Module->m_Value );
nb_items++ ; nb_items++;
msg.Printf( wxT("%d"),nb_items) ; msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre(this, 64,wxEmptyString,msg,LIGHTBLUE) ; Affiche_1_Parametre( this, 64, wxEmptyString, msg, LIGHTBLUE );
} }
pt_texte = (TEXTE_MODULE *) Module->m_Drawings; pt_texte = (TEXTE_MODULE*) Module->m_Drawings;
for( ;pt_texte != NULL ; pt_texte = (TEXTE_MODULE*)pt_texte->Pnext) for( ; pt_texte != NULL; pt_texte = (TEXTE_MODULE*) pt_texte->Pnext )
{ {
if(pt_texte->Type() != TYPETEXTEMODULE ) continue; if( pt_texte->Type() != TYPETEXTEMODULE )
continue;
if( !Sel_Texte_Divers ) continue; if( !Sel_Texte_Divers )
continue;
if( (pt_texte->m_NoShow) && !Sel_Texte_Invisible ) if( (pt_texte->m_NoShow) && !Sel_Texte_Invisible )
continue; continue;
if( (g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer) == 0) if( (g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer) == 0 )
continue; continue;
PlotTextModule(pt_texte); PlotTextModule( pt_texte );
nb_items++ ; nb_items++;
msg.Printf( wxT("%d"),nb_items) ; msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre(this, 64,wxEmptyString,msg,LIGHTBLUE) ; Affiche_1_Parametre( this, 64, wxEmptyString, msg, LIGHTBLUE );
} }
} }
} }
/**************************************************/ /**************************************************/
static void PlotTextModule(TEXTE_MODULE * pt_texte) static void PlotTextModule( TEXTE_MODULE* pt_texte )
/**************************************************/ /**************************************************/
{ {
wxSize size; wxSize size;
wxPoint pos; wxPoint pos;
int orient, epaisseur, no_miroir; int orient, epaisseur, no_miroir;
/* calcul des parametres du texte :*/ /* calcul des parametres du texte :*/
size = pt_texte->m_Size; size = pt_texte->m_Size;
...@@ -265,76 +292,79 @@ int orient, epaisseur, no_miroir; ...@@ -265,76 +292,79 @@ int orient, epaisseur, no_miroir;
no_miroir = pt_texte->m_Miroir & 1; no_miroir = pt_texte->m_Miroir & 1;
epaisseur = pt_texte->m_Width; epaisseur = pt_texte->m_Width;
if ( Plot_Mode == FILAIRE ) epaisseur = g_PlotLine_Width; if( Plot_Mode == FILAIRE )
epaisseur = g_PlotLine_Width;
if ( no_miroir == 0 ) size.y = -size.y; // Text is mirrored if( no_miroir == 0 )
size.y = -size.y; // Text is mirrored
Plot_1_texte(format_plot, pt_texte->m_Text, Plot_1_texte( format_plot, pt_texte->m_Text,
orient, epaisseur, orient, epaisseur,
pos.x, pos.y, size.x, size.y); pos.x, pos.y, size.x, size.y );
} }
/*******************************************************************************/ /*******************************************************************************/
void PlotCotation( COTATION * Cotation, int format_plot,int masque_layer) void PlotCotation( COTATION* Cotation, int format_plot, int masque_layer )
/*******************************************************************************/ /*******************************************************************************/
{ {
DRAWSEGMENT *DrawTmp; DRAWSEGMENT* DrawTmp;
if( (g_TabOneLayerMask[Cotation->GetLayer()] & masque_layer) == 0) return; if( (g_TabOneLayerMask[Cotation->GetLayer()] & masque_layer) == 0 )
return;
DrawTmp = new DRAWSEGMENT(NULL); DrawTmp = new DRAWSEGMENT( NULL );
// (Following command has been superceded by new commands elsewhere.) // (Following command has been superceded by new commands elsewhere.)
// masque_layer |= EDGE_LAYER; // masque_layer |= EDGE_LAYER;
DrawTmp->m_Width = Cotation->m_Width; DrawTmp->m_Width = Cotation->m_Width;
DrawTmp->SetLayer( Cotation->GetLayer() ); DrawTmp->SetLayer( Cotation->GetLayer() );
PlotTextePcb( Cotation->m_Text,format_plot, masque_layer); PlotTextePcb( Cotation->m_Text, format_plot, masque_layer );
DrawTmp->m_Start.x = Cotation->Barre_ox; DrawTmp->m_Start.y =Cotation->Barre_oy; DrawTmp->m_Start.x = Cotation->Barre_ox; DrawTmp->m_Start.y = Cotation->Barre_oy;
DrawTmp->m_End.x = Cotation->Barre_fx; DrawTmp->m_End.y =Cotation->Barre_fy; DrawTmp->m_End.x = Cotation->Barre_fx; DrawTmp->m_End.y = Cotation->Barre_fy;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Start.x = Cotation->TraitG_ox; DrawTmp->m_Start.y =Cotation->TraitG_oy; DrawTmp->m_Start.x = Cotation->TraitG_ox; DrawTmp->m_Start.y = Cotation->TraitG_oy;
DrawTmp->m_End.x = Cotation->TraitG_fx; DrawTmp->m_End.y =Cotation->TraitG_fy; DrawTmp->m_End.x = Cotation->TraitG_fx; DrawTmp->m_End.y = Cotation->TraitG_fy;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Start.x = Cotation->TraitD_ox; DrawTmp->m_Start.y =Cotation->TraitD_oy; DrawTmp->m_Start.x = Cotation->TraitD_ox; DrawTmp->m_Start.y = Cotation->TraitD_oy;
DrawTmp->m_End.x = Cotation->TraitD_fx; DrawTmp->m_End.y =Cotation->TraitD_fy; DrawTmp->m_End.x = Cotation->TraitD_fx; DrawTmp->m_End.y = Cotation->TraitD_fy;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Start.x = Cotation->FlecheD1_ox; DrawTmp->m_Start.y =Cotation->FlecheD1_oy; DrawTmp->m_Start.x = Cotation->FlecheD1_ox; DrawTmp->m_Start.y = Cotation->FlecheD1_oy;
DrawTmp->m_End.x = Cotation->FlecheD1_fx; DrawTmp->m_End.y =Cotation->FlecheD1_fy; DrawTmp->m_End.x = Cotation->FlecheD1_fx; DrawTmp->m_End.y = Cotation->FlecheD1_fy;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Start.x = Cotation->FlecheD2_ox; DrawTmp->m_Start.y = Cotation->FlecheD2_oy; DrawTmp->m_Start.x = Cotation->FlecheD2_ox; DrawTmp->m_Start.y = Cotation->FlecheD2_oy;
DrawTmp->m_End.x = Cotation->FlecheD2_fx; DrawTmp->m_End.y = Cotation->FlecheD2_fy; DrawTmp->m_End.x = Cotation->FlecheD2_fx; DrawTmp->m_End.y = Cotation->FlecheD2_fy;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Start.x = Cotation->FlecheG1_ox; DrawTmp->m_Start.y =Cotation->FlecheG1_oy; DrawTmp->m_Start.x = Cotation->FlecheG1_ox; DrawTmp->m_Start.y = Cotation->FlecheG1_oy;
DrawTmp->m_End.x = Cotation->FlecheG1_fx; DrawTmp->m_End.y =Cotation->FlecheG1_fy; DrawTmp->m_End.x = Cotation->FlecheG1_fx; DrawTmp->m_End.y = Cotation->FlecheG1_fy;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Start.x = Cotation->FlecheG2_ox; DrawTmp->m_Start.y =Cotation->FlecheG2_oy; DrawTmp->m_Start.x = Cotation->FlecheG2_ox; DrawTmp->m_Start.y = Cotation->FlecheG2_oy;
DrawTmp->m_End.x = Cotation->FlecheG2_fx; DrawTmp->m_End.y =Cotation->FlecheG2_fy; DrawTmp->m_End.x = Cotation->FlecheG2_fx; DrawTmp->m_End.y = Cotation->FlecheG2_fy;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
delete DrawTmp; delete DrawTmp;
} }
/*****************************************************************/ /*****************************************************************/
void PlotMirePcb( MIREPCB* Mire, int format_plot,int masque_layer) void PlotMirePcb( MIREPCB* Mire, int format_plot, int masque_layer )
/*****************************************************************/ /*****************************************************************/
{ {
DRAWSEGMENT *DrawTmp; DRAWSEGMENT* DrawTmp;
int dx1,dx2, dy1, dy2, rayon; int dx1, dx2, dy1, dy2, rayon;
if( (g_TabOneLayerMask[Mire->GetLayer()] & masque_layer) == 0) return; if( (g_TabOneLayerMask[Mire->GetLayer()] & masque_layer) == 0 )
return;
DrawTmp = new DRAWSEGMENT(NULL); DrawTmp = new DRAWSEGMENT( NULL );
// (Following command has been superceded by new commands elsewhere.) // (Following command has been superceded by new commands elsewhere.)
// masque_layer |= EDGE_LAYER; // masque_layer |= EDGE_LAYER;
...@@ -345,106 +375,116 @@ int dx1,dx2, dy1, dy2, rayon; ...@@ -345,106 +375,116 @@ int dx1,dx2, dy1, dy2, rayon;
DrawTmp->m_End.x = DrawTmp->m_Start.x + (Mire->m_Size / 4); DrawTmp->m_End.x = DrawTmp->m_Start.x + (Mire->m_Size / 4);
DrawTmp->m_End.y = DrawTmp->m_Start.y; DrawTmp->m_End.y = DrawTmp->m_Start.y;
DrawTmp->m_Shape = S_CIRCLE; DrawTmp->m_Shape = S_CIRCLE;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Shape = S_SEGMENT; DrawTmp->m_Shape = S_SEGMENT;
/* Trace des 2 traits */ /* Trace des 2 traits */
rayon = Mire->m_Size/2; rayon = Mire->m_Size / 2;
dx1 = rayon, dy1 = 0; dx2 = 0, dy2 = rayon; dx1 = rayon, dy1 = 0; dx2 = 0, dy2 = rayon;
if( Mire->m_Shape) /* Forme X */ if( Mire->m_Shape ) /* Forme X */
{ {
dx1 = dy1 = (rayon * 7)/5; dx2 = dx1; dy2 = -dy1; dx1 = dy1 = (rayon * 7) / 5; dx2 = dx1; dy2 = -dy1;
} }
DrawTmp->m_Start.x = Mire->m_Pos.x - dx1; DrawTmp->m_Start.y = Mire->m_Pos.y - dy1; DrawTmp->m_Start.x = Mire->m_Pos.x - dx1; DrawTmp->m_Start.y = Mire->m_Pos.y - dy1;
DrawTmp->m_End.x = Mire->m_Pos.x + dx1; DrawTmp->m_End.y = Mire->m_Pos.y + dy1; DrawTmp->m_End.x = Mire->m_Pos.x + dx1; DrawTmp->m_End.y = Mire->m_Pos.y + dy1;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
DrawTmp->m_Start.x = Mire->m_Pos.x - dx2; DrawTmp->m_Start.y = Mire->m_Pos.y - dy2; DrawTmp->m_Start.x = Mire->m_Pos.x - dx2; DrawTmp->m_Start.y = Mire->m_Pos.y - dy2;
DrawTmp->m_End.x = Mire->m_Pos.x + dx2; DrawTmp->m_End.y = Mire->m_Pos.y + dy2; DrawTmp->m_End.x = Mire->m_Pos.x + dx2; DrawTmp->m_End.y = Mire->m_Pos.y + dy2;
PlotDrawSegment( DrawTmp, format_plot, masque_layer); PlotDrawSegment( DrawTmp, format_plot, masque_layer );
delete DrawTmp; delete DrawTmp;
} }
/**********************************************************************/ /**********************************************************************/
void Plot_Edges_Modules(BOARD * pcb, int format_plot, int masque_layer) 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 */
MODULE * Module; MODULE* Module;
EDGE_MODULE * PtEdge; EDGE_MODULE* PtEdge;
wxString msg; wxString msg;
nb_items = 0 ; nb_items = 0;
Module = pcb->m_Modules; Module = pcb->m_Modules;
for( ; Module != NULL ; Module = (MODULE *) Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
PtEdge = (EDGE_MODULE*) Module->m_Drawings; PtEdge = (EDGE_MODULE*) Module->m_Drawings;
for ( ;PtEdge != NULL; PtEdge = (EDGE_MODULE*)PtEdge->Pnext) for( ; PtEdge != NULL; PtEdge = (EDGE_MODULE*) PtEdge->Pnext )
{ {
if(PtEdge->Type() != TYPEEDGEMODULE) continue; if( PtEdge->Type() != TYPEEDGEMODULE )
if( (g_TabOneLayerMask[PtEdge->GetLayer()] & masque_layer) == 0) continue; continue;
Plot_1_EdgeModule(format_plot, PtEdge); if( (g_TabOneLayerMask[PtEdge->GetLayer()] & masque_layer) == 0 )
continue;
Plot_1_EdgeModule( format_plot, PtEdge );
} }
/* Affichage du nombre de modules traites */ /* Affichage du nombre de modules traites */
nb_items++ ; nb_items++;
msg.Printf( wxT("%d"),nb_items) ; msg.Printf( wxT( "%d" ), nb_items );
} }
} }
/**************************************************************/ /**************************************************************/
void Plot_1_EdgeModule(int format_plot, EDGE_MODULE * PtEdge) 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 epaisseur; /* epaisseur des segments */ int epaisseur; /* epaisseur des segments */
int rayon; /* rayon des cercles a tracer */ int rayon; /* rayon 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() != TYPEEDGEMODULE) return; if( PtEdge->Type() != TYPEEDGEMODULE )
return;
type_trace = PtEdge->m_Shape; type_trace = PtEdge->m_Shape;
epaisseur = PtEdge->m_Width; epaisseur = PtEdge->m_Width;
if ( Plot_Mode == FILAIRE ) epaisseur = g_PlotLine_Width; if( Plot_Mode == FILAIRE )
epaisseur = g_PlotLine_Width;
pos = PtEdge->m_Start; pos = PtEdge->m_Start;
end = PtEdge->m_End; end = PtEdge->m_End;
switch(type_trace ) switch( type_trace )
{ {
case S_SEGMENT: /* segment simple */ case S_SEGMENT:
switch ( format_plot )
/* segment simple */
switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
PlotGERBERLine(pos,end, epaisseur) ; PlotGERBERLine( pos, end, epaisseur );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_segment_HPGL(pos.x,pos.y,end.x,end.y, epaisseur) ; trace_1_segment_HPGL( pos.x, pos.y, end.x, end.y, epaisseur );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
PlotFilledSegmentPS(pos, end, epaisseur) ; PlotFilledSegmentPS( pos, end, epaisseur );
break; break;
} }
break; /* Fin trace segment simple */ break; /* Fin trace segment simple */
case S_CIRCLE: case S_CIRCLE:
rayon = (int)hypot((double)(end.x - pos.x),(double)(end.y - pos.y) ); rayon = (int) hypot( (double) (end.x - pos.x), (double) (end.y - pos.y) );
PlotCircle(format_plot,epaisseur, pos, rayon) ; PlotCircle( format_plot, epaisseur, pos, rayon );
break; break;
case S_ARC: case S_ARC:
rayon = (int)hypot((double)(end.x - pos.x),(double)(end.y - pos.y) ); rayon = (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) EXCHG (StAngle, EndAngle); if( StAngle > EndAngle )
PlotArc(format_plot, pos, StAngle, EndAngle, rayon, epaisseur); EXCHG( StAngle, EndAngle );
PlotArc( format_plot, pos, StAngle, EndAngle, rayon, epaisseur );
break; break;
case S_POLYGON: case S_POLYGON:
...@@ -452,18 +492,18 @@ wxPoint pos, end; /* Coord des segments a tracer */ ...@@ -452,18 +492,18 @@ wxPoint pos, end; /* Coord des segments a tracer */
// 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
int ii, * source, * ptr, * ptr_base; int ii, * source, * ptr, * ptr_base;
MODULE * Module = NULL; MODULE* Module = NULL;
if ( PtEdge->m_Parent && (PtEdge->m_Parent->Type() == TYPEMODULE) ) if( PtEdge->m_Parent && (PtEdge->m_Parent->Type() == TYPEMODULE) )
Module = (MODULE*) PtEdge->m_Parent; Module = (MODULE*) PtEdge->m_Parent;
ptr = ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyCount * sizeof(int) ); ptr = ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyCount * sizeof(int) );
source = PtEdge->m_PolyList; source = PtEdge->m_PolyList;
for (ii = 0; ii < PtEdge->m_PolyCount; ii++ ) for( ii = 0; ii < PtEdge->m_PolyCount; ii++ )
{ {
int x, y; int x, y;
x = *source; source++; y = *source; source++; x = *source; source++; y = *source; source++;
if ( Module ) if( Module )
{ {
RotatePoint (&x, &y, Module->m_Orient); RotatePoint( &x, &y, Module->m_Orient );
x += Module->m_Pos.x; x += Module->m_Pos.x;
y += Module->m_Pos.y; y += Module->m_Pos.y;
} }
...@@ -471,27 +511,28 @@ wxPoint pos, end; /* Coord des segments a tracer */ ...@@ -471,27 +511,28 @@ wxPoint pos, end; /* Coord des segments a tracer */
y += PtEdge->m_Start0.y; y += PtEdge->m_Start0.y;
*ptr = x; ptr++; *ptr = y; ptr++; *ptr = x; ptr++; *ptr = y; ptr++;
} }
PlotPolygon(format_plot, TRUE, PtEdge->m_PolyCount, ptr_base);
free ( ptr_base); PlotPolygon( format_plot, TRUE, PtEdge->m_PolyCount, ptr_base );
free( ptr_base );
break; break;
} }
} }
} }
/****************************************************************************/ /****************************************************************************/
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 */ /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules */
{ {
int no_miroir, orient, epaisseur; int no_miroir, orient, epaisseur;
wxPoint pos; wxPoint pos;
wxSize size; wxSize size;
if( pt_texte->m_Text.IsEmpty() ) return; if( pt_texte->m_Text.IsEmpty() )
if( (g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer) == 0 ) return ; return;
if( (g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer) == 0 )
return;
/* calcul des parametres du texte :*/ /* calcul des parametres du texte :*/
size = pt_texte->m_Size; size = pt_texte->m_Size;
...@@ -500,107 +541,123 @@ wxSize size; ...@@ -500,107 +541,123 @@ wxSize size;
no_miroir = pt_texte->m_Miroir & 1; no_miroir = pt_texte->m_Miroir & 1;
epaisseur = pt_texte->m_Width; epaisseur = pt_texte->m_Width;
if ( no_miroir == FALSE) size.x = - size.x; if( no_miroir == FALSE )
size.x = -size.x;
Plot_1_texte(format_plot, pt_texte->m_Text,orient, Plot_1_texte( format_plot, pt_texte->m_Text, orient,
epaisseur, pos.x, pos.y, size.x, size.y); epaisseur, pos.x, pos.y, size.x, size.y );
} }
/**********************************************************************/ /**********************************************************************/
void Plot_1_texte(int format_plot,const wxString & Text, int angle, void Plot_1_texte( int format_plot, const wxString& Text, int angle,
int epaisseur, int cX,int cY,int size_h,int size_v, int epaisseur, int cX, int cY, int size_h, int size_v,
bool centreX, bool centreY) bool centreX, bool centreY )
/***********************************************************************/ /***********************************************************************/
/* /*
Trace de 1 texte: * Trace de 1 texte:
ptr = pointeur sur le texte * ptr = pointeur sur le texte
angle = angle d'orientation, dependant aussi du mode de trace (miroir..) * angle = angle d'orientation, dependant aussi du mode de trace (miroir..)
cX, cY = position du centre du texte * cX, cY = position du centre du texte
size_h , size_v = dimensions ( algebriques ); * size_h , size_v = dimensions ( algebriques );
*/ */
{ {
int kk = 0, k1 , k2, end ; int kk = 0, k1, k2, end;
int espacement; int espacement;
char f_cod , plume ; char f_cod, plume;
const SH_CODE * ptcar; const SH_CODE* ptcar;
int ox,oy,fx,fy; /* Coord de debut et fin des segments a tracer */ int ox, oy, fx, fy; /* Coord de debut et fin des segments a tracer */
int sx, sy; /* coord du debut du caractere courant */ int sx, sy; /* coord du debut du caractere courant */
int nbcodes = Text.Len(); int nbcodes = Text.Len();
espacement = ((10 * size_h) / 9) + ( (size_h >= 0 ) ? epaisseur : - epaisseur); espacement = ( (10 * size_h) / 9 ) + ( (size_h >= 0 ) ? epaisseur : -epaisseur );
/* calcul de la position du debut du texte */ /* calcul de la position du debut du texte */
if ( centreX ) sx = cX - ((espacement * nbcodes) / 2 ) + (espacement /9); if( centreX )
else sx = cX; sx = cX - ( (espacement * nbcodes) / 2 ) + (espacement / 9);
if ( centreY ) sy = cY + (size_v / 2); else
else sy = cY; sx = cX;
if( centreY )
sy = cY + (size_v / 2);
else
sy = cY;
/* trace du texte */ /* trace du texte */
for( ; kk < nbcodes; kk++) for( ; kk < nbcodes; kk++ )
{ {
int code = Text.GetChar(kk) & 0xFF; int code = Text.GetChar( kk ) & 0xFF;
ptcar = graphic_fonte_shape[code] ; /* ptcar pointe la description ptcar = graphic_fonte_shape[code]; /* ptcar pointe la description
du caractere a dessiner */ * du caractere a dessiner */
plume = 'U'; ox = sx; oy = sy; plume = 'U'; ox = sx; oy = sy;
RotatePoint(&ox, &oy, cX, cY, angle); RotatePoint( &ox, &oy, cX, cY, angle );
fx = ox; fy = oy; fx = ox; fy = oy;
for(end = 0; end == 0; ptcar++) for( end = 0; end == 0; ptcar++ )
{ {
f_cod = * ptcar; /* get code n de la forme selectionnee */ f_cod = *ptcar;
switch(f_cod)
/* get code n de la forme selectionnee */
switch( f_cod )
{ {
case 'X' : end = 1;/* fin du caractere */ case 'X':
end = 1; /* fin du caractere */
break; break;
case 'U' : case 'U':
case 'D' : plume = f_cod ; break ; case 'D':
plume = f_cod; break;
default : default:
k1 = f_cod; // Coord X k1 = f_cod; // Coord X
k1 = (k1 * size_v) / 9; k1 = (k1 * size_v) / 9;
ptcar++ ; ptcar++;
k2 = *ptcar; // Coord Y k2 = *ptcar; // Coord Y
k2 = (k2 * size_h) / 8 ; k2 = (k2 * size_h) / 8;
fx = k2 + sx ; fy = -k1 + sy ; fx = k2 + sx; fy = -k1 + sy;
RotatePoint(&fx, &fy, cX, cY, angle); RotatePoint( &fx, &fy, cX, cY, angle );
/* Trace du segment */ /* Trace du segment */
if ( plume == 'D' ) if( plume == 'D' )
{ {
switch ( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
PlotGERBERLine(wxPoint(ox,oy),wxPoint(fx,fy), epaisseur) ; PlotGERBERLine( wxPoint( ox, oy ), wxPoint( fx, fy ), epaisseur );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_segment_HPGL(ox,oy,fx,fy, epaisseur) ; trace_1_segment_HPGL( ox, oy, fx, fy, epaisseur );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
PlotFilledSegmentPS(wxPoint(ox,oy), wxPoint(fx,fy), epaisseur) ; PlotFilledSegmentPS( wxPoint( ox, oy ), wxPoint( fx, fy ), epaisseur );
break; break;
} }
} }
ox = fx; oy = fy; ox = fx; oy = fy;
} /* fin switch decodade matrice de forme */ }
/* fin switch decodade matrice de forme */
}
} /* end boucle for = end trace de 1 caractere */ /* end boucle for = end trace de 1 caractere */
sx += espacement; sx += espacement;
} /* end trace du texte */ }
/* end trace du texte */
} }
/***********************************/ /***********************************/
void Affiche_erreur( int nb_err) void Affiche_erreur( int nb_err )
/***********************************/ /***********************************/
/* Affiche le nombre d'erreurs commises ( segments traces avec plume trop grosse /* Affiche le nombre d'erreurs commises ( segments traces avec plume trop grosse
ou autres */ * ou autres */
{ {
// sprintf(msg,"%d",nb_err) ; // sprintf(msg,"%d",nb_err) ;
// Affiche_1_Parametre(this, 30,"Err",msg,GREEN) ; // Affiche_1_Parametre(this, 30,"Err",msg,GREEN) ;
...@@ -608,180 +665,203 @@ void Affiche_erreur( int nb_err) ...@@ -608,180 +665,203 @@ void Affiche_erreur( int nb_err)
/******************************************************************************/ /******************************************************************************/
void PlotDrawSegment(DRAWSEGMENT * pt_segm, int Format, int masque_layer ) void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer )
/******************************************************************************/ /******************************************************************************/
/* Trace un element du type DRAWSEGMENT draw appartenant /* Trace un element du type DRAWSEGMENT draw appartenant
aux couches specifiees par masque_layer * aux couches specifiees par masque_layer
*/ */
{ {
wxPoint start, end; wxPoint start, end;
int epaisseur; int epaisseur;
int rayon = 0, StAngle = 0, EndAngle = 0; int rayon = 0, StAngle = 0, EndAngle = 0;
if( (g_TabOneLayerMask[pt_segm->GetLayer()] & masque_layer) == 0) return; if( (g_TabOneLayerMask[pt_segm->GetLayer()] & masque_layer) == 0 )
return;
epaisseur = pt_segm->m_Width; epaisseur = pt_segm->m_Width;
if ( Plot_Mode == FILAIRE) epaisseur = g_PlotLine_Width; if( Plot_Mode == FILAIRE )
epaisseur = g_PlotLine_Width;
start = pt_segm->m_Start; end = pt_segm->m_End; start = pt_segm->m_Start; end = pt_segm->m_End;
if(pt_segm->m_Shape == S_CIRCLE) if( pt_segm->m_Shape == S_CIRCLE )
{ {
rayon = (int)hypot((double)(end.x - start.x),(double)(end.y - start.y) ); rayon = (int) hypot( (double) (end.x - start.x), (double) (end.y - start.y) );
} }
if(pt_segm->m_Shape == S_ARC) if( pt_segm->m_Shape == S_ARC )
{ {
rayon = (int)hypot((double)(end.x - start.x),(double)(end.y - start.y) ); rayon = (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) EXCHG (StAngle, EndAngle); if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle );
} }
switch ( Format ) switch( Format )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
if(pt_segm->m_Shape == S_CIRCLE) if( pt_segm->m_Shape == S_CIRCLE )
PlotCircle(PLOT_FORMAT_GERBER,epaisseur, start , rayon) ; PlotCircle( PLOT_FORMAT_GERBER, epaisseur, start, rayon );
else if(pt_segm->m_Shape == S_ARC) else if( pt_segm->m_Shape == S_ARC )
PlotArc(PLOT_FORMAT_GERBER, start , PlotArc( PLOT_FORMAT_GERBER, start,
StAngle, EndAngle, rayon, epaisseur); StAngle, EndAngle, rayon, epaisseur );
else PlotGERBERLine(start, end, epaisseur) ; else
PlotGERBERLine( start, end, epaisseur );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
if(pt_segm->m_Shape == S_CIRCLE) if( pt_segm->m_Shape == S_CIRCLE )
PlotCircle(PLOT_FORMAT_HPGL,epaisseur, start , rayon) ; PlotCircle( PLOT_FORMAT_HPGL, epaisseur, start, rayon );
else if(pt_segm->m_Shape == S_ARC) else if( pt_segm->m_Shape == S_ARC )
PlotArc(PLOT_FORMAT_HPGL, start , StAngle, EndAngle, rayon, epaisseur); PlotArc( PLOT_FORMAT_HPGL, start, StAngle, EndAngle, rayon, epaisseur );
else trace_1_segment_HPGL(start.x,start.y, end.x,end.y, epaisseur) ; else
trace_1_segment_HPGL( start.x, start.y, end.x, end.y, epaisseur );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
if(pt_segm->m_Shape == S_CIRCLE) if( pt_segm->m_Shape == S_CIRCLE )
PlotCircle(PLOT_FORMAT_POST,epaisseur, start, rayon) ; PlotCircle( PLOT_FORMAT_POST, epaisseur, start, rayon );
else if(pt_segm->m_Shape == S_ARC) else if( pt_segm->m_Shape == S_ARC )
PlotArc(PLOT_FORMAT_POST, start, PlotArc( PLOT_FORMAT_POST, start,
StAngle, EndAngle, rayon, epaisseur); StAngle, EndAngle, rayon, epaisseur );
else PlotFilledSegmentPS(start, end, epaisseur) ; else
PlotFilledSegmentPS( start, end, epaisseur );
break; break;
} }
} }
/*****************************************************************************/ /*****************************************************************************/
void PlotCircle( int format_plot, int epaisseur, wxPoint centre, int rayon) void PlotCircle( int format_plot, int epaisseur, wxPoint centre, int rayon )
/*****************************************************************************/ /*****************************************************************************/
/* routine de trace de 1 cercle de centre cx, cy */ /* routine de trace de 1 cercle de centre cx, cy */
{ {
switch ( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
PlotCircle_GERBER( centre, rayon, epaisseur) ; PlotCircle_GERBER( centre, rayon, epaisseur );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_pastille_RONDE_HPGL( centre, rayon * 2, FILAIRE) ; trace_1_pastille_RONDE_HPGL( centre, rayon * 2, FILAIRE );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
PlotCircle_PS ( centre, rayon * 2, epaisseur); PlotCircle_PS( centre, rayon * 2, epaisseur );
break; break;
} }
} }
/**********************************************************************/ /**********************************************************************/
void PlotPolygon(int format_plot, bool Filled, int nbpoints, int * coord) void PlotPolygon( int format_plot, bool Filled, int nbpoints, int* coord )
/**********************************************************************/ /**********************************************************************/
/* plot a polygon */ /* plot a polygon */
{ {
switch ( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
PlotPolygon_GERBER(nbpoints, coord, Filled) ; PlotPolygon_GERBER( nbpoints, coord, Filled );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
PlotPolyHPGL( nbpoints, coord, Filled); PlotPolyHPGL( nbpoints, coord, Filled );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
PlotPolyPS( nbpoints, coord, Filled); PlotPolyPS( nbpoints, coord, Filled );
break; break;
} }
} }
/************************************************************************/ /************************************************************************/
void PlotArc(int format_plot,wxPoint centre,int start_angle,int end_angle, void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
int rayon,int epaisseur) int rayon, int epaisseur )
/************************************************************************/ /************************************************************************/
/* Polt 1 arc /* Polt 1 arc
start, end = angles in 1/10 degree for start and stop point * start, end = angles in 1/10 degree for start and stop point
*/ */
{ {
int ii; int ii;
int ox, oy, fx, fy; int ox, oy, fx, fy;
int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */ int delta;/* increment (en 0.1 degres) angulaire pour trace de cercles */
if ( Plot_Mode == FILAIRE) epaisseur = g_PlotLine_Width; if( Plot_Mode == FILAIRE )
epaisseur = g_PlotLine_Width;
if( format_plot == PLOT_FORMAT_POST ) if( format_plot == PLOT_FORMAT_POST )
{ {
PlotArcPS(centre,start_angle,end_angle, rayon, epaisseur); PlotArcPS( centre, start_angle, end_angle, rayon, epaisseur );
return; return;
} }
// change due to Y axis is negative orientation on screen // change due to Y axis is negative orientation on screen
start_angle = -start_angle; start_angle = -start_angle;
end_angle = - end_angle; end_angle = -end_angle;
EXCHG (start_angle, end_angle); EXCHG( start_angle, end_angle );
/* Correction pour petits cercles par rapport a l'epaisseur du trait */ /* Correction pour petits cercles par rapport a l'epaisseur du trait */
if( rayon < (epaisseur * 10) ) delta = 225; /* 16 segm pour 360 deg */ if( rayon < (epaisseur * 10) )
if( rayon < (epaisseur * 5) ) delta = 300; /* 12 segm pour 360 deg */ delta = 225; /* 16 segm pour 360 deg */
if( rayon < (epaisseur * 5) )
delta = 300; /* 12 segm pour 360 deg */
if ( start_angle > end_angle ) end_angle += 3600; if( start_angle > end_angle )
end_angle += 3600;
ox = rayon; oy = 0; ox = rayon; oy = 0;
RotatePoint(&ox, &oy, start_angle ); RotatePoint( &ox, &oy, start_angle );
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 )
{ {
fx = rayon; fy = 0; fx = rayon; fy = 0;
RotatePoint(&fx, &fy, ii); RotatePoint( &fx, &fy, ii );
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), epaisseur) ; wxPoint( centre.x + fx, centre.y + fy ), epaisseur );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_segment_HPGL(centre.x+ox,centre.y+oy,centre.x+fx,centre.y+fy, epaisseur) ; trace_1_segment_HPGL( centre.x + ox,
centre.y + oy,
centre.x + fx,
centre.y + fy,
epaisseur );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
break; break;
} }
ox = fx; oy = fy ;
ox = fx; oy = fy;
} }
fx = rayon; fy = 0; fx = rayon; fy = 0;
RotatePoint(&fx, &fy, end_angle); RotatePoint( &fx, &fy, 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), epaisseur) ; wxPoint( centre.x + fx, centre.y + fy ), epaisseur );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_segment_HPGL(centre.x+ox,centre.y+oy,centre.x+fx,centre.y+fy, epaisseur) ; trace_1_segment_HPGL( centre.x + ox,
centre.y + oy,
centre.x + fx,
centre.y + fy,
epaisseur );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
break; break;
} }
} }
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