3d-viewer: code cleaning.
This commit is contained in:
parent
5e032ef08a
commit
4c20fb4c4b
|
@ -161,7 +161,7 @@ void EDA_3D_CANVAS::OnChar( wxKeyEvent& event )
|
||||||
void EDA_3D_CANVAS::SetView3D( int keycode )
|
void EDA_3D_CANVAS::SetView3D( int keycode )
|
||||||
{
|
{
|
||||||
int ii;
|
int ii;
|
||||||
double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
|
double delta_move = 0.7 * GetPrm3DVisu().m_Zoom;
|
||||||
|
|
||||||
switch( keycode )
|
switch( keycode )
|
||||||
{
|
{
|
||||||
|
@ -182,22 +182,22 @@ void EDA_3D_CANVAS::SetView3D( int keycode )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_HOME:
|
case WXK_HOME:
|
||||||
g_Parm_3D_Visu.m_Zoom = 1.0;
|
GetPrm3DVisu().m_Zoom = 1.0;
|
||||||
m_draw3dOffset.x = m_draw3dOffset.y = 0;
|
m_draw3dOffset.x = m_draw3dOffset.y = 0;
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_END:
|
case WXK_END:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_F1:
|
case WXK_F1:
|
||||||
g_Parm_3D_Visu.m_Zoom /= 1.4;
|
GetPrm3DVisu().m_Zoom /= 1.4;
|
||||||
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
|
if( GetPrm3DVisu().m_Zoom <= 0.01 )
|
||||||
g_Parm_3D_Visu.m_Zoom = 0.01;
|
GetPrm3DVisu().m_Zoom = 0.01;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_F2:
|
case WXK_F2:
|
||||||
g_Parm_3D_Visu.m_Zoom *= 1.4;
|
GetPrm3DVisu().m_Zoom *= 1.4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '+':
|
case '+':
|
||||||
|
@ -210,59 +210,59 @@ void EDA_3D_CANVAS::SetView3D( int keycode )
|
||||||
case 'R':
|
case 'R':
|
||||||
m_draw3dOffset.x = m_draw3dOffset.y = 0;
|
m_draw3dOffset.x = m_draw3dOffset.y = 0;
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
g_Parm_3D_Visu.m_ROTZ = -90;
|
GetPrm3DVisu().m_ROTZ = -90;
|
||||||
g_Parm_3D_Visu.m_ROTX = -90;
|
GetPrm3DVisu().m_ROTX = -90;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'X':
|
case 'X':
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
g_Parm_3D_Visu.m_ROTZ = 90;
|
GetPrm3DVisu().m_ROTZ = 90;
|
||||||
g_Parm_3D_Visu.m_ROTX = -90;
|
GetPrm3DVisu().m_ROTX = -90;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
g_Parm_3D_Visu.m_ROTX = -90;
|
GetPrm3DVisu().m_ROTX = -90;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Y':
|
case 'Y':
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
g_Parm_3D_Visu.m_ROTX = -90;
|
GetPrm3DVisu().m_ROTX = -90;
|
||||||
g_Parm_3D_Visu.m_ROTZ = -180;
|
GetPrm3DVisu().m_ROTZ = -180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'z':
|
case 'z':
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Z':
|
case 'Z':
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
g_Parm_3D_Visu.m_ROTX = -180;
|
GetPrm3DVisu().m_ROTX = -180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -279,47 +279,35 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event )
|
||||||
if( event.ShiftDown() )
|
if( event.ShiftDown() )
|
||||||
{
|
{
|
||||||
if( event.GetWheelRotation() < 0 )
|
if( event.GetWheelRotation() < 0 )
|
||||||
{
|
SetView3D( WXK_UP ); // move up
|
||||||
/* up */
|
|
||||||
SetView3D( WXK_UP );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
SetView3D( WXK_DOWN ); // move down
|
||||||
/* down */
|
|
||||||
SetView3D( WXK_DOWN );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( event.ControlDown() )
|
else if( event.ControlDown() )
|
||||||
{
|
{
|
||||||
if( event.GetWheelRotation() > 0 )
|
if( event.GetWheelRotation() > 0 )
|
||||||
{
|
SetView3D( WXK_RIGHT ); // move right
|
||||||
/* right */
|
|
||||||
SetView3D( WXK_RIGHT );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
SetView3D( WXK_LEFT ); // move left
|
||||||
/* left */
|
|
||||||
SetView3D( WXK_LEFT );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( event.GetWheelRotation() > 0 )
|
if( event.GetWheelRotation() > 0 )
|
||||||
{
|
{
|
||||||
g_Parm_3D_Visu.m_Zoom /= 1.4;
|
GetPrm3DVisu().m_Zoom /= 1.4;
|
||||||
|
|
||||||
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
|
if( GetPrm3DVisu().m_Zoom <= 0.01 )
|
||||||
g_Parm_3D_Visu.m_Zoom = 0.01;
|
GetPrm3DVisu().m_Zoom = 0.01;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_Parm_3D_Visu.m_Zoom *= 1.4;
|
GetPrm3DVisu().m_Zoom *= 1.4;
|
||||||
|
|
||||||
DisplayStatus();
|
DisplayStatus();
|
||||||
Refresh( false );
|
Refresh( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Parm_3D_Visu.m_Beginx = event.GetX();
|
GetPrm3DVisu().m_Beginx = event.GetX();
|
||||||
g_Parm_3D_Visu.m_Beginy = event.GetY();
|
GetPrm3DVisu().m_Beginy = event.GetY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,12 +322,12 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
|
||||||
{
|
{
|
||||||
/* drag in progress, simulate trackball */
|
/* drag in progress, simulate trackball */
|
||||||
trackball( spin_quat,
|
trackball( spin_quat,
|
||||||
(2.0 * g_Parm_3D_Visu.m_Beginx - size.x) / size.x,
|
(2.0 * GetPrm3DVisu().m_Beginx - size.x) / size.x,
|
||||||
(size.y - 2.0 * g_Parm_3D_Visu.m_Beginy) / size.y,
|
(size.y - 2.0 * GetPrm3DVisu().m_Beginy) / size.y,
|
||||||
( 2.0 * event.GetX() - size.x) / size.x,
|
( 2.0 * event.GetX() - size.x) / size.x,
|
||||||
( size.y - 2.0 * event.GetY() ) / size.y );
|
( size.y - 2.0 * event.GetY() ) / size.y );
|
||||||
|
|
||||||
add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat );
|
add_quats( spin_quat, GetPrm3DVisu().m_Quat, GetPrm3DVisu().m_Quat );
|
||||||
}
|
}
|
||||||
else if( event.MiddleIsDown() )
|
else if( event.MiddleIsDown() )
|
||||||
{
|
{
|
||||||
|
@ -347,11 +335,11 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
|
||||||
|
|
||||||
/* Current zoom and an additional factor are taken into account
|
/* Current zoom and an additional factor are taken into account
|
||||||
* for the amount of panning. */
|
* for the amount of panning. */
|
||||||
const double PAN_FACTOR = 8.0 * g_Parm_3D_Visu.m_Zoom;
|
const double PAN_FACTOR = 8.0 * GetPrm3DVisu().m_Zoom;
|
||||||
m_draw3dOffset.x -= PAN_FACTOR *
|
m_draw3dOffset.x -= PAN_FACTOR *
|
||||||
( g_Parm_3D_Visu.m_Beginx - event.GetX() ) / size.x;
|
( GetPrm3DVisu().m_Beginx - event.GetX() ) / size.x;
|
||||||
m_draw3dOffset.y -= PAN_FACTOR *
|
m_draw3dOffset.y -= PAN_FACTOR *
|
||||||
(event.GetY() - g_Parm_3D_Visu.m_Beginy) / size.y;
|
(event.GetY() - GetPrm3DVisu().m_Beginy) / size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* orientation has changed, redraw mesh */
|
/* orientation has changed, redraw mesh */
|
||||||
|
@ -359,8 +347,8 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
|
||||||
Refresh( false );
|
Refresh( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Parm_3D_Visu.m_Beginx = event.GetX();
|
GetPrm3DVisu().m_Beginx = event.GetX();
|
||||||
g_Parm_3D_Visu.m_Beginy = event.GetY();
|
GetPrm3DVisu().m_Beginy = event.GetY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -502,7 +490,7 @@ void EDA_3D_CANVAS::DisplayStatus()
|
||||||
msg.Printf( wxT( "dy %3.2f" ), m_draw3dOffset.y );
|
msg.Printf( wxT( "dy %3.2f" ), m_draw3dOffset.y );
|
||||||
Parent()->SetStatusText( msg, 2 );
|
Parent()->SetStatusText( msg, 2 );
|
||||||
|
|
||||||
msg.Printf( wxT( "View: %3.1f" ), 45 * g_Parm_3D_Visu.m_Zoom );
|
msg.Printf( wxT( "View: %3.1f" ), 45 * GetPrm3DVisu().m_Zoom );
|
||||||
Parent()->SetStatusText( msg, 3 );
|
Parent()->SetStatusText( msg, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +527,8 @@ GLuint load_and_generate_texture( tsImage *image )
|
||||||
|
|
||||||
glGenTextures( 1, &texture );
|
glGenTextures( 1, &texture );
|
||||||
glBindTexture( GL_TEXTURE_2D, texture );
|
glBindTexture( GL_TEXTURE_2D, texture );
|
||||||
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, image->width, image->height, GL_RGBA, GL_UNSIGNED_BYTE, image->pixel_data );
|
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, image->width, image->height,
|
||||||
|
GL_RGBA, GL_UNSIGNED_BYTE, image->pixel_data );
|
||||||
|
|
||||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
||||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||||
|
@ -561,7 +550,7 @@ void EDA_3D_CANVAS::InitGL()
|
||||||
m_text_pcb = load_and_generate_texture( (tsImage *)&text_pcb );
|
m_text_pcb = load_and_generate_texture( (tsImage *)&text_pcb );
|
||||||
m_text_silk = load_and_generate_texture( (tsImage *)&text_silk );
|
m_text_silk = load_and_generate_texture( (tsImage *)&text_silk );
|
||||||
|
|
||||||
g_Parm_3D_Visu.m_Zoom = 1.0;
|
GetPrm3DVisu().m_Zoom = 1.0;
|
||||||
m_ZBottom = 1.0;
|
m_ZBottom = 1.0;
|
||||||
m_ZTop = 10.0;
|
m_ZTop = 10.0;
|
||||||
|
|
||||||
|
@ -590,12 +579,8 @@ void EDA_3D_CANVAS::InitGL()
|
||||||
/* Initialize OpenGL light sources. */
|
/* Initialize OpenGL light sources. */
|
||||||
void EDA_3D_CANVAS::SetLights()
|
void EDA_3D_CANVAS::SetLights()
|
||||||
{
|
{
|
||||||
/* set viewing projection */
|
// activate light. the source is above the xy plane, at source_pos
|
||||||
GLfloat Z_axis_pos[4] = { 0.0, 0.0, 30.0, 0.0 };
|
GLfloat source_pos[4] = { 0.0, 0.0, 30.0, 0.0 };
|
||||||
// GLfloat lowZ_axis_pos[4] = { 0.0, 0.0, -30.0, 0.5 };
|
|
||||||
|
|
||||||
// activate lights. 2 lights are used:
|
|
||||||
// One is above the xy plane, the other is below the xy plane
|
|
||||||
GLfloat light_color[4]; // color of lights (RGBA values)
|
GLfloat light_color[4]; // color of lights (RGBA values)
|
||||||
light_color[3] = 1.0;
|
light_color[3] = 1.0;
|
||||||
|
|
||||||
|
@ -609,22 +594,12 @@ void EDA_3D_CANVAS::SetLights()
|
||||||
light_color[0] = light_color[1] = light_color[2] = 1.0;
|
light_color[0] = light_color[1] = light_color[2] = 1.0;
|
||||||
glLightfv( GL_LIGHT0, GL_SPECULAR, light_color );
|
glLightfv( GL_LIGHT0, GL_SPECULAR, light_color );
|
||||||
|
|
||||||
glLightfv( GL_LIGHT0, GL_POSITION, Z_axis_pos );
|
glLightfv( GL_LIGHT0, GL_POSITION, source_pos );
|
||||||
|
|
||||||
light_color[0] = light_color[1] = light_color[2] = 0.1;
|
light_color[0] = light_color[1] = light_color[2] = 0.1;
|
||||||
glLightModelfv( GL_LIGHT_MODEL_AMBIENT, light_color );
|
glLightModelfv( GL_LIGHT_MODEL_AMBIENT, light_color );
|
||||||
|
|
||||||
/*
|
|
||||||
// Light below the xy plane
|
|
||||||
glLightfv( GL_LIGHT1, GL_POSITION, lowZ_axis_pos );
|
|
||||||
light_color[0] = light_color[1] = light_color[2] = 0.4;
|
|
||||||
glLightfv( GL_LIGHT1, GL_DIFFUSE, light_color );
|
|
||||||
|
|
||||||
light_color[0] = light_color[1] = light_color[2] = 0.1;
|
|
||||||
glLightfv( GL_LIGHT1, GL_SPECULAR, light_color );
|
|
||||||
*/
|
|
||||||
glEnable( GL_LIGHT0 ); // White spot on Z axis ( top )
|
glEnable( GL_LIGHT0 ); // White spot on Z axis ( top )
|
||||||
glDisable( GL_LIGHT1 ); // White spot on Z axis ( bottom )
|
|
||||||
glEnable( GL_LIGHTING );
|
glEnable( GL_LIGHTING );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,12 @@ enum GL_LIST_ID
|
||||||
GL_ID_AUX_LAYERS, // List id for user layers (draw, eco, comment)
|
GL_ID_AUX_LAYERS, // List id for user layers (draw, eco, comment)
|
||||||
GL_ID_3DSHAPES_SOLID_FRONT, // List id for 3D shapes, non transparent entities
|
GL_ID_3DSHAPES_SOLID_FRONT, // List id for 3D shapes, non transparent entities
|
||||||
GL_ID_3DSHAPES_TRANSP_FRONT,// List id for 3D shapes, transparent entities
|
GL_ID_3DSHAPES_TRANSP_FRONT,// List id for 3D shapes, transparent entities
|
||||||
GL_ID_3DSHAPES_SOLID_BACK, // List id for 3D shapes, non transparent entities
|
GL_ID_3DSHAPES_SOLID_BACK, // List id for 3D shapes, non transparent entities
|
||||||
GL_ID_3DSHAPES_TRANSP_BACK,// List id for 3D shapes, transparent entities
|
GL_ID_3DSHAPES_TRANSP_BACK, // List id for 3D shapes, transparent entities
|
||||||
GL_ID_SHADOW_FRONT,
|
GL_ID_SHADOW_FRONT,
|
||||||
GL_ID_SHADOW_BACK,
|
GL_ID_SHADOW_BACK,
|
||||||
GL_ID_SHADOW_BOARD,
|
GL_ID_SHADOW_BOARD,
|
||||||
GL_ID_BODY, // Body only list
|
GL_ID_BODY, // Body only list
|
||||||
GL_ID_END
|
GL_ID_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,6 +142,9 @@ public:
|
||||||
m_draw3dOffset.y = aPosY;
|
m_draw3dOffset.y = aPosY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return the INFO3D_VISU which contains the current parameters
|
||||||
|
* to draw the 3D view og the board
|
||||||
|
*/
|
||||||
INFO3D_VISU& GetPrm3DVisu() const;
|
INFO3D_VISU& GetPrm3DVisu() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -121,12 +121,11 @@ static void Draw3D_VerticalPolygonalCylinder( const CPOLYGONS_LIST& aPolysList,
|
||||||
|
|
||||||
void SetGLColor( EDA_COLOR_T color, double alpha )
|
void SetGLColor( EDA_COLOR_T color, double alpha )
|
||||||
{
|
{
|
||||||
double red, green, blue;
|
|
||||||
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
|
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
|
||||||
|
|
||||||
red = colordata.m_Red / 255.0;
|
double red = colordata.m_Red / 255.0;
|
||||||
blue = colordata.m_Blue / 255.0;
|
double blue = colordata.m_Blue / 255.0;
|
||||||
green = colordata.m_Green / 255.0;
|
double green = colordata.m_Green / 255.0;
|
||||||
glColor4f( red, green, blue, alpha );
|
glColor4f( red, green, blue, alpha );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
|
||||||
g_Parm_3D_Visu.m_CurrentZpos = zpos;
|
g_Parm_3D_Visu.m_CurrentZpos = zpos;
|
||||||
v_data[2] = aZpos + (aThickness / 2.0);
|
v_data[2] = aZpos + (aThickness / 2.0);
|
||||||
|
|
||||||
// Set normal to toward positive Z axis, for a solid object only (to draw the top side)
|
// Set normal toward positive Z axis, for a solid object on the top side
|
||||||
if( aThickness )
|
if( aThickness )
|
||||||
SetNormalZpos();
|
SetNormalZpos();
|
||||||
|
|
||||||
|
@ -222,7 +221,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
|
||||||
zpos = ( aZpos - (aThickness / 2.0) ) * aBiuTo3DUnits;
|
zpos = ( aZpos - (aThickness / 2.0) ) * aBiuTo3DUnits;
|
||||||
g_Parm_3D_Visu.m_CurrentZpos = zpos;
|
g_Parm_3D_Visu.m_CurrentZpos = zpos;
|
||||||
v_data[2] = zpos;
|
v_data[2] = zpos;
|
||||||
// Now;, set normal to toward negative Z axis, for the solid object bottom side
|
// Set normal toward negative Z axis, for a solid object on bottom side
|
||||||
SetNormalZneg();
|
SetNormalZneg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +431,7 @@ void CALLBACK tessCPolyPt2Vertex( const GLvoid* data )
|
||||||
if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) )
|
if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) )
|
||||||
{
|
{
|
||||||
glTexCoord2f( ptr->x* g_Parm_3D_Visu.m_BiuTo3Dunits * m_texture_scale,
|
glTexCoord2f( ptr->x* g_Parm_3D_Visu.m_BiuTo3Dunits * m_texture_scale,
|
||||||
-ptr->y * g_Parm_3D_Visu.m_BiuTo3Dunits * m_texture_scale);
|
-ptr->y * g_Parm_3D_Visu.m_BiuTo3Dunits * m_texture_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
glVertex3d( ptr->x * g_Parm_3D_Visu.m_BiuTo3Dunits,
|
glVertex3d( ptr->x * g_Parm_3D_Visu.m_BiuTo3Dunits,
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
INFO3D_VISU& EDA_3D_CANVAS::GetPrm3DVisu() const
|
INFO3D_VISU& EDA_3D_CANVAS::GetPrm3DVisu() const
|
||||||
{
|
{
|
||||||
return g_Parm_3D_Visu;
|
return Parent()->GetPrm3DVisu();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize EDA_3D_CANVAS::getBoardSize() const
|
wxSize EDA_3D_CANVAS::getBoardSize() const
|
||||||
|
|
|
@ -224,15 +224,15 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
|
||||||
{
|
{
|
||||||
EDA_BASE_FRAME::LoadSettings( aCfg );
|
EDA_BASE_FRAME::LoadSettings( aCfg );
|
||||||
|
|
||||||
INFO3D_VISU& prms = g_Parm_3D_Visu;
|
INFO3D_VISU& prms = GetPrm3DVisu();
|
||||||
|
|
||||||
aCfg->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.4 );
|
aCfg->Read( keyBgColor_Red, &GetPrm3DVisu().m_BgColor.m_Red, 0.4 );
|
||||||
aCfg->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.4 );
|
aCfg->Read( keyBgColor_Green, &GetPrm3DVisu().m_BgColor.m_Green, 0.4 );
|
||||||
aCfg->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.5 );
|
aCfg->Read( keyBgColor_Blue, &GetPrm3DVisu().m_BgColor.m_Blue, 0.5 );
|
||||||
|
|
||||||
aCfg->Read( keyBgColor_Red_Top, &g_Parm_3D_Visu.m_BgColor_Top.m_Red, 0.8 );
|
aCfg->Read( keyBgColor_Red_Top, &GetPrm3DVisu().m_BgColor_Top.m_Red, 0.8 );
|
||||||
aCfg->Read( keyBgColor_Green_Top, &g_Parm_3D_Visu.m_BgColor_Top.m_Green, 0.8 );
|
aCfg->Read( keyBgColor_Green_Top, &GetPrm3DVisu().m_BgColor_Top.m_Green, 0.8 );
|
||||||
aCfg->Read( keyBgColor_Blue_Top, &g_Parm_3D_Visu.m_BgColor_Top.m_Blue, 0.9 );
|
aCfg->Read( keyBgColor_Blue_Top, &GetPrm3DVisu().m_BgColor_Top.m_Blue, 0.9 );
|
||||||
|
|
||||||
bool tmp;
|
bool tmp;
|
||||||
aCfg->Read( keyShowRealisticMode, &tmp, false );
|
aCfg->Read( keyShowRealisticMode, &tmp, false );
|
||||||
|
@ -297,15 +297,15 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
|
||||||
{
|
{
|
||||||
EDA_BASE_FRAME::SaveSettings( aCfg );
|
EDA_BASE_FRAME::SaveSettings( aCfg );
|
||||||
|
|
||||||
INFO3D_VISU& prms = g_Parm_3D_Visu;
|
INFO3D_VISU& prms = GetPrm3DVisu();
|
||||||
|
|
||||||
aCfg->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
|
aCfg->Write( keyBgColor_Red, GetPrm3DVisu().m_BgColor.m_Red );
|
||||||
aCfg->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
|
aCfg->Write( keyBgColor_Green, GetPrm3DVisu().m_BgColor.m_Green );
|
||||||
aCfg->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
|
aCfg->Write( keyBgColor_Blue, GetPrm3DVisu().m_BgColor.m_Blue );
|
||||||
|
|
||||||
aCfg->Write( keyBgColor_Red_Top, g_Parm_3D_Visu.m_BgColor_Top.m_Red );
|
aCfg->Write( keyBgColor_Red_Top, GetPrm3DVisu().m_BgColor_Top.m_Red );
|
||||||
aCfg->Write( keyBgColor_Green_Top, g_Parm_3D_Visu.m_BgColor_Top.m_Green );
|
aCfg->Write( keyBgColor_Green_Top, GetPrm3DVisu().m_BgColor_Top.m_Green );
|
||||||
aCfg->Write( keyBgColor_Blue_Top, g_Parm_3D_Visu.m_BgColor_Top.m_Blue );
|
aCfg->Write( keyBgColor_Blue_Top, GetPrm3DVisu().m_BgColor_Top.m_Blue );
|
||||||
|
|
||||||
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
|
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
|
||||||
|
|
||||||
|
@ -340,23 +340,23 @@ void EDA_3D_FRAME::Process_Zoom( wxCommandEvent& event )
|
||||||
case ID_ZOOM_PAGE:
|
case ID_ZOOM_PAGE:
|
||||||
|
|
||||||
for( ii = 0; ii < 4; ii++ )
|
for( ii = 0; ii < 4; ii++ )
|
||||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
GetPrm3DVisu().m_Rot[ii] = 0.0;
|
||||||
|
|
||||||
g_Parm_3D_Visu.m_Zoom = 1.0;
|
GetPrm3DVisu().m_Zoom = 1.0;
|
||||||
m_canvas->SetOffset( 0.0, 0.0 );
|
m_canvas->SetOffset( 0.0, 0.0 );
|
||||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ZOOM_IN:
|
case ID_ZOOM_IN:
|
||||||
g_Parm_3D_Visu.m_Zoom /= 1.2;
|
GetPrm3DVisu().m_Zoom /= 1.2;
|
||||||
|
|
||||||
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
|
if( GetPrm3DVisu().m_Zoom <= 0.01 )
|
||||||
g_Parm_3D_Visu.m_Zoom = 0.01;
|
GetPrm3DVisu().m_Zoom = 0.01;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ZOOM_OUT:
|
case ID_ZOOM_OUT:
|
||||||
g_Parm_3D_Visu.m_Zoom *= 1.2;
|
GetPrm3DVisu().m_Zoom *= 1.2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ZOOM_REDRAW:
|
case ID_ZOOM_REDRAW:
|
||||||
|
@ -410,27 +410,27 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ROTATE3D_X_POS:
|
case ID_ROTATE3D_X_POS:
|
||||||
g_Parm_3D_Visu.m_ROTX += ROT_ANGLE;
|
GetPrm3DVisu().m_ROTX += ROT_ANGLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ROTATE3D_X_NEG:
|
case ID_ROTATE3D_X_NEG:
|
||||||
g_Parm_3D_Visu.m_ROTX -= ROT_ANGLE;
|
GetPrm3DVisu().m_ROTX -= ROT_ANGLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ROTATE3D_Y_POS:
|
case ID_ROTATE3D_Y_POS:
|
||||||
g_Parm_3D_Visu.m_ROTY += ROT_ANGLE;
|
GetPrm3DVisu().m_ROTY += ROT_ANGLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ROTATE3D_Y_NEG:
|
case ID_ROTATE3D_Y_NEG:
|
||||||
g_Parm_3D_Visu.m_ROTY -= ROT_ANGLE;
|
GetPrm3DVisu().m_ROTY -= ROT_ANGLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ROTATE3D_Z_POS:
|
case ID_ROTATE3D_Z_POS:
|
||||||
g_Parm_3D_Visu.m_ROTZ += ROT_ANGLE;
|
GetPrm3DVisu().m_ROTZ += ROT_ANGLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ROTATE3D_Z_NEG:
|
case ID_ROTATE3D_Z_NEG:
|
||||||
g_Parm_3D_Visu.m_ROTZ -= ROT_ANGLE;
|
GetPrm3DVisu().m_ROTZ -= ROT_ANGLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MOVE3D_LEFT:
|
case ID_MOVE3D_LEFT:
|
||||||
|
@ -460,97 +460,97 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU3D_BGCOLOR_SELECTION:
|
case ID_MENU3D_BGCOLOR_SELECTION:
|
||||||
Set3DBgColor( g_Parm_3D_Visu.m_BgColor );
|
Get3DColorFromUser( GetPrm3DVisu().m_BgColor );
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_BGCOLOR_TOP_SELECTION:
|
case ID_MENU3D_BGCOLOR_TOP_SELECTION:
|
||||||
Set3DBgColor( g_Parm_3D_Visu.m_BgColor_Top );
|
Get3DColorFromUser( GetPrm3DVisu().m_BgColor_Top );
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_REALISTIC_MODE:
|
case ID_MENU3D_REALISTIC_MODE:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_USE_REALISTIC_MODE, isChecked );
|
GetPrm3DVisu().SetFlag( FL_USE_REALISTIC_MODE, isChecked );
|
||||||
NewDisplay();
|
NewDisplay();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_FL_RENDER_SHADOWS:
|
case ID_MENU3D_FL_RENDER_SHADOWS:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_RENDER_SHADOWS, isChecked );
|
GetPrm3DVisu().SetFlag( FL_RENDER_SHADOWS, isChecked );
|
||||||
NewDisplay();
|
NewDisplay();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES:
|
case ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES, isChecked );
|
GetPrm3DVisu().SetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES, isChecked );
|
||||||
NewDisplay();
|
NewDisplay();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_FL_RENDER_TEXTURES:
|
case ID_MENU3D_FL_RENDER_TEXTURES:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_RENDER_TEXTURES, isChecked );
|
GetPrm3DVisu().SetFlag( FL_RENDER_TEXTURES, isChecked );
|
||||||
NewDisplay(GL_ID_BOARD);
|
NewDisplay(GL_ID_BOARD);
|
||||||
NewDisplay(GL_ID_TECH_LAYERS);
|
NewDisplay(GL_ID_TECH_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_FL_RENDER_SMOOTH:
|
case ID_MENU3D_FL_RENDER_SMOOTH:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_RENDER_SMOOTH, isChecked );
|
GetPrm3DVisu().SetFlag( FL_RENDER_SMOOTH, isChecked );
|
||||||
NewDisplay();
|
NewDisplay();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_FL_RENDER_MATERIAL:
|
case ID_MENU3D_FL_RENDER_MATERIAL:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_RENDER_MATERIAL, isChecked );
|
GetPrm3DVisu().SetFlag( FL_RENDER_MATERIAL, isChecked );
|
||||||
NewDisplay();
|
NewDisplay();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_SHOW_BOARD_BODY:
|
case ID_MENU3D_SHOW_BOARD_BODY:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
|
GetPrm3DVisu().SetFlag( FL_SHOW_BOARD_BODY, isChecked );
|
||||||
NewDisplay();
|
NewDisplay();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_AXIS_ONOFF:
|
case ID_MENU3D_AXIS_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_AXIS, isChecked );
|
GetPrm3DVisu().SetFlag( FL_AXIS, isChecked );
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_MODULE_ONOFF:
|
case ID_MENU3D_MODULE_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_MODULE, isChecked );
|
GetPrm3DVisu().SetFlag( FL_MODULE, isChecked );
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_USE_COPPER_THICKNESS:
|
case ID_MENU3D_USE_COPPER_THICKNESS:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_USE_COPPER_THICKNESS, isChecked );
|
GetPrm3DVisu().SetFlag( FL_USE_COPPER_THICKNESS, isChecked );
|
||||||
NewDisplay(GL_ID_BOARD);
|
NewDisplay(GL_ID_BOARD);
|
||||||
NewDisplay(GL_ID_TECH_LAYERS);
|
NewDisplay(GL_ID_TECH_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_ZONE_ONOFF:
|
case ID_MENU3D_ZONE_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_ZONE, isChecked );
|
GetPrm3DVisu().SetFlag( FL_ZONE, isChecked );
|
||||||
NewDisplay(GL_ID_BOARD);
|
NewDisplay(GL_ID_BOARD);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_ADHESIVE_ONOFF:
|
case ID_MENU3D_ADHESIVE_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_ADHESIVE, isChecked );
|
GetPrm3DVisu().SetFlag( FL_ADHESIVE, isChecked );
|
||||||
NewDisplay(GL_ID_TECH_LAYERS);
|
NewDisplay(GL_ID_TECH_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_SILKSCREEN_ONOFF:
|
case ID_MENU3D_SILKSCREEN_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_SILKSCREEN, isChecked );
|
GetPrm3DVisu().SetFlag( FL_SILKSCREEN, isChecked );
|
||||||
NewDisplay(GL_ID_TECH_LAYERS);
|
NewDisplay(GL_ID_TECH_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_SOLDER_MASK_ONOFF:
|
case ID_MENU3D_SOLDER_MASK_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_SOLDERMASK, isChecked );
|
GetPrm3DVisu().SetFlag( FL_SOLDERMASK, isChecked );
|
||||||
NewDisplay(GL_ID_TECH_LAYERS);
|
NewDisplay(GL_ID_TECH_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_SOLDER_PASTE_ONOFF:
|
case ID_MENU3D_SOLDER_PASTE_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_SOLDERPASTE, isChecked );
|
GetPrm3DVisu().SetFlag( FL_SOLDERPASTE, isChecked );
|
||||||
NewDisplay(GL_ID_TECH_LAYERS);
|
NewDisplay(GL_ID_TECH_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_COMMENTS_ONOFF:
|
case ID_MENU3D_COMMENTS_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_COMMENTS, isChecked );
|
GetPrm3DVisu().SetFlag( FL_COMMENTS, isChecked );
|
||||||
NewDisplay(GL_ID_AUX_LAYERS);
|
NewDisplay(GL_ID_AUX_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ID_MENU3D_ECO_ONOFF:
|
case ID_MENU3D_ECO_ONOFF:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_ECO, isChecked );
|
GetPrm3DVisu().SetFlag( FL_ECO, isChecked );
|
||||||
NewDisplay(GL_ID_AUX_LAYERS);
|
NewDisplay(GL_ID_AUX_LAYERS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -579,27 +579,27 @@ void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event )
|
||||||
switch( id )
|
switch( id )
|
||||||
{
|
{
|
||||||
case ID_MENU3D_GRID_NOGRID:
|
case ID_MENU3D_GRID_NOGRID:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_GRID, false );
|
GetPrm3DVisu().SetFlag( FL_GRID, false );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU3D_GRID_10_MM:
|
case ID_MENU3D_GRID_10_MM:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
|
GetPrm3DVisu().SetFlag( FL_GRID, true );
|
||||||
g_Parm_3D_Visu.m_3D_Grid = 10.0;
|
GetPrm3DVisu().m_3D_Grid = 10.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU3D_GRID_5_MM:
|
case ID_MENU3D_GRID_5_MM:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
|
GetPrm3DVisu().SetFlag( FL_GRID, true );
|
||||||
g_Parm_3D_Visu.m_3D_Grid = 5.0;
|
GetPrm3DVisu().m_3D_Grid = 5.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU3D_GRID_2P5_MM:
|
case ID_MENU3D_GRID_2P5_MM:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
|
GetPrm3DVisu().SetFlag( FL_GRID, true );
|
||||||
g_Parm_3D_Visu.m_3D_Grid = 2.5;
|
GetPrm3DVisu().m_3D_Grid = 2.5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU3D_GRID_1_MM:
|
case ID_MENU3D_GRID_1_MM:
|
||||||
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
|
GetPrm3DVisu().SetFlag( FL_GRID, true );
|
||||||
g_Parm_3D_Visu.m_3D_Grid = 1.0;
|
GetPrm3DVisu().m_3D_Grid = 1.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -636,7 +636,7 @@ void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
|
||||||
|
|
||||||
/* called to set the background color of the 3D scene
|
/* called to set the background color of the 3D scene
|
||||||
*/
|
*/
|
||||||
bool EDA_3D_FRAME::Set3DBgColor( S3D_COLOR &color )
|
bool EDA_3D_FRAME::Get3DColorFromUser( S3D_COLOR &color )
|
||||||
{
|
{
|
||||||
wxColour newcolor, oldcolor;
|
wxColour newcolor, oldcolor;
|
||||||
|
|
||||||
|
@ -663,3 +663,17 @@ BOARD* EDA_3D_FRAME::GetBoard()
|
||||||
{
|
{
|
||||||
return Parent()->GetBoard();
|
return Parent()->GetBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INFO3D_VISU& EDA_3D_FRAME::GetPrm3DVisu() const
|
||||||
|
{
|
||||||
|
// return the INFO3D_VISU which contains the current parameters
|
||||||
|
// to draw the 3D view og the board
|
||||||
|
return g_Parm_3D_Visu;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EDA_3D_FRAME::IsEnabled( DISPLAY3D_FLG aItem ) const
|
||||||
|
{
|
||||||
|
// return true if aItem must be displayed
|
||||||
|
return GetPrm3DVisu().GetFlag( aItem );
|
||||||
|
}
|
||||||
|
|
|
@ -71,25 +71,25 @@ void SetOpenGlDefaultMaterial()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void S3D_MATERIAL::SetOpenGLMaterial( unsigned int materialIndex )
|
void S3D_MATERIAL::SetOpenGLMaterial( unsigned int aMaterialIndex, bool aUseMaterial )
|
||||||
{
|
{
|
||||||
S3D_MASTER * s3dParent = (S3D_MASTER *) GetParent();
|
S3D_MASTER * s3dParent = (S3D_MASTER *) GetParent();
|
||||||
|
|
||||||
if( ! s3dParent->IsOpenGlAllowed() )
|
if( ! s3dParent->IsOpenGlAllowed() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_MATERIAL ) )
|
if( aUseMaterial )
|
||||||
{
|
{
|
||||||
float transparency_value = 0.0f;
|
float transparency_value = 0.0f;
|
||||||
if( m_Transparency.size() > materialIndex )
|
if( m_Transparency.size() > aMaterialIndex )
|
||||||
{
|
{
|
||||||
transparency_value = m_Transparency[materialIndex];
|
transparency_value = m_Transparency[aMaterialIndex];
|
||||||
s3dParent->SetLastTransparency( transparency_value );
|
s3dParent->SetLastTransparency( transparency_value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_DiffuseColor.size() > materialIndex )
|
if( m_DiffuseColor.size() > aMaterialIndex )
|
||||||
{
|
{
|
||||||
glm::vec3 color = m_DiffuseColor[materialIndex];
|
glm::vec3 color = m_DiffuseColor[aMaterialIndex];
|
||||||
|
|
||||||
if( m_AmbientColor.size() == 0 )
|
if( m_AmbientColor.size() == 0 )
|
||||||
{
|
{
|
||||||
|
@ -99,49 +99,49 @@ void S3D_MATERIAL::SetOpenGLMaterial( unsigned int materialIndex )
|
||||||
glColor4f( color.x, color.y, color.z, 1.0 - transparency_value );
|
glColor4f( color.x, color.y, color.z, 1.0 - transparency_value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_Shininess.size() > materialIndex )
|
if( m_Shininess.size() > aMaterialIndex )
|
||||||
{
|
{
|
||||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_Shininess[materialIndex] );
|
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_Shininess[aMaterialIndex] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// emissive
|
// emissive
|
||||||
if( m_EmissiveColor.size() > materialIndex )
|
if( m_EmissiveColor.size() > aMaterialIndex )
|
||||||
{
|
{
|
||||||
glm::vec4 emissive;
|
glm::vec4 emissive;
|
||||||
emissive[0] = m_EmissiveColor[materialIndex].x;
|
emissive[0] = m_EmissiveColor[aMaterialIndex].x;
|
||||||
emissive[1] = m_EmissiveColor[materialIndex].y;
|
emissive[1] = m_EmissiveColor[aMaterialIndex].y;
|
||||||
emissive[2] = m_EmissiveColor[materialIndex].z;
|
emissive[2] = m_EmissiveColor[aMaterialIndex].z;
|
||||||
emissive[3] = 1.0f;
|
emissive[3] = 1.0f;
|
||||||
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x );
|
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x );
|
||||||
}
|
}
|
||||||
|
|
||||||
// specular
|
// specular
|
||||||
if( m_SpecularColor.size() > materialIndex )
|
if( m_SpecularColor.size() > aMaterialIndex )
|
||||||
{
|
{
|
||||||
glm::vec4 specular;
|
glm::vec4 specular;
|
||||||
specular[0] = m_SpecularColor[materialIndex].x;
|
specular[0] = m_SpecularColor[aMaterialIndex].x;
|
||||||
specular[1] = m_SpecularColor[materialIndex].y;
|
specular[1] = m_SpecularColor[aMaterialIndex].y;
|
||||||
specular[2] = m_SpecularColor[materialIndex].z;
|
specular[2] = m_SpecularColor[aMaterialIndex].z;
|
||||||
specular[3] = 1.0f;
|
specular[3] = 1.0f;
|
||||||
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
|
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ambient
|
// ambient
|
||||||
if( m_AmbientColor.size() > materialIndex )
|
if( m_AmbientColor.size() > aMaterialIndex )
|
||||||
{
|
{
|
||||||
glm::vec4 ambient;
|
glm::vec4 ambient;
|
||||||
ambient[0] = m_AmbientColor[materialIndex].x;
|
ambient[0] = m_AmbientColor[aMaterialIndex].x;
|
||||||
ambient[1] = m_AmbientColor[materialIndex].y;
|
ambient[1] = m_AmbientColor[aMaterialIndex].y;
|
||||||
ambient[2] = m_AmbientColor[materialIndex].z;
|
ambient[2] = m_AmbientColor[aMaterialIndex].z;
|
||||||
ambient[3] = 1.0f;
|
ambient[3] = 1.0f;
|
||||||
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
|
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( m_DiffuseColor.size() > materialIndex )
|
if( m_DiffuseColor.size() > aMaterialIndex )
|
||||||
{
|
{
|
||||||
glm::vec3 color = m_DiffuseColor[materialIndex];
|
glm::vec3 color = m_DiffuseColor[aMaterialIndex];
|
||||||
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
||||||
glColor4f( color.x, color.y, color.z, 1.0 );
|
glColor4f( color.x, color.y, color.z, 1.0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,13 @@ public:
|
||||||
S3D_MATERIAL* Next() const { return (S3D_MATERIAL*) Pnext; }
|
S3D_MATERIAL* Next() const { return (S3D_MATERIAL*) Pnext; }
|
||||||
S3D_MATERIAL* Back() const { return (S3D_MATERIAL*) Pback; }
|
S3D_MATERIAL* Back() const { return (S3D_MATERIAL*) Pback; }
|
||||||
|
|
||||||
void SetOpenGLMaterial(unsigned int materialIndex);
|
/**
|
||||||
|
* Initialize the material prms.
|
||||||
|
* @param aMaterialIndex = the index in list of available materials
|
||||||
|
* @param aUseMaterial = true to use the values found in the available material
|
||||||
|
* = false to use only the color, and other prms are fixed
|
||||||
|
*/
|
||||||
|
void SetOpenGLMaterial(unsigned int aMaterialIndex, bool aUseMaterial);
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
||||||
|
|
|
@ -89,10 +89,13 @@ void S3D_MESH::openGL_RenderAllChilds()
|
||||||
void S3D_MESH::openGL_Render()
|
void S3D_MESH::openGL_Render()
|
||||||
{
|
{
|
||||||
//DBG( printf( "openGL_Render" ) );
|
//DBG( printf( "openGL_Render" ) );
|
||||||
|
bool useMaterial = g_Parm_3D_Visu.GetFlag( FL_RENDER_MATERIAL );
|
||||||
|
bool smoothShapes = g_Parm_3D_Visu.IsRealisticMode()
|
||||||
|
&& g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH );
|
||||||
|
|
||||||
if( m_Materials )
|
if( m_Materials )
|
||||||
{
|
{
|
||||||
m_Materials->SetOpenGLMaterial( 0 );
|
m_Materials->SetOpenGLMaterial( 0, useMaterial );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_CoordIndex.size() == 0)
|
if( m_CoordIndex.size() == 0)
|
||||||
|
@ -113,7 +116,7 @@ void S3D_MESH::openGL_Render()
|
||||||
|
|
||||||
if( m_PerVertexNormalsNormalized.size() == 0 )
|
if( m_PerVertexNormalsNormalized.size() == 0 )
|
||||||
{
|
{
|
||||||
if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH ) )
|
if( smoothShapes )
|
||||||
{
|
{
|
||||||
calcPerPointNormals();
|
calcPerPointNormals();
|
||||||
}
|
}
|
||||||
|
@ -125,7 +128,7 @@ void S3D_MESH::openGL_Render()
|
||||||
{
|
{
|
||||||
if( m_Materials )
|
if( m_Materials )
|
||||||
{
|
{
|
||||||
m_Materials->SetOpenGLMaterial( m_MaterialIndex[idx] );
|
m_Materials->SetOpenGLMaterial( m_MaterialIndex[idx], useMaterial );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +151,8 @@ void S3D_MESH::openGL_Render()
|
||||||
glm::vec3 point = m_Point[m_CoordIndex[idx][ii]];
|
glm::vec3 point = m_Point[m_CoordIndex[idx][ii]];
|
||||||
glVertex3fv( &point.x );
|
glVertex3fv( &point.x );
|
||||||
}
|
}
|
||||||
} else if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH ) )
|
}
|
||||||
|
else if( smoothShapes )
|
||||||
{
|
{
|
||||||
std::vector< glm::vec3 > normals_list;
|
std::vector< glm::vec3 > normals_list;
|
||||||
normals_list = m_PerFaceVertexNormals[idx];
|
normals_list = m_PerFaceVertexNormals[idx];
|
||||||
|
@ -161,7 +165,8 @@ void S3D_MESH::openGL_Render()
|
||||||
glm::vec3 point = m_Point[m_CoordIndex[idx][ii]];
|
glm::vec3 point = m_Point[m_CoordIndex[idx][ii]];
|
||||||
glVertex3fv( &point.x );
|
glVertex3fv( &point.x );
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Flat
|
// Flat
|
||||||
glm::vec3 normal = m_PerFaceNormalsNormalized[idx];
|
glm::vec3 normal = m_PerFaceNormalsNormalized[idx];
|
||||||
|
|
|
@ -119,7 +119,7 @@ int S3D_MASTER::ReadData()
|
||||||
|
|
||||||
if( parser )
|
if( parser )
|
||||||
{
|
{
|
||||||
parser->Load( filename );
|
parser->Load( filename, g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB );
|
||||||
delete parser;
|
delete parser;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,12 +211,12 @@ void EDA_3D_FRAME::CreateMenuBar()
|
||||||
gridlistMenu->AppendCheckItem( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString );
|
gridlistMenu->AppendCheckItem( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString );
|
||||||
|
|
||||||
// If the grid is on, check the corresponding menuitem showing the grid size
|
// If the grid is on, check the corresponding menuitem showing the grid size
|
||||||
if( g_Parm_3D_Visu.GetFlag( FL_GRID ) )
|
if( IsEnabled( FL_GRID ) )
|
||||||
{
|
{
|
||||||
gridlistMenu->Check( ID_MENU3D_GRID_10_MM, g_Parm_3D_Visu.m_3D_Grid == 10.0 );
|
gridlistMenu->Check( ID_MENU3D_GRID_10_MM, GetPrm3DVisu().m_3D_Grid == 10.0 );
|
||||||
gridlistMenu->Check( ID_MENU3D_GRID_5_MM, g_Parm_3D_Visu.m_3D_Grid == 5.0 );
|
gridlistMenu->Check( ID_MENU3D_GRID_5_MM, GetPrm3DVisu().m_3D_Grid == 5.0 );
|
||||||
gridlistMenu->Check( ID_MENU3D_GRID_2P5_MM, g_Parm_3D_Visu.m_3D_Grid == 2.5 );
|
gridlistMenu->Check( ID_MENU3D_GRID_2P5_MM, GetPrm3DVisu().m_3D_Grid == 2.5 );
|
||||||
gridlistMenu->Check( ID_MENU3D_GRID_1_MM, g_Parm_3D_Visu.m_3D_Grid == 1.0 );
|
gridlistMenu->Check( ID_MENU3D_GRID_1_MM, GetPrm3DVisu().m_3D_Grid == 1.0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true );
|
gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true );
|
||||||
|
@ -273,58 +273,58 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
|
||||||
wxMenuItem* item;
|
wxMenuItem* item;
|
||||||
// Set the state of toggle menus according to the current display options
|
// Set the state of toggle menus according to the current display options
|
||||||
item = menuBar->FindItem( ID_MENU3D_REALISTIC_MODE );
|
item = menuBar->FindItem( ID_MENU3D_REALISTIC_MODE );
|
||||||
item->Check( g_Parm_3D_Visu.IsRealisticMode() );
|
item->Check( GetPrm3DVisu().IsRealisticMode() );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS );
|
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_SHADOWS ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SHADOWS ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS );
|
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_SHADOWS ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SHADOWS ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES );
|
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_TEXTURES );
|
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_TEXTURES );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_TEXTURES ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SMOOTH );
|
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SMOOTH );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SMOOTH ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL );
|
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_MATERIAL ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_MATERIAL ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY );
|
item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_SHOW_BOARD_BODY ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS );
|
item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_USE_COPPER_THICKNESS ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_USE_COPPER_THICKNESS ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_MODULE_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_MODULE_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_MODULE ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_MODULE ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_ZONE ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_ZONE ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_AXIS_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_AXIS_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_AXIS ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_AXIS ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_ADHESIVE ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_ADHESIVE ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_SILKSCREEN_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_SILKSCREEN_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_SILKSCREEN ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_SILKSCREEN ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_SOLDER_MASK_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_SOLDER_MASK_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_SOLDERMASK ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_SOLDERMASK ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_SOLDER_PASTE_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_SOLDER_PASTE_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_SOLDERPASTE ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_SOLDERPASTE ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_COMMENTS_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_COMMENTS_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_COMMENTS ) );
|
item->Check( GetPrm3DVisu().GetFlag( FL_COMMENTS ) );
|
||||||
|
|
||||||
item = menuBar->FindItem( ID_MENU3D_ECO_ONOFF );
|
item = menuBar->FindItem( ID_MENU3D_ECO_ONOFF );
|
||||||
item->Check( g_Parm_3D_Visu.GetFlag( FL_ECO ));
|
item->Check( GetPrm3DVisu().GetFlag( FL_ECO ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDA_3D_FRAME::SetToolbars()
|
void EDA_3D_FRAME::SetToolbars()
|
||||||
|
|
|
@ -98,9 +98,21 @@ public:
|
||||||
/// Toggles orthographic projection on and off
|
/// Toggles orthographic projection on and off
|
||||||
void ToggleOrtho(){ m_ortho = !m_ortho ; Refresh(true);};
|
void ToggleOrtho(){ m_ortho = !m_ortho ; Refresh(true);};
|
||||||
|
|
||||||
/// Returns the orthographic projection flag
|
/// @return the orthographic projection flag
|
||||||
bool ModeIsOrtho() { return m_ortho ;};
|
bool ModeIsOrtho() { return m_ortho ;};
|
||||||
|
|
||||||
|
/** @return the INFO3D_VISU which contains the current parameters
|
||||||
|
* to draw the 3D view og the board
|
||||||
|
*/
|
||||||
|
INFO3D_VISU& GetPrm3DVisu() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if aItem must be displayed
|
||||||
|
* @param aItem = an item of DISPLAY3D_FLG enum
|
||||||
|
*/
|
||||||
|
bool IsEnabled( DISPLAY3D_FLG aItem ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Event handlers:
|
// Event handlers:
|
||||||
void Exit3DFrame( wxCommandEvent& event );
|
void Exit3DFrame( wxCommandEvent& event );
|
||||||
|
@ -128,7 +140,10 @@ private:
|
||||||
double BestZoom();
|
double BestZoom();
|
||||||
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
||||||
|
|
||||||
bool Set3DBgColor( S3D_COLOR &color );
|
// Get a S3D_COLOR from a wx colour dialog
|
||||||
|
// return true if a new color is chosen, false if
|
||||||
|
// no change or aborted by user
|
||||||
|
bool Get3DColorFromUser( S3D_COLOR &color );
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -65,6 +65,7 @@ INFO3D_VISU::INFO3D_VISU()
|
||||||
m_copperThickness = 0;
|
m_copperThickness = 0;
|
||||||
m_epoxyThickness = 0;
|
m_epoxyThickness = 0;
|
||||||
m_nonCopperLayerThickness = 0;
|
m_nonCopperLayerThickness = 0;
|
||||||
|
m_BiuTo3Dunits = 1.0;
|
||||||
|
|
||||||
// Set copper color, in realistic mode
|
// Set copper color, in realistic mode
|
||||||
#define LUMINANCE 0.7/255.0
|
#define LUMINANCE 0.7/255.0
|
||||||
|
@ -94,8 +95,7 @@ INFO3D_VISU::INFO3D_VISU()
|
||||||
m_BoardBodyColor.m_Blue = 110.0*LUMINANCE;
|
m_BoardBodyColor.m_Blue = 110.0*LUMINANCE;
|
||||||
|
|
||||||
// default all special item layers Visible
|
// default all special item layers Visible
|
||||||
for( ii = 0; ii < FL_LAST; ii++ )
|
m_drawFlags.set();
|
||||||
m_drawFlags[ii] = true;
|
|
||||||
|
|
||||||
SetFlag( FL_GRID, false );
|
SetFlag( FL_GRID, false );
|
||||||
SetFlag( FL_USE_COPPER_THICKNESS, false );
|
SetFlag( FL_USE_COPPER_THICKNESS, false );
|
||||||
|
@ -230,9 +230,10 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
|
||||||
*/
|
*/
|
||||||
double INFO3D_VISU::GetModulesZcoord3DIU( bool aIsFlipped )
|
double INFO3D_VISU::GetModulesZcoord3DIU( bool aIsFlipped )
|
||||||
{
|
{
|
||||||
|
// NOTE: Z position to display modules in top of Paste and near the shadow
|
||||||
if( aIsFlipped )
|
if( aIsFlipped )
|
||||||
return m_layerZcoord[B_Paste] - ( m_copperThickness / 2 ); //B_Cu NOTE: in order to display modules in top of Paste and near the shadow
|
return m_layerZcoord[B_Paste] - ( m_copperThickness / 2 );
|
||||||
else
|
else
|
||||||
return m_layerZcoord[F_Paste] + ( m_copperThickness / 2 ); //F_Cu
|
return m_layerZcoord[F_Paste] + ( m_copperThickness / 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,9 @@
|
||||||
|
|
||||||
class BOARD_DESIGN_SETTINGS;
|
class BOARD_DESIGN_SETTINGS;
|
||||||
|
|
||||||
class S3D_COLOR /* 3D color (R, G, B) 3 floats range 0 to 1.0*/
|
/** Minor class to store a 3D color (R, G, B) 3 floats range 0 to 1.0
|
||||||
|
*/
|
||||||
|
class S3D_COLOR
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
double m_Red, m_Green, m_Blue;
|
double m_Red, m_Green, m_Blue;
|
||||||
|
@ -62,7 +64,6 @@ public: S3D_COLOR()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* information needed to display 3D board */
|
|
||||||
enum DISPLAY3D_FLG {
|
enum DISPLAY3D_FLG {
|
||||||
FL_AXIS=0, FL_MODULE, FL_ZONE,
|
FL_AXIS=0, FL_MODULE, FL_ZONE,
|
||||||
FL_ADHESIVE, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE,
|
FL_ADHESIVE, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE,
|
||||||
|
@ -79,6 +80,8 @@ enum DISPLAY3D_FLG {
|
||||||
FL_LAST
|
FL_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Helper class to handle information needed to display 3D board
|
||||||
|
*/
|
||||||
class INFO3D_VISU
|
class INFO3D_VISU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -112,27 +115,25 @@ private:
|
||||||
double m_copperThickness; // Copper thickness (normalized)
|
double m_copperThickness; // Copper thickness (normalized)
|
||||||
double m_epoxyThickness; // Epoxy thickness (normalized)
|
double m_epoxyThickness; // Epoxy thickness (normalized)
|
||||||
double m_nonCopperLayerThickness; // Non copper layers thickness
|
double m_nonCopperLayerThickness; // Non copper layers thickness
|
||||||
bool m_drawFlags[FL_LAST]; // Enable/disable flags (see DISPLAY3D_FLG list)
|
std::bitset<FL_LAST> m_drawFlags; // Enable/disable flags (see DISPLAY3D_FLG list)
|
||||||
|
|
||||||
public: INFO3D_VISU();
|
public: INFO3D_VISU();
|
||||||
~INFO3D_VISU();
|
~INFO3D_VISU();
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
bool GetFlag( DISPLAY3D_FLG aFlag ) const { return m_drawFlags[aFlag]; }
|
bool GetFlag( DISPLAY3D_FLG aFlag ) const { return m_drawFlags[aFlag]; }
|
||||||
bool SetFlag( DISPLAY3D_FLG aFlag, bool aState )
|
void SetFlag( DISPLAY3D_FLG aFlag, bool aState )
|
||||||
{
|
{
|
||||||
return m_drawFlags[aFlag] = aState;
|
m_drawFlags[aFlag] = aState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function InitSettings
|
* Initialize 3D Parameters depending on aBoard
|
||||||
* Initialize info 3D Parameters from aBoard
|
|
||||||
* @param aBoard: the board to display
|
* @param aBoard: the board to display
|
||||||
*/
|
*/
|
||||||
void InitSettings( BOARD* aBoard );
|
void InitSettings( BOARD* aBoard );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function GetModulesZcoord3DIU
|
|
||||||
* @return the Z position of 3D shapes, in 3D Units
|
* @return the Z position of 3D shapes, in 3D Units
|
||||||
* @param aIsFlipped: true for modules on Front (top) layer, false
|
* @param aIsFlipped: true for modules on Front (top) layer, false
|
||||||
* if on back (bottom) layer
|
* if on back (bottom) layer
|
||||||
|
@ -140,7 +141,6 @@ public: INFO3D_VISU();
|
||||||
double GetModulesZcoord3DIU( bool aIsFlipped );
|
double GetModulesZcoord3DIU( bool aIsFlipped );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function GetLayerZcoordBIU
|
|
||||||
* @return the Z coordinate of the layer aLayer, in Board Internal Units
|
* @return the Z coordinate of the layer aLayer, in Board Internal Units
|
||||||
* @param aLayerId: the layer number
|
* @param aLayerId: the layer number
|
||||||
*/
|
*/
|
||||||
|
@ -150,7 +150,6 @@ public: INFO3D_VISU();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function GetCopperThicknessBIU
|
|
||||||
* @return the thickness (Z size) of the copper, in Board Internal Units
|
* @return the thickness (Z size) of the copper, in Board Internal Units
|
||||||
* note: the thickness (Z size) of the copper is not the thickness
|
* note: the thickness (Z size) of the copper is not the thickness
|
||||||
* of the layer (the thickness of the layer is the epoxy thickness / layer count)
|
* of the layer (the thickness of the layer is the epoxy thickness / layer count)
|
||||||
|
|
|
@ -66,12 +66,15 @@ public:
|
||||||
* @param aExtension is file extension of the file you are going to parse.
|
* @param aExtension is file extension of the file you are going to parse.
|
||||||
*/
|
*/
|
||||||
static S3D_MODEL_PARSER* Create( S3D_MASTER* aMaster, const wxString aExtension );
|
static S3D_MODEL_PARSER* Create( S3D_MASTER* aMaster, const wxString aExtension );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Load
|
* pure virtual Function
|
||||||
*
|
|
||||||
* Concrete parsers should implement this function
|
* Concrete parsers should implement this function
|
||||||
|
* @param aFilename = the full file name of the file to load
|
||||||
|
* @param aVrmlunits_to_3Dunits = the scaling factor, i.e. the
|
||||||
|
* convertion from file unit to internal 3D units
|
||||||
*/
|
*/
|
||||||
virtual void Load( const wxString aFilename ) = 0;
|
virtual void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits ) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
S3D_MASTER* master;
|
S3D_MASTER* master;
|
||||||
|
@ -89,7 +92,8 @@ class X3D_MODEL_PARSER: public S3D_MODEL_PARSER
|
||||||
public:
|
public:
|
||||||
X3D_MODEL_PARSER( S3D_MASTER* aMaster );
|
X3D_MODEL_PARSER( S3D_MASTER* aMaster );
|
||||||
~X3D_MODEL_PARSER();
|
~X3D_MODEL_PARSER();
|
||||||
void Load( const wxString aFilename );
|
|
||||||
|
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
|
||||||
|
|
||||||
typedef std::map< wxString, wxString > PROPERTY_MAP;
|
typedef std::map< wxString, wxString > PROPERTY_MAP;
|
||||||
typedef std::vector< wxXmlNode* > NODE_LIST;
|
typedef std::vector< wxXmlNode* > NODE_LIST;
|
||||||
|
@ -148,7 +152,8 @@ class VRML2_MODEL_PARSER: public S3D_MODEL_PARSER
|
||||||
public:
|
public:
|
||||||
VRML2_MODEL_PARSER( S3D_MASTER* aMaster );
|
VRML2_MODEL_PARSER( S3D_MASTER* aMaster );
|
||||||
~VRML2_MODEL_PARSER();
|
~VRML2_MODEL_PARSER();
|
||||||
void Load( const wxString aFilename );
|
|
||||||
|
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return string representing VRML2 file in vrml2 format
|
* Return string representing VRML2 file in vrml2 format
|
||||||
|
@ -191,7 +196,8 @@ class VRML1_MODEL_PARSER: public S3D_MODEL_PARSER
|
||||||
public:
|
public:
|
||||||
VRML1_MODEL_PARSER( S3D_MASTER* aMaster );
|
VRML1_MODEL_PARSER( S3D_MASTER* aMaster );
|
||||||
~VRML1_MODEL_PARSER();
|
~VRML1_MODEL_PARSER();
|
||||||
void Load( const wxString aFilename );
|
|
||||||
|
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return string representing VRML2 file in vrml2 format
|
* Return string representing VRML2 file in vrml2 format
|
||||||
|
@ -236,7 +242,8 @@ class VRML_MODEL_PARSER: public S3D_MODEL_PARSER
|
||||||
public:
|
public:
|
||||||
VRML_MODEL_PARSER( S3D_MASTER* aMaster );
|
VRML_MODEL_PARSER( S3D_MASTER* aMaster );
|
||||||
~VRML_MODEL_PARSER();
|
~VRML_MODEL_PARSER();
|
||||||
void Load( const wxString aFilename );
|
|
||||||
|
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VRML1_MODEL_PARSER *vrml1_parser;
|
VRML1_MODEL_PARSER *vrml1_parser;
|
||||||
|
|
|
@ -53,11 +53,11 @@ VRML1_MODEL_PARSER::~VRML1_MODEL_PARSER()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VRML1_MODEL_PARSER::Load( const wxString aFilename )
|
void VRML1_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[128];
|
||||||
|
|
||||||
// DBG( printf( "Load %s\n", static_cast<const char*>(aFilename.mb_str()) ) );
|
// DBG( printf( "Load %s\n", GetChars(aFilename) ) );
|
||||||
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
||||||
|
|
||||||
if( m_file == NULL )
|
if( m_file == NULL )
|
||||||
|
@ -65,7 +65,7 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
|
float vrmlunits_to_3Dunits = aVrmlunits_to_3Dunits;
|
||||||
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
||||||
|
|
||||||
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
|
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
|
||||||
|
@ -87,8 +87,7 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
|
||||||
|
|
||||||
glScalef( matScale.x, matScale.y, matScale.z );
|
glScalef( matScale.x, matScale.y, matScale.z );
|
||||||
|
|
||||||
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
LOCALE_IO toggle; // Switch the locale to standard C
|
||||||
SetLocaleTo_C_standard();
|
|
||||||
|
|
||||||
childs.clear();
|
childs.clear();
|
||||||
|
|
||||||
|
@ -108,8 +107,6 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( m_file );
|
fclose( m_file );
|
||||||
SetLocaleTo_Default(); // revert to the current locale
|
|
||||||
|
|
||||||
|
|
||||||
// DBG( printf( "chils size:%lu\n", childs.size() ) );
|
// DBG( printf( "chils size:%lu\n", childs.size() ) );
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,11 @@ VRML2_MODEL_PARSER::~VRML2_MODEL_PARSER()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VRML2_MODEL_PARSER::Load( const wxString aFilename )
|
void VRML2_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[128];
|
||||||
|
|
||||||
// DBG( printf( "Load %s\n", static_cast<const char*>(aFilename.mb_str()) ) );
|
// DBG( printf( "Load %s\n", GetChars(aFilename) ) );
|
||||||
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
||||||
|
|
||||||
if( m_file == NULL )
|
if( m_file == NULL )
|
||||||
|
@ -67,7 +67,7 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
|
float vrmlunits_to_3Dunits = aVrmlunits_to_3Dunits;
|
||||||
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
||||||
|
|
||||||
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
|
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
|
||||||
|
|
|
@ -59,12 +59,12 @@ VRML_MODEL_PARSER::~VRML_MODEL_PARSER()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VRML_MODEL_PARSER::Load( const wxString aFilename )
|
void VRML_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
||||||
{
|
{
|
||||||
char line[12];
|
char line[128];
|
||||||
FILE* file;
|
FILE* file;
|
||||||
|
|
||||||
//DBG( printf( "Load %s", static_cast<const char*>(aFilename.mb_str()) ) );
|
//DBG( printf( "Load %s", GetChars( aFilename ) ) );
|
||||||
|
|
||||||
file = wxFopen( aFilename, wxT( "rt" ) );
|
file = wxFopen( aFilename, wxT( "rt" ) );
|
||||||
|
|
||||||
|
@ -86,14 +86,14 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename )
|
||||||
if( stricmp( line, "#VRML V2.0" ) == 0 )
|
if( stricmp( line, "#VRML V2.0" ) == 0 )
|
||||||
{
|
{
|
||||||
//DBG( printf( "About to parser a #VRML V2.0 file\n" ) );
|
//DBG( printf( "About to parser a #VRML V2.0 file\n" ) );
|
||||||
vrml2_parser->Load( aFilename );
|
vrml2_parser->Load( aFilename, aVrmlunits_to_3Dunits );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( stricmp( line, "#VRML V1.0" ) == 0 )
|
else if( stricmp( line, "#VRML V1.0" ) == 0 )
|
||||||
{
|
{
|
||||||
//DBG( printf( "About to parser a #VRML V1.0 file\n" ) );
|
//DBG( printf( "About to parser a #VRML V1.0 file\n" ) );
|
||||||
vrml1_parser->Load( aFilename );
|
vrml1_parser->Load( aFilename, aVrmlunits_to_3Dunits );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ X3D_MODEL_PARSER::~X3D_MODEL_PARSER()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void X3D_MODEL_PARSER::Load( const wxString aFilename )
|
void X3D_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
||||||
{
|
{
|
||||||
wxXmlDocument doc;
|
wxXmlDocument doc;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void X3D_MODEL_PARSER::Load( const wxString aFilename )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
|
float vrmlunits_to_3Dunits = aVrmlunits_to_3Dunits;
|
||||||
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
||||||
|
|
||||||
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
|
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
|
||||||
|
|
|
@ -1320,7 +1320,8 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
|
||||||
if( parser )
|
if( parser )
|
||||||
{
|
{
|
||||||
// embed x3d model in vrml format
|
// embed x3d model in vrml format
|
||||||
parser->Load( fname );
|
double vrml_to_x3d = aVRMLModelsToBiu;
|
||||||
|
parser->Load( fname, vrml_to_x3d );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue