|
|
|
@ -1,5 +1,4 @@ |
|
|
|
//////////////////////////////////////
|
|
|
|
|
|
|
|
// Name: 3d_draw.cpp
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
|
|
|
@ -47,7 +46,8 @@ static void Draw3D_ArcSegment(double startx, double starty, |
|
|
|
double endx, double endy,double width, double zpos); |
|
|
|
static void Draw3D_CircleSegment(double startx, double starty, |
|
|
|
double endx, double endy,double width, double zpos); |
|
|
|
|
|
|
|
static int Get3DLayerEnable(int act_layer); |
|
|
|
static GLfloat Get3DLayerSide(int act_layer); |
|
|
|
|
|
|
|
/******************************************/ |
|
|
|
void Pcb3D_GLCanvas::Redraw( bool finish ) |
|
|
|
@ -122,7 +122,8 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() |
|
|
|
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_cu = 10 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
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_CMP] = zpos_cmp + zpos_cu; |
|
|
|
@ -138,19 +139,21 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() |
|
|
|
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); |
|
|
|
|
|
|
|
/* draw axes */ |
|
|
|
glEnable( GL_COLOR_MATERIAL ); |
|
|
|
SetGLColor( WHITE ); |
|
|
|
glBegin( GL_LINES ); |
|
|
|
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, -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(); |
|
|
|
|
|
|
|
if (g_Parm_3D_Visu.m_Draw3DAxis){ |
|
|
|
glEnable( GL_COLOR_MATERIAL ); |
|
|
|
SetGLColor( WHITE ); |
|
|
|
glBegin( GL_LINES ); |
|
|
|
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, -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(); |
|
|
|
} |
|
|
|
|
|
|
|
/* Draw epoxy limits (do not use, works and test in progress) */ |
|
|
|
#if 0
|
|
|
|
glEnable( GL_FOG ); |
|
|
|
@ -198,15 +201,32 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() |
|
|
|
else |
|
|
|
Draw3D_Track( pt_piste ); |
|
|
|
} |
|
|
|
if (g_Parm_3D_Visu.m_Draw3DZone){ |
|
|
|
for( pt_piste = pcb->m_Zone; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) |
|
|
|
{ |
|
|
|
if( pt_piste->Type() == TYPEZONE ) |
|
|
|
Draw3D_Track( pt_piste ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* Tracé des edges */ |
|
|
|
EDA_BaseStruct* PtStruct; |
|
|
|
for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext ) |
|
|
|
{ |
|
|
|
#define STRUCT ( (DRAWSEGMENT*) PtStruct )
|
|
|
|
if( PtStruct->Type() != TYPEDRAWSEGMENT ) |
|
|
|
continue; |
|
|
|
Draw3D_DrawSegment( STRUCT ); |
|
|
|
//if( PtStruct->Type() != TYPEDRAWSEGMENT )
|
|
|
|
// continue;
|
|
|
|
if( PtStruct->Type() == TYPEDRAWSEGMENT ) |
|
|
|
{ |
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (DRAWSEGMENT*) PtStruct )
|
|
|
|
Draw3D_DrawSegment( STRUCT ); |
|
|
|
} |
|
|
|
if( PtStruct->Type() == TYPETEXTE ) |
|
|
|
{ |
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (TEXTE_PCB*) PtStruct )
|
|
|
|
Draw3D_DrawText( STRUCT ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* tracé des modules */ |
|
|
|
@ -284,8 +304,11 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) |
|
|
|
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]; |
|
|
|
if( color & ITEM_NOT_SHOW ) |
|
|
|
continue; |
|
|
|
SetGLColor( color ); |
|
|
|
//SetGLColor( color );
|
|
|
|
SetGLColor( LIGHTGRAY ); |
|
|
|
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 ); |
|
|
|
if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
Draw3D_FilledCircle( x, -y, r, hole, zpos ); |
|
|
|
if( layer >= top_layer ) |
|
|
|
break; |
|
|
|
@ -339,11 +362,75 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->GetLayer()]; |
|
|
|
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos ); |
|
|
|
layer = segment->GetLayer(); |
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayerSide(layer) ); |
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; |
|
|
|
if (Get3DLayerEnable(layer)) |
|
|
|
{ |
|
|
|
switch( segment->m_Shape ) |
|
|
|
{ |
|
|
|
case S_ARC: |
|
|
|
Draw3D_ArcSegment( x, -y, xf, -yf, w, zpos); |
|
|
|
break; |
|
|
|
case S_CIRCLE: |
|
|
|
Draw3D_CircleSegment( x, -y, xf, -yf, w, zpos); |
|
|
|
break; |
|
|
|
default : |
|
|
|
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************/ |
|
|
|
void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) |
|
|
|
/*************************************************************/ |
|
|
|
{ |
|
|
|
int layer = text->GetLayer(); |
|
|
|
double x, y, xf, yf; |
|
|
|
double zpos, w; |
|
|
|
int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; |
|
|
|
int coord[104]; |
|
|
|
int ii, jj, kk, ll, nbpoints; |
|
|
|
|
|
|
|
|
|
|
|
if (Get3DLayerEnable(layer)) |
|
|
|
{ |
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; |
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayerSide(layer) ); |
|
|
|
|
|
|
|
text->CreateDrawData(); |
|
|
|
jj = 5; ii = jj + 1; |
|
|
|
while( ii < text->m_TextDrawingsSize ) |
|
|
|
{ |
|
|
|
nbpoints = text->m_TextDrawings[jj]; |
|
|
|
if( nbpoints > 50 ) |
|
|
|
nbpoints = 50; |
|
|
|
|
|
|
|
for( kk = 0, ll = 0; (kk < nbpoints) && (ii < text->m_TextDrawingsSize); kk++ ) |
|
|
|
{ |
|
|
|
coord[ll++] = text->m_TextDrawings[ii++] + text->m_Pos.x; |
|
|
|
coord[ll++] = text->m_TextDrawings[ii++] + text->m_Pos.y; |
|
|
|
} |
|
|
|
|
|
|
|
jj = ii++; |
|
|
|
|
|
|
|
for( kk = 0, ll = 0; kk < (nbpoints - 1); kk++, ll += 2 ) |
|
|
|
{ |
|
|
|
SetGLColor( color ); |
|
|
|
w = text->m_Width * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
x = coord[ll] * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
y = coord[ll + 1] * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
xf = coord[ll + 2] * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
yf = coord[ll + 3] * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
|
|
|
|
//printf("text koordinata x=%d, y=%d, x2=%d, y2=%d\n",x,y,xf,yf);
|
|
|
|
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*********************************************/ |
|
|
|
void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
@ -373,34 +460,43 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
} |
|
|
|
|
|
|
|
/* Draw module shape: 3D shape if exists (or module edge if not exists) */ |
|
|
|
Struct3D_Master* Struct3D = m_3D_Drawings; |
|
|
|
bool As3dShape = FALSE; |
|
|
|
glPushMatrix(); |
|
|
|
glTranslatef( m_Pos.x * g_Parm_3D_Visu.m_BoardScale, |
|
|
|
-m_Pos.y * g_Parm_3D_Visu.m_BoardScale, |
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[m_Layer] ); |
|
|
|
if( m_Orient ) |
|
|
|
{ |
|
|
|
glRotatef( (double) m_Orient / 10, 0.0, 0.0, 1.0 ); |
|
|
|
} |
|
|
|
if( m_Layer == COPPER_LAYER_N ) |
|
|
|
{ |
|
|
|
glRotatef( 180.0, 0.0, 1.0, 0.0 ); |
|
|
|
glRotatef( 180.0, 0.0, 0.0, 1.0 ); |
|
|
|
} |
|
|
|
DataScale3D = g_Parm_3D_Visu.m_BoardScale * UNITS3D_TO_UNITSPCB; |
|
|
|
|
|
|
|
for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext ) |
|
|
|
{ |
|
|
|
if( !Struct3D->m_Shape3DName.IsEmpty() ) |
|
|
|
{ |
|
|
|
As3dShape = TRUE; |
|
|
|
Struct3D->ReadData(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
glPopMatrix(); |
|
|
|
|
|
|
|
Struct3D_Master* Struct3D = m_3D_Drawings; |
|
|
|
bool As3dShape = FALSE; |
|
|
|
bool Place3D; |
|
|
|
if ( (Struct3D->m_Shape3DName.Find(wxString(wxT("placa"))) != -1) || |
|
|
|
(Struct3D->m_Shape3DName.Find(wxString(wxT("place"))) != -1) ) |
|
|
|
Place3D = TRUE; |
|
|
|
else Place3D = FALSE; |
|
|
|
|
|
|
|
if ( (g_Parm_3D_Visu.m_Draw3DModule && !Place3D) || |
|
|
|
(g_Parm_3D_Visu.m_Draw3DPlace && Place3D) ) |
|
|
|
{ |
|
|
|
glPushMatrix(); |
|
|
|
glTranslatef( m_Pos.x * g_Parm_3D_Visu.m_BoardScale, |
|
|
|
-m_Pos.y * g_Parm_3D_Visu.m_BoardScale, |
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[m_Layer] ); |
|
|
|
if( m_Orient ) |
|
|
|
{ |
|
|
|
glRotatef( (double) m_Orient / 10, 0.0, 0.0, 1.0 ); |
|
|
|
} |
|
|
|
if( m_Layer == COPPER_LAYER_N ) |
|
|
|
{ |
|
|
|
glRotatef( 180.0, 0.0, 1.0, 0.0 ); |
|
|
|
glRotatef( 180.0, 0.0, 0.0, 1.0 ); |
|
|
|
} |
|
|
|
DataScale3D = g_Parm_3D_Visu.m_BoardScale * UNITS3D_TO_UNITSPCB; |
|
|
|
|
|
|
|
for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext ) |
|
|
|
{ |
|
|
|
if( !Struct3D->m_Shape3DName.IsEmpty() ) |
|
|
|
{ |
|
|
|
As3dShape = TRUE; |
|
|
|
Struct3D->ReadData(); |
|
|
|
} |
|
|
|
} |
|
|
|
glPopMatrix(); |
|
|
|
} |
|
|
|
|
|
|
|
if( !As3dShape ) |
|
|
|
{ |
|
|
|
EDA_BaseStruct* Struct = m_Drawings; |
|
|
|
@ -546,9 +642,12 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; |
|
|
|
if( color & ITEM_NOT_SHOW ) |
|
|
|
continue; |
|
|
|
SetGLColor( color ); |
|
|
|
//SetGLColor( color );
|
|
|
|
SetGLColor( LIGHTGRAY ); |
|
|
|
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 ); |
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; |
|
|
|
if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
Draw3D_FilledCircle( x, -y, r, hole, zpos ); |
|
|
|
} |
|
|
|
|
|
|
|
@ -591,8 +690,11 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 ); |
|
|
|
if( color & ITEM_NOT_SHOW ) |
|
|
|
continue; |
|
|
|
SetGLColor( color ); |
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; |
|
|
|
//SetGLColor( color );
|
|
|
|
SetGLColor( LIGHTGRAY ); |
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; |
|
|
|
if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
Draw3D_FilledSegmentWithHole( ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos ); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -662,8 +764,11 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 ); |
|
|
|
if( color & ITEM_NOT_SHOW ) |
|
|
|
continue; |
|
|
|
SetGLColor( color ); |
|
|
|
//SetGLColor( color );
|
|
|
|
SetGLColor( LIGHTGRAY ); |
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; |
|
|
|
if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
glBegin( GL_QUAD_STRIP ); |
|
|
|
for( ii = 0; ii < 8; ii++ ) |
|
|
|
{ |
|
|
|
@ -946,3 +1051,40 @@ double x, y, hole, rayon; |
|
|
|
} |
|
|
|
glEnd(); |
|
|
|
} |
|
|
|
|
|
|
|
/******************************************/ |
|
|
|
static int Get3DLayerEnable(int act_layer) |
|
|
|
/******************************************/ |
|
|
|
{ |
|
|
|
bool enablelayer; |
|
|
|
|
|
|
|
enablelayer = TRUE; |
|
|
|
if (act_layer == DRAW_N && !g_Parm_3D_Visu.m_Draw3DDrawings) |
|
|
|
enablelayer = FALSE; |
|
|
|
if (act_layer == COMMENT_N && !g_Parm_3D_Visu.m_Draw3DComments) |
|
|
|
enablelayer = FALSE; |
|
|
|
if (act_layer == ECO1_N && !g_Parm_3D_Visu.m_Draw3DEco1) |
|
|
|
enablelayer = FALSE; |
|
|
|
if (act_layer == ECO2_N && !g_Parm_3D_Visu.m_Draw3DEco2) |
|
|
|
enablelayer = FALSE; |
|
|
|
|
|
|
|
return enablelayer; |
|
|
|
} |
|
|
|
|
|
|
|
/******************************************/ |
|
|
|
static GLfloat Get3DLayerSide(int act_layer) |
|
|
|
/******************************************/ |
|
|
|
{ |
|
|
|
GLfloat nZ; |
|
|
|
nZ = 1.0; |
|
|
|
if ( |
|
|
|
(act_layer <= LAST_COPPER_LAYER-1) || |
|
|
|
(act_layer == ADHESIVE_N_CU) || |
|
|
|
(act_layer == SOLDERPASTE_N_CU) || |
|
|
|
(act_layer == SILKSCREEN_N_CU) || |
|
|
|
(act_layer == SOLDERMASK_N_CU) |
|
|
|
) |
|
|
|
nZ = -1.0; |
|
|
|
return nZ; |
|
|
|
|
|
|
|
} |