Commit fafd19c6 authored by jean-pierre charras's avatar jean-pierre charras

Add patch from Mario Luzeiro to 3D viewer. Fix a serious issue due to...

Add patch from Mario Luzeiro to 3D viewer. Fix a serious issue due to duplicate ID used in menus and toolbars between sub-applications, related to wxUpdateUIEvent events loop.
wxUpdateUIEvent events can be sent to parent frames, when opening a menu in a child frame, if parent and child frame share same ID fro menuitems (or tools)
The wrong menuitem can be used in some cases ( because there are more than one menuitem with the same identifier), by a wxUpdateUIEvent event function run in a parent frame.
parent 12229246
......@@ -520,8 +520,8 @@ GLuint load_and_generate_texture( tsImage *image )
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_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
return texture;
......@@ -547,7 +547,7 @@ void EDA_3D_CANVAS::InitGL()
glEnable( GL_ALPHA_TEST );
glEnable( GL_LINE_SMOOTH );
// glEnable(GL_POLYGON_SMOOTH); // creates issues with some graphic cards
glShadeModel( GL_SMOOTH );
glEnable( GL_NORMALIZE );
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
......@@ -569,7 +569,7 @@ void EDA_3D_CANVAS::SetLights()
{
/* set viewing projection */
GLfloat Z_axis_pos[4] = { 0.0, 0.0, 30.0, 0.0 };
GLfloat lowZ_axis_pos[4] = { 0.0, 0.0, -30.0, 0.5 };
// 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
......@@ -577,14 +577,21 @@ void EDA_3D_CANVAS::SetLights()
light_color[3] = 1.0;
// Light above the xy plane
// The default setting for GL_AMBIENT light intensity is (0.0, 0.0, 0.0, 1.0)
glLightfv( GL_LIGHT0, GL_POSITION, Z_axis_pos );
light_color[0] = light_color[1] = light_color[2] = 0.1;
glLightfv( GL_LIGHT0, GL_AMBIENT, light_color );
light_color[0] = light_color[1] = light_color[2] = 1.0;
glLightfv( GL_LIGHT0, GL_DIFFUSE, light_color );
light_color[0] = light_color[1] = light_color[2] = 0.2;
light_color[0] = light_color[1] = light_color[2] = 1.0;
glLightfv( GL_LIGHT0, GL_SPECULAR, light_color );
glLightfv( GL_LIGHT0, GL_POSITION, Z_axis_pos );
light_color[0] = light_color[1] = light_color[2] = 0.1;
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;
......@@ -592,9 +599,9 @@ void EDA_3D_CANVAS::SetLights()
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_LIGHT1 ); // White spot on Z axis ( bottom )
glDisable( GL_LIGHT1 ); // White spot on Z axis ( bottom )
glEnable( GL_LIGHTING );
}
......
......@@ -109,8 +109,8 @@ static void blur_tex( GLuint aTex, int aPasses, GLuint aTexture_size )
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, aTex );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
while (aPasses > 0)
{
......@@ -172,7 +172,7 @@ void EDA_3D_CANVAS::Create_and_Render_Shadow_Buffer( GLuint *aDst_gl_texture,
{
if( m_glLists[GL_ID_BODY] )
{
glCallList( m_glLists[GL_ID_BOARD] );
glCallList( m_glLists[GL_ID_BODY] );
}
}
......@@ -311,7 +311,7 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
glTranslatef( 0, 0, -0.4f );
glRotatef( 180.0, 0.0, 1.0, 0.0 );
Create_and_Render_Shadow_Buffer( &m_text_fake_shadow_board, 512, true, 10 );
Create_and_Render_Shadow_Buffer( &m_text_fake_shadow_board, 512, true, 20 );
}
......@@ -334,7 +334,7 @@ void EDA_3D_CANVAS::Redraw()
InitGL();
if( g_Parm_3D_Visu.GetFlag( FL_MODULE ) && g_Parm_3D_Visu.IsRealisticMode() &&
g_Parm_3D_Visu.HightQualityMode() )
g_Parm_3D_Visu.GetFlag( FL_RENDER_SHADOWS ) )
{
GenerateFakeShadowsTextures();
}
......@@ -348,6 +348,15 @@ void EDA_3D_CANVAS::Redraw()
glClearDepth( 1.0 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH ) )
{
glShadeModel( GL_SMOOTH );
}
else
{
glShadeModel( GL_FLAT );
}
// Draw background
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
......@@ -362,24 +371,22 @@ void EDA_3D_CANVAS::Redraw()
// Draw the background ( rectangle with color gradient)
glBegin( GL_QUADS );
#define BGCOLOR1(x) (x)
#define BGCOLOR2(x) (x * 0.3)
glColor4f( BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Red ),
BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Green ),
BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Blue ),
glColor4f( g_Parm_3D_Visu.m_BgColor_Top.m_Red,
g_Parm_3D_Visu.m_BgColor_Top.m_Green,
g_Parm_3D_Visu.m_BgColor_Top.m_Blue,
1.0 );
glVertex2f( -1.0, 1.0 ); // Top left corner
glColor4f( BGCOLOR2( g_Parm_3D_Visu.m_BgColor.m_Red ),
BGCOLOR2( g_Parm_3D_Visu.m_BgColor.m_Green ),
BGCOLOR2( g_Parm_3D_Visu.m_BgColor.m_Blue ),
glColor4f( g_Parm_3D_Visu.m_BgColor.m_Red,
g_Parm_3D_Visu.m_BgColor.m_Green,
g_Parm_3D_Visu.m_BgColor.m_Blue,
1.0 );
glVertex2f( -1.0,-1.0 ); // bottom left corner
glVertex2f( 1.0,-1.0 ); // bottom right corner
glColor4f( BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Red ),
BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Green ),
BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Blue ),
glColor4f( g_Parm_3D_Visu.m_BgColor_Top.m_Red,
g_Parm_3D_Visu.m_BgColor_Top.m_Green,
g_Parm_3D_Visu.m_BgColor_Top.m_Blue,
1.0 );
glVertex2f( 1.0, 1.0 ); // top right corner
......@@ -403,7 +410,7 @@ void EDA_3D_CANVAS::Redraw()
// Initialize Projection Matrix for Ortographic View
glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor,
-size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 10 );
-size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 100 );
}
else
{
......@@ -411,7 +418,7 @@ void EDA_3D_CANVAS::Redraw()
double ratio_HV = (double) size.x / size.y;
// Initialize Projection Matrix for Perspective View
gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 10 );
gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 100 );
}
// position viewer
......@@ -460,17 +467,56 @@ void EDA_3D_CANVAS::Redraw()
CreateDrawGL_List();
}
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glDisable( GL_TEXTURE_2D );
glEnable( GL_COLOR_MATERIAL );
SetOpenGlDefaultMaterial();
glColor4f( 1.0, 1.0, 1.0, 1.0 );
if( g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) )
{
if( g_Parm_3D_Visu.GetFlag( FL_SOLDERMASK ) )
{
glDisable( GL_TEXTURE_2D );
}
else
{
glEnable( GL_TEXTURE_2D );
}
glDisable( GL_LIGHTING );
if( m_glLists[GL_ID_BODY] )
{
glCallList( m_glLists[GL_ID_BODY] );
}
glEnable( GL_LIGHTING );
}
glEnable( GL_COLOR_MATERIAL );
SetOpenGlDefaultMaterial();
glm::vec4 specular( g_Parm_3D_Visu.m_CopperColor.m_Red * 0.3,
g_Parm_3D_Visu.m_CopperColor.m_Green * 0.3,
g_Parm_3D_Visu.m_CopperColor.m_Blue * 0.3, 1.0 );
GLint shininess_value = 8;
glMateriali ( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value );
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) )
{
glEnable( GL_TEXTURE_2D );
}
else
{
glDisable( GL_TEXTURE_2D );
}
if( m_glLists[GL_ID_BOARD] )
{
glCallList( m_glLists[GL_ID_BOARD] );
}
SetOpenGlDefaultMaterial();
if( m_glLists[GL_ID_TECH_LAYERS] )
{
glCallList( m_glLists[GL_ID_TECH_LAYERS] );
......@@ -485,7 +531,9 @@ void EDA_3D_CANVAS::Redraw()
}
// Draw Component Shadow
if( g_Parm_3D_Visu.GetFlag( FL_MODULE ) && g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.HightQualityMode() )
if( g_Parm_3D_Visu.GetFlag( FL_MODULE ) &&
g_Parm_3D_Visu.IsRealisticMode() &&
g_Parm_3D_Visu.GetFlag( FL_RENDER_SHADOWS ) )
{
glEnable( GL_CULL_FACE );
glDisable( GL_DEPTH_TEST );
......@@ -546,7 +594,9 @@ void EDA_3D_CANVAS::Redraw()
glCallList( m_glLists[GL_ID_3DSHAPES_TRANSP_FRONT] );
// Draw Board Shadow
if( g_Parm_3D_Visu.GetFlag( FL_MODULE ) && g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.HightQualityMode() )
if( g_Parm_3D_Visu.GetFlag( FL_MODULE ) &&
g_Parm_3D_Visu.IsRealisticMode() &&
g_Parm_3D_Visu.GetFlag( FL_RENDER_SHADOWS ) )
{
if( m_glLists[GL_ID_SHADOW_BOARD] )
{
......@@ -643,10 +693,10 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
{
BOARD* pcb = GetBoard();
// If hightQualityMode is true, holes are correctly removed from copper zones areas.
// If hightQualityMode is false, holes are not removed from copper zones areas,
// If FL_RENDER_SHOW_HOLES_IN_ZONES is true, holes are correctly removed from copper zones areas.
// If FL_RENDER_SHOW_HOLES_IN_ZONES is false, holes are not removed from copper zones areas,
// but the calculation time is twice shorter.
bool hightQualityMode = g_Parm_3D_Visu.HightQualityMode();
bool remove_Holes = g_Parm_3D_Visu.GetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES );
bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
......@@ -783,7 +833,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
if( zonelayer == layer )
{
zone->TransformSolidAreasShapesToPolygonSet(
hightQualityMode ? bufferPolys : bufferZonesPolys,
remove_Holes ? bufferPolys : bufferZonesPolys,
segcountLowQuality, correctionFactorLQ );
}
}
......@@ -853,6 +903,13 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
thickness,
g_Parm_3D_Visu.m_BiuTo3Dunits );
if( g_Parm_3D_Visu.GetFlag( FL_USE_COPPER_THICKNESS ) == true )
{
thickness -= ( 0.04 * IU_PER_MM );
}
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
if( bufferZonesPolys.GetCornersCount() )
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos,
thickness,
......@@ -881,13 +938,14 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
}
}
glEndList();
glNewList( aBodyOnlyList, GL_COMPILE );
if( g_Parm_3D_Visu.IsRealisticMode() )
{
SetGLEpoxyColor( 1.0 );
if( g_Parm_3D_Visu.HightQualityMode() )
{
SetGLTexture( m_text_pcb, 35.0f );
}
SetGLEpoxyColor( 0.95 );
}
else
{
......@@ -927,27 +985,10 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
bufferPcbOutlines.RemoveAllContours();
bufferPcbOutlines.ImportFrom( currLayerPolyset );
// Draw board substrate:
if( bufferPcbOutlines.GetCornersCount() &&
( g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) ) )
{
// for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
// sides
Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2.0,
board_thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
}
glEndList();
glNewList( aBodyOnlyList, GL_COMPILE );
if( bufferPcbOutlines.GetCornersCount() )
{
glColor4f( 1.0, 1.0, 1.0, 1.0 );
Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2.0,
board_thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
board_thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
}
glEndList();
......@@ -1017,7 +1058,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
KI_POLYGON_SET brdpolysetHoles;
allLayerHoles.ExportTo( brdpolysetHoles );
static const LAYER_ID sequence[] = {
static const LAYER_ID teckLayerList[] = {
B_Adhes,
F_Adhes,
B_Paste,
......@@ -1028,13 +1069,13 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
F_Mask,
};
for( LSEQ seq = pcb->GetEnabledLayers().Seq( sequence, DIM( sequence ) ); seq; ++seq )
for( LSEQ seq = LSET::AllTechMask().Seq( teckLayerList, DIM( teckLayerList ) ); seq; ++seq )
{
LAYER_ID layer = *seq;
// Skip user layers, which are not drawn here
if( IsUserLayer( layer) )
continue;
// if( IsUserLayer( layer) )
// continue;
if( !Is3DLayerEnabled( layer ) )
continue;
......@@ -1479,16 +1520,16 @@ static bool Is3DLayerEnabled( LAYER_ID aLayer )
break;
default:
// the layer is an internal copper layer
// the layer is an internal copper layer, used the visibility
//
if( realistic_mode )
return false;
return g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer );
}
// if the layer has a flag, return the flag
return g_Parm_3D_Visu.GetFlag( flg ) &&
g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer );
// The layer has a flag, return the flag
return g_Parm_3D_Visu.GetFlag( flg );
}
......
......@@ -422,7 +422,7 @@ void CALLBACK tessCPolyPt2Vertex( const GLvoid* data )
// cast back to double type
const CPolyPt* ptr = (const CPolyPt*) data;
if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.HightQualityMode() )
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,
-ptr->y * g_Parm_3D_Visu.m_BiuTo3Dunits * m_texture_scale);
......
......@@ -40,16 +40,17 @@
#include <info3d_visu.h>
#include <3d_draw_basic_functions.h>
#define TEXTURE_PCB_SCALE 5.0
// Helper function: initialize the copper color to draw the board
// in realistic mode.
void EDA_3D_CANVAS::SetGLCopperColor()
{
glDisable( GL_TEXTURE_2D );
// Generates a golden yellow color, near board "copper" color
const double lum = 0.7/255.0;
glColor4f( 255.0*lum, 223.0*lum, 0.0*lum, 1.0 );
glColor4f( g_Parm_3D_Visu.m_CopperColor.m_Red,
g_Parm_3D_Visu.m_CopperColor.m_Green,
g_Parm_3D_Visu.m_CopperColor.m_Blue,
1.0 );
}
// Helper function: initialize the color to draw the epoxy
......@@ -57,8 +58,15 @@ void EDA_3D_CANVAS::SetGLCopperColor()
void EDA_3D_CANVAS::SetGLEpoxyColor( double aTransparency )
{
// Generates an epoxy color, near board color
const double lum = 0.2/255.0;
glColor4f( 255.0*lum, 218.0*lum, 110.0*lum, aTransparency );
glColor4f( 0.45 * 0.85 - (1.0 - g_Parm_3D_Visu.m_BoardColor.m_Red) * 0.32,
0.39 * 0.85 - (1.0 - g_Parm_3D_Visu.m_BoardColor.m_Green) * 0.28,
0.33 * 0.85 - (1.0 - g_Parm_3D_Visu.m_BoardColor.m_Blue) * 0.23,
aTransparency );
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) )
{
SetGLTexture( m_text_pcb, TEXTURE_PCB_SCALE );
}
}
// Helper function: initialize the color to draw the
......@@ -66,8 +74,15 @@ void EDA_3D_CANVAS::SetGLEpoxyColor( double aTransparency )
void EDA_3D_CANVAS::SetGLSolderMaskColor( double aTransparency )
{
// Generates a solder mask color
const double lum = 0.2/255.0;
glColor4f( 100.0*lum, 255.0*lum, 180.0*lum, aTransparency );
glColor4f( g_Parm_3D_Visu.m_BoardColor.m_Red,
g_Parm_3D_Visu.m_BoardColor.m_Green,
g_Parm_3D_Visu.m_BoardColor.m_Blue,
aTransparency );
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) )
{
SetGLTexture( m_text_pcb, TEXTURE_PCB_SCALE );
}
}
// Helper function: initialize the color to draw the non copper layers
......@@ -87,20 +102,31 @@ void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
case B_SilkS:
case F_SilkS:
SetGLColor( LIGHTGRAY, 0.9 );
if( g_Parm_3D_Visu.HightQualityMode() )
{
SetGLTexture( m_text_silk, 50.0f );
// http://en.wikipedia.org/wiki/Luminance_(relative)
double luminance = g_Parm_3D_Visu.m_BoardColor.m_Red * 0.2126 +
g_Parm_3D_Visu.m_BoardColor.m_Green * 0.7152 +
g_Parm_3D_Visu.m_BoardColor.m_Blue * 0.0722;
if( luminance < 0.5 )
{
glColor4f( 0.9, 0.9, 0.9, 0.96 );
}
else
{
glColor4f( 0.1, 0.1, 0.1, 0.96 );
}
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) )
{
SetGLTexture( m_text_silk, 10.0f );
}
}
break;
case B_Mask:
case F_Mask:
SetGLSolderMaskColor( 0.7 );
if( g_Parm_3D_Visu.HightQualityMode() )
{
SetGLTexture( m_text_pcb, 35.0f );
}
SetGLSolderMaskColor( 0.90 );
break;
default:
......
......@@ -45,8 +45,26 @@ INFO3D_VISU g_Parm_3D_Visu;
static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
static const wxChar keyBgColor_Red_Top[] = wxT( "BgColor_Red_Top" );
static const wxChar keyBgColor_Green_Top[] = wxT( "BgColor_Green_Top" );
static const wxChar keyBgColor_Blue_Top[] = wxT( "BgColor_Blue_Top" );
static const wxChar keyBoardColor_Red[] = wxT( "BoardColor_Red" );
static const wxChar keyBoardColor_Green[] = wxT( "BoardColor_Green" );
static const wxChar keyBoardColor_Blue[] = wxT( "BoardColor_Blue" );
static const wxChar keyCopperColor_Red[] = wxT( "CopperColor_Red" );
static const wxChar keyCopperColor_Green[] = wxT( "CopperColor_Green" );
static const wxChar keyCopperColor_Blue[] = wxT( "CopperColor_Blue" );
static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keyUseHQinRealisticMode[] = wxT( "UseHQinRealisticMode" );
static const wxChar keyRenderShadows[] = wxT( "Render_Shadows" );
static const wxChar keyRenderRemoveHoles[] = wxT( "Render_RemoveHoles" );
static const wxChar keyRenderTextures[] = wxT( "Render_Textures" );
static const wxChar keyRenderSmooth[] = wxT( "Render_Smooth" );
static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
static const wxChar keyShowGridSize[] = wxT( "Grid3DSize" );
......@@ -216,16 +234,40 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
INFO3D_VISU& prms = g_Parm_3D_Visu;
aCfg->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
aCfg->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
aCfg->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
aCfg->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.4 );
aCfg->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.4 );
aCfg->Read( keyBgColor_Blue, &g_Parm_3D_Visu.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_Green_Top, &g_Parm_3D_Visu.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( keyBoardColor_Red, &g_Parm_3D_Visu.m_BoardColor.m_Red, 0.0 );
aCfg->Read( keyBoardColor_Green, &g_Parm_3D_Visu.m_BoardColor.m_Green, 0.5 );
aCfg->Read( keyBoardColor_Blue, &g_Parm_3D_Visu.m_BoardColor.m_Blue, 0.0 );
aCfg->Read( keyCopperColor_Red, &g_Parm_3D_Visu.m_CopperColor.m_Red, 0.8 );
aCfg->Read( keyCopperColor_Green, &g_Parm_3D_Visu.m_CopperColor.m_Green, 0.75 );
aCfg->Read( keyCopperColor_Blue, &g_Parm_3D_Visu.m_CopperColor.m_Blue, 0.0 );
bool tmp;
aCfg->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
aCfg->Read( keyUseHQinRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, tmp );
aCfg->Read( keyRenderShadows, &tmp, false );
prms.SetFlag( FL_RENDER_SHADOWS, tmp );
aCfg->Read( keyRenderRemoveHoles, &tmp, false );
prms.SetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES, tmp );
aCfg->Read( keyRenderTextures, &tmp, false );
prms.SetFlag( FL_RENDER_TEXTURES, tmp );
aCfg->Read( keyRenderSmooth, &tmp, false );
prms.SetFlag( FL_RENDER_SMOOTH, tmp );
aCfg->Read( keyRenderMaterial, &tmp, false );
prms.SetFlag( FL_RENDER_MATERIAL, tmp );
aCfg->Read( keyShowAxis, &tmp, true );
prms.SetFlag( FL_AXIS, tmp );
......@@ -234,7 +276,6 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
prms.SetFlag( FL_GRID, tmp );
aCfg->Read( keyShowGridSize, &prms.m_3D_Grid, 10.0 );
prms.SetFlag( FL_MODULE, tmp );
aCfg->Read( keyShowFootprints, &tmp, true );
prms.SetFlag( FL_MODULE, tmp );
......@@ -277,21 +318,40 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
aCfg->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
aCfg->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keyUseHQinRealisticMode, prms.GetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE ) );
aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
aCfg->Write( keyShowGrid, prms.GetFlag( FL_GRID ) );
aCfg->Write( keyShowGridSize, prms.m_3D_Grid );
aCfg->Write( keyShowFootprints, prms.GetFlag( FL_MODULE ) );
aCfg->Write( keyShowCopperThickness, prms.GetFlag( FL_USE_COPPER_THICKNESS ) );
aCfg->Write( keyShowZones, prms.GetFlag( FL_ZONE ) );
aCfg->Write( keyShowAdhesiveLayers, prms.GetFlag( FL_ADHESIVE ) );
aCfg->Write( keyShowSilkScreenLayers, prms.GetFlag( FL_SILKSCREEN ) );
aCfg->Write( keyShowSolderMaskLayers, prms.GetFlag( FL_SOLDERMASK ) );
aCfg->Write( keyShowSolderPasteLayers, prms.GetFlag( FL_SOLDERPASTE ) );
aCfg->Write( keyShowCommentsLayer, prms.GetFlag( FL_COMMENTS ) );
aCfg->Write( keyShowEcoLayers, prms.GetFlag( FL_ECO ) );
aCfg->Write( keyShowBoardBody, prms.GetFlag( FL_SHOW_BOARD_BODY ) );
aCfg->Write( keyBgColor_Red_Top, g_Parm_3D_Visu.m_BgColor_Top.m_Red );
aCfg->Write( keyBgColor_Green_Top, g_Parm_3D_Visu.m_BgColor_Top.m_Green );
aCfg->Write( keyBgColor_Blue_Top, g_Parm_3D_Visu.m_BgColor_Top.m_Blue );
aCfg->Write( keyBoardColor_Red, g_Parm_3D_Visu.m_BoardColor.m_Red );
aCfg->Write( keyBoardColor_Green, g_Parm_3D_Visu.m_BoardColor.m_Green );
aCfg->Write( keyBoardColor_Blue, g_Parm_3D_Visu.m_BoardColor.m_Blue );
aCfg->Write( keyCopperColor_Red, g_Parm_3D_Visu.m_CopperColor.m_Red );
aCfg->Write( keyCopperColor_Green, g_Parm_3D_Visu.m_CopperColor.m_Green );
aCfg->Write( keyCopperColor_Blue, g_Parm_3D_Visu.m_CopperColor.m_Blue );
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keyRenderShadows, prms.GetFlag( FL_RENDER_SHADOWS ) );
aCfg->Write( keyRenderRemoveHoles, prms.GetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES ) );
aCfg->Write( keyRenderTextures, prms.GetFlag( FL_RENDER_TEXTURES ) );
aCfg->Write( keyRenderSmooth, prms.GetFlag( FL_RENDER_SMOOTH ) );
aCfg->Write( keyRenderMaterial, prms.GetFlag( FL_RENDER_MATERIAL ) );
aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
aCfg->Write( keyShowGrid, prms.GetFlag( FL_GRID ) );
aCfg->Write( keyShowGridSize, prms.m_3D_Grid );
aCfg->Write( keyShowFootprints, prms.GetFlag( FL_MODULE ) );
aCfg->Write( keyShowCopperThickness, prms.GetFlag( FL_USE_COPPER_THICKNESS ) );
aCfg->Write( keyShowZones, prms.GetFlag( FL_ZONE ) );
aCfg->Write( keyShowAdhesiveLayers, prms.GetFlag( FL_ADHESIVE ) );
aCfg->Write( keyShowSilkScreenLayers, prms.GetFlag( FL_SILKSCREEN ) );
aCfg->Write( keyShowSolderMaskLayers, prms.GetFlag( FL_SOLDERMASK ) );
aCfg->Write( keyShowSolderPasteLayers, prms.GetFlag( FL_SOLDERPASTE ) );
aCfg->Write( keyShowCommentsLayer, prms.GetFlag( FL_COMMENTS ) );
aCfg->Write( keyShowEcoLayers, prms.GetFlag( FL_ECO ) );
aCfg->Write( keyShowBoardBody, prms.GetFlag( FL_SHOW_BOARD_BODY ) );
}
......@@ -424,7 +484,26 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_MENU3D_BGCOLOR_SELECTION:
Set3DBgColor();
Set3DBgColor( g_Parm_3D_Visu.m_BgColor );
return;
case ID_MENU3D_BGCOLOR_TOP_SELECTION:
Set3DBgColor( g_Parm_3D_Visu.m_BgColor_Top );
return;
case ID_MENU3D_BOARDCOLOR_SELECTION:
if( Set3DBgColor( g_Parm_3D_Visu.m_BoardColor ) == true )
{
NewDisplay(GL_ID_TECH_LAYERS);
NewDisplay(GL_ID_BOARD);
}
return;
case ID_MENU3D_COPPERCOLOR_SELECTION:
if( Set3DBgColor( g_Parm_3D_Visu.m_CopperColor ) == true )
{
NewDisplay(GL_ID_BOARD);
}
return;
case ID_MENU3D_REALISTIC_MODE:
......@@ -432,8 +511,29 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
NewDisplay();
return;
case ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE:
g_Parm_3D_Visu.SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, isChecked );
case ID_MENU3D_FL_RENDER_SHADOWS:
g_Parm_3D_Visu.SetFlag( FL_RENDER_SHADOWS, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES:
g_Parm_3D_Visu.SetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_TEXTURES:
g_Parm_3D_Visu.SetFlag( FL_RENDER_TEXTURES, isChecked );
NewDisplay(GL_ID_BOARD);
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_FL_RENDER_SMOOTH:
g_Parm_3D_Visu.SetFlag( FL_RENDER_SMOOTH, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_MATERIAL:
g_Parm_3D_Visu.SetFlag( FL_RENDER_MATERIAL, isChecked );
NewDisplay();
return;
......@@ -455,6 +555,7 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MENU3D_USE_COPPER_THICKNESS:
g_Parm_3D_Visu.SetFlag( FL_USE_COPPER_THICKNESS, isChecked );
NewDisplay(GL_ID_BOARD);
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_ZONE_ONOFF:
......@@ -506,7 +607,7 @@ void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event )
{
int id = event.GetId();
for( int ii = ID_MENU3D_GRID; ii < ID_MENU3D_GRID_END; ii++ )
for( int ii = ID_MENU3D_GRID_NOGRID; ii < ID_MENU3D_GRID_END; ii++ )
{
if( event.GetId() == ii )
continue;
......@@ -574,27 +675,27 @@ void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
/* called to set the background color of the 3D scene
*/
void EDA_3D_FRAME::Set3DBgColor()
bool EDA_3D_FRAME::Set3DBgColor( S3D_COLOR &color )
{
S3D_COLOR color;
wxColour newcolor, oldcolor;
oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ),
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
oldcolor.Set( KiROUND( color.m_Red * 255 ),
KiROUND( color.m_Green * 255 ),
KiROUND( color.m_Blue * 255 ) );
newcolor = wxGetColourFromUser( this, oldcolor );
if( !newcolor.IsOk() ) // Cancel command
return;
return false;
if( newcolor != oldcolor )
{
g_Parm_3D_Visu.m_BgColor.m_Red = (double) newcolor.Red() / 255.0;
g_Parm_3D_Visu.m_BgColor.m_Green = (double) newcolor.Green() / 255.0;
g_Parm_3D_Visu.m_BgColor.m_Blue = (double) newcolor.Blue() / 255.0;
color.m_Red = (double) newcolor.Red() / 255.0;
color.m_Green = (double) newcolor.Green() / 255.0;
color.m_Blue = (double) newcolor.Blue() / 255.0;
m_canvas->Redraw();
}
return true;
}
BOARD* EDA_3D_FRAME::GetBoard()
......
......@@ -28,6 +28,7 @@
#include <fctsys.h>
#include <3d_struct.h>
#include <3d_material.h>
#include <info3d_visu.h>
#ifdef __WXMAC__
# ifdef __DARWIN__
......@@ -54,17 +55,18 @@ S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
void SetOpenGlDefaultMaterial()
{
glm::vec4 ambient( 0.15, 0.15, 0.15, 1.0 );
glm::vec4 specular( 0.1, 0.1, 0.1, 1.0 );
glm::vec4 emissive( 0.1, 0.1, 0.1, 1.0 );
GLint shininess_value = 80;
glm::vec4 ambient( 0.2, 0.2, 0.2, 1.0 );
glm::vec4 specular( 0.0, 0.0, 0.0, 1.0 );
glm::vec4 emissive( 0.0, 0.0, 0.0, 1.0 );
glm::vec4 diffuse( 0.0, 0.0, 0.0, 1.0 );
GLint shininess_value = 0;
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
//glColor4f( 1.0, 1.0, 1.0, 1.0 );
glMateriali ( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value );
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x );
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.x );
}
......@@ -76,61 +78,73 @@ void S3D_MATERIAL::SetOpenGLMaterial( unsigned int materialIndex )
if( ! s3dParent->IsOpenGlAllowed() )
return;
float transparency_value = 0.0f;
if( m_Transparency.size() > materialIndex )
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_MATERIAL ) )
{
transparency_value = m_Transparency[materialIndex];
s3dParent->SetLastTransparency( transparency_value );
}
float transparency_value = 0.0f;
if( m_Transparency.size() > materialIndex )
{
transparency_value = m_Transparency[materialIndex];
s3dParent->SetLastTransparency( transparency_value );
}
if( m_DiffuseColor.size() > materialIndex )
{
glm::vec3 color = m_DiffuseColor[materialIndex];
if( m_DiffuseColor.size() > materialIndex )
{
glm::vec3 color = m_DiffuseColor[materialIndex];
if( m_AmbientColor.size() == 0 )
{
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
}
glColor4f( color.x, color.y, color.z, 1.0 - transparency_value );
}
if( m_AmbientColor.size() == 0 )
if( m_Shininess.size() > materialIndex )
{
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_Shininess[materialIndex] );
}
glColor4f( color.x, color.y, color.z, 1.0 - transparency_value );
}
if( m_Shininess.size() > materialIndex )
{
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, m_Shininess[materialIndex] );
}
// emissive
if( m_EmissiveColor.size() > materialIndex )
{
glm::vec4 emissive;
emissive[0] = m_EmissiveColor[materialIndex].x;
emissive[1] = m_EmissiveColor[materialIndex].y;
emissive[2] = m_EmissiveColor[materialIndex].z;
emissive[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x );
}
// emissive
if( m_EmissiveColor.size() > materialIndex )
{
glm::vec4 emissive;
emissive[0] = m_EmissiveColor[materialIndex].x;
emissive[1] = m_EmissiveColor[materialIndex].y;
emissive[2] = m_EmissiveColor[materialIndex].z;
emissive[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x );
}
// specular
if( m_SpecularColor.size() > materialIndex )
{
glm::vec4 specular;
specular[0] = m_SpecularColor[materialIndex].x;
specular[1] = m_SpecularColor[materialIndex].y;
specular[2] = m_SpecularColor[materialIndex].z;
specular[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
}
// specular
if( m_SpecularColor.size() > materialIndex )
{
glm::vec4 specular;
specular[0] = m_SpecularColor[materialIndex].x;
specular[1] = m_SpecularColor[materialIndex].y;
specular[2] = m_SpecularColor[materialIndex].z;
specular[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
// ambient
if( m_AmbientColor.size() > materialIndex )
{
glm::vec4 ambient;
ambient[0] = m_AmbientColor[materialIndex].x;
ambient[1] = m_AmbientColor[materialIndex].y;
ambient[2] = m_AmbientColor[materialIndex].z;
ambient[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
}
}
// ambient
if( m_AmbientColor.size() > materialIndex )
else
{
glm::vec4 ambient;
ambient[0] = m_AmbientColor[materialIndex].x;
ambient[1] = m_AmbientColor[materialIndex].y;
ambient[2] = m_AmbientColor[materialIndex].z;
ambient[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
}
if( m_DiffuseColor.size() > materialIndex )
{
glm::vec3 color = m_DiffuseColor[materialIndex];
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glColor4f( color.x, color.y, color.z, 1.0 );
}
}
}
......@@ -113,7 +113,7 @@ void S3D_MESH::openGL_Render()
if( m_PerVertexNormalsNormalized.size() == 0 )
{
if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.HightQualityMode() )
if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH ) )
{
calcPerPointNormals();
}
......@@ -148,7 +148,7 @@ void S3D_MESH::openGL_Render()
glm::vec3 point = m_Point[m_CoordIndex[idx][ii]];
glVertex3fv( &point.x );
}
} else if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.HightQualityMode() )
} else if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH ) )
{
std::vector< glm::vec3 > normals_list;
normals_list = m_PerFaceVertexNormals[idx];
......
......@@ -156,16 +156,55 @@ void EDA_3D_FRAME::CreateMenuBar()
_( "Realistic Mode" ),
KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE,
_( "Max Quality in Realistic Mode" ),
_( "When using max quality, holes are removed from copper zones, "
"but the calculation time is longer" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
wxMenu * renderOptionsMenu = new wxMenu;
AddMenuItem( prefsMenu, renderOptionsMenu, ID_MENU3D_COLOR,
_( "Render options" ), KiBitmap( tools_xpm ) );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_SHADOWS,
_( "Render Shadows" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES,
_( "Show Holes in Zones" ),
_( "Holes inside a copper layer copper zones are shown, "
"but the calculation time is longer" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_TEXTURES,
_( "Render Textures" ),
_( "Apply a grid/cloud textures to Board, Solder Mask and Silkscreen" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_SMOOTH,
_( "Render Smooth Normals" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_MATERIAL,
_( "Render Material properties" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
prefsMenu->AppendSeparator();
AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION,
_( "Choose Background Color" ), KiBitmap( palette_xpm ) );
wxMenu * backgrounColorMenu = new wxMenu;
// Add submenu Choose Colors
AddMenuItem( prefsMenu, backgrounColorMenu, ID_MENU3D_COLOR,
_( "Choose Colors" ), KiBitmap( palette_xpm ) );
AddMenuItem( backgrounColorMenu, ID_MENU3D_BGCOLOR_TOP_SELECTION,
_( "Background Top Color" ), KiBitmap( palette_xpm ) );
AddMenuItem( backgrounColorMenu, ID_MENU3D_BGCOLOR_SELECTION,
_( "Background Botton Color" ), KiBitmap( palette_xpm ) );
backgrounColorMenu->AppendSeparator();
AddMenuItem( backgrounColorMenu, ID_MENU3D_BOARDCOLOR_SELECTION,
_( "Board Mask Color" ), KiBitmap( pads_mask_layers_xpm ) );
AddMenuItem( backgrounColorMenu, ID_MENU3D_COPPERCOLOR_SELECTION,
_( "Copper Color" ), KiBitmap( use_3D_copper_thickness_xpm ) );
//
AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
_( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK );
......@@ -174,11 +213,11 @@ void EDA_3D_FRAME::CreateMenuBar()
wxMenu * gridlistMenu = new wxMenu;
AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
_( "3D Grid" ), KiBitmap( grid_xpm ) );
gridlistMenu->Append( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_10_MM, _( "3D Grid 10 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_5_MM, _( "3D Grid 5 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString, true );
gridlistMenu->AppendCheckItem( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString );
gridlistMenu->AppendCheckItem( ID_MENU3D_GRID_10_MM, _( "3D Grid 10 mm" ), wxEmptyString );
gridlistMenu->AppendCheckItem( ID_MENU3D_GRID_5_MM, _( "3D Grid 5 mm" ), wxEmptyString );
gridlistMenu->AppendCheckItem( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5 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( g_Parm_3D_Visu.GetFlag( FL_GRID ) )
......@@ -207,22 +246,26 @@ void EDA_3D_FRAME::CreateMenuBar()
prefsMenu->AppendSeparator();
AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF,
wxMenu * layersMenu = new wxMenu;
AddMenuItem( prefsMenu, layersMenu, ID_MENU3D_LAYERS,
_( "Show Layers" ), KiBitmap( tools_xpm ) );
AddMenuItem( layersMenu, ID_MENU3D_ADHESIVE_ONOFF,
_( "Show &Adhesive Layers" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_SILKSCREEN_ONOFF,
AddMenuItem( layersMenu, ID_MENU3D_SILKSCREEN_ONOFF,
_( "Show &Silkscreen Layer" ), KiBitmap( add_text_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_MASK_ONOFF,
AddMenuItem( layersMenu, ID_MENU3D_SOLDER_MASK_ONOFF,
_( "Show Solder &Mask Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_PASTE_ONOFF,
AddMenuItem( layersMenu, ID_MENU3D_SOLDER_PASTE_ONOFF,
_( "Show Solder &Paste Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
AddMenuItem( layersMenu, ID_MENU3D_COMMENTS_ONOFF,
_( "Show &Comments and Drawings Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_ECO_ONOFF,
AddMenuItem( layersMenu, ID_MENU3D_ECO_ONOFF,
_( "Show &Eco Layers" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
SetMenuBar( menuBar );
......@@ -241,8 +284,23 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
item = menuBar->FindItem( ID_MENU3D_REALISTIC_MODE );
item->Check( g_Parm_3D_Visu.IsRealisticMode() );
item = menuBar->FindItem( ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE );
item->Check( g_Parm_3D_Visu.HightQualityMode() );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS );
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_SHADOWS ) );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS );
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_SHADOWS ) );
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 = menuBar->FindItem( ID_MENU3D_FL_RENDER_TEXTURES );
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SMOOTH );
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH ) );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL );
item->Check( g_Parm_3D_Visu.GetFlag( FL_RENDER_MATERIAL ) );
item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY );
item->Check( g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) );
......
......@@ -38,6 +38,7 @@
#include <wx/glcanvas.h>
#include <3d_struct.h>
#include <info3d_visu.h>
#define KISYS3DMOD "KISYS3DMOD"
......@@ -127,7 +128,7 @@ private:
double BestZoom();
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void Set3DBgColor();
bool Set3DBgColor( S3D_COLOR &color );
DECLARE_EVENT_TABLE()
};
......
......@@ -8,13 +8,15 @@
* Please add IDs that are unique to the 3D viewer here and not in the global
* id.h file. This will prevent the entire project from being rebuilt when
* adding new commands to the 3D viewer.
* However the number of IDs should be < ROOM_FOR_3D_VIEWER, defined in id.h
* Please change the value of ROOM_FOR_3D_VIEWER if too small.
*/
#include <id.h> // Generic Id.
#include <id.h> // Generic Id.
enum id_3dview_frm
{
ID_START_COMMAND_3D = ID_END_LIST,
ID_START_COMMAND_3D = ID_KICAD_3D_VIEWER_START,
ID_ROTATE3D_X_NEG,
ID_ROTATE3D_X_POS,
ID_ROTATE3D_Y_NEG,
......@@ -28,11 +30,16 @@ enum id_3dview_frm
ID_MOVE3D_UP,
ID_MOVE3D_DOWN,
ID_ORTHO,
ID_MENU3D_COLOR,
ID_MENU3D_BGCOLOR_SELECTION,
ID_MENU3D_BGCOLOR_TOP_SELECTION,
ID_MENU3D_BOARDCOLOR_SELECTION,
ID_MENU3D_COPPERCOLOR_SELECTION,
ID_MENU3D_USE_COPPER_THICKNESS,
ID_MENU3D_AXIS_ONOFF,
ID_MENU3D_MODULE_ONOFF,
ID_MENU3D_ZONE_ONOFF,
ID_MENU3D_LAYERS,
ID_MENU3D_ADHESIVE_ONOFF,
ID_MENU3D_SILKSCREEN_ONOFF,
ID_MENU3D_SOLDER_PASTE_ONOFF,
......@@ -41,7 +48,11 @@ enum id_3dview_frm
ID_MENU3D_ECO_ONOFF,
ID_MENU3D_SHOW_BOARD_BODY,
ID_MENU3D_REALISTIC_MODE,
ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE,
ID_MENU3D_FL_RENDER_SHADOWS,
ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES,
ID_MENU3D_FL_RENDER_TEXTURES,
ID_MENU3D_FL_RENDER_SMOOTH,
ID_MENU3D_FL_RENDER_MATERIAL,
ID_END_COMMAND_3D,
ID_TOOL_SET_VISIBLE_ITEMS,
......
......@@ -72,7 +72,8 @@ INFO3D_VISU::INFO3D_VISU()
SetFlag( FL_GRID, false );
SetFlag( FL_USE_COPPER_THICKNESS, false );
SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, false );
SetFlag( FL_RENDER_SHADOWS, false );
SetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES, false );
}
......
......@@ -71,7 +71,11 @@ enum DISPLAY3D_FLG {
FL_USE_COPPER_THICKNESS,
FL_SHOW_BOARD_BODY,
FL_USE_REALISTIC_MODE,
FL_USE_MAXQUALITY_IN_REALISTIC_MODE,
FL_RENDER_SHADOWS,
FL_RENDER_SHOW_HOLES_IN_ZONES,
FL_RENDER_TEXTURES,
FL_RENDER_SMOOTH,
FL_RENDER_MATERIAL,
FL_LAST
};
......@@ -84,6 +88,9 @@ public:
double m_Zoom; // 3D zoom value
double m_3D_Grid; // 3D grid value, in mm
S3D_COLOR m_BgColor;
S3D_COLOR m_BgColor_Top;
S3D_COLOR m_BoardColor;
S3D_COLOR m_CopperColor;
wxPoint m_BoardPos; // center board actual position in board units
wxSize m_BoardSize; // board actual size in board units
int m_CopperLayersCount; // Number of copper layers actually used by the board
......@@ -97,7 +104,7 @@ public:
// used in some calculation
double zpos_offset;
private:
double m_layerZcoord[LAYER_ID_COUNT]; // Z position of each layer (normalized)
double m_copperThickness; // Copper thickness (normalized)
......@@ -200,7 +207,6 @@ public: INFO3D_VISU();
}
bool IsRealisticMode() { return GetFlag( FL_USE_REALISTIC_MODE ); }
bool HightQualityMode() { return GetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE ); }
};
extern INFO3D_VISU g_Parm_3D_Visu;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -65,9 +65,6 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
return;
}
glShadeModel( GL_SMOOTH );
glEnable( GL_NORMALIZE );
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
......
......@@ -67,9 +67,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename )
return;
}
glShadeModel( GL_SMOOTH );
glEnable( GL_NORMALIZE );
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
......
......@@ -68,8 +68,6 @@ void X3D_MODEL_PARSER::Load( const wxString aFilename )
return;
}
glShadeModel( GL_SMOOTH );
glEnable( GL_NORMALIZE );
float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
......@@ -295,6 +293,13 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
if( values.GetNextToken().ToDouble( &shine ) )
{
// VRML value is normalized and openGL expects a value 0 - 128
if( shine > 1.0 )
{
shine = 1.0;
} else if( shine < 0.0 )
{
shine = 0.0;
}
shine = shine * 128.0f;
m_model->m_Materials->m_Shininess.push_back( shine );
}
......@@ -607,7 +612,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
else
{
coord_list.push_back( index );
vrml_coord_indx_list.Append( wxString::Format( wxT( "%u " ), index ) );
vrml_coord_indx_list.Append( wxString::Format( wxT( "%ld " ), index ) );
}
}
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
......@@ -31,8 +31,6 @@
#ifndef ID_H_
#define ID_H_
#define MAX_ITEMS_IN_PICKER 15 ///< max no. items in the popup menu for item selection
/**
* Common command IDs shared by more than one of the KiCad applications.
*
......@@ -40,8 +38,28 @@
* across multple applications such as the zoom, grid, and language IDs.
* Application specific IDs should be defined in the appropriate header
* file to prevent the entire project from being rebuilt.
*
* However, we must avoid duplicate IDs in menus and toolbar items, when wxUpdateUIEvent
* are associated to menuitems and/or toolbar items
* The reason is the fact wxWidgets try to send a wxUpdateUIEvent event to a given window and,
* if a wxUpdateUIEvent event function is not defined for a menuitem, wxWidgets
* propagates this event ID to parents of the given window.
* Therefore duplicate IDs could create strange behavior in menus and subtle bugs, depending
* on the code inside the wxUpdateUIEvent event functions called in parent frames.
* I did not seen this propagation to child frames, only to parent frames
*
* Issues exist only if 2 menus have the same ID, and only one menu is associated to
* a wxUpdateUIEvent event, and this one is defined in a parent Window.
* The probability it happens is low, but not null.
*
* Therefore we reserve room in ID list for each sub application.
* Please, change these values if needed
*/
// Define room for IDs, for each sub application
#define ROOM_FOR_KICADMANAGER 50
#define ROOM_FOR_3D_VIEWER 100
enum main_id
{
ID_RUN_PCB = wxID_HIGHEST,
......@@ -250,6 +268,25 @@ enum main_id
ID_DIALOG_ERC, ///< eeschema ERC modeless dialog ID
// IDs specifics to a sub-application (Eeschema, Kicad manager....) start here
//
// We reserve here Ids for each sub-application, to avoid duplicate IDs
// between them.
// mainly we experienced issues related to wxUpdateUIEvent calls when 2 (or more) wxFrames
// share the same ID in menus, mainly in menubars/toolbars
// The reason is the fact wxWidgets propagates the wxUpdateUIEvent to all parent windows
// to find wxUpdateUIEvent event functions matching the menuitem IDs found when activate a menu in the first frame.
// Reserve ROOM_FOR_KICADMANAGER IDs, for Kicad manager
// Change it if this count is too small.
ID_KICAD_MANAGER_START,
ID_KICAD_MANAGER_END = ID_KICAD_MANAGER_START + ROOM_FOR_KICADMANAGER,
// Reserve ROOM_FOR_KICADMANAGER IDs, for Kicad manager
// Change it if this count is too small.
ID_KICAD_3D_VIEWER_START,
ID_KICAD_3D_VIEWER_END = ID_KICAD_3D_VIEWER_START + ROOM_FOR_3D_VIEWER,
ID_END_LIST
};
......
......@@ -81,13 +81,26 @@ enum TreeFileType {
/**
* Command IDs for KiCad.
*
* Please add IDs that are unique to Kicad here and not in the global id.h
* file. This will prevent the entire project from being rebuilt when adding
* Please add IDs that are unique to Kicad here and not in the global id.h file.
* This will prevent the entire project from being rebuilt when adding
* new commands to KiCad.
*
* However, now the Kicad manager and other sub applications are running inside
* the same application, these IDs are kept unique inside the whole Kicad code
* See the global id.h which reserves room for the Kicad manager IDs
* and expand this room if needed
*
* We have experienced issues with duplicate menus IDs between frames
* because wxUpdateUIEvent events are sent to parent frames, when a wxUpdateUIEvent
* event function does not exists for some menuitems ID, and therefore
* with duplicate menuitems IDs in different frames, the wrong menuitem can be used
* by a function called by the wxUpdateUIEvent event loop.
*
* The number of items in this list should be less than ROOM_FOR_KICADMANAGER (see id.h)
*/
enum id_kicad_frm {
ID_LEFT_FRAME = ID_END_LIST,
ID_LEFT_FRAME = ID_KICAD_MANAGER_START,
ID_PROJECT_TREE,
ID_PROJECT_TXTEDIT,
ID_PROJECT_TREE_REFRESH,
......@@ -114,9 +127,12 @@ enum id_kicad_frm {
ID_SELECT_DEFAULT_PDF_BROWSER,
ID_SAVE_AND_ZIP_FILES,
ID_READ_ZIP_ARCHIVE,
ID_INIT_WATCHED_PATHS
};
ID_INIT_WATCHED_PATHS,
// Please, verify: the number of items in this list should be
// less than ROOM_FOR_KICADMANAGER (see id.h)
ID_KICADMANAGER_END_LIST
};
/**
* Class KICAD_MANAGER_FRAME
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2014 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......
......@@ -11,6 +11,8 @@
* from being rebuilt when adding new commands to the Pcbnew.
*/
#define MAX_ITEMS_IN_PICKER 15 ///< max no. items in the popup menu for item selection
enum pcbnew_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
......@@ -371,7 +373,9 @@ enum pcbnew_ids
ID_FOOTPRINT_WIZARD_PAGES_WINDOW,
ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW,
ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD
ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD,
ID_PCBNEW_END_LIST
};
#endif // PCBNEW_ID_H_
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