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 );
}
......
This diff is collapsed.
......@@ -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,8 +318,27 @@ 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( 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( keyUseHQinRealisticMode, prms.GetFlag( FL_USE_MAXQUALITY_IN_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 );
......@@ -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,6 +78,8 @@ void S3D_MATERIAL::SetOpenGLMaterial( unsigned int materialIndex )
if( ! s3dParent->IsOpenGlAllowed() )
return;
if( g_Parm_3D_Visu.GetFlag( FL_RENDER_MATERIAL ) )
{
float transparency_value = 0.0f;
if( m_Transparency.size() > materialIndex )
{
......@@ -97,7 +101,7 @@ void S3D_MATERIAL::SetOpenGLMaterial( unsigned int materialIndex )
if( m_Shininess.size() > materialIndex )
{
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, m_Shininess[materialIndex] );
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_Shininess[materialIndex] );
}
// emissive
......@@ -132,5 +136,15 @@ void S3D_MATERIAL::SetOpenGLMaterial( unsigned int materialIndex )
ambient[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
}
}
else
{
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, "
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
......@@ -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 diff is collapsed.
This diff is collapsed.
......@@ -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