Commit 57463862 authored by g_harland's avatar g_harland

Added definitions for FIRST_COPPER_LAYER and LAST_COPPER_LAYER

parent 74b4e032
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "pcbstruct.h" #include "pcbstruct.h"
#include "macros.h" #include "macros.h"
//#include "pcbnew.h" // #include "pcbnew.h"
#include "3d_viewer.h" #include "3d_viewer.h"
#include "trackball.h" #include "trackball.h"
...@@ -59,7 +59,8 @@ void Pcb3D_GLCanvas::Redraw( bool finish ) ...@@ -59,7 +59,8 @@ void Pcb3D_GLCanvas::Redraw( bool finish )
glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0); glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0);
glRotatef(g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0); glRotatef(g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0);
if( m_gllist ) glCallList( m_gllist ); if( m_gllist )
glCallList( m_gllist );
else else
{ {
m_gllist = CreateDrawGL_List(); m_gllist = CreateDrawGL_List();
...@@ -67,15 +68,17 @@ void Pcb3D_GLCanvas::Redraw( bool finish ) ...@@ -67,15 +68,17 @@ void Pcb3D_GLCanvas::Redraw( bool finish )
} }
glFlush(); glFlush();
if (finish) glFinish(); if( finish )
glFinish();
SwapBuffers(); SwapBuffers();
} }
/**********************************************/ /**********************************************/
GLuint Pcb3D_GLCanvas::CreateDrawGL_List() GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
/**********************************************/ /**********************************************/
/* Creation de la liste des elements a afficher /* Creation de la liste des elements a afficher
*/ */
{ {
GLuint gllist = glGenLists( 1 ); GLuint gllist = glGenLists( 1 );
WinEDA_BasePcbFrame * pcbframe = m_Parent->m_Parent; WinEDA_BasePcbFrame * pcbframe = m_Parent->m_Parent;
...@@ -93,20 +96,21 @@ int ii; ...@@ -93,20 +96,21 @@ int ii;
g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount; g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount;
g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX(g_Parm_3D_Visu.m_BoardSize.x, g_Parm_3D_Visu.m_BoardSize.y); g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX(g_Parm_3D_Visu.m_BoardSize.x, g_Parm_3D_Visu.m_BoardSize.y);
float epoxy_width = 1.6; // epoxy width in mm float epoxy_width = 1.6; // epoxy width in mm
g_Parm_3D_Visu.m_Epoxy_Width = epoxy_width/2.54 * 1000 g_Parm_3D_Visu.m_Epoxy_Width = epoxy_width / 2.54 * 1000
* g_Parm_3D_Visu.m_BoardScale; * g_Parm_3D_Visu.m_BoardScale;
/* calcul de l'altitude de chaque couche */ /* calcul de l'altitude de chaque couche */
for ( ii = 0; ii < 32; ii++ ) for( ii = 0; ii < 32; ii++ )
{ {
if ( ii < g_Parm_3D_Visu.m_Layers ) if( ii < g_Parm_3D_Visu.m_Layers )
g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width * ii g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width * ii
/ (g_Parm_3D_Visu.m_Layers-1); / (g_Parm_3D_Visu.m_Layers - 1);
else g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width; else
g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width;
} }
GLfloat zpos_cu = 500 * g_Parm_3D_Visu.m_BoardScale; GLfloat zpos_cu = 500 * g_Parm_3D_Visu.m_BoardScale;
GLfloat zpos_cmp = g_Parm_3D_Visu.m_Epoxy_Width + zpos_cu; GLfloat zpos_cmp = g_Parm_3D_Visu.m_Epoxy_Width + zpos_cu;
g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CU] = -zpos_cu*2; g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CU] = -zpos_cu * 2;
g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CMP] = zpos_cmp + zpos_cu; g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CMP] = zpos_cmp + zpos_cu;
g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CU] = -zpos_cu; g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CU] = -zpos_cu;
g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CMP] = zpos_cmp; g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CMP] = zpos_cmp;
...@@ -119,43 +123,49 @@ int ii; ...@@ -119,43 +123,49 @@ int ii;
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
/* draw axes*/ /* draw axes */
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
SetGLColor(WHITE); SetGLColor(WHITE);
glBegin(GL_LINES); glBegin(GL_LINES);
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); // X axis glVertex3f( 0.0, 0.0, 0.0 );
glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(0.0, -1.0, 0.0); // y axis glVertex3f( 1.0, 0.0, 0.0 ); // X axis
glNormal3f( 1.0, 0.0, 0.0); // Normal is Y axis glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(0.0, 0.0, 0.3); // z axis glVertex3f( 0.0, -1.0, 0.0); // Y axis
glNormal3f( 1.0, 0.0, 0.0); // Normal is Y axis
glVertex3f( 0.0 , 0.0, 0.0);
glVertex3f( 0.0, 0.0, 0.3 ); // Z axis
glEnd(); glEnd();
/* Draw epoxy limits (do not use, works and test in progress)*/ /* Draw epoxy limits (do not use, works and test in progress) */
#if 0 #if 0
glEnable(GL_FOG); glEnable(GL_FOG);
GLfloat param; GLfloat param;
// param = GL_LINEAR; glFogfv(GL_FOG_MODE,& param); // param = GL_LINEAR;
param = 0.2; glFogfv(GL_FOG_DENSITY,& param); // glFogfv(GL_FOG_MODE, & param);
param = g_Parm_3D_Visu.m_LayerZcoord[15]; glFogfv(GL_FOG_END,& param); param = 0.2;
glFogfv(GL_FOG_DENSITY, & param);
param = g_Parm_3D_Visu.m_LayerZcoord[15];
glFogfv(GL_FOG_END, & param);
glBegin(GL_QUADS); glBegin(GL_QUADS);
SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]); SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]);
double sx = DataScale3D * g_Parm_3D_Visu.m_BoardSize.x / 2; double sx = DataScale3D * g_Parm_3D_Visu.m_BoardSize.x / 2;
double sy = DataScale3D * g_Parm_3D_Visu.m_BoardSize.y / 2; double sy = DataScale3D * g_Parm_3D_Visu.m_BoardSize.y / 2;
double zpos = g_Parm_3D_Visu.m_LayerZcoord[15]; double zpos = g_Parm_3D_Visu.m_LayerZcoord[15];
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
sx = sy = 0.5; sx = sy = 0.5;
glVertex3f( -sx, -sy , zpos); glVertex3f( -sx, -sy, zpos );
glVertex3f( -sx, sy , zpos); glVertex3f( -sx, sy, zpos );
glVertex3f( sx, sy , zpos); glVertex3f( sx, sy, zpos );
glVertex3f( sx, -sy , zpos); glVertex3f( sx, -sy, zpos );
glEnd(); glEnd();
glBegin(GL_QUADS); glBegin(GL_QUADS);
SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[COPPER_LAYER_N]); SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[COPPER_LAYER_N]);
glNormal3f( 0.0, 0.0, -1.0); // Normal is -Z axis glNormal3f( 0.0, 0.0, -1.0 ); // Normal is -Z axis
glVertex3f( -sx, -sy , 0); glVertex3f( -sx, -sy, 0 );
glVertex3f( -sx, sy , 0); glVertex3f( -sx, sy, 0 );
glVertex3f( sx, sy , 0); glVertex3f( sx, sy, 0 );
glVertex3f( sx, -sy , 0); glVertex3f( sx, -sy, 0 );
glEnd(); glEnd();
#endif #endif
...@@ -164,27 +174,29 @@ glEnable(GL_FOG); ...@@ -164,27 +174,29 @@ glEnable(GL_FOG);
-g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale, -g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale,
0.0F); 0.0F);
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
/* Trac des pistes : */ /* Trac des pistes : */
for (pt_piste = pcb->m_Track ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) for( pt_piste = pcb->m_Track; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
{ {
if ( pt_piste->Type() == TYPEVIA ) if( pt_piste->Type() == TYPEVIA )
Draw3D_Via((SEGVIA*)pt_piste); Draw3D_Via((SEGVIA*)pt_piste);
else Draw3D_Track( pt_piste); else
} Draw3D_Track( pt_piste);
}
/* Trac des edges */ /* Trac des edges */
EDA_BaseStruct * PtStruct; EDA_BaseStruct * PtStruct;
for ( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext) for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
#define STRUCT ((DRAWSEGMENT *) PtStruct) #define STRUCT ((DRAWSEGMENT *) PtStruct)
if( PtStruct->Type() != TYPEDRAWSEGMENT ) continue; if( PtStruct->Type() != TYPEDRAWSEGMENT )
continue;
Draw3D_DrawSegment(STRUCT); Draw3D_DrawSegment(STRUCT);
} }
/* trac des modules */ /* trac des modules */
MODULE * Module = (MODULE*) pcb->m_Modules; MODULE * Module = (MODULE*) pcb->m_Modules;
for ( ; Module != NULL; Module = (MODULE *) Module->Pnext ) for( ; Module != NULL; Module = (MODULE *) Module->Pnext )
{ {
Module->Draw3D(this); Module->Draw3D(this);
} }
...@@ -192,11 +204,12 @@ MODULE * Module = (MODULE*) pcb->m_Modules; ...@@ -192,11 +204,12 @@ MODULE * Module = (MODULE*) pcb->m_Modules;
/* Test for errors */ /* Test for errors */
GLenum err = glGetError(); GLenum err = glGetError();
if ( err != GL_NO_ERROR ) if( err != GL_NO_ERROR )
DisplayError(this, wxT("Error in GL commands") ); DisplayError(this, wxT("Error in GL commands") );
return gllist; return gllist;
} }
/************************************************/ /************************************************/
void Pcb3D_GLCanvas::Draw3D_Track(TRACK * track) void Pcb3D_GLCanvas::Draw3D_Track(TRACK * track)
/************************************************/ /************************************************/
...@@ -207,13 +220,14 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; ...@@ -207,13 +220,14 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
double ox, oy, fx, fy; double ox, oy, fx, fy;
double w; double w;
if ( color & ITEM_NOT_SHOW ) return; if( color & ITEM_NOT_SHOW )
if ( layer == CMP_N ) return;
layer = g_Parm_3D_Visu.m_Layers -1; if( layer == LAST_COPPER_LAYER )
layer = g_Parm_3D_Visu.m_Layers - 1;
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
SetGLColor(color); SetGLColor(color);
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0); glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
w = track->m_Width * g_Parm_3D_Visu.m_BoardScale; w = track->m_Width * g_Parm_3D_Visu.m_BoardScale;
ox = track->m_Start.x * g_Parm_3D_Visu.m_BoardScale; ox = track->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
...@@ -223,11 +237,12 @@ double w; ...@@ -223,11 +237,12 @@ double w;
Draw3D_FilledSegment(ox, -oy, fx, -fy, w, zpos); Draw3D_FilledSegment(ox, -oy, fx, -fy, w, zpos);
} }
/********************************************/ /********************************************/
void Pcb3D_GLCanvas::Draw3D_Via(SEGVIA * via) void Pcb3D_GLCanvas::Draw3D_Via(SEGVIA * via)
/*********************************************/ /*********************************************/
/* 3D drawing for a VIA (cylinder + filled circles) /* 3D drawing for a VIA (cylinder + filled circles)
*/ */
{ {
double x, y, r, hole; double x, y, r, hole;
int layer, top_layer, bottom_layer; int layer, top_layer, bottom_layer;
...@@ -236,24 +251,26 @@ int color; ...@@ -236,24 +251,26 @@ int color;
r = via->m_Width * g_Parm_3D_Visu.m_BoardScale / 2; r = via->m_Width * g_Parm_3D_Visu.m_BoardScale / 2;
hole = g_Parm_3D_Visu.m_BoardSettings->m_ViaDrill * g_Parm_3D_Visu.m_BoardScale / 2; hole = g_Parm_3D_Visu.m_BoardSettings->m_ViaDrill * g_Parm_3D_Visu.m_BoardScale / 2;
x = via->m_Start.x * g_Parm_3D_Visu.m_BoardScale; x = via->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
y = via->m_Start.y * g_Parm_3D_Visu.m_BoardScale; y = via->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
via->ReturnLayerPair(&top_layer, &bottom_layer); via->ReturnLayerPair(&top_layer, &bottom_layer);
// Drawing filled circles: // Drawing filled circles:
for ( layer = bottom_layer; layer < g_Parm_3D_Visu.m_Layers; layer++ ) for( layer = bottom_layer; layer < g_Parm_3D_Visu.m_Layers; layer++ )
{ {
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
if ( layer < g_Parm_3D_Visu.m_Layers-1 ) if( layer < g_Parm_3D_Visu.m_Layers - 1 )
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
else color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]; else
if ( color & ITEM_NOT_SHOW ) continue; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N];
if( color & ITEM_NOT_SHOW )
continue;
SetGLColor(color); SetGLColor(color);
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0); glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
Draw3D_FilledCircle(x, -y, r, hole, zpos); Draw3D_FilledCircle(x, -y, r, hole, zpos);
if ( layer >= top_layer) break; if( layer >= top_layer)
break;
} }
// Drawing hole: // Drawing hole:
SetGLColor(DARKGRAY); SetGLColor(DARKGRAY);
...@@ -271,34 +288,34 @@ double x, y, xf, yf; ...@@ -271,34 +288,34 @@ double x, y, xf, yf;
double zpos, w; double zpos, w;
int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->GetLayer()]; int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->GetLayer()];
if ( color & ITEM_NOT_SHOW ) return; if( color & ITEM_NOT_SHOW )
return;
SetGLColor(color); SetGLColor(color);
w = segment->m_Width * g_Parm_3D_Visu.m_BoardScale; w = segment->m_Width * g_Parm_3D_Visu.m_BoardScale;
x = segment->m_Start.x * g_Parm_3D_Visu.m_BoardScale; x = segment->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
y = segment->m_Start.y * g_Parm_3D_Visu.m_BoardScale; y = segment->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
xf = segment->m_End.x * g_Parm_3D_Visu.m_BoardScale; xf = segment->m_End.x * g_Parm_3D_Visu.m_BoardScale;
yf = segment->m_End.y * g_Parm_3D_Visu.m_BoardScale; yf = segment->m_End.y * g_Parm_3D_Visu.m_BoardScale;
if ( segment->GetLayer() == EDGE_N) if( segment->GetLayer() == EDGE_N )
{ {
for ( layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ ) for( layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ )
{ {
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0); glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos); Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos );
} }
} }
else else
{ {
zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->GetLayer()]; zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->GetLayer()];
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos); Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos );
} }
} }
/*********************************************/ /*********************************************/
void MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas) void MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas)
/*********************************************/ /*********************************************/
...@@ -308,43 +325,45 @@ D_PAD * pad = m_Pads; ...@@ -308,43 +325,45 @@ D_PAD * pad = m_Pads;
#if 0 #if 0
if( ! DisplayOpt.Show_Modules_Cmp ) if( ! DisplayOpt.Show_Modules_Cmp )
{ {
if(m_Layer == CMP_N) return; if( m_Layer == CMP_N )
return;
} }
if( ! DisplayOpt.Show_Modules_Cu ) if( ! DisplayOpt.Show_Modules_Cu )
{ {
if(m_Layer == COPPER_LAYER_N) return; if( m_Layer == COPPER_LAYER_N )
return;
} }
#endif #endif
/* Draw pads */ /* Draw pads */
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
{ {
pad->Draw3D(glcanvas); pad->Draw3D(glcanvas);
} }
/* Draw module shape: 3D shape if exists (or module edge if not exists)*/ /* Draw module shape: 3D shape if exists (or module edge if not exists) */
Struct3D_Master * Struct3D = m_3D_Drawings; Struct3D_Master * Struct3D = m_3D_Drawings;
bool As3dShape = FALSE; bool As3dShape = FALSE;
glPushMatrix(); glPushMatrix();
glTranslatef(m_Pos.x * g_Parm_3D_Visu.m_BoardScale, glTranslatef( m_Pos.x * g_Parm_3D_Visu.m_BoardScale,
-m_Pos.y * g_Parm_3D_Visu.m_BoardScale, -m_Pos.y * g_Parm_3D_Visu.m_BoardScale,
g_Parm_3D_Visu.m_LayerZcoord[m_Layer] ); g_Parm_3D_Visu.m_LayerZcoord[m_Layer] );
if ( m_Orient ) if( m_Orient )
{ {
glRotatef( (double)m_Orient / 10, 0.0, 0.0, 1.0 ); glRotatef( (double)m_Orient / 10, 0.0, 0.0, 1.0 );
} }
if ( m_Layer == COPPER_LAYER_N ) if( m_Layer == COPPER_LAYER_N )
{ {
glRotatef( 180.0, 0.0, 1.0, 0.0 ); glRotatef( 180.0, 0.0, 1.0, 0.0 );
glRotatef( 180.0, 0.0, 0.0, 1.0 ); glRotatef( 180.0, 0.0, 0.0, 1.0 );
} }
DataScale3D = g_Parm_3D_Visu.m_BoardScale*UNITS3D_TO_UNITSPCB; DataScale3D = g_Parm_3D_Visu.m_BoardScale * UNITS3D_TO_UNITSPCB;
for ( ; Struct3D != NULL; Struct3D = (Struct3D_Master *) Struct3D->Pnext ) for( ; Struct3D != NULL; Struct3D = (Struct3D_Master *) Struct3D->Pnext )
{ {
if ( ! Struct3D->m_Shape3DName.IsEmpty() ) if( ! Struct3D->m_Shape3DName.IsEmpty() )
{ {
As3dShape = TRUE; As3dShape = TRUE;
Struct3D->ReadData(); Struct3D->ReadData();
...@@ -352,39 +371,42 @@ bool As3dShape = FALSE; ...@@ -352,39 +371,42 @@ bool As3dShape = FALSE;
} }
glPopMatrix(); glPopMatrix();
if ( ! As3dShape) if( ! As3dShape )
{ {
EDA_BaseStruct * Struct = m_Drawings; EDA_BaseStruct * Struct = m_Drawings;
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
for( ;Struct != NULL; Struct = Struct->Pnext ) for( ; Struct != NULL; Struct = Struct->Pnext )
{ {
switch( Struct->Type() ) switch( Struct->Type() )
{ {
case TYPETEXTEMODULE: case TYPETEXTEMODULE:
break; break;
case TYPEEDGEMODULE: case TYPEEDGEMODULE:
((EDGE_MODULE *) Struct)->Draw3D(glcanvas); ((EDGE_MODULE *) Struct)->Draw3D(glcanvas);
break; break;
default: break; default:
break;
} }
} }
} }
} }
/***************************************************/ /***************************************************/
void EDGE_MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas) void EDGE_MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas)
/***************************************************/ /***************************************************/
{ {
int ux0, uy0, dx, dy,rayon, StAngle, EndAngle; int ux0, uy0, dx, dy, rayon, StAngle, EndAngle;
double scale, x, y, fx, fy, w, zpos ; double scale, x, y, fx, fy, w, zpos;
int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer]; int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer];
if ( color & ITEM_NOT_SHOW ) return; if( color & ITEM_NOT_SHOW )
return;
SetGLColor(color); SetGLColor(color);
glNormal3f( 0.0, 0.0, (m_Layer == COPPER_LAYER_N) ? -1.0 : 1.0); glNormal3f( 0.0, 0.0, (m_Layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
scale = g_Parm_3D_Visu.m_BoardScale; scale = g_Parm_3D_Visu.m_BoardScale;
ux0 = m_Start.x; ux0 = m_Start.x;
...@@ -393,28 +415,28 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer]; ...@@ -393,28 +415,28 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer];
dy = m_End.y; dy = m_End.y;
zpos = g_Parm_3D_Visu.m_LayerZcoord[m_Layer]; zpos = g_Parm_3D_Visu.m_LayerZcoord[m_Layer];
w = m_Width * g_Parm_3D_Visu.m_BoardScale; w = m_Width * g_Parm_3D_Visu.m_BoardScale;
switch (m_Shape ) switch( m_Shape )
{ {
case S_SEGMENT: case S_SEGMENT:
x = m_Start.x * g_Parm_3D_Visu.m_BoardScale; x = m_Start.x * g_Parm_3D_Visu.m_BoardScale;
y = m_Start.y * g_Parm_3D_Visu.m_BoardScale; y = m_Start.y * g_Parm_3D_Visu.m_BoardScale;
fx = dx * g_Parm_3D_Visu.m_BoardScale; fx = dx * g_Parm_3D_Visu.m_BoardScale;
fy = dy * g_Parm_3D_Visu.m_BoardScale; fy = dy * g_Parm_3D_Visu.m_BoardScale;
Draw3D_FilledSegment(x, -y, fx, -fy, w, zpos); Draw3D_FilledSegment(x, -y, fx, -fy, w, zpos);
break ; break ;
case S_CIRCLE: case S_CIRCLE:
rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); rayon = (int)hypot( (double)(dx - ux0), (double)(dy - uy0) );
/* TO DO */ /* TO DO */
break; break;
case S_ARC: case S_ARC:
rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); rayon = (int)hypot( (double)(dx - ux0), (double)(dy - uy0) );
StAngle = (int)ArcTangente( dy-uy0, dx-ux0 ); StAngle = (int)ArcTangente( dy - uy0, dx - ux0 );
EndAngle = StAngle + m_Angle; EndAngle = StAngle + m_Angle;
/* TO DO */ /* TO DO */
break; break;
} }
} }
...@@ -422,11 +444,11 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer]; ...@@ -422,11 +444,11 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer];
void D_PAD::Draw3D(Pcb3D_GLCanvas * glcanvas) void D_PAD::Draw3D(Pcb3D_GLCanvas * glcanvas)
/***********************************************/ /***********************************************/
/* Dessin 3D des pads avec leur trou de percage /* Dessin 3D des pads avec leur trou de percage
*/ */
{ {
int ii, ll, layer, nlmax; int ii, ll, layer, nlmax;
int ux0,uy0, int ux0, uy0,
dx,dx0,dy,dy0, dx, dx0, dy, dy0,
delta_cx, delta_cy, delta_cx, delta_cy,
xc, yc; xc, yc;
int angle, delta_angle; int angle, delta_angle;
...@@ -443,7 +465,7 @@ int color; ...@@ -443,7 +465,7 @@ int color;
scale = g_Parm_3D_Visu.m_BoardScale; scale = g_Parm_3D_Visu.m_BoardScale;
holeX = (double)m_Drill.x * scale / 2; holeX = (double)m_Drill.x * scale / 2;
holeY = (double)m_Drill.y * scale / 2; holeY = (double)m_Drill.y * scale / 2;
hole = MIN (holeX,holeY); hole = MIN(holeX, holeY);
/* calcul du centre des formes des pads : */ /* calcul du centre des formes des pads : */
shape_pos = ReturnShapePos(); shape_pos = ReturnShapePos();
...@@ -453,86 +475,98 @@ int color; ...@@ -453,86 +475,98 @@ int color;
yc = uy0; yc = uy0;
/* le trace depend de la rotation de l'empreinte */ /* le trace depend de la rotation de l'empreinte */
dx = dx0 = m_Size.x >> 1 ; dx = dx0 = m_Size.x >> 1;
dy = dy0 = m_Size.y >> 1 ; /* demi dim dx et dy */ dy = dy0 = m_Size.y >> 1; /* demi dim dx et dy */
angle = m_Orient; angle = m_Orient;
drillx = m_Pos.x * scale; drillx = m_Pos.x * scale;
drilly = m_Pos.y * scale; drilly = m_Pos.y * scale;
/* Draw the pad hole (TODO: draw OBLONG hole)*/ /* Draw the pad hole (TODO: draw OBLONG hole) */
if ( holeX && holeY ) if( holeX && holeY )
{ {
SetGLColor(DARKGRAY); SetGLColor(DARKGRAY);
Draw3D_FilledCylinder(drillx, -drilly, hole, g_Parm_3D_Visu.m_LayerZcoord[CMP_N], 0.0); Draw3D_FilledCylinder(drillx, -drilly, hole, g_Parm_3D_Visu.m_LayerZcoord[CMP_N], 0.0);
} }
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
nlmax = g_Parm_3D_Visu.m_Layers-1; nlmax = g_Parm_3D_Visu.m_Layers - 1;
Oncu = (m_Masque_Layer & CUIVRE_LAYER) ? TRUE : FALSE; Oncu = (m_Masque_Layer & CUIVRE_LAYER) ? TRUE : FALSE;
Oncmp = (m_Masque_Layer & CMP_LAYER) ? TRUE : FALSE; Oncmp = (m_Masque_Layer & CMP_LAYER) ? TRUE : FALSE;
Both = Oncu && Oncmp; Both = Oncu && Oncmp;
switch (m_PadShape & 0x7F) switch( m_PadShape & 0x7F )
{
case CIRCLE :
x = xc * scale;
y = yc * scale;
r = (double)dx * scale;
for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ )
{ {
case CIRCLE : if( layer && (layer == nlmax) )
x = xc * scale; layer = CMP_N;
y = yc * scale; if( (layer == CMP_N) && ! Oncmp )
r = (double)dx * scale; continue;
for ( layer = COPPER_LAYER_N; layer <= CMP_N; layer ++) if( (layer == COPPER_LAYER_N) && ! Oncu )
{ continue;
if (layer && (layer == nlmax) ) layer = CMP_N; if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both)
if ( (layer == CMP_N) && ! Oncmp ) continue; continue;
if ( (layer == COPPER_LAYER_N) && ! Oncu ) continue; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
if ( (layer > COPPER_LAYER_N) && (layer < CMP_N) && !Both) continue; if( color & ITEM_NOT_SHOW )
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; continue;
if ( color & ITEM_NOT_SHOW ) continue; SetGLColor(color);
SetGLColor(color); glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0); zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; Draw3D_FilledCircle(x, -y, r, hole, zpos);
Draw3D_FilledCircle(x, -y, r, hole, zpos); }
} break;
break;
case OVALE : case OVALE :
/* calcul de l'entraxe de l'ellipse */ /* calcul de l'entraxe de l'ellipse */
if( dx > dy ) /* ellipse horizontale */ if( dx > dy ) /* ellipse horizontale */
{ {
delta_cx = dx - dy; delta_cy = 0; delta_cx = dx - dy;
w = m_Size.y * scale; delta_cy = 0;
delta_angle = angle+900; w = m_Size.y * scale;
} delta_angle = angle + 900;
else /* ellipse verticale */ }
{ else /* ellipse verticale */
delta_cx = 0; delta_cy = dy - dx; {
w = m_Size.x * scale; delta_cx = 0;
delta_angle = angle; delta_cy = dy - dx;
} w = m_Size.x * scale;
RotatePoint(&delta_cx, &delta_cy, angle); delta_angle = angle;
{ }
RotatePoint(&delta_cx, &delta_cy, angle);
{
double ox, oy, fx, fy; double ox, oy, fx, fy;
ox = (double)(ux0 + delta_cx) * scale; ox = (double)(ux0 + delta_cx) * scale;
oy = (double)(uy0 + delta_cy) * scale; oy = (double)(uy0 + delta_cy) * scale;
fx = (double)(ux0 - delta_cx) * scale; fx = (double)(ux0 - delta_cx) * scale;
fy = (double)(uy0 - delta_cy) * scale; fy = (double)(uy0 - delta_cy) * scale;
for ( layer = COPPER_LAYER_N; layer <= CMP_N; layer ++) for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer ++ )
{ {
if (layer && (layer == nlmax) ) layer = CMP_N; if( layer && (layer == nlmax) )
if ( (layer == CMP_N) && ! Oncmp ) continue; layer = CMP_N;
if ( (layer == COPPER_LAYER_N) && ! Oncu ) continue; if( (layer == CMP_N) && ! Oncmp )
if ( (layer > COPPER_LAYER_N) && (layer < CMP_N) && !Both) continue; continue;
if( (layer == COPPER_LAYER_N) && ! Oncu )
continue;
if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both )
continue;
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0); glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
if ( color & ITEM_NOT_SHOW ) continue; if( color & ITEM_NOT_SHOW )
continue;
SetGLColor(color); SetGLColor(color);
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
Draw3D_FilledSegmentWithHole(ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos); Draw3D_FilledSegmentWithHole(ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos);
} }
} }
break; break;
case RECT : case RECT :
// case SPECIAL_PAD: // case SPECIAL_PAD:
case TRAPEZE: case TRAPEZE:
{ {
int ddx, ddy ; int ddx, ddy ;
ddx = m_DeltaSize.x >> 1 ; ddx = m_DeltaSize.x >> 1 ;
ddy = m_DeltaSize.y >> 1 ; /* demi dim dx et dy */ ddy = m_DeltaSize.y >> 1 ; /* demi dim dx et dy */
...@@ -549,74 +583,84 @@ int color; ...@@ -549,74 +583,84 @@ int color;
coord[3][0] = + dx + ddy; coord[3][0] = + dx + ddy;
coord[3][1] = + dy - ddx; coord[3][1] = + dy - ddx;
for (ii = 0; ii < 4; ii++) for( ii = 0; ii < 4; ii++ )
{ {
RotatePoint(&coord[ii][0],&coord[ii][1], angle); RotatePoint(&coord[ii][0], &coord[ii][1], angle);
coord[ii][0] += ux0; coord[ii][0] += ux0;
coord[ii][1] += uy0; coord[ii][1] += uy0;
ll = ii*2; ll = ii * 2;
fcoord[ll][0] = coord[ii][0] * scale; fcoord[ll][0] = coord[ii][0] * scale;
fcoord[ll][1] = coord[ii][1] * scale; fcoord[ll][1] = coord[ii][1] * scale;
} }
for (ii = 0; ii < 7; ii+=2)
{ for( ii = 0; ii < 7; ii += 2 )
ll = ii+2; if (ll > 7) ll -= 8; {
fcoord[ii+1][0] = (fcoord[ii][0] + fcoord[ll][0])/2; ll = ii + 2;
fcoord[ii+1][1] = (fcoord[ii][1] + fcoord[ll][1])/2; if( ll > 7 )
} ll -= 8;
for (ii = 0; ii < 8; ii++) fcoord[ii + 1][0] = (fcoord[ii][0] + fcoord[ll][0]) / 2;
{ fcoord[ii + 1][1] = (fcoord[ii][1] + fcoord[ll][1]) / 2;
f_hole_coord[ii][0] = -hole*0.707; }
f_hole_coord[ii][1] = hole*0.707;
for( ii = 0; ii < 8; ii++ )
{
f_hole_coord[ii][0] = -hole * 0.707;
f_hole_coord[ii][1] = hole * 0.707;
RotatePoint(&f_hole_coord[ii][0], &f_hole_coord[ii][1], RotatePoint(&f_hole_coord[ii][0], &f_hole_coord[ii][1],
angle -(ii * 450) ); angle - (ii * 450));
f_hole_coord[ii][0] += drillx; f_hole_coord[ii][0] += drillx;
f_hole_coord[ii][1] += drilly; f_hole_coord[ii][1] += drilly;
} }
for ( layer = COPPER_LAYER_N; layer <= CMP_N; layer ++) for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ )
{ {
if (layer && (layer == nlmax) ) layer = CMP_N; if( layer && (layer == nlmax) )
if ( (layer == CMP_N) && ! Oncmp ) continue; layer = CMP_N;
if ( (layer == COPPER_LAYER_N) && ! Oncu ) continue; if( (layer == CMP_N) && ! Oncmp )
if ( (layer > COPPER_LAYER_N) && (layer < CMP_N) && !Both) continue; continue;
if( (layer == COPPER_LAYER_N) && ! Oncu )
continue;
if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both )
continue;
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0); glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
if ( color & ITEM_NOT_SHOW ) continue; if( color & ITEM_NOT_SHOW )
continue;
SetGLColor(color); SetGLColor(color);
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for ( ii = 0; ii < 8; ii++ ) for( ii = 0; ii < 8; ii++ )
{ {
glVertex3f( f_hole_coord[ii][0], -f_hole_coord[ii][1] , zpos); glVertex3f( f_hole_coord[ii][0], -f_hole_coord[ii][1], zpos );
glVertex3f( fcoord[ii][0], -fcoord[ii][1] , zpos); glVertex3f( fcoord[ii][0], -fcoord[ii][1], zpos );
} }
glVertex3f( f_hole_coord[0][0], -f_hole_coord[0][1] , zpos); glVertex3f( f_hole_coord[0][0], -f_hole_coord[0][1], zpos );
glVertex3f( fcoord[0][0], -fcoord[0][1] , zpos); glVertex3f( fcoord[0][0], -fcoord[0][1], zpos );
glEnd(); glEnd();
} }
break;
default:
break;
}
} }
break;
default:
break;
}
} }
/*************************/ /*************************/
void SetGLColor(int color) void SetGLColor(int color)
/*************************/ /*************************/
{ {
double red, green,blue; double red, green, blue;
StructColors colordata = ColorRefs[color & MASKCOLOR]; StructColors colordata = ColorRefs[color & MASKCOLOR];
red = colordata.m_Red / 255.0; red = colordata.m_Red / 255.0;
blue = colordata.m_Blue / 255.0; blue = colordata.m_Blue / 255.0;
green = colordata.m_Green / 255.0; green = colordata.m_Green / 255.0;
glColor3f(red, green,blue); glColor3f(red, green, blue);
} }
/********************************************************/ /********************************************************/
static void Draw3D_FilledCircle(double posx, double posy, static void Draw3D_FilledCircle(double posx, double posy,
double rayon, double hole, double zpos) double rayon, double hole, double zpos)
...@@ -626,18 +670,21 @@ int ii, slice = 16; ...@@ -626,18 +670,21 @@ int ii, slice = 16;
double x, y; double x, y;
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for ( ii = 0; ii <= slice; ii++ ) for( ii = 0; ii <= slice; ii++ )
{ {
x = hole; y = 0.0; x = hole;
y = 0.0;
RotatePoint(&x, &y, ii * 225); RotatePoint(&x, &y, ii * 225);
glVertex3f( x + posx, y + posy, zpos); glVertex3f( x + posx, y + posy, zpos );
x = rayon; y = 0.0; x = rayon;
y = 0.0;
RotatePoint(&x, &y, ii * 225); RotatePoint(&x, &y, ii * 225);
glVertex3f( x + posx, y + posy, zpos); glVertex3f( x + posx, y + posy, zpos );
} }
glEnd(); glEnd();
} }
/*********************************************************/ /*********************************************************/
static void Draw3D_FilledCylinder(double posx, double posy, static void Draw3D_FilledCylinder(double posx, double posy,
double rayon, double height, double zpos) double rayon, double height, double zpos)
...@@ -649,43 +696,46 @@ double x, y; ...@@ -649,43 +696,46 @@ double x, y;
S3D_Vertex coords[4]; S3D_Vertex coords[4];
double tmp = DataScale3D; double tmp = DataScale3D;
DataScale3D = 1.0; //les coord sont deja a l'echelle pour Set_Object_Data(); DataScale3D = 1.0; // les coord sont deja a l'echelle pour Set_Object_Data();
coords[0].x = coords[1].x = posx + rayon; coords[0].x = coords[1].x = posx + rayon;
coords[0].y = coords[1].y = posy; coords[0].y = coords[1].y = posy;
coords[0].z = coords[3].z = zpos; coords[0].z = coords[3].z = zpos;
coords[1].z = coords[2].z = zpos + height; coords[1].z = coords[2].z = zpos + height;
for ( ii = 0; ii <= NB_SEGM; ii++ ) for( ii = 0; ii <= NB_SEGM; ii++ )
{ {
x = rayon; y = 0.0; x = rayon;
RotatePoint(&x, &y, ii * (3600/NB_SEGM)); y = 0.0;
RotatePoint(&x, &y, ii * (3600 / NB_SEGM));
coords[2].x = coords[3].x = posx + x; coords[2].x = coords[3].x = posx + x;
coords[2].y = coords[3].y = posy + y; coords[2].y = coords[3].y = posy + y;
Set_Object_Data(coords, 4 ); Set_Object_Data( coords, 4 );
coords[0].x = coords[2].x; coords[0].x = coords[2].x;
coords[0].y = coords[2].y; coords[0].y = coords[2].y;
coords[1].x = coords[3].x; coords[1].x = coords[3].x;
coords[1].y = coords[3].y; coords[1].y = coords[3].y;
} }
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
DataScale3D = tmp; DataScale3D = tmp;
} }
/*****************************************************************/ /*****************************************************************/
static void Draw3D_FilledSegment(double startx, double starty, static void Draw3D_FilledSegment(double startx, double starty,
double endx, double endy,double width, double zpos) double endx, double endy,double width, double zpos)
/*****************************************************************/ /*****************************************************************/
/* trace un polygone semblable a un segment a bouts ronds /* trace un polygone semblable a un segment a bouts ronds
*/ */
{ {
double dx, dy, x, y, firstx=0, firsty=0; double dx, dy, x, y, firstx=0, firsty=0;
int ii, angle; int ii, angle;
/* on va calculer les coordonnes du segment suppos horizontal, // on va calculer les coordonnes du segment suppos horizontal,
puis tourner les cordonnes de l'angle voulu */ // puis tourner les cordonnes de l'angle voulu
dx = endx - startx; dy = endy - starty; dx = endx - startx;
angle = (int)(( atan2( dy, dx ) / M_PI * 1800)+0.5) ; dy = endy - starty;
angle = (int)( ( atan2(dy, dx) * 1800 / M_PI ) + 0.5 );
RotatePoint(&dx, &dy, angle); // apres rotation: dx = longueur du segment RotatePoint(&dx, &dy, angle); // apres rotation: dx = longueur du segment
// dy = 0; // dy = 0;
...@@ -693,64 +743,71 @@ int ii, angle; ...@@ -693,64 +743,71 @@ int ii, angle;
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
// trac de l'arrondi a droite (1er demi polygone a la fin du segment) // trac de l'arrondi a droite (1er demi polygone a la fin du segment)
for ( ii = 0; ii <= 8; ii++ ) for( ii = 0; ii <= 8; ii++ )
{ {
x = 0.0; y =-width; x = 0.0;
y = -width;
RotatePoint(&x, &y, -ii * 225); RotatePoint(&x, &y, -ii * 225);
x += dx; x += dx;
RotatePoint(&x, &y, -angle); RotatePoint(&x, &y, -angle);
glVertex3f( startx + x, starty+y, zpos); glVertex3f( startx + x, starty+y, zpos );
if ( ii == 0 ) if( ii == 0 )
{ {
firstx = startx + x; firstx = startx + x;
firsty = starty + y; firsty = starty + y;
} }
} }
// trac de l'arrondi a gauche (2ieme demi polygone a l'origine du segment) // trac de l'arrondi a gauche (2ieme demi polygone a l'origine du segment)
for ( ii = 0; ii <= 8; ii++ ) for( ii = 0; ii <= 8; ii++ )
{ {
int jj = ii * 225; int jj = ii * 225;
x = 0.0; y = width; x = 0.0;
RotatePoint(&x, &y, -angle -jj); y = width;
glVertex3f( startx + x, starty+y, zpos); RotatePoint(&x, &y, -angle - jj);
glVertex3f( startx + x, starty+y, zpos );
} }
glVertex3f( firstx, firsty, zpos); glVertex3f( firstx, firsty, zpos );
glEnd(); glEnd();
} }
/*****************************************************************/ /*****************************************************************/
static void Draw3D_FilledSegmentWithHole(double startx, double starty, static void Draw3D_FilledSegmentWithHole(double startx, double starty,
double endx, double endy,double width, double endx, double endy, double width,
double holex, double holey, double holeradius, double zpos) double holex, double holey, double holeradius, double zpos)
/*****************************************************************/ /*****************************************************************/
/* trace un polygone semblable a un segment a bouts ronds avec trou /* trace un polygone semblable a un segment a bouts ronds avec trou
*/ */
{ {
double x, y, xin, yin; double x, y, xin, yin;
double firstx=0, firsty=0, firstxin=0, firstyin=0; double firstx = 0, firsty = 0, firstxin = 0, firstyin = 0;
int ii, angle, theta; int ii, angle, theta;
/* on va calculer les coordonnes du segment suppos horizontal, // on va calculer les coordonnes du segment suppos horizontal,
puis tourner les cordonnes de l'angle voulu // puis tourner les cordonnes de l'angle voulu
Tous des calculs se font avec startx, starty comme origine du trac */ // Tous des calculs se font avec startx, starty comme origine du trac
endx -= startx; endy -= starty; endx -= startx;
holex -= startx; holey -= starty; endy -= starty;
angle = (int)(( atan2( endy, endx ) / M_PI * 1800)+0.5) ; holex -= startx;
holey -= starty;
angle = (int)( ( atan2(endy, endx) * 1800 / M_PI ) + 0.5 );
RotatePoint(&endx, &endy, angle); // apres rotation: endx = longueur du segment RotatePoint(&endx, &endy, angle); // apres rotation: endx = longueur du segment
// endy = 0; // endy = 0;
RotatePoint(&holex, &holey, angle); RotatePoint(&holex, &holey, angle);
width /= 2; width /= 2;
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
// trac de l'arrondi a droite (1er demi polygone a la fin du segment) // trac de l'arrondi a droite (1er demi polygone a la fin du segment)
// autour du demi-trou de percage // autour du demi-trou de percage
for ( ii = 0; ii <= 8; ii++ ) for( ii = 0; ii <= 8; ii++ )
{ {
x = 0.0; y = -width; x = 0.0;
xin = 0.0; yin = - holeradius; y = -width;
xin = 0.0;
yin = -holeradius;
theta = -ii * 225; theta = -ii * 225;
RotatePoint(&x, &y, theta); RotatePoint(&x, &y, theta);
RotatePoint(&xin, &yin, theta); RotatePoint(&xin, &yin, theta);
...@@ -758,9 +815,9 @@ int ii, angle, theta; ...@@ -758,9 +815,9 @@ int ii, angle, theta;
RotatePoint(&x, &y, -angle); RotatePoint(&x, &y, -angle);
xin += holex; xin += holex;
RotatePoint(&xin, &yin, -angle); RotatePoint(&xin, &yin, -angle);
glVertex3f( startx + xin, starty+yin, zpos); glVertex3f( startx + xin, starty+yin, zpos );
glVertex3f( startx + x, starty+y, zpos); glVertex3f( startx + x, starty+y, zpos );
if ( ii == 0 ) // Memorisation du point de dpart du trac if( ii == 0 ) // Memorisation du point de dpart du trac
{ {
firstx = startx + x; firstx = startx + x;
firsty = starty + y; firsty = starty + y;
...@@ -769,21 +826,22 @@ int ii, angle, theta; ...@@ -769,21 +826,22 @@ int ii, angle, theta;
} }
} }
// trac de l'arrondi a gauche (2ieme demi polygone a l'origine du segment) // trac de l'arrondi a gauche (2ieme demi polygone a l'origine du segment)
for ( ii = 0; ii <= 8; ii++ ) for( ii = 0; ii <= 8; ii++ )
{ {
theta = - ii * 225; theta = -ii * 225;
x = 0.0; y = width; x = 0.0;
y = width;
RotatePoint(&x, &y, -angle + theta); RotatePoint(&x, &y, -angle + theta);
xin = 0.0; yin = holeradius; xin = 0.0;
yin = holeradius;
RotatePoint(&xin, &yin, theta); RotatePoint(&xin, &yin, theta);
xin += holex; xin += holex;
RotatePoint(&xin, &yin, -angle); RotatePoint(&xin, &yin, -angle);
glVertex3f( startx + xin,starty + yin, zpos); glVertex3f( startx + xin,starty + yin, zpos );
glVertex3f( startx + x, starty + y, zpos); glVertex3f( startx + x, starty + y, zpos );
} }
glVertex3f( firstxin, firstyin, zpos); glVertex3f( firstxin, firstyin, zpos );
glVertex3f( firstx, firsty, zpos); glVertex3f( firstx, firsty, zpos );
glEnd(); glEnd();
} }
...@@ -4,6 +4,14 @@ Started 2007-June-11 ...@@ -4,6 +4,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Nov-01 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ pcbnew
* Provided new definitions of FIRST_COPPER_LAYER and LAST_COPPER_LAYER within
include/pcbstruct.h, and used those definitions within various other files.
Beautified and generally refined 3d-viewer/3d_draw.cpp and pcbnew/plotgerb.cpp.
2007-Oct-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2007-Oct-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+kicad: +kicad:
...@@ -401,8 +409,8 @@ email address. ...@@ -401,8 +409,8 @@ email address.
field. (Refer to 2007-Oct-2 UPDATE notes for the relevance of this.) field. (Refer to 2007-Oct-2 UPDATE notes for the relevance of this.)
* Beautification and house keeping. * Beautification and house keeping.
+ eeschema + eeschema
* The editpart.cpp and editpart.cpp files (which are no longer used) have been * The editpart.cpp and libedpart.cpp files (which are no longer used) have been
removed, and replaced with editpart.cpp.notused and editpart.cpp.notused removed, and replaced with editpart.cpp.notused and libedpart.cpp.notused
+ cvpcb + cvpcb
* Additional "OK", "Cancel", and "Apply" buttons have now been provided for the * Additional "OK", "Cancel", and "Apply" buttons have now been provided for the
"Options" dialog box which lists various display options for footprints. "Options" dialog box which lists various display options for footprints.
......
...@@ -153,7 +153,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -153,7 +153,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
if( pcb_layer_number < 0 ) if( pcb_layer_number < 0 )
continue; continue;
if( pcb_layer_number > CMP_N ) if( pcb_layer_number > LAST_COPPER_LAYER )
{ {
DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPEDRAWSEGMENT ); DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPEDRAWSEGMENT );
...@@ -169,7 +169,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -169,7 +169,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
TRACK* newtrack; TRACK* newtrack;
// replace spots with vias when possible // replace spots with vias when possible
if( track->m_Shape == S_SPOT_CIRCLE if( track->m_Shape == S_SPOT_CIRCLE
|| track->m_Shape == S_SPOT_RECT || track->m_Shape == S_SPOT_RECT
|| track->m_Shape == S_SPOT_OVALE ) || track->m_Shape == S_SPOT_OVALE )
{ {
......
...@@ -266,7 +266,7 @@ bool AsCmpLayer = false; ...@@ -266,7 +266,7 @@ bool AsCmpLayer = false;
AsCmpLayer = true; AsCmpLayer = true;
else else
{ {
if( LayerLookUpTable[ii] >= CMP_N ) if( LayerLookUpTable[ii] >= LAST_COPPER_LAYER )
continue; // not a copper layer continue; // not a copper layer
if( LayerLookUpTable[ii] >= g_DesignSettings.m_CopperLayerCount ) if( LayerLookUpTable[ii] >= g_DesignSettings.m_CopperLayerCount )
g_DesignSettings.m_CopperLayerCount++; g_DesignSettings.m_CopperLayerCount++;
...@@ -275,8 +275,8 @@ bool AsCmpLayer = false; ...@@ -275,8 +275,8 @@ bool AsCmpLayer = false;
if( AsCmpLayer ) if( AsCmpLayer )
g_DesignSettings.m_CopperLayerCount++; g_DesignSettings.m_CopperLayerCount++;
if( g_DesignSettings.m_CopperLayerCount > CMP_N + 1 ) // should not occur. if( g_DesignSettings.m_CopperLayerCount > NB_COPPER_LAYERS ) // should not occur.
g_DesignSettings.m_CopperLayerCount = CMP_N + 1; g_DesignSettings.m_CopperLayerCount = NB_COPPER_LAYERS;
EndModal( 1 ); EndModal( 1 );
} }
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
/* Layer identification (layer number) */ /* Layer identification (layer number) */
#define FIRST_COPPER_LAYER 0
#define COPPER_LAYER_N 0 #define COPPER_LAYER_N 0
#define LAYER_N_2 1 /* Numero layer 2 */ #define LAYER_N_2 1 /* Numero layer 2 */
#define LAYER_N_3 2 /* Numero layer 3 */ #define LAYER_N_3 2 /* Numero layer 3 */
...@@ -52,7 +53,8 @@ ...@@ -52,7 +53,8 @@
#define LAYER_N_15 14 /* Numero layer 15 */ #define LAYER_N_15 14 /* Numero layer 15 */
#define LAYER_CMP_N 15 #define LAYER_CMP_N 15
#define CMP_N 15 #define CMP_N 15
#define NB_COPPER_LAYERS (CMP_N + 1) #define LAST_COPPER_LAYER 15
#define NB_COPPER_LAYERS (LAST_COPPER_LAYER + 1)
#define FIRST_NO_COPPER_LAYER 16 #define FIRST_NO_COPPER_LAYER 16
#define ADHESIVE_N_CU 16 #define ADHESIVE_N_CU 16
......
...@@ -181,7 +181,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer ) ...@@ -181,7 +181,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer )
// Copper layers cannot be selected unconditionally; how many // Copper layers cannot be selected unconditionally; how many
// of those layers are currently enabled needs to be checked. // of those layers are currently enabled needs to be checked.
if( (layer >= COPPER_LAYER_N) && (layer <= CMP_N) ) if( (layer >= FIRST_COPPER_LAYER) && (layer <= LAST_COPPER_LAYER) )
{ {
// If only one copper layer is enabled, the only such layer // If only one copper layer is enabled, the only such layer
// that can be selected to is the "Copper" layer (so the // that can be selected to is the "Copper" layer (so the
......
...@@ -173,7 +173,7 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -173,7 +173,7 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
typeaff = frame->m_DisplayModEdge; typeaff = frame->m_DisplayModEdge;
if( m_Layer <= CMP_N ) if( m_Layer <= LAST_COPPER_LAYER )
{ {
typeaff = frame->m_DisplayPcbTrackFill; typeaff = frame->m_DisplayPcbTrackFill;
if( !typeaff ) if( !typeaff )
......
...@@ -99,8 +99,8 @@ int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum ) ...@@ -99,8 +99,8 @@ int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
{ {
sscanf( Line + 2, " %d %d %lX %d\n", &m_Layer, &m_Miroir, sscanf( Line + 2, " %d %d %lX %d\n", &m_Layer, &m_Miroir,
&m_TimeStamp, &dummy ); &m_TimeStamp, &dummy );
if( m_Layer < COPPER_LAYER_N ) if( m_Layer < FIRST_COPPER_LAYER )
m_Layer = COPPER_LAYER_N; m_Layer = FIRST_COPPER_LAYER;
if( m_Layer > LAST_NO_COPPER_LAYER ) if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER; m_Layer = LAST_NO_COPPER_LAYER;
......
...@@ -268,7 +268,7 @@ int TRACK::ReturnMaskLayer() ...@@ -268,7 +268,7 @@ int TRACK::ReturnMaskLayer()
if( via_type == VIA_THROUGH ) if( via_type == VIA_THROUGH )
return ALL_CU_LAYERS; return ALL_CU_LAYERS;
// VIA_BLIND ou VIA_BURIED: // VIA_BLIND or VIA_BURIED:
int bottom_layer, top_layer; int bottom_layer, top_layer;
...@@ -720,7 +720,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode ) ...@@ -720,7 +720,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode )
} }
/* Shows clearance (for tracks and vias, not for zone segments */ /* Shows clearance (for tracks and vias, not for zone segments */
if( DisplayOpt.DisplayTrackIsol && ( m_Layer <= CMP_N ) if( DisplayOpt.DisplayTrackIsol && ( m_Layer <= LAST_COPPER_LAYER )
&& ( Type() == TYPETRACK || Type() == TYPEVIA) ) && ( Type() == TYPETRACK || Type() == TYPEVIA) )
{ {
GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
......
...@@ -136,12 +136,12 @@ WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* ...@@ -136,12 +136,12 @@ WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame*
wxDefaultPosition, wxDefaultSize ); wxDefaultPosition, wxDefaultSize );
LeftBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); LeftBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
int ii; int ii;
for( ii = CMP_N + 1; ii < NB_LAYERS; ii++ ) for( ii = FIRST_NO_COPPER_LAYER; ii < NB_LAYERS; ii++ )
{ {
m_SelLayerBox->Append( ReturnPcbLayerName( ii ) ); m_SelLayerBox->Append( ReturnPcbLayerName( ii ) );
} }
m_SelLayerBox->SetSelection( Cotation->GetLayer() - (CMP_N + 1) ); m_SelLayerBox->SetSelection( Cotation->GetLayer() - FIRST_NO_COPPER_LAYER );
GetSizer()->Fit( this ); GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
...@@ -175,8 +175,8 @@ void WinEDA_CotationPropertiesFrame::OnOkClick( wxCommandEvent& event ) ...@@ -175,8 +175,8 @@ void WinEDA_CotationPropertiesFrame::OnOkClick( wxCommandEvent& event )
m_TxtWidthCtrl->GetValue(); m_TxtWidthCtrl->GetValue();
CurrentCotation->m_Text->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; CurrentCotation->m_Text->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0;
CurrentCotation->SetLayer( m_SelLayerBox->GetChoice() + CMP_N + 1 ); CurrentCotation->SetLayer( m_SelLayerBox->GetChoice() + FIRST_NO_COPPER_LAYER );
CurrentCotation->m_Text->SetLayer( m_SelLayerBox->GetChoice() + CMP_N + 1 ); CurrentCotation->m_Text->SetLayer( m_SelLayerBox->GetChoice() + FIRST_NO_COPPER_LAYER );
CurrentCotation->m_Text->CreateDrawData(); CurrentCotation->m_Text->CreateDrawData();
......
...@@ -194,11 +194,11 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -194,11 +194,11 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge, wxDC* DC )
/* Ask for the new layer */ /* Ask for the new layer */
new_layer = SelectLayer( new_layer, COPPER_LAYER_N, LAST_NO_COPPER_LAYER ); new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER );
if( new_layer < 0 ) if( new_layer < 0 )
return; return;
if ( new_layer >= COPPER_LAYER_N && new_layer <= LAYER_CMP_N ) if ( new_layer >= FIRST_COPPER_LAYER && new_layer <= LAST_COPPER_LAYER )
/* an edge is put on a copper layer, and it is very dangerous. a confirmation is requested */ /* an edge is put on a copper layer, and it is very dangerous. a confirmation is requested */
{ {
if ( ! IsOK(this, _("The graphic item will be on a copper layer.It is very dangerous. Are you sure") ) ) if ( ! IsOK(this, _("The graphic item will be on a copper layer.It is very dangerous. Are you sure") ) )
......
...@@ -632,7 +632,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -632,7 +632,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_SELECT_CU_LAYER: case ID_POPUP_PCB_SELECT_CU_LAYER:
itmp = SelectLayer( GetScreen()->m_Active_Layer, -1, CMP_N ); itmp = SelectLayer( GetScreen()->m_Active_Layer, -1, LAST_COPPER_LAYER );
if( itmp >= 0 ) if( itmp >= 0 )
GetScreen()->m_Active_Layer = itmp; GetScreen()->m_Active_Layer = itmp;
break; break;
...@@ -1005,7 +1005,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) ...@@ -1005,7 +1005,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// Copper layers cannot be selected unconditionally; how many // Copper layers cannot be selected unconditionally; how many
// of those layers are currently enabled needs to be checked. // of those layers are currently enabled needs to be checked.
if( (layer >= COPPER_LAYER_N) && (layer <= CMP_N) ) if( (layer >= FIRST_COPPER_LAYER) && (layer <= LAST_COPPER_LAYER) )
{ {
// If only one copper layer is enabled, the only such layer // If only one copper layer is enabled, the only such layer
// that can be selected to is the "Copper" layer (so the // that can be selected to is the "Copper" layer (so the
......
...@@ -162,7 +162,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -162,7 +162,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
COTATION* Cotation; COTATION* Cotation;
int layer = Segment->GetLayer(); int layer = Segment->GetLayer();
if( layer <= CMP_N ) if( layer <= LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 ); DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 );
return; return;
......
...@@ -202,12 +202,12 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -202,12 +202,12 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_SWITCH_LAYER_TO_PREVIOUS: case HK_SWITCH_LAYER_TO_PREVIOUS:
ll = GetScreen()->m_Active_Layer; ll = GetScreen()->m_Active_Layer;
if( (ll <= COPPER_LAYER_N) || (ll > CMP_N) ) if( (ll <= FIRST_COPPER_LAYER) || (ll > LAST_COPPER_LAYER) )
break; break;
if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) // Single layer if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) // Single layer
ll = COPPER_LAYER_N; ll = COPPER_LAYER_N;
else if( ll == CMP_N ) else if( ll == LAST_COPPER_LAYER )
ll = MAX( COPPER_LAYER_N, m_Pcb->m_BoardSettings->m_CopperLayerCount - 2 ); ll = MAX( FIRST_COPPER_LAYER, m_Pcb->m_BoardSettings->m_CopperLayerCount - 2 );
else else
ll--; ll--;
SwitchLayer( DC, ll ); SwitchLayer( DC, ll );
...@@ -215,12 +215,12 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -215,12 +215,12 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_SWITCH_LAYER_TO_NEXT: case HK_SWITCH_LAYER_TO_NEXT:
ll = GetScreen()->m_Active_Layer; ll = GetScreen()->m_Active_Layer;
if( (ll < COPPER_LAYER_N) || (ll >= CMP_N) ) if( (ll < FIRST_COPPER_LAYER) || (ll >= LAST_COPPER_LAYER) )
break; break;
if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) // Single layer if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) // Single layer
ll = COPPER_LAYER_N; ll = COPPER_LAYER_N;
else if( ll >= m_Pcb->m_BoardSettings->m_CopperLayerCount - 2 ) else if( ll >= m_Pcb->m_BoardSettings->m_CopperLayerCount - 2 )
ll = CMP_N; ll = LAST_COPPER_LAYER;
else else
ll++; ll++;
SwitchLayer( DC, ll ); SwitchLayer( DC, ll );
...@@ -299,7 +299,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -299,7 +299,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_BACK_SPACE: case HK_BACK_SPACE:
if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= CMP_N ) if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= LAST_COPPER_LAYER )
{ {
if( ItemFree ) if( ItemFree )
{ {
...@@ -570,7 +570,7 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) ...@@ -570,7 +570,7 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
switch( m_ID_current_state ) switch( m_ID_current_state )
{ {
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if( GetScreen()->m_Active_Layer > CMP_N ) if( GetScreen()->m_Active_Layer > LAST_COPPER_LAYER )
return FALSE; return FALSE;
if( ItemFree ) if( ItemFree )
{ {
......
...@@ -163,9 +163,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -163,9 +163,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( m_ID_current_state == ID_PCB_ARC_BUTT ) if( m_ID_current_state == ID_PCB_ARC_BUTT )
shape = S_ARC; shape = S_ARC;
if( GetScreen()->m_Active_Layer <= CMP_N ) if( GetScreen()->m_Active_Layer <= LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Graphic not autorized on Copper layers" ) ); DisplayError( this, _( "Graphic not authorized on Copper layers" ) );
break; break;
} }
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
...@@ -186,7 +186,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -186,7 +186,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if( GetScreen()->m_Active_Layer > CMP_N ) if( GetScreen()->m_Active_Layer > LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Tracks on Copper layers only " ) ); DisplayError( this, _( "Tracks on Copper layers only " ) );
break; break;
...@@ -262,9 +262,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -262,9 +262,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_PCB_COTATION_BUTT: case ID_PCB_COTATION_BUTT:
if( GetScreen()->m_Active_Layer <= CMP_N ) if( GetScreen()->m_Active_Layer <= LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Cotation not autorized on Copper layers" ) ); DisplayError( this, _( "Cotation not authorized on Copper layers" ) );
break; break;
} }
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
...@@ -426,4 +426,3 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -426,4 +426,3 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break; break;
} }
} }
/****************************************/ /****************************************/
/**** Routine de trace GERBER RS274X ****/ /**** Routine de trace GERBER RS274X ****/
/****************************************/ /****************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
/* Variables locales : */ /* Variables locales : */
static int s_Last_D_code ; static int s_Last_D_code;
static float Gerb_scale_plot; /*Coeff de conversion d'unites des traces */ static float Gerb_scale_plot; // Coeff de conversion d'unites des traces
static int scale_spot_mini; /* Ouverture mini (pour remplissages) */ static int scale_spot_mini; // Ouverture mini (pour remplissages)
static D_CODE * s_DCodeList; /* Pointeur sur la zone de stockage des D_CODES */ static D_CODE * s_DCodeList; // Pointeur sur la zone de stockage des D_CODES
wxString GerberFullFileName; wxString GerberFullFileName;
static double scale_x , scale_y ; /* echelles de convertion en X et Y (compte tenu static double scale_x, scale_y; // echelles de convertion en X et Y (compte tenu
des unites relatives du PCB et des traceurs*/ // des unites relatives du PCB et des traceurs
static bool ShowDcodeError = TRUE; static bool ShowDcodeError = TRUE;
/* Routines Locales */ /* Routines Locales */
...@@ -29,22 +29,23 @@ static bool ShowDcodeError = TRUE; ...@@ -29,22 +29,23 @@ static bool ShowDcodeError = TRUE;
static void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile); static void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile);
static void Init_ApertureList(); static void Init_ApertureList();
static void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile); static void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile);
static void Plot_1_CIRCLE_pad_GERBER(wxPoint pos,int diametre) ; static void Plot_1_CIRCLE_pad_GERBER(wxPoint pos, int diametre);
static void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size,int orient); static void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient);
static void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient); static void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient);
static D_CODE * get_D_code(int dx,int dy, int type, int drill ) ; static D_CODE * get_D_code(int dx, int dy, int type, int drill);
static void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta, static void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size, wxSize delta,
int orient,int modetrace); int orient, int modetrace);
/********************************************************************************/ /********************************************************************************/
void WinEDA_BasePcbFrame::Genere_GERBER(const wxString & FullFileName, int Layer, void WinEDA_BasePcbFrame::Genere_GERBER(const wxString & FullFileName, int Layer,
bool PlotOriginIsAuxAxis) bool PlotOriginIsAuxAxis)
/********************************************************************************/ /********************************************************************************/
/* Genere les divers fichiers de trace: /* Genere les divers fichiers de trace:
Pour chaque couche 1 fichier xxxc.PHO au format RS274X * Pour chaque couche 1 fichier xxxc.PHO au format RS274X
*/ */
{ {
int tracevia = 1; int tracevia = 1;
...@@ -52,25 +53,25 @@ int tracevia = 1; ...@@ -52,25 +53,25 @@ int tracevia = 1;
GerberFullFileName = FullFileName; GerberFullFileName = FullFileName;
g_PlotOrient = 0; g_PlotOrient = 0;
if (Plot_Set_MIROIR) g_PlotOrient |= PLOT_MIROIR; if( Plot_Set_MIROIR )
g_PlotOrient |= PLOT_MIROIR;
/* Calcul des echelles de conversion */ /* Calcul des echelles de conversion */
Gerb_scale_plot = 1.0; /* pour unites gerber en 0,1 Mils, format 3.4 */ Gerb_scale_plot = 1.0; /* pour unites gerber en 0,1 Mils, format 3.4 */
scale_spot_mini = (int)(spot_mini * 10 * Gerb_scale_plot); scale_spot_mini = (int)(10 * spot_mini * Gerb_scale_plot);
scale_x = Scale_X * Gerb_scale_plot; scale_x = Scale_X * Gerb_scale_plot;
scale_y = Scale_Y * Gerb_scale_plot; scale_y = Scale_Y * Gerb_scale_plot;
g_PlotOffset.x = 0; g_PlotOffset.x = 0;
g_PlotOffset.y = 0; g_PlotOffset.y = 0;
if ( PlotOriginIsAuxAxis ) if( PlotOriginIsAuxAxis )
{
g_PlotOffset = m_Auxiliary_Axis_Position; g_PlotOffset = m_Auxiliary_Axis_Position;
}
dest = wxFopen(FullFileName, wxT("wt")); dest = wxFopen( FullFileName, wxT("wt") );
if (dest == NULL) if( dest == NULL )
{ {
wxString msg = _("unable to create file ") + FullFileName; wxString msg = _("unable to create file ") + FullFileName;
DisplayError(this, msg); return ; DisplayError(this, msg);
return;
} }
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
...@@ -80,11 +81,11 @@ int tracevia = 1; ...@@ -80,11 +81,11 @@ int tracevia = 1;
/* Clear the memory used for handle the D_CODE (aperture) list */ /* Clear the memory used for handle the D_CODE (aperture) list */
Init_ApertureList(); Init_ApertureList();
Affiche_1_Parametre(this, 0, _("File"),FullFileName,CYAN) ; Affiche_1_Parametre(this, 0, _("File"), FullFileName, CYAN);
Init_Trace_GERBER(this, dest) ; Init_Trace_GERBER(this, dest);
nb_plot_erreur = 0 ; nb_plot_erreur = 0;
int layer_mask = g_TabOneLayerMask[Layer]; int layer_mask = g_TabOneLayerMask[Layer];
// Specify that the contents of the "Edges Pcb" layer are also to be // Specify that the contents of the "Edges Pcb" layer are also to be
...@@ -92,46 +93,48 @@ int tracevia = 1; ...@@ -92,46 +93,48 @@ int tracevia = 1;
if( ! Exclude_Edges_Pcb ) if( ! Exclude_Edges_Pcb )
layer_mask |= EDGE_LAYER; layer_mask |= EDGE_LAYER;
switch(Layer) switch( Layer )
{ {
case COPPER_LAYER_N : case FIRST_COPPER_LAYER:
case LAYER_N_2 : case LAYER_N_2:
case LAYER_N_3 : case LAYER_N_3:
case LAYER_N_4 : case LAYER_N_4:
case LAYER_N_5 : case LAYER_N_5:
case LAYER_N_6 : case LAYER_N_6:
case LAYER_N_7 : case LAYER_N_7:
case LAYER_N_8 : case LAYER_N_8:
case LAYER_N_9 : case LAYER_N_9:
case LAYER_N_10 : case LAYER_N_10:
case LAYER_N_11: case LAYER_N_11:
case LAYER_N_12: case LAYER_N_12:
case LAYER_N_13 : case LAYER_N_13:
case LAYER_N_14 : case LAYER_N_14:
case LAYER_N_15 : case LAYER_N_15:
case CMP_N : case LAST_COPPER_LAYER:
Plot_Layer_GERBER(dest, layer_mask, 0, 1); Plot_Layer_GERBER(dest, layer_mask, 0, 1);
break; break;
case SOLDERMASK_N_CU : case SOLDERMASK_N_CU:
case SOLDERMASK_N_CMP : /* Trace du vernis epargne */ case SOLDERMASK_N_CMP: /* Trace du vernis epargne */
if ( g_DrawViaOnMaskLayer ) tracevia = 1; if( g_DrawViaOnMaskLayer )
else tracevia = 0; tracevia = 1;
Plot_Layer_GERBER(dest, layer_mask, g_DesignSettings.m_MaskMargin, tracevia); else
break; tracevia = 0;
Plot_Layer_GERBER(dest, layer_mask, g_DesignSettings.m_MaskMargin, tracevia);
case SOLDERPASTE_N_CU : break;
case SOLDERPASTE_N_CMP : /* Trace du masque de pate de soudure */
Plot_Layer_GERBER(dest, layer_mask, 0, 0); case SOLDERPASTE_N_CU:
break; case SOLDERPASTE_N_CMP: /* Trace du masque de pate de soudure */
Plot_Layer_GERBER(dest, layer_mask, 0, 0);
default: break;
Plot_Serigraphie(PLOT_FORMAT_GERBER, dest, layer_mask);
break; default:
} Plot_Serigraphie(PLOT_FORMAT_GERBER, dest, layer_mask);
break;
}
Fin_Trace_GERBER(this, dest) ; Fin_Trace_GERBER( this, dest );
setlocale(LC_NUMERIC, ""); setlocale( LC_NUMERIC, "" );
} }
...@@ -139,8 +142,9 @@ int tracevia = 1; ...@@ -139,8 +142,9 @@ int tracevia = 1;
void WinEDA_BasePcbFrame::Plot_Layer_GERBER(FILE * File,int masque_layer, void WinEDA_BasePcbFrame::Plot_Layer_GERBER(FILE * File,int masque_layer,
int garde, int tracevia) int garde, int tracevia)
/***********************************************************************/ /***********************************************************************/
/* Trace en format GERBER. d'une couche cuivre ou masque /* Trace en format GERBER. d'une couche cuivre ou masque
*/ */
{ {
wxPoint pos; wxPoint pos;
wxSize size; wxSize size;
...@@ -150,179 +154,198 @@ TRACK * track ; ...@@ -150,179 +154,198 @@ TRACK * track ;
EDA_BaseStruct * PtStruct; EDA_BaseStruct * PtStruct;
wxString msg; wxString msg;
// (Following command has been superceded by new command on lines 92 and 93.) // (Following command has been superceded by new command on lines 93 and 94.)
// masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */ // masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */
/* trace des elements type Drawings Pcb : */ /* trace des elements type Drawings Pcb : */
PtStruct = m_Pcb->m_Drawings; PtStruct = m_Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_GERBER, PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_GERBER,
masque_layer ); masque_layer );
break; break;
case TYPETEXTE: case TYPETEXTE:
PlotTextePcb( (TEXTE_PCB*) PtStruct, PLOT_FORMAT_GERBER, PlotTextePcb( (TEXTE_PCB*) PtStruct, PLOT_FORMAT_GERBER,
masque_layer ); masque_layer );
break; break;
case TYPECOTATION: case TYPECOTATION:
PlotCotation( (COTATION*) PtStruct, PLOT_FORMAT_GERBER, PlotCotation( (COTATION*) PtStruct, PLOT_FORMAT_GERBER,
masque_layer ); masque_layer );
break; break;
case TYPEMIRE: case TYPEMIRE:
PlotMirePcb( (MIREPCB*) PtStruct, PLOT_FORMAT_GERBER, PlotMirePcb( (MIREPCB*) PtStruct, PLOT_FORMAT_GERBER,
masque_layer ); masque_layer );
break; break;
case TYPEMARQUEUR: case TYPEMARQUEUR:
break; break;
default: default:
DisplayError(this, wxT("Type Draw non gere")); DisplayError( this, wxT("Type Draw non gere") );
break; break;
}
} }
}
/* Trace des Elements des modules autres que pads */ /* Trace des Elements des modules autres que pads */
nb_items = 0 ; nb_items = 0;
Affiche_1_Parametre(this, 38, wxT("DrawMod"), wxEmptyString,GREEN) ; Affiche_1_Parametre(this, 38, wxT("DrawMod"), 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 )
{
PtStruct = Module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
PtStruct = Module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEEDGEMODULE: case TYPEEDGEMODULE:
if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->GetLayer()] ) if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->GetLayer()] )
Plot_1_EdgeModule(PLOT_FORMAT_GERBER, (EDGE_MODULE*) PtStruct); Plot_1_EdgeModule(PLOT_FORMAT_GERBER, (EDGE_MODULE*) PtStruct);
break; break;
default: break; default:
} break;
} }
} }
}
/* Trace des Elements des modules : Pastilles */ /* Trace des Elements des modules : Pastilles */
nb_items = 0 ; nb_items = 0;
Affiche_1_Parametre(this, 48, wxT("Pads"),wxEmptyString,GREEN) ; Affiche_1_Parametre(this, 48, 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 )
{ {
PtPad = (D_PAD*) Module->m_Pads; PtPad = (D_PAD*) Module->m_Pads;
for ( ; PtPad != NULL ; PtPad = (D_PAD*)PtPad->Pnext ) for( ; PtPad != NULL; PtPad = (D_PAD*)PtPad->Pnext )
{ {
wxPoint shape_pos; wxPoint shape_pos;
if( (PtPad->m_Masque_Layer & masque_layer) == 0) if( (PtPad->m_Masque_Layer & masque_layer) == 0 )
continue ; continue;
shape_pos = PtPad->ReturnShapePos(); shape_pos = PtPad->ReturnShapePos();
pos = shape_pos; pos = shape_pos;
size.x = PtPad->m_Size.x + (garde * 2) ; size.x = PtPad->m_Size.x + 2 * garde;
size.y = PtPad->m_Size.y + (garde * 2) ; size.y = PtPad->m_Size.y + 2 * garde;
/* Don't draw a null size item : */ /* Don't draw a null size item : */
if ( (size.x == 0) || (size.y == 0) ) continue; if( size.x <= 0 || size.y <= 0 )
continue;
nb_items++ ; nb_items++;
switch (PtPad->m_PadShape) switch( PtPad->m_PadShape )
{ {
case CIRCLE : case CIRCLE:
Plot_1_CIRCLE_pad_GERBER(pos,size.x) ; Plot_1_CIRCLE_pad_GERBER(pos, size.x);
break ; break;
case OVALE : case OVALE:
{ // Check whether the pad really has a circular shape instead
trace_1_pastille_OVALE_GERBER(pos, size,PtPad->m_Orient); if( size.x == size.y )
break ; Plot_1_CIRCLE_pad_GERBER(pos, size.x);
} else
trace_1_pastille_OVALE_GERBER(pos, size, PtPad->m_Orient);
case TRAPEZE : break;
{
case TRAPEZE:
{
wxSize delta = PtPad->m_DeltaSize; wxSize delta = PtPad->m_DeltaSize;
trace_1_pad_TRAPEZE_GERBER(pos,size, trace_1_pad_TRAPEZE_GERBER(pos, size,
delta, PtPad->m_Orient, FILLED) ; delta, PtPad->m_Orient, FILLED);
break ; }
} break;
case RECT: case RECT:
default: default:
PlotRectangularPad_GERBER(pos,size, PtPad->m_Orient) ; PlotRectangularPad_GERBER(pos, size, PtPad->m_Orient);
break ; break;
} }
msg.Printf( wxT("%d"),nb_items) ; msg.Printf( wxT("%d"), nb_items );
Affiche_1_Parametre(this, 48,wxEmptyString, msg,GREEN) ; Affiche_1_Parametre(this, 48, wxEmptyString, msg, GREEN);
} }
} }
/* trace des VIAS : */ /* trace des VIAS : */
if(tracevia) if( tracevia )
{ {
nb_items = 0 ; nb_items = 0;
Affiche_1_Parametre(this, 56, wxT("Vias"), wxEmptyString,RED) ; Affiche_1_Parametre(this, 56, wxT("Vias"), wxEmptyString, RED);
for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext) for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
{ {
if( track->Type() != TYPEVIA ) continue; if( track->Type() != TYPEVIA )
continue;
SEGVIA * Via = (SEGVIA *) track; SEGVIA * Via = (SEGVIA *) track;
/* vias not plotted if not on selected layer, but if layer // vias not plotted if not on selected layer, but if layer
== SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn , // == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn,
if they are on a external copper layer // if they are on a external copper layer
*/
int via_mask_layer = Via->ReturnMaskLayer(); int via_mask_layer = Via->ReturnMaskLayer();
if ( (via_mask_layer & CUIVRE_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CU; if( via_mask_layer & CUIVRE_LAYER )
if ( (via_mask_layer & CMP_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CMP; via_mask_layer |= SOLDERMASK_LAYER_CU;
if( (via_mask_layer & masque_layer) == 0 ) continue; if( via_mask_layer & CMP_LAYER )
via_mask_layer |= SOLDERMASK_LAYER_CMP;
if( ( via_mask_layer & masque_layer) == 0 )
continue;
pos = Via->m_Start; pos = Via->m_Start;
size.x = size.y = Via->m_Width + (garde * 2); size.x = size.y = Via->m_Width + 2 * garde;
Plot_1_CIRCLE_pad_GERBER(pos,size.x) ; /* Don't draw a null size item : */
nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; if( size.x <= 0 )
Affiche_1_Parametre(this, 56,wxEmptyString, msg,RED) ; continue;
Plot_1_CIRCLE_pad_GERBER(pos, size.x);
nb_items++;
msg.Printf( wxT("%d"), nb_items );
Affiche_1_Parametre(this, 56, wxEmptyString, msg, RED);
} }
} }
/* trace des pistes : */ /* trace des pistes : */
nb_items = 0 ; nb_items = 0;
Affiche_1_Parametre(this, 64, wxT("Tracks"),wxEmptyString,YELLOW) ; Affiche_1_Parametre(this, 64, wxT("Tracks"), wxEmptyString, YELLOW);
for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext) for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
{ {
wxPoint end; wxPoint end;
if ( track->Type() == TYPEVIA ) continue ; if( track->Type() == TYPEVIA )
if( (g_TabOneLayerMask[track->GetLayer()] & masque_layer) == 0 ) continue; continue;
if( (g_TabOneLayerMask[track->GetLayer()] & masque_layer) == 0 )
continue;
size.x = size.y = track->m_Width; size.x = size.y = track->m_Width;
pos = track->m_Start; end = track->m_End; pos = track->m_Start;
end = track->m_End;
PlotGERBERLine(pos,end, size.x) ; PlotGERBERLine(pos, end, size.x);
nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; nb_items++;
Affiche_1_Parametre(this, 64, wxEmptyString, msg,YELLOW) ; msg.Printf( wxT("%d"), nb_items );
Affiche_1_Parametre(this, 64, wxEmptyString, msg, YELLOW);
} }
/* trace des zones: */ /* trace des zones: */
nb_items = 0 ; nb_items = 0;
if ( m_Pcb->m_Zone ) Affiche_1_Parametre(this, 72, wxT("Zones "),wxEmptyString,YELLOW) ; if( m_Pcb->m_Zone )
Affiche_1_Parametre(this, 72, wxT("Zones "), wxEmptyString, YELLOW);
for( track = m_Pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext) for( track = m_Pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext )
{ {
wxPoint end; wxPoint end;
if( (g_TabOneLayerMask[track->GetLayer()] & masque_layer) == 0 ) continue; if( (g_TabOneLayerMask[track->GetLayer()] & masque_layer) == 0 )
continue;
size.x = size.y = track->m_Width; size.x = size.y = track->m_Width;
pos = track->m_Start; end = track->m_End; pos = track->m_Start;
end = track->m_End;
PlotGERBERLine(pos,end, size.x) ; PlotGERBERLine(pos, end, size.x);
nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; nb_items++;
Affiche_1_Parametre(this, 72, wxEmptyString,msg,YELLOW) ; msg.Printf( wxT("%d"), nb_items );
Affiche_1_Parametre(this, 72, wxEmptyString, msg, YELLOW);
} }
} }
...@@ -330,53 +353,57 @@ wxString msg; ...@@ -330,53 +353,57 @@ wxString msg;
/**********************************************************************/ /**********************************************************************/
void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient) void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient)
/**********************************************************************/ /**********************************************************************/
/* Trace 1 pastille OVALE en position pos_X,Y: /* Trace 1 pastille OVALE en position pos_X,Y:
dimensions dx,dy, * dimensions dx, dy,
orientation orient * orientation orient
Pour une orientation verticale ou horizontale, la forme est flashee * Pour une orientation verticale ou horizontale, la forme est flashee
Pour une orientation quelconque la forme est tracee comme un segment * Pour une orientation quelconque la forme est tracee comme un segment
*/ */
{ {
D_CODE * dcode_ptr; D_CODE * dcode_ptr;
int x0, y0, x1, y1, delta; int x0, y0, x1, y1, delta;
if( (orient == 900) || (orient == 2700)) /* orient tournee de 90 deg */ if( orient == 900 || orient == 2700 ) /* orient tournee de 90 deg */
{ EXCHG(size.x, size.y);
EXCHG(size.x,size.y);
}
/* Trace de la forme flashee */ /* Trace de la forme flashee */
if( (orient == 0) || (orient == 900) || if( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
(orient == 1800) || (orient == 2700) )
{ {
UserToDeviceCoordinate(pos) ; UserToDeviceCoordinate(pos);
UserToDeviceSize(size); UserToDeviceSize(size);
dcode_ptr = get_D_code(size.x,size.y,GERB_OVALE,0) ; dcode_ptr = get_D_code(size.x, size.y, GERB_OVALE, 0);
if (dcode_ptr->m_NumDcode != s_Last_D_code ) if( dcode_ptr->m_NumDcode != s_Last_D_code )
{ {
sprintf(cbuf,"G54D%d*\n",dcode_ptr->m_NumDcode) ; sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode);
fputs(cbuf,dest) ; fputs(cbuf, dest);
s_Last_D_code = dcode_ptr->m_NumDcode; s_Last_D_code = dcode_ptr->m_NumDcode;
} }
sprintf(cbuf,"X%5.5dY%5.5dD03*\n", pos.x, pos.y); sprintf(cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y);
fputs(cbuf,dest) ; fputs(cbuf, dest);
} }
else /* Forme tracee comme un segment */ else /* Forme tracee comme un segment */
{ {
if(size.x > size.y ) if( size.x > size.y )
{ {
EXCHG(size.x,size.y); orient += 900; EXCHG(size.x, size.y);
if( orient < 2700 )
orient += 900;
else
orient -= 2700;
} }
/* la pastille est ramenee a une pastille ovale avec dy > dx */ /* la pastille est ramenee a une pastille ovale avec dy > dx */
delta = size.y - size.x; delta = size.y - size.x;
x0 = 0; y0 = -delta / 2; x0 = 0;
x1 = 0; y1 = delta / 2; y0 = -delta / 2;
RotatePoint(&x0,&y0, orient); x1 = 0;
RotatePoint(&x1,&y1, orient); y1 = delta / 2;
RotatePoint(&x0, &y0, orient);
RotatePoint(&x1, &y1, orient);
PlotGERBERLine( wxPoint(pos.x + x0, pos.y + y0), PlotGERBERLine( wxPoint(pos.x + x0, pos.y + y0),
wxPoint(pos.x + x1, pos.y + y1), size.x); wxPoint(pos.x + x1, pos.y + y1), size.x );
} }
} }
...@@ -384,8 +411,9 @@ int x0, y0, x1, y1, delta; ...@@ -384,8 +411,9 @@ int x0, y0, x1, y1, delta;
/******************************************************************/ /******************************************************************/
void Plot_1_CIRCLE_pad_GERBER(wxPoint pos,int diametre) void Plot_1_CIRCLE_pad_GERBER(wxPoint pos,int diametre)
/******************************************************************/ /******************************************************************/
/* Plot a circulat pad or via at the user position pos
*/ /* Plot a circular pad or via at the user position pos
*/
{ {
D_CODE * dcode_ptr; D_CODE * dcode_ptr;
wxSize size(diametre, diametre); wxSize size(diametre, diametre);
...@@ -393,56 +421,59 @@ wxSize size(diametre, diametre); ...@@ -393,56 +421,59 @@ wxSize size(diametre, diametre);
UserToDeviceCoordinate(pos); UserToDeviceCoordinate(pos);
UserToDeviceSize(size); UserToDeviceSize(size);
dcode_ptr = get_D_code(size.x,size.x,GERB_CIRCLE,0) ; dcode_ptr = get_D_code(size.x, size.x, GERB_CIRCLE, 0);
if (dcode_ptr->m_NumDcode != s_Last_D_code ) if( dcode_ptr->m_NumDcode != s_Last_D_code )
{ {
sprintf(cbuf,"G54D%d*\n", dcode_ptr->m_NumDcode) ; sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode);
fputs(cbuf,dest) ; fputs(cbuf, dest);
s_Last_D_code = dcode_ptr->m_NumDcode; s_Last_D_code = dcode_ptr->m_NumDcode;
} }
sprintf(cbuf,"X%5.5dY%5.5dD03*\n", pos.x, pos.y); sprintf(cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y);
fputs(cbuf,dest) ; fputs(cbuf, dest);
} }
/**************************************************************************/ /**************************************************************************/
void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient) void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient)
/**************************************************************************/ /**************************************************************************/
/*
Trace 1 pad rectangulaire d'orientation quelconque /* Trace 1 pad rectangulaire d'orientation quelconque
donne par son centre, ses dimensions, et son orientation * donne par son centre, ses dimensions, et son orientation
Pour une orientation verticale ou horizontale, la forme est flashee * Pour une orientation verticale ou horizontale, la forme est flashee
Pour une orientation quelconque la forme est tracee par 4 segments * Pour une orientation quelconque la forme est tracee par 4 segments
de largeur 1/2 largeur pad * de largeur 1/2 largeur pad
*/ */
{ {
D_CODE * dcode_ptr; D_CODE * dcode_ptr;
/* Trace de la forme flashee */ /* Trace de la forme flashee */
switch (orient) switch( orient )
{ {
case 900 : case 900:
case 2700 : /* la rotation de 90 ou 270 degres revient a permutter des dimensions */ case 2700: /* la rotation de 90 ou 270 degres revient a permutter des dimensions */
EXCHG(size.x,size.y); EXCHG(size.x, size.y);
case 1800 : // Pass through
case 0 :
UserToDeviceCoordinate(pos) ;
UserToDeviceSize(size);
dcode_ptr = get_D_code(size.x,size.y,GERB_RECT,0) ;
if (dcode_ptr->m_NumDcode != s_Last_D_code )
{
sprintf(cbuf,"G54D%d*\n", dcode_ptr->m_NumDcode) ;
fputs(cbuf,dest) ;
s_Last_D_code = dcode_ptr->m_NumDcode;
}
sprintf(cbuf,"X%5.5dY%5.5dD03*\n", pos.x, pos.y);
fputs(cbuf,dest) ;
break;
default: /* Forme tracee par remplissage */ case 0:
trace_1_pad_TRAPEZE_GERBER(pos, size, wxSize(0, 0), orient,FILLED); case 1800:
break; UserToDeviceCoordinate(pos);
UserToDeviceSize(size);
dcode_ptr = get_D_code(size.x, size.y, GERB_RECT, 0);
if( dcode_ptr->m_NumDcode != s_Last_D_code )
{
sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode);
fputs(cbuf, dest);
s_Last_D_code = dcode_ptr->m_NumDcode;
}
sprintf(cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y);
fputs(cbuf, dest);
break;
default: /* Forme tracee par remplissage */
trace_1_pad_TRAPEZE_GERBER(pos, size, wxSize(0, 0), orient, FILLED);
break;
} }
} }
...@@ -451,20 +482,22 @@ D_CODE * dcode_ptr; ...@@ -451,20 +482,22 @@ D_CODE * dcode_ptr;
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 /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque
donne par son centre, * donne par son centre,
ses dimensions , * ses dimensions ,
ses variations , * ses variations ,
l'epaisseur du trait, * l'epaisseur du trait,
et son orientation orient * et son orientation orient
*/ */
{ {
int ii; int ii;
wxPoint coord[4]; wxPoint coord[4];
size.x /= 2; size.y /= 2 ; size.x /= 2;
delta.x /= 2; delta.y /= 2 ; /* demi dim dx et dy */ size.y /= 2;
delta.x /= 2;
delta.y /= 2; /* demi dim dx et dy */
coord[0].x = pos.x - size.x - delta.y; coord[0].x = pos.x - size.x - delta.y;
coord[0].y = pos.y + size.y + delta.x; coord[0].y = pos.y + size.y + delta.x;
...@@ -478,16 +511,15 @@ wxPoint coord[4]; ...@@ -478,16 +511,15 @@ wxPoint coord[4];
coord[3].x = pos.x + size.x + delta.y; coord[3].x = pos.x + size.x + delta.y;
coord[3].y = pos.y + size.y - delta.x; coord[3].y = pos.y + size.y - delta.x;
for (ii = 0; ii < 4; ii++) for( ii = 0; ii < 4; ii++ )
{ {
RotatePoint(&coord[ii].x, &coord[ii].y, pos.x, pos.y, orient); RotatePoint(&coord[ii].x, &coord[ii].y, pos.x, pos.y, orient);
} }
PlotGERBERLine( coord[0], coord[1], penwidth); PlotGERBERLine( coord[0], coord[1], penwidth );
PlotGERBERLine( coord[1], coord[2], penwidth); PlotGERBERLine( coord[1], coord[2], penwidth );
PlotGERBERLine( coord[2], coord[3], penwidth); PlotGERBERLine( coord[2], coord[3], penwidth );
PlotGERBERLine( coord[3], coord[0], penwidth); PlotGERBERLine( coord[3], coord[0], penwidth );
} }
...@@ -496,69 +528,74 @@ void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta, ...@@ -496,69 +528,74 @@ void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta,
int orient,int modetrace) int orient,int modetrace)
/*******************************************************************/ /*******************************************************************/
/* /* Trace 1 pad trapezoidal donne par :
Trace 1 pad trapezoidal donne par : * son centre pos.x,pos.y
son centre pos.x,pos.y * ses dimensions size.x et size.y
ses dimensions size.x et size.y * les variations delta.x et delta.y ( 1 des deux au moins doit etre nulle)
les variations delta.x et delta.y ( 1 des deux au moins doit etre nulle) * son orientation orient en 0.1 degres
son orientation orient en 0.1 degres * le mode de trace (FILLED, SKETCH, FILAIRE)
le mode de trace (FILLED, SKETCH, FILAIRE) *
* Le trace n'est fait que pour un trapeze, c.a.d que delta.x ou delta.y
Le trace n'est fait que pour un trapeze, c.a.d que delta.x ou delta.y * = 0.
= 0. *
* les notation des sommets sont ( vis a vis de la table tracante )
les notation des sommets sont ( vis a vis de la table tracante ) *
* " 0 ------------- 3 "
" 0 ------------- 3 " * " . . "
" . . " * " . O . "
" . O . " * " . . "
" . . " * " 1 ---- 2 "
" 1 ---- 2 " *
*
* exemple de Disposition pour delta.y > 0, delta.x = 0
exemple de Disposition pour delta.y > 0, delta.x = 0 * " 1 ---- 2 "
" 1 ---- 2 " * " . . "
" . . " * " . O . "
" . O . " * " . . "
" . . " * " 0 ------------- 3 "
" 0 ------------- 3 " *
*
* exemple de Disposition pour delta.y = 0, delta.x > 0
exemple de Disposition pour delta.y = 0, delta.x > 0 * " 0 "
" 0 " * " . . "
" . . " * " . . "
" . . " * " . 3 "
" . 3 " * " . . "
" . . " * " . O . "
" . O . " * " . . "
" . . " * " . 2 "
" . 2 " * " . . "
" . . " * " . . "
" . . " * " 1 "
" 1 " */
*/
{ {
int ii , jj; int ii, jj;
int dx,dy; int dx, dy;
wxPoint polygone[4]; /* coord sommets */ wxPoint polygone[4]; /* coord sommets */
int coord[8]; int coord[8];
int ddx, ddy ; int ddx, ddy;
/* calcul des dimensions optimales du spot choisi = 1/4 plus petite dim */ /* calcul des dimensions optimales du spot choisi = 1/4 plus petite dim */
dx = size.x - abs(delta.y); dx = size.x - abs(delta.y);
dy = size.y - abs(delta.x); dy = size.y - abs(delta.x);
dx = size.x / 2; dy = size.y / 2 ; dx = size.x / 2;
ddx = delta.x / 2; ddy = delta.y / 2 ; dy = size.y / 2;
ddx = delta.x / 2;
ddy = delta.y / 2;
polygone[0].x = - dx - ddy; polygone[0].y = + dy + ddx; polygone[0].x = - dx - ddy;
polygone[1].x = - dx + ddy; polygone[1].y = - dy - ddx; polygone[0].y = + dy + ddx;
polygone[2].x = + dx - ddy; polygone[2].y = - dy + ddx; polygone[1].x = - dx + ddy;
polygone[3].x = + dx + ddy; polygone[3].y = + dy - ddx; polygone[1].y = - dy - ddx;
polygone[2].x = + dx - ddy;
polygone[2].y = - dy + ddx;
polygone[3].x = + dx + ddy;
polygone[3].y = + dy - ddx;
/* Dessin du polygone et Remplissage eventuel de l'interieur */ /* Dessin du polygone et Remplissage eventuel de l'interieur */
for (ii = 0, jj = 0; ii < 4; ii++) for( ii = 0, jj = 0; ii < 4; ii++ )
{ {
RotatePoint(&polygone[ii].x, &polygone[ii].y, orient); RotatePoint(&polygone[ii].x, &polygone[ii].y, orient);
coord[jj] = polygone[ii].x += pos.x; coord[jj] = polygone[ii].x += pos.x;
...@@ -567,12 +604,12 @@ int ddx, ddy ; ...@@ -567,12 +604,12 @@ int ddx, ddy ;
jj++; jj++;
} }
if(modetrace != FILLED ) if( modetrace != FILLED )
{ {
PlotGERBERLine( polygone[0], polygone[1], scale_spot_mini); PlotGERBERLine( polygone[0], polygone[1], scale_spot_mini );
PlotGERBERLine( polygone[1], polygone[2], scale_spot_mini); PlotGERBERLine( polygone[1], polygone[2], scale_spot_mini );
PlotGERBERLine( polygone[2], polygone[3], scale_spot_mini); PlotGERBERLine( polygone[2], polygone[3], scale_spot_mini );
PlotGERBERLine( polygone[3], polygone[0], scale_spot_mini); PlotGERBERLine( polygone[3], polygone[0], scale_spot_mini );
} }
else else
...@@ -583,52 +620,63 @@ int ddx, ddy ; ...@@ -583,52 +620,63 @@ int ddx, ddy ;
/**********************************************************/ /**********************************************************/
void PlotGERBERLine(wxPoint start, wxPoint end, int large) void PlotGERBERLine(wxPoint start, wxPoint end, int large)
/**********************************************************/ /**********************************************************/
/* Trace 1 segment de piste : /* Trace 1 segment de piste :
*/ */
{ {
D_CODE * dcode_ptr; D_CODE * dcode_ptr;
UserToDeviceCoordinate(start); UserToDeviceCoordinate(start);
UserToDeviceCoordinate(end); UserToDeviceCoordinate(end);
dcode_ptr = get_D_code(large,large,GERB_LINE,0) ; dcode_ptr = get_D_code(large, large, GERB_LINE, 0);
if (dcode_ptr->m_NumDcode != s_Last_D_code ) if(dcode_ptr->m_NumDcode != s_Last_D_code )
{ {
sprintf(cbuf,"G54D%d*\n", dcode_ptr->m_NumDcode) ; sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode);
fputs(cbuf,dest) ; fputs(cbuf, dest);
s_Last_D_code = dcode_ptr->m_NumDcode; s_Last_D_code = dcode_ptr->m_NumDcode;
} }
sprintf(cbuf,"X%5.5dY%5.5dD02*\n",start.x,start.y) ; fputs(cbuf,dest) ; sprintf(cbuf, "X%5.5dY%5.5dD02*\n", start.x, start.y);
sprintf(cbuf,"X%5.5dY%5.5dD01*\n",end.x,end.y) ; fputs(cbuf,dest) ; fputs(cbuf, dest);
sprintf(cbuf, "X%5.5dY%5.5dD01*\n", end.x, end.y);
fputs(cbuf, dest);
} }
/********************************************************************/ /********************************************************************/
void PlotCircle_GERBER( wxPoint centre, int rayon, int epaisseur) void PlotCircle_GERBER( wxPoint centre, int rayon, int epaisseur )
/********************************************************************/ /********************************************************************/
/* routine de trace de 1 cercle de centre centre par approximation de segments /* routine de trace de 1 cercle de centre centre par approximation de segments
*/ */
{ {
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 */
delta = 120; /* un cercle sera trace en 3600/delta segments */ delta = 120; /* un cercle sera trace en 3600/delta segments */
/* 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 * 2) ) delta = 600; /* 6 segm pour 360 deg */ if( rayon < (epaisseur * 5) )
delta = 300; /* 12 segm pour 360 deg */
ox = centre.x + rayon; oy = centre.y; if( rayon < (epaisseur * 2) )
for (ii = delta ; ii < 3600 ; ii += delta ) delta = 600; /* 6 segm pour 360 deg */
{
ox = centre.x + rayon;
oy = centre.y;
for( ii = delta; ii < 3600; ii += delta )
{
fx = centre.x + (int)(rayon * fcosinus[ii]); fx = centre.x + (int)(rayon * fcosinus[ii]);
fy = centre.y + (int)(rayon * fsinus[ii]); fy = centre.y + (int)(rayon * fsinus[ii]);
PlotGERBERLine(wxPoint(ox,oy), wxPoint(fx,fy), epaisseur) ; PlotGERBERLine(wxPoint(ox, oy), wxPoint(fx, fy), epaisseur);
ox = fx; oy = fy; ox = fx;
} oy = fy;
}
fx = centre.x + rayon; fy = centre.y; fx = centre.x + rayon;
PlotGERBERLine(wxPoint(ox,oy), wxPoint(fx,fy), epaisseur) ; fy = centre.y;
PlotGERBERLine(wxPoint(ox ,oy), wxPoint(fx, fy), epaisseur);
} }
...@@ -640,16 +688,20 @@ int ii; ...@@ -640,16 +688,20 @@ int ii;
wxPoint pos; wxPoint pos;
fputs("G36*\n", dest); fputs("G36*\n", dest);
pos.x = *coord; coord++; pos.x = *coord;
pos.y = *coord; coord++; coord++;
pos.y = *coord;
coord++;
UserToDeviceCoordinate(pos); UserToDeviceCoordinate(pos);
fprintf(dest, "X%5.5dY%5.5dD02*\n", pos.x, pos.y ); fprintf( dest, "X%5.5dY%5.5dD02*\n", pos.x, pos.y );
for ( ii = 1; ii < nb_segm; ii++ ) for( ii = 1; ii < nb_segm; ii++ )
{ {
pos.x = *coord; coord++; pos.x = *coord;
pos.y = *coord; coord++; coord++;
pos.y = *coord;
coord++;
UserToDeviceCoordinate(pos); UserToDeviceCoordinate(pos);
fprintf(dest, "X%5.5dY%5.5dD01*\n", pos.x, pos.y ); fprintf( dest, "X%5.5dY%5.5dD01*\n", pos.x, pos.y );
} }
fputs("G37*\n", dest); fputs("G37*\n", dest);
...@@ -657,12 +709,12 @@ wxPoint pos; ...@@ -657,12 +709,12 @@ wxPoint pos;
/*******************************************************/ /*******************************************************/
D_CODE * get_D_code(int dx,int dy, int type, int drill ) D_CODE * get_D_code( int dx, int dy, int type, int drill )
/*******************************************************/ /*******************************************************/
/*
Fonction Recherchant et Creant eventuellement la description /* Fonction Recherchant et Creant eventuellement la description
du D_CODE du type et dimensions demandees * du D_CODE du type et dimensions demandees
*/ */
{ {
D_CODE * ptr_tool, * last_dcode_ptr; D_CODE * ptr_tool, * last_dcode_ptr;
int num_new_D_code = FIRST_DCODE_VALUE; int num_new_D_code = FIRST_DCODE_VALUE;
...@@ -670,32 +722,33 @@ int num_new_D_code = FIRST_DCODE_VALUE; ...@@ -670,32 +722,33 @@ int num_new_D_code = FIRST_DCODE_VALUE;
ptr_tool = last_dcode_ptr = s_DCodeList; ptr_tool = last_dcode_ptr = s_DCodeList;
while(ptr_tool && ptr_tool->m_Type >= 0 ) while( ptr_tool && ptr_tool->m_Type >= 0 )
{ {
if( ( ptr_tool->m_Size.x == dx ) && if( ( ptr_tool->m_Size.x == dx ) &&
( ptr_tool->m_Size.y == dy ) && ( ptr_tool->m_Size.y == dy ) &&
( ptr_tool->m_Type == type ) ) ( ptr_tool->m_Type == type ) )
return(ptr_tool); /* D_code deja existant */ return(ptr_tool); /* D_code deja existant */
last_dcode_ptr = ptr_tool; last_dcode_ptr = ptr_tool;
ptr_tool = ptr_tool->m_Pnext ; ptr_tool = ptr_tool->m_Pnext;
num_new_D_code++ ; num_new_D_code++;
} }
/* At this point, the requested D_CODE does not exist: It will be created */ /* At this point, the requested D_CODE does not exist: It will be created */
if ( ptr_tool == NULL ) /* We must create a new data */ if( ptr_tool == NULL ) /* We must create a new data */
{ {
ptr_tool = new D_CODE(); ptr_tool = new D_CODE();
ptr_tool->m_NumDcode = num_new_D_code; ptr_tool->m_NumDcode = num_new_D_code;
if ( last_dcode_ptr ) if( last_dcode_ptr )
{ {
ptr_tool->m_Pback = last_dcode_ptr; ptr_tool->m_Pback = last_dcode_ptr;
last_dcode_ptr->m_Pnext = ptr_tool; last_dcode_ptr->m_Pnext = ptr_tool;
} }
else s_DCodeList = ptr_tool; else
s_DCodeList = ptr_tool;
} }
ptr_tool->m_Size.x = dx ; ptr_tool->m_Size.x = dx;
ptr_tool->m_Size.y = dy ; ptr_tool->m_Size.y = dy;
ptr_tool->m_Type = type ; ptr_tool->m_Type = type;
return(ptr_tool); return(ptr_tool);
} }
...@@ -706,20 +759,20 @@ void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile) ...@@ -706,20 +759,20 @@ void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile)
{ {
char Line[1024]; char Line[1024];
s_Last_D_code = 0 ; s_Last_D_code = 0;
DateAndTime(Line); DateAndTime(Line);
wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion();
fprintf(gerbfile,"G04 (Genere par %s) le %s*\n",CONV_TO_UTF8(Title), Line); fprintf(gerbfile, "G04 (Genere par %s) le %s*\n", CONV_TO_UTF8(Title), Line);
// Specify linear interpol (G01), unit = INCH (G70), abs format (G90): // Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
fputs("G01*\nG70*\nG90*\n", gerbfile); fputs("G01*\nG70*\nG90*\n", gerbfile);
fputs("%MOIN*%\n", gerbfile); // set unites = INCHES fputs("%MOIN*%\n", gerbfile); // set unites = INCHES
/* Set gerber format to 3.4 */ /* Set gerber format to 3.4 */
strcpy(Line,"G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n") ; strcpy(Line, "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n");
fputs(Line,gerbfile); fputs(Line, gerbfile);
fputs("G04 APERTURE LIST*\n", gerbfile); fputs("G04 APERTURE LIST*\n", gerbfile);
} }
...@@ -728,21 +781,24 @@ char Line[1024]; ...@@ -728,21 +781,24 @@ char Line[1024];
/***********************************/ /***********************************/
static void Init_ApertureList() static void Init_ApertureList()
/***********************************/ /***********************************/
/* Init the memory to handle the aperture list: /* Init the memory to handle the aperture list:
the member .m_Type is used by get_D_code() to handle the end of list: * the member .m_Type is used by get_D_code() to handle the end of list:
.m_Type < 0 is the first free aperture descr */ * .m_Type < 0 is the first free aperture descr
*/
{ {
D_CODE * ptr_tool; D_CODE * ptr_tool;
ptr_tool = s_DCodeList; ptr_tool = s_DCodeList;
while ( ptr_tool ) while( ptr_tool )
{ {
s_DCodeList->m_Type = -1; s_DCodeList->m_Type = -1;
ptr_tool = ptr_tool->m_Pnext ; ptr_tool = ptr_tool->m_Pnext;
} }
ShowDcodeError = TRUE; ShowDcodeError = TRUE;
} }
/*****************************************************************/ /*****************************************************************/
void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile) void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile)
/*****************************************************************/ /*****************************************************************/
...@@ -751,22 +807,22 @@ char line[1024]; ...@@ -751,22 +807,22 @@ char line[1024];
wxString TmpFileName, msg; wxString TmpFileName, msg;
FILE * outfile; FILE * outfile;
fputs("M02*\n",gerbfile); fputs("M02*\n", gerbfile);
fclose(gerbfile); fclose(gerbfile);
// Reouverture gerbfile pour ajout des Apertures // Reouverture gerbfile pour ajout des Apertures
gerbfile = wxFopen(GerberFullFileName, wxT("rt") ); gerbfile = wxFopen( GerberFullFileName, wxT("rt") );
if (gerbfile == NULL) if( gerbfile == NULL )
{ {
msg.Printf( _("unable to reopen file <%s>"),GerberFullFileName.GetData() ) ; msg.Printf( _("unable to reopen file <%s>"), GerberFullFileName.GetData() );
DisplayError(frame, msg); return ; DisplayError(frame, msg);
return;
} }
// Ouverture tmpfile // Ouverture tmpfile
TmpFileName = GerberFullFileName + wxT(".$$$"); TmpFileName = GerberFullFileName + wxT(".$$$");
outfile = wxFopen(TmpFileName, wxT("wt") ); outfile = wxFopen( TmpFileName, wxT("wt") );
if ( outfile == NULL ) if( outfile == NULL )
{ {
fclose(gerbfile); fclose(gerbfile);
DisplayError(frame, wxT("Fin_Trace_GERBER(): Can't Open tmp file")); DisplayError(frame, wxT("Fin_Trace_GERBER(): Can't Open tmp file"));
...@@ -775,10 +831,10 @@ FILE * outfile; ...@@ -775,10 +831,10 @@ FILE * outfile;
// Placement des Apertures en RS274X // Placement des Apertures en RS274X
rewind(gerbfile); rewind(gerbfile);
while ( fgets(line, 1024, gerbfile) ) while( fgets(line, 1024, gerbfile) )
{ {
fputs(line, outfile); fputs(line, outfile);
if ( strcmp(strtok(line, "\n\r"),"G04 APERTURE LIST*") == 0 ) if( strcmp(strtok(line, "\n\r"), "G04 APERTURE LIST*") == 0 )
{ {
frame->Gen_D_CODE_File(outfile); frame->Gen_D_CODE_File(outfile);
fputs("G04 APERTURE END LIST*\n", outfile); fputs("G04 APERTURE END LIST*\n", outfile);
...@@ -789,16 +845,16 @@ FILE * outfile; ...@@ -789,16 +845,16 @@ FILE * outfile;
fclose(gerbfile); fclose(gerbfile);
wxRemoveFile(GerberFullFileName); wxRemoveFile(GerberFullFileName);
wxRenameFile(TmpFileName, GerberFullFileName); wxRenameFile(TmpFileName, GerberFullFileName);
} }
/******************************************************/ /******************************************************/
int WinEDA_BasePcbFrame::Gen_D_CODE_File(FILE * penfile) int WinEDA_BasePcbFrame::Gen_D_CODE_File(FILE * penfile)
/******************************************************/ /******************************************************/
/* Genere la liste courante des D_CODES /* Genere la liste courante des D_CODES
Retourne le nombre de D_Codes utilises * Retourne le nombre de D_Codes utilises
Genere une sequence RS274X * Genere une sequence RS274X
*/ */
{ {
D_CODE * ptr_tool; D_CODE * ptr_tool;
...@@ -807,44 +863,43 @@ int nb_dcodes = 0 ; ...@@ -807,44 +863,43 @@ int nb_dcodes = 0 ;
/* Init : */ /* Init : */
ptr_tool = s_DCodeList; ptr_tool = s_DCodeList;
while(ptr_tool && (ptr_tool->m_Type >= 0 ) ) while( ptr_tool && ( ptr_tool->m_Type >= 0 ) )
{ {
float fscale = 0.0001; // For 3.4 format float fscale = 0.0001; // For 3.4 format
char * text; char * text;
sprintf(cbuf,"%%ADD%d", ptr_tool->m_NumDcode); sprintf(cbuf, "%%ADD%d", ptr_tool->m_NumDcode);
text = cbuf + strlen(cbuf); text = cbuf + strlen(cbuf);
switch ( ptr_tool->m_Type ) switch( ptr_tool->m_Type )
{ {
case 1: // Circle (flash ) case 1: // Circle (flash )
sprintf(text,"C,%f*%%\n", ptr_tool->m_Size.x * fscale); sprintf(text, "C,%f*%%\n", ptr_tool->m_Size.x * fscale);
break; break;
case 2: // RECT case 2: // RECT
sprintf(text,"R,%fX%f*%%\n", ptr_tool->m_Size.x * fscale, sprintf(text, "R,%fX%f*%%\n", ptr_tool->m_Size.x * fscale,
ptr_tool->m_Size.y * fscale); ptr_tool->m_Size.y * fscale);
break; break;
case 3: // Circle ( lines ) case 3: // Circle ( lines )
sprintf(text,"C,%f*%%\n", ptr_tool->m_Size.x * fscale); sprintf(text, "C,%f*%%\n", ptr_tool->m_Size.x * fscale);
break; break;
case 4: // OVALE case 4: // OVALE
sprintf(text,"O,%fX%f*%%\n", ptr_tool->m_Size.x * fscale, sprintf(text, "O,%fX%f*%%\n", ptr_tool->m_Size.x * fscale,
ptr_tool->m_Size.y * fscale); ptr_tool->m_Size.y * fscale);
break; break;
default: default:
DisplayError(this, wxT("Gen_D_CODE_File(): Dcode Type err") ); DisplayError( this, wxT("Gen_D_CODE_File(): Dcode Type err") );
break; break;
} }
// compensation localisation printf (float x.y gnr x,y) // compensation localisation printf (float x.y gnr x,y)
to_point ( text + 2 ); to_point( text + 2 );
fputs(cbuf,penfile) ; fputs(cbuf, penfile);
ptr_tool = ptr_tool->m_Pnext; nb_dcodes++ ; ptr_tool = ptr_tool->m_Pnext;
nb_dcodes++;
} }
return(nb_dcodes); return( nb_dcodes );
} }
...@@ -136,7 +136,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) ...@@ -136,7 +136,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer )
switch( Layer ) switch( Layer )
{ {
case COPPER_LAYER_N: case FIRST_COPPER_LAYER:
case LAYER_N_2: case LAYER_N_2:
case LAYER_N_3: case LAYER_N_3:
case LAYER_N_4: case LAYER_N_4:
...@@ -151,7 +151,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) ...@@ -151,7 +151,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer )
case LAYER_N_13: case LAYER_N_13:
case LAYER_N_14: case LAYER_N_14:
case LAYER_N_15: case LAYER_N_15:
case CMP_N: case LAST_COPPER_LAYER:
Plot_Layer_HPGL( dest, layer_mask, 0, 1, modetrace ); Plot_Layer_HPGL( dest, layer_mask, 0, 1, modetrace );
break; break;
......
...@@ -178,7 +178,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer ) ...@@ -178,7 +178,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer )
Plot_Layer_PS( dest, layer_mask, 0, 1, modetrace ); Plot_Layer_PS( dest, layer_mask, 0, 1, modetrace );
break; break;
case COPPER_LAYER_N: case FIRST_COPPER_LAYER:
case LAYER_N_2: case LAYER_N_2:
case LAYER_N_3: case LAYER_N_3:
case LAYER_N_4: case LAYER_N_4:
...@@ -193,7 +193,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer ) ...@@ -193,7 +193,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer )
case LAYER_N_13: case LAYER_N_13:
case LAYER_N_14: case LAYER_N_14:
case LAYER_N_15: case LAYER_N_15:
case CMP_N: case LAST_COPPER_LAYER:
Plot_Layer_PS( dest, layer_mask, 0, 1, modetrace ); Plot_Layer_PS( dest, layer_mask, 0, 1, modetrace );
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