3D viewer: fix update UI event infinite loop.
Lay groundwork to fetch OpenGL version for disabling ray tracing when the current OpenGL version lacks proper support.
This commit is contained in:
parent
a0a4e5e18d
commit
4f0749b0b4
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -48,10 +48,11 @@ extern struct EDA_HOTKEY_CONFIG g_3DViewer_Hokeys_Descr[];
|
|||
|
||||
|
||||
/**
|
||||
* Trace mask used to enable or disable the trace output of this class.
|
||||
* The debug output can be turned on by setting the WXTRACE environment variable to
|
||||
* "KI_TRACE_EDA_3D_CANVAS". See the wxWidgets documentation on wxLogTrace for
|
||||
* more information.
|
||||
* Flag to enable 3D canvas debug tracing.
|
||||
*
|
||||
* Use "KI_TRACE_EDA_3D_CANVAS" to enable.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
const wxChar * EDA_3D_CANVAS::m_logTrace = wxT( "KI_TRACE_EDA_3D_CANVAS" );
|
||||
|
||||
|
@ -64,16 +65,16 @@ BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas )
|
|||
EVT_CHAR_HOOK( EDA_3D_CANVAS::OnCharHook )
|
||||
|
||||
// mouse events
|
||||
EVT_LEFT_DOWN( EDA_3D_CANVAS::OnLeftDown )
|
||||
EVT_LEFT_UP( EDA_3D_CANVAS::OnLeftUp )
|
||||
EVT_MIDDLE_UP( EDA_3D_CANVAS::OnMiddleUp )
|
||||
EVT_LEFT_DOWN( EDA_3D_CANVAS::OnLeftDown )
|
||||
EVT_LEFT_UP( EDA_3D_CANVAS::OnLeftUp )
|
||||
EVT_MIDDLE_UP( EDA_3D_CANVAS::OnMiddleUp )
|
||||
EVT_MIDDLE_DOWN( EDA_3D_CANVAS::OnMiddleDown)
|
||||
EVT_RIGHT_DOWN( EDA_3D_CANVAS::OnRightClick )
|
||||
EVT_MOUSEWHEEL( EDA_3D_CANVAS::OnMouseWheel )
|
||||
EVT_MOTION( EDA_3D_CANVAS::OnMouseMove )
|
||||
EVT_RIGHT_DOWN( EDA_3D_CANVAS::OnRightClick )
|
||||
EVT_MOUSEWHEEL( EDA_3D_CANVAS::OnMouseWheel )
|
||||
EVT_MOTION( EDA_3D_CANVAS::OnMouseMove )
|
||||
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
EVT_MAGNIFY( EDA_3D_CANVAS::OnMagnify )
|
||||
EVT_MAGNIFY( EDA_3D_CANVAS::OnMagnify )
|
||||
#endif
|
||||
|
||||
// other events
|
||||
|
@ -90,7 +91,6 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent,
|
|||
const int *aAttribList,
|
||||
BOARD *aBoard,
|
||||
CINFO3D_VISU &aSettings , S3D_CACHE *a3DCachePointer ) :
|
||||
|
||||
HIDPI_GL_CANVAS( aParent,
|
||||
wxID_ANY,
|
||||
aAttribList,
|
||||
|
@ -101,9 +101,8 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent,
|
|||
m_settings( aSettings )
|
||||
{
|
||||
// Run test cases in debug mode, once.
|
||||
//DBG( Run_3d_viewer_test_cases() );
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::EDA_3D_CANVAS" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::EDA_3D_CANVAS" );
|
||||
|
||||
m_editing_timeout_timer.SetOwner( this );
|
||||
Connect( m_editing_timeout_timer.GetId(),
|
||||
|
@ -130,6 +129,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent,
|
|||
m_is_opengl_initialized = false;
|
||||
|
||||
m_render_raytracing_was_requested = false;
|
||||
m_opengl_supports_raytracing = false;
|
||||
|
||||
m_parentStatusBar = NULL;
|
||||
m_glRC = NULL;
|
||||
|
@ -154,7 +154,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent,
|
|||
|
||||
EDA_3D_CANVAS::~EDA_3D_CANVAS()
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::~EDA_3D_CANVAS" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::~EDA_3D_CANVAS" );
|
||||
|
||||
releaseOpenGL();
|
||||
}
|
||||
|
@ -189,14 +189,16 @@ void EDA_3D_CANVAS::OnCloseWindow( wxCloseEvent &event )
|
|||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::OnResize( wxSizeEvent &event )
|
||||
{
|
||||
this->Request_refresh();
|
||||
}
|
||||
|
||||
|
||||
bool EDA_3D_CANVAS::initializeOpenGL()
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::initializeOpenGL" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::initializeOpenGL" );
|
||||
|
||||
const GLenum err = glewInit();
|
||||
|
||||
|
@ -210,11 +212,15 @@ bool EDA_3D_CANVAS::initializeOpenGL()
|
|||
}
|
||||
else
|
||||
{
|
||||
wxLogTrace( m_logTrace,
|
||||
wxString( wxT( "EDA_3D_CANVAS::initializeOpenGL Using GLEW " ) ) +
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::initializeOpenGL Using GLEW version %s",
|
||||
FROM_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
|
||||
}
|
||||
|
||||
const GLubyte* version = glGetString( GL_VERSION );
|
||||
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::%s OpenGL version string %s.",
|
||||
__WXFUNCTION__, FROM_UTF8( (char*) version ) );
|
||||
|
||||
m_is_opengl_initialized = true;
|
||||
|
||||
return true;
|
||||
|
@ -260,14 +266,11 @@ void EDA_3D_CANVAS::DisplayStatus()
|
|||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( wxT( "dx %3.2f" ), m_settings.CameraGet().GetCameraPos().x );
|
||||
msg.Printf( "dx %3.2f", m_settings.CameraGet().GetCameraPos().x );
|
||||
m_parentStatusBar->SetStatusText( msg, 1 );
|
||||
|
||||
msg.Printf( wxT( "dy %3.2f" ), m_settings.CameraGet().GetCameraPos().y );
|
||||
msg.Printf( "dy %3.2f", m_settings.CameraGet().GetCameraPos().y );
|
||||
m_parentStatusBar->SetStatusText( msg, 2 );
|
||||
|
||||
//msg.Printf( _( "Zoom: %3.1f" ), 50 * m_settings.CameraGet().ZoomGet() );
|
||||
//m_parentStatusBar->SetStatusText( msg, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,7 +285,7 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
|||
// SwapBuffer requires the window to be shown before calling
|
||||
if( !IsShownOnScreen() )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnPaint !IsShown" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnPaint !IsShown" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -301,7 +304,6 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
|||
//WX_STRING_REPORTER errorReporter( &err_messages );
|
||||
STATUS_TEXT_REPORTER activityReporter( m_parentStatusBar, 0 );
|
||||
|
||||
|
||||
unsigned strtime = GetRunningMicroSecs();
|
||||
|
||||
// "Makes the OpenGL state that is represented by the OpenGL rendering
|
||||
|
@ -324,7 +326,6 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
|||
|
||||
const bool windows_size_changed = m_settings.CameraGet().SetCurWindowSize( clientSize );
|
||||
|
||||
|
||||
// Initialize openGL if need
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
if( !m_is_opengl_initialized )
|
||||
|
@ -337,7 +338,6 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if a raytacing was requented and need to switch to raytracing mode
|
||||
if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY )
|
||||
{
|
||||
|
@ -356,7 +356,6 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
float curtime_delta_s = 0.0f;
|
||||
|
||||
if( m_camera_is_moving )
|
||||
|
@ -380,7 +379,6 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// It will return true if the render request a new redraw
|
||||
bool requested_redraw = false;
|
||||
|
||||
|
@ -433,7 +431,7 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
|||
|
||||
void EDA_3D_CANVAS::OnEraseBackground( wxEraseEvent &event )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnEraseBackground" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnEraseBackground" );
|
||||
// Do nothing, to avoid flashing.
|
||||
}
|
||||
|
||||
|
@ -442,7 +440,7 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent &event )
|
|||
{
|
||||
bool mouseActivity = false;
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnMouseWheel" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnMouseWheel" );
|
||||
|
||||
if( m_camera_is_moving )
|
||||
return;
|
||||
|
@ -601,7 +599,7 @@ void EDA_3D_CANVAS::OnMiddleUp( wxMouseEvent &event )
|
|||
|
||||
void EDA_3D_CANVAS::OnRightClick( wxMouseEvent &event )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnRightClick" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnRightClick" );
|
||||
|
||||
SetFocus();
|
||||
|
||||
|
@ -692,7 +690,7 @@ void EDA_3D_CANVAS::OnPopUpMenu( wxCommandEvent &event )
|
|||
{
|
||||
int id = event.GetId();
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnPopUpMenu id:%d" ), id );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnPopUpMenu id:%d", id );
|
||||
|
||||
int key = 0;
|
||||
|
||||
|
@ -756,14 +754,14 @@ void EDA_3D_CANVAS::OnPopUpMenu( wxCommandEvent &event )
|
|||
|
||||
void EDA_3D_CANVAS::OnCharHook( wxKeyEvent &event )
|
||||
{
|
||||
//wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnCharHook" ) );
|
||||
//wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnCharHook" );
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::OnKeyEvent( wxKeyEvent& event )
|
||||
{
|
||||
//wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnKeyEvent" ) );
|
||||
//wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnKeyEvent" );
|
||||
int localkey = event.GetKeyCode();
|
||||
|
||||
// Use only upper char values in comparisons
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -47,7 +47,6 @@
|
|||
|
||||
|
||||
/**
|
||||
* Class EDA_3D_CANVAS
|
||||
* Implement a canvas based on a wxGLCanvas
|
||||
*/
|
||||
class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
|
||||
|
@ -270,6 +269,8 @@ class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
|
|||
/// Flags that the user requested the current view to be render with raytracing
|
||||
bool m_render_raytracing_was_requested;
|
||||
|
||||
bool m_opengl_supports_raytracing;
|
||||
|
||||
/**
|
||||
* Trace mask used to enable or disable the trace output of this class.
|
||||
* The debug output can be turned on by setting the WXTRACE environment variable to
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -40,7 +40,7 @@ extern struct EDA_HOTKEY_CONFIG g_3DViewer_Hokeys_Descr[];
|
|||
|
||||
void EDA_3D_VIEWER::CreateMenuBar()
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::CreateMenuBar" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" );
|
||||
|
||||
wxMenuBar* menuBar = new wxMenuBar;
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
|
@ -343,71 +343,4 @@ void EDA_3D_VIEWER::CreateMenuBar()
|
|||
KiBitmap( about_xpm ) );
|
||||
|
||||
SetMenuBar( menuBar );
|
||||
SetMenuBarOptionsState();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::SetMenuBarOptionsState()
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::SetMenuBarOptionsState" ) );
|
||||
|
||||
wxMenuBar* menuBar = GetMenuBar();
|
||||
|
||||
if( menuBar == NULL )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::SetMenuBarOptionsState menuBar == NULL" ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
wxMenuItem* item;
|
||||
// Set the state of toggle menus according to the current display options
|
||||
item = menuBar->FindItem( ID_MENU3D_ENGINE_OPENGL_LEGACY );
|
||||
item->Check( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_ENGINE_RAYTRACING );
|
||||
item->Check( m_settings.RenderEngineGet() == RENDER_ENGINE_RAYTRACING );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL );
|
||||
item->Check( m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY );
|
||||
item->Check( m_settings.MaterialModeGet() == MATERIAL_MODE_DIFFUSE_ONLY );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE );
|
||||
item->Check( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE );
|
||||
|
||||
// OpenGL
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_OPENGL_RENDER_COPPER_THICKNESS );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_OPENGL_RENDER_SHOW_MODEL_BBOX );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) );
|
||||
|
||||
// Raytracing
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RAYTRACING_RENDER_SHADOWS );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RAYTRACING_BACKFLOOR );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RAYTRACING_REFRACTIONS );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RAYTRACING_REFLECTIONS );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RAYTRACING_POST_PROCESSING );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RAYTRACING_ANTI_ALIASING );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) );
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_FL_RAYTRACING_PROCEDURAL_TEXTURES );
|
||||
item->Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) );
|
||||
|
||||
|
||||
item = menuBar->FindItem( ID_MENU3D_AXIS_ONOFF );
|
||||
item->Check( m_settings.GetFlag( FL_AXIS ) );
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
void EDA_3D_VIEWER::ReCreateMainToolbar()
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::ReCreateMainToolbar" ) );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::ReCreateMainToolbar" );
|
||||
|
||||
if( m_mainToolBar != NULL )
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2014-2018 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
|
||||
|
@ -52,8 +52,6 @@ void EDA_3D_VIEWER::Install3DViewOptionDialog( wxCommandEvent& event )
|
|||
|
||||
if( dlg.ShowModal() == wxID_OK )
|
||||
{
|
||||
SetMenuBarOptionsState();
|
||||
|
||||
NewDisplay( true );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -134,20 +134,28 @@ BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
|
|||
EVT_MENU_RANGE( ID_MENU3D_GRID, ID_MENU3D_GRID_END,
|
||||
EDA_3D_VIEWER::On3DGridSelection )
|
||||
|
||||
EVT_MENU_RANGE( ID_MENU3D_ENGINE, ID_MENU3D_ENGINE_END,
|
||||
EVT_MENU_RANGE( ID_MENU3D_ENGINE_OPENGL_LEGACY, ID_MENU3D_ENGINE_RAYTRACING,
|
||||
EDA_3D_VIEWER::OnRenderEngineSelection )
|
||||
|
||||
EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
|
||||
|
||||
EVT_UPDATE_UI_RANGE( ID_START_COMMAND_3D, ID_MENU_COMMAND_END,
|
||||
EDA_3D_VIEWER::OnUpdateMenus )
|
||||
|
||||
EVT_UPDATE_UI_RANGE( ID_MENU3D_ENGINE_OPENGL_LEGACY, ID_MENU3D_ENGINE_RAYTRACING,
|
||||
EDA_3D_VIEWER::OnUpdateUIEngine )
|
||||
EVT_UPDATE_UI_RANGE( ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL,
|
||||
ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE,
|
||||
EDA_3D_VIEWER::OnUpdateUIMaterial )
|
||||
EVT_UPDATE_UI_RANGE( ID_MENU3D_FL_OPENGL_RENDER_COPPER_THICKNESS,
|
||||
ID_MENU3D_FL_OPENGL_RENDER_SHOW_MODEL_BBOX,
|
||||
EDA_3D_VIEWER::OnUpdateUIOpenGL )
|
||||
EVT_UPDATE_UI_RANGE( ID_MENU3D_FL_RAYTRACING_RENDER_SHADOWS,
|
||||
ID_MENU3D_FL_RAYTRACING_PROCEDURAL_TEXTURES,
|
||||
EDA_3D_VIEWER::OnUpdateUIRayTracing )
|
||||
EVT_UPDATE_UI( ID_MENU3D_AXIS_ONOFF, EDA_3D_VIEWER::OnUpdateUIAxis )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
|
||||
const wxString &aTitle, long style ) :
|
||||
|
||||
KIWAY_PLAYER( aKiway, aParent,
|
||||
FRAME_PCB_DISPLAY3D, aTitle,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
|
@ -189,7 +197,7 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
|
|||
|
||||
m_auimgr.SetManagedWindow( this );
|
||||
|
||||
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
||||
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
|
||||
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
|
||||
m_auimgr.Update();
|
||||
|
@ -210,7 +218,8 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
|
|||
|
||||
EDA_3D_VIEWER::~EDA_3D_VIEWER()
|
||||
{
|
||||
m_mainToolBar->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ), NULL, this );
|
||||
m_mainToolBar->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ),
|
||||
NULL, this );
|
||||
|
||||
m_auimgr.UnInit();
|
||||
|
||||
|
@ -270,7 +279,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|||
bool isChecked = event.IsChecked();
|
||||
|
||||
wxLogTrace( m_logTrace,
|
||||
"EDA_3D_VIEWER::Process_Special_Functions id:%d isChecked:%d",
|
||||
"EDA_3D_VIEWER::Process_Special_Functions id %d isChecked %d",
|
||||
id, isChecked );
|
||||
|
||||
if( m_canvas == NULL )
|
||||
|
@ -386,7 +395,6 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|||
|
||||
case ID_MENU3D_REALISTIC_MODE:
|
||||
m_settings.SetFlag( FL_USE_REALISTIC_MODE, isChecked );
|
||||
SetMenuBarOptionsState();
|
||||
NewDisplay( true );
|
||||
return;
|
||||
|
||||
|
@ -513,13 +521,10 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|||
case ID_MENU3D_RESET_DEFAULTS:
|
||||
{
|
||||
// Reload settings with a dummy config, so it will load the defaults
|
||||
wxConfig *fooconfig = new wxConfig("FooBarApp");
|
||||
wxConfig *fooconfig = new wxConfig( "FooBarApp" );
|
||||
LoadSettings( fooconfig );
|
||||
delete fooconfig;
|
||||
|
||||
// Refresh menu option state
|
||||
SetMenuBarOptionsState();
|
||||
|
||||
// Tell canvas that we (may have) changed the render engine
|
||||
RenderEngineChanged();
|
||||
|
||||
|
@ -534,7 +539,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|||
return;
|
||||
|
||||
default:
|
||||
wxLogMessage( "EDA_3D_VIEWER::Process_Special_Functions() error: unknown command %d", id );
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -547,7 +552,7 @@ void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
|
|||
wxASSERT( id < ID_MENU3D_GRID_END );
|
||||
wxASSERT( id > ID_MENU3D_GRID );
|
||||
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::On3DGridSelection id:%d", id );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::On3DGridSelection id %d", id );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
|
@ -572,7 +577,7 @@ void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
|
|||
break;
|
||||
|
||||
default:
|
||||
wxLogMessage( "EDA_3D_VIEWER::On3DGridSelection() error: unknown command %d", id );
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::On3DGridSelection()" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -588,7 +593,7 @@ void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
|
|||
wxASSERT( id < ID_MENU3D_ENGINE_END );
|
||||
wxASSERT( id > ID_MENU3D_ENGINE );
|
||||
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection id:%d", id );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection id %d", id );
|
||||
|
||||
const RENDER_ENGINE old_engine = m_settings.RenderEngineGet();
|
||||
|
||||
|
@ -605,7 +610,7 @@ void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
|
|||
break;
|
||||
|
||||
default:
|
||||
wxLogMessage( "EDA_3D_VIEWER::OnRenderEngineSelection() error: unknown command %d", id );
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnRenderEngineSelection()" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -616,14 +621,6 @@ void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
|
|||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::OnUpdateMenus(wxUpdateUIEvent &event)
|
||||
{
|
||||
//!TODO: verify how many times this event is called and check if that is OK
|
||||
// to have it working this way
|
||||
SetMenuBarOptionsState();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
|
||||
{
|
||||
int id = event.GetId();
|
||||
|
@ -652,7 +649,7 @@ void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
|
|||
break;
|
||||
|
||||
default:
|
||||
wxLogMessage( "EDA_3D_VIEWER::ProcessZoom() error: unknown command %d", id );
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::ProcessZoom()" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -994,13 +991,10 @@ void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
|
|||
|
||||
void EDA_3D_VIEWER::RenderEngineChanged()
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
|
||||
|
||||
if( m_canvas )
|
||||
m_canvas->RenderEngineChanged();
|
||||
|
||||
m_mainToolBar->EnableTool( ID_RENDER_CURRENT_VIEW,
|
||||
(m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY) );
|
||||
|
||||
m_mainToolBar->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1135,3 +1129,116 @@ bool EDA_3D_VIEWER::Set3DSolderPasteColorFromUser()
|
|||
|
||||
return change;
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::OnUpdateUIEngine( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIEngine() id %d", aEvent.GetId() );
|
||||
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_MENU3D_ENGINE_OPENGL_LEGACY:
|
||||
aEvent.Check( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_ENGINE_RAYTRACING:
|
||||
aEvent.Check( m_settings.RenderEngineGet() == RENDER_ENGINE_RAYTRACING );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIEngine()" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::OnUpdateUIMaterial( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIMaterial() id %d", aEvent.GetId() );
|
||||
|
||||
// Set the state of toggle menus according to the current display options
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL:
|
||||
aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY:
|
||||
aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_DIFFUSE_ONLY );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE:
|
||||
aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::OnUpdateUIOpenGL( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIOpenGL() id %d", aEvent.GetId() );
|
||||
|
||||
// OpenGL
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_MENU3D_FL_OPENGL_RENDER_COPPER_THICKNESS:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_OPENGL_RENDER_SHOW_MODEL_BBOX:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIOpenGL()" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::OnUpdateUIRayTracing( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIRayTracing() id %d", aEvent.GetId() );
|
||||
|
||||
// Raytracing
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_MENU3D_FL_RAYTRACING_RENDER_SHADOWS:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RAYTRACING_BACKFLOOR:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RAYTRACING_REFRACTIONS:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RAYTRACING_REFLECTIONS:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RAYTRACING_POST_PROCESSING:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RAYTRACING_ANTI_ALIASING:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) );
|
||||
break;
|
||||
|
||||
case ID_MENU3D_FL_RAYTRACING_PROCEDURAL_TEXTURES:
|
||||
aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::OnUpdateUIAxis( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
aEvent.Check( m_settings.GetFlag( FL_AXIS ) );
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -161,7 +161,11 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
|
|||
|
||||
void OnRenderEngineSelection( wxCommandEvent &event );
|
||||
|
||||
void OnUpdateMenus(wxUpdateUIEvent& event);
|
||||
void OnUpdateUIEngine( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateUIMaterial( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateUIOpenGL( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateUIRayTracing( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateUIAxis( wxUpdateUIEvent& aEvent );
|
||||
|
||||
void ProcessZoom( wxCommandEvent &event );
|
||||
|
||||
|
@ -175,11 +179,6 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
|
|||
|
||||
void DisplayHotKeys();
|
||||
|
||||
/**
|
||||
* Set the state of toggle menus according to the current display options
|
||||
*/
|
||||
void SetMenuBarOptionsState();
|
||||
|
||||
void ReCreateMainToolbar();
|
||||
|
||||
void SetToolbars();
|
||||
|
|
Loading…
Reference in New Issue