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:
......
This diff is collapsed.
......@@ -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 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