2016-07-19 17:35:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2024-02-08 12:19:54 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-07-19 17:35:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-11-10 23:24:01 +00:00
|
|
|
#include <gal/opengl/kiglew.h> // Must be included first
|
2023-09-20 03:06:44 +00:00
|
|
|
#include <gal/opengl/gl_utils.h>
|
2019-01-19 13:02:10 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
#include "../common_ogl/ogl_utils.h"
|
|
|
|
#include "eda_3d_canvas.h"
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <eda_3d_viewer_frame.h>
|
2021-10-21 13:29:19 +00:00
|
|
|
#include <3d_rendering/raytracing/render_3d_raytrace.h>
|
|
|
|
#include <3d_rendering/opengl/render_3d_opengl.h>
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <3d_viewer_id.h>
|
2023-04-07 17:08:43 +00:00
|
|
|
#include <advanced_config.h>
|
2024-05-05 18:30:21 +00:00
|
|
|
#include <build_version.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-06-03 23:00:40 +00:00
|
|
|
#include <reporter.h>
|
2023-09-20 03:06:44 +00:00
|
|
|
#include <gal/opengl/gl_context_mgr.h>
|
2023-09-07 11:22:10 +00:00
|
|
|
#include <core/profile.h> // To use GetRunningMicroSecs or another profiling utility
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2017-05-26 11:28:51 +00:00
|
|
|
|
2019-05-12 13:08:30 +00:00
|
|
|
#include <widgets/wx_busy_indicator.h>
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2019-01-13 19:04:34 +00:00
|
|
|
* Flag to enable 3D canvas debug tracing.
|
|
|
|
*
|
|
|
|
* Use "KI_TRACE_EDA_3D_CANVAS" to enable.
|
|
|
|
*
|
|
|
|
* @ingroup trace_env_vars
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-02 21:05:29 +00:00
|
|
|
const wxChar* EDA_3D_CANVAS::m_logTrace = wxT( "KI_TRACE_EDA_3D_CANVAS" );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
|
2020-07-14 13:52:01 +00:00
|
|
|
// A custom event, used to call DoRePaint during an idle time
|
2022-10-22 20:57:51 +00:00
|
|
|
wxDEFINE_EVENT( wxEVT_REFRESH_CUSTOM_COMMAND, wxEvent );
|
2020-07-14 13:52:01 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2023-01-28 19:08:38 +00:00
|
|
|
BEGIN_EVENT_TABLE( EDA_3D_CANVAS, HIDPI_GL_3D_CANVAS )
|
2016-07-19 17:35:25 +00:00
|
|
|
EVT_PAINT( EDA_3D_CANVAS::OnPaint )
|
|
|
|
|
|
|
|
// mouse events
|
2019-01-13 19:04:34 +00:00
|
|
|
EVT_LEFT_DOWN( EDA_3D_CANVAS::OnLeftDown )
|
|
|
|
EVT_LEFT_UP( EDA_3D_CANVAS::OnLeftUp )
|
|
|
|
EVT_MIDDLE_UP( EDA_3D_CANVAS::OnMiddleUp )
|
2016-07-19 17:35:25 +00:00
|
|
|
EVT_MIDDLE_DOWN( EDA_3D_CANVAS::OnMiddleDown)
|
2019-01-13 19:04:34 +00:00
|
|
|
EVT_MOUSEWHEEL( EDA_3D_CANVAS::OnMouseWheel )
|
|
|
|
EVT_MOTION( EDA_3D_CANVAS::OnMouseMove )
|
|
|
|
EVT_MAGNIFY( EDA_3D_CANVAS::OnMagnify )
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// other events
|
|
|
|
EVT_ERASE_BACKGROUND( EDA_3D_CANVAS::OnEraseBackground )
|
2020-07-14 13:52:01 +00:00
|
|
|
EVT_CUSTOM(wxEVT_REFRESH_CUSTOM_COMMAND, ID_CUSTOM_EVENT_1, EDA_3D_CANVAS::OnRefreshRequest )
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
EVT_CLOSE( EDA_3D_CANVAS::OnCloseWindow )
|
2017-07-25 16:09:22 +00:00
|
|
|
EVT_SIZE( EDA_3D_CANVAS::OnResize )
|
2016-07-19 17:35:25 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2021-07-18 15:44:54 +00:00
|
|
|
EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
|
2021-01-02 21:05:29 +00:00
|
|
|
BOARD_ADAPTER& aBoardAdapter, CAMERA& aCamera,
|
2022-10-22 20:57:51 +00:00
|
|
|
S3D_CACHE* a3DCachePointer ) :
|
2023-09-07 00:07:09 +00:00
|
|
|
HIDPI_GL_3D_CANVAS( EDA_DRAW_PANEL_GAL::GetVcSettings(), aCamera, aParent, wxID_ANY,
|
|
|
|
aAttribList, wxDefaultPosition,
|
2022-10-22 20:57:51 +00:00
|
|
|
wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ),
|
|
|
|
m_eventDispatcher( nullptr ),
|
|
|
|
m_parentStatusBar( nullptr ),
|
|
|
|
m_parentInfoBar( nullptr ),
|
|
|
|
m_glRC( nullptr ),
|
|
|
|
m_is_opengl_initialized( false ),
|
|
|
|
m_is_opengl_version_supported( true ),
|
|
|
|
m_editing_timeout_timer( this, wxID_HIGHEST + 1 ),
|
|
|
|
m_redraw_trigger_timer( this, wxID_HIGHEST + 2 ),
|
|
|
|
m_render_pivot( false ),
|
|
|
|
m_camera_moving_speed( 1.0f ),
|
|
|
|
m_strtime_camera_movement( 0 ),
|
|
|
|
m_animation_enabled( true ),
|
|
|
|
m_moving_speed_multiplier( 3 ),
|
|
|
|
m_boardAdapter( aBoardAdapter ),
|
|
|
|
m_3d_render( nullptr ),
|
|
|
|
m_opengl_supports_raytracing( true ),
|
|
|
|
m_render_raytracing_was_requested( false ),
|
|
|
|
m_accelerator3DShapes( nullptr ),
|
|
|
|
m_currentRollOverItem( nullptr )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::EDA_3D_CANVAS" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
m_editing_timeout_timer.SetOwner( this );
|
2021-01-02 21:05:29 +00:00
|
|
|
Connect( m_editing_timeout_timer.GetId(), wxEVT_TIMER,
|
|
|
|
wxTimerEventHandler( EDA_3D_CANVAS::OnTimerTimeout_Editing ), nullptr, this );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
m_redraw_trigger_timer.SetOwner( this );
|
2021-01-02 21:05:29 +00:00
|
|
|
Connect( m_redraw_trigger_timer.GetId(), wxEVT_TIMER,
|
|
|
|
wxTimerEventHandler( EDA_3D_CANVAS::OnTimerTimeout_Redraw ), nullptr, this );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-11-03 00:13:31 +00:00
|
|
|
m_is_currently_painting.clear();
|
|
|
|
|
2021-08-16 14:28:46 +00:00
|
|
|
m_3d_render_raytracing = new RENDER_3D_RAYTRACE( this, m_boardAdapter, m_camera );
|
2021-10-21 13:29:19 +00:00
|
|
|
m_3d_render_opengl = new RENDER_3D_OPENGL( this, m_boardAdapter, m_camera );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( m_3d_render_raytracing != nullptr );
|
2021-10-21 13:29:19 +00:00
|
|
|
wxASSERT( m_3d_render_opengl != nullptr );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-07-29 21:02:35 +00:00
|
|
|
auto busy_indicator_factory =
|
|
|
|
[]()
|
|
|
|
{
|
|
|
|
return std::make_unique<WX_BUSY_INDICATOR>();
|
|
|
|
};
|
2019-05-12 13:08:30 +00:00
|
|
|
|
|
|
|
m_3d_render_raytracing->SetBusyIndicatorFactory( busy_indicator_factory );
|
2021-10-21 13:29:19 +00:00
|
|
|
m_3d_render_opengl->SetBusyIndicatorFactory( busy_indicator_factory );
|
2019-05-12 13:08:30 +00:00
|
|
|
|
2022-02-09 09:10:48 +00:00
|
|
|
// We always start with the opengl engine (raytracing is avoided due to very
|
|
|
|
// long calculation time)
|
|
|
|
m_3d_render = m_3d_render_opengl;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2023-05-01 14:51:01 +00:00
|
|
|
m_boardAdapter.ReloadColorSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( a3DCachePointer != nullptr );
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.Set3dCacheManager( a3DCachePointer );
|
2020-03-18 22:48:36 +00:00
|
|
|
|
|
|
|
const wxEventType events[] =
|
|
|
|
{
|
|
|
|
// Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
|
|
|
|
// especially special key like arrow keys, are handled by the GAL event dispatcher,
|
|
|
|
// and not sent to GUI without filtering, because they have a default action (scroll)
|
|
|
|
// that must not be called.
|
|
|
|
wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
|
|
|
|
wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
|
|
|
|
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
|
2020-03-24 01:01:23 +00:00
|
|
|
wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, wxEVT_CHAR_HOOK,
|
|
|
|
wxEVT_MAGNIFY,
|
|
|
|
wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT
|
2020-03-18 22:48:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for( wxEventType eventType : events )
|
2021-01-02 21:05:29 +00:00
|
|
|
Connect( eventType, wxEventHandler( EDA_3D_CANVAS::OnEvent ), nullptr, m_eventDispatcher );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDA_3D_CANVAS::~EDA_3D_CANVAS()
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::~EDA_3D_CANVAS" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-09-04 00:00:56 +00:00
|
|
|
delete m_accelerator3DShapes;
|
2021-01-02 21:05:29 +00:00
|
|
|
m_accelerator3DShapes = nullptr;
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
releaseOpenGL();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::releaseOpenGL()
|
|
|
|
{
|
|
|
|
if( m_glRC )
|
|
|
|
{
|
|
|
|
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
|
|
|
|
|
|
|
delete m_3d_render_raytracing;
|
2021-01-02 21:05:29 +00:00
|
|
|
m_3d_render_raytracing = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-10-21 13:29:19 +00:00
|
|
|
delete m_3d_render_opengl;
|
|
|
|
m_3d_render_opengl = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
// This is just a copy of a pointer, can safely be set to NULL.
|
|
|
|
m_3d_render = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
|
|
|
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glRC );
|
2021-01-02 21:05:29 +00:00
|
|
|
m_glRC = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnCloseWindow( wxCloseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
releaseOpenGL();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2019-01-13 19:04:34 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnResize( wxSizeEvent& event )
|
2017-07-25 16:09:22 +00:00
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
Request_refresh();
|
2017-07-25 16:09:22 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-01-13 19:04:34 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
bool EDA_3D_CANVAS::initializeOpenGL()
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::initializeOpenGL" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
const GLenum err = glewInit();
|
|
|
|
|
|
|
|
if( GLEW_OK != err )
|
|
|
|
{
|
|
|
|
const wxString msgError = (const char*) glewGetErrorString( err );
|
|
|
|
|
2016-08-17 07:37:51 +00:00
|
|
|
wxLogMessage( msgError );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::initializeOpenGL Using GLEW version %s" ),
|
2023-09-09 04:10:57 +00:00
|
|
|
From_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2024-05-05 18:30:21 +00:00
|
|
|
SetOpenGLInfo( (const char*) glGetString( GL_VENDOR ), (const char*) glGetString( GL_RENDERER ),
|
|
|
|
(const char*) glGetString( GL_VERSION ) );
|
|
|
|
|
2023-09-09 04:10:57 +00:00
|
|
|
wxString version = From_UTF8( (char *) glGetString( GL_VERSION ) );
|
2019-01-13 19:04:34 +00:00
|
|
|
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::%s OpenGL version string %s." ),
|
2019-01-19 13:02:10 +00:00
|
|
|
__WXFUNCTION__, version );
|
|
|
|
|
|
|
|
// Extract OpenGL version from string. This method is used because prior to OpenGL 2,
|
|
|
|
// getting the OpenGL major and minor version as integers didn't exist.
|
|
|
|
wxString tmp;
|
|
|
|
|
|
|
|
wxStringTokenizer tokenizer( version );
|
|
|
|
|
|
|
|
if( tokenizer.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
long major = 0;
|
|
|
|
long minor = 0;
|
|
|
|
|
|
|
|
tmp = tokenizer.GetNextToken();
|
|
|
|
|
2022-02-04 20:21:07 +00:00
|
|
|
tokenizer.SetString( tmp, wxString( wxT( "." ) ) );
|
2019-01-19 13:02:10 +00:00
|
|
|
|
|
|
|
if( tokenizer.HasMoreTokens() )
|
|
|
|
tokenizer.GetNextToken().ToLong( &major );
|
|
|
|
|
|
|
|
if( tokenizer.HasMoreTokens() )
|
|
|
|
tokenizer.GetNextToken().ToLong( &minor );
|
|
|
|
|
2020-10-05 00:06:53 +00:00
|
|
|
if( major < 2 || ( ( major == 2 ) && ( minor < 1 ) ) )
|
2019-01-19 13:02:10 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::%s OpenGL ray tracing not supported." ),
|
2019-01-19 13:02:10 +00:00
|
|
|
__WXFUNCTION__ );
|
|
|
|
|
|
|
|
if( GetParent() )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_MENU, ID_DISABLE_RAY_TRACING );
|
|
|
|
GetParent()->ProcessWindowEvent( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_opengl_supports_raytracing = false;
|
|
|
|
}
|
2020-10-05 00:06:53 +00:00
|
|
|
|
|
|
|
if( ( major == 1 ) && ( minor < 5 ) )
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::%s OpenGL not supported." ),
|
|
|
|
__WXFUNCTION__ );
|
2020-10-05 00:06:53 +00:00
|
|
|
|
|
|
|
m_is_opengl_version_supported = false;
|
|
|
|
}
|
2019-01-19 13:02:10 +00:00
|
|
|
}
|
2019-01-13 19:04:34 +00:00
|
|
|
|
2020-07-04 04:43:31 +00:00
|
|
|
GL_UTILS::SetSwapInterval( -1 );
|
2016-07-19 17:35:25 +00:00
|
|
|
m_is_opengl_initialized = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::GetScreenshot( wxImage& aDstImage )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
OglGetScreenshot( aDstImage );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::ReloadRequest( BOARD* aBoard , S3D_CACHE* aCachePointer )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
if( aCachePointer != nullptr )
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.Set3dCacheManager( aCachePointer );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( aBoard != nullptr )
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.SetBoard( aBoard );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2023-05-01 14:51:01 +00:00
|
|
|
m_boardAdapter.ReloadColorSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( m_3d_render )
|
|
|
|
m_3d_render->ReloadRequest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::RenderRaytracingRequest()
|
|
|
|
{
|
|
|
|
m_3d_render = m_3d_render_raytracing;
|
|
|
|
|
|
|
|
if( m_3d_render )
|
|
|
|
m_3d_render->ReloadRequest();
|
|
|
|
|
|
|
|
m_render_raytracing_was_requested = true;
|
|
|
|
|
|
|
|
Request_refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::DisplayStatus()
|
|
|
|
{
|
|
|
|
if( m_parentStatusBar )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2022-02-04 20:21:07 +00:00
|
|
|
msg.Printf( wxT( "dx %3.2f" ), m_camera.GetCameraPos().x );
|
2020-02-03 22:09:14 +00:00
|
|
|
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::X_POS ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-02-04 20:21:07 +00:00
|
|
|
msg.Printf( wxT( "dy %3.2f" ), m_camera.GetCameraPos().y );
|
2020-02-03 22:09:14 +00:00
|
|
|
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::Y_POS ) );
|
2023-09-01 17:51:50 +00:00
|
|
|
|
|
|
|
msg.Printf( wxT( "zoom %3.2f" ), 1 / m_camera.GetZoom() );
|
|
|
|
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::ZOOM_LEVEL ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-14 13:52:01 +00:00
|
|
|
void EDA_3D_CANVAS::OnPaint( wxPaintEvent& aEvent )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
// Please have a look at: https://lists.launchpad.net/kicad-developers/msg25149.html
|
2020-07-14 13:52:01 +00:00
|
|
|
DoRePaint();
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-07-14 13:52:01 +00:00
|
|
|
void EDA_3D_CANVAS::DoRePaint()
|
|
|
|
{
|
2020-11-03 00:13:31 +00:00
|
|
|
if( m_is_currently_painting.test_and_set() )
|
|
|
|
return;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// SwapBuffer requires the window to be shown before calling
|
|
|
|
if( !IsShownOnScreen() )
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::DoRePaint !IsShown" ) );
|
2020-11-03 00:13:31 +00:00
|
|
|
m_is_currently_painting.clear();
|
2016-07-19 17:35:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Because the board to draw is handled by the parent viewer frame,
|
|
|
|
// ensure this parent is still alive. When it is closed before the viewer
|
|
|
|
// frame, a paint event can be generated after the parent is closed,
|
|
|
|
// therefore with invalid board.
|
2019-01-19 13:02:10 +00:00
|
|
|
// This is dependent of the platform.
|
2016-07-19 17:35:25 +00:00
|
|
|
// Especially on OSX, but also on Windows, it frequently happens
|
2021-08-19 21:28:54 +00:00
|
|
|
if( !GetParent()->GetParent()->IsShownOnScreen() )
|
2016-07-19 17:35:25 +00:00
|
|
|
return; // The parent board editor frame is no more alive
|
|
|
|
|
2024-02-05 11:13:45 +00:00
|
|
|
wxString err_messages;
|
2020-06-03 23:00:40 +00:00
|
|
|
INFOBAR_REPORTER warningReporter( m_parentInfoBar );
|
2022-07-30 10:32:22 +00:00
|
|
|
STATUSBAR_REPORTER activityReporter( m_parentStatusBar, EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
|
2024-03-03 18:39:53 +00:00
|
|
|
int64_t start_time = GetRunningMicroSecs();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// "Makes the OpenGL state that is represented by the OpenGL rendering
|
|
|
|
// context context current, i.e. it will be used by all subsequent OpenGL calls.
|
|
|
|
// This function may only be called when the window is shown on screen"
|
|
|
|
|
|
|
|
// Explicitly create a new rendering context instance for this canvas.
|
2021-01-02 21:05:29 +00:00
|
|
|
if( m_glRC == nullptr )
|
2016-07-19 17:35:25 +00:00
|
|
|
m_glRC = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
|
|
|
|
|
2023-02-15 02:18:28 +00:00
|
|
|
// CreateCtx could and does fail per sentry crash events, lets be graceful
|
|
|
|
if( m_glRC == nullptr )
|
|
|
|
{
|
|
|
|
warningReporter.Report( _( "OpenGL context creation error" ), RPT_SEVERITY_ERROR );
|
|
|
|
warningReporter.Finalize();
|
|
|
|
m_is_currently_painting.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
|
|
|
|
|
|
|
// Set the OpenGL viewport according to the client size of this canvas.
|
|
|
|
// This is done here rather than in a wxSizeEvent handler because our
|
|
|
|
// OpenGL rendering context (and thus viewport setting) is used with
|
|
|
|
// multiple canvases: If we updated the viewport in the wxSizeEvent
|
|
|
|
// handler, changing the size of one canvas causes a viewport setting that
|
|
|
|
// is wrong when next another canvas is repainted.
|
2019-02-19 23:17:13 +00:00
|
|
|
wxSize clientSize = GetNativePixelSize();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
const bool windows_size_changed = m_camera.SetCurWindowSize( clientSize );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Initialize openGL if need
|
|
|
|
if( !m_is_opengl_initialized )
|
|
|
|
{
|
|
|
|
if( !initializeOpenGL() )
|
|
|
|
{
|
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
2020-11-03 00:13:31 +00:00
|
|
|
m_is_currently_painting.clear();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2020-10-05 00:06:53 +00:00
|
|
|
|
|
|
|
if( !m_is_opengl_version_supported )
|
|
|
|
{
|
2020-12-16 22:10:42 +00:00
|
|
|
warningReporter.Report( _( "Your OpenGL version is not supported. Minimum required "
|
2021-07-05 12:40:38 +00:00
|
|
|
"is 1.5." ), RPT_SEVERITY_ERROR );
|
2020-10-05 00:06:53 +00:00
|
|
|
|
|
|
|
warningReporter.Finalize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !m_is_opengl_version_supported )
|
|
|
|
{
|
|
|
|
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
|
|
|
|
glClear( GL_COLOR_BUFFER_BIT );
|
|
|
|
|
|
|
|
SwapBuffers();
|
|
|
|
|
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
2020-11-03 00:13:31 +00:00
|
|
|
m_is_currently_painting.clear();
|
2020-10-05 00:06:53 +00:00
|
|
|
|
|
|
|
return;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2019-01-19 13:02:10 +00:00
|
|
|
// Don't attend to ray trace if OpenGL doesn't support it.
|
|
|
|
if( !m_opengl_supports_raytracing )
|
|
|
|
{
|
2021-10-21 13:29:19 +00:00
|
|
|
m_3d_render = m_3d_render_opengl;
|
2019-01-19 13:02:10 +00:00
|
|
|
m_render_raytracing_was_requested = false;
|
2021-08-30 20:30:18 +00:00
|
|
|
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::OPENGL;
|
2019-01-19 13:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a raytacing was requested and need to switch to raytracing mode
|
2021-08-30 20:30:18 +00:00
|
|
|
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
const bool was_camera_changed = m_camera.ParametersChanged();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// It reverts back to OpenGL mode if it was requested a raytracing
|
|
|
|
// render of the current scene. AND the mouse / camera is moving
|
2020-12-16 22:10:42 +00:00
|
|
|
if( ( m_mouse_is_moving || m_camera_is_moving || was_camera_changed
|
|
|
|
|| windows_size_changed )
|
|
|
|
&& m_render_raytracing_was_requested )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_render_raytracing_was_requested = false;
|
2021-10-21 13:29:19 +00:00
|
|
|
m_3d_render = m_3d_render_opengl;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float curtime_delta_s = 0.0f;
|
|
|
|
|
|
|
|
if( m_camera_is_moving )
|
|
|
|
{
|
2024-03-03 18:39:53 +00:00
|
|
|
const int64_t curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
|
2016-07-19 17:35:25 +00:00
|
|
|
curtime_delta_s = (curtime_delta / 1e6) * m_camera_moving_speed;
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.Interpolate( curtime_delta_s );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( curtime_delta_s > 1.0f )
|
|
|
|
{
|
|
|
|
m_render_pivot = false;
|
|
|
|
m_camera_is_moving = false;
|
|
|
|
m_mouse_was_moved = true;
|
|
|
|
|
|
|
|
restart_editingTimeOut_Timer();
|
|
|
|
DisplayStatus();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Request_refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It will return true if the render request a new redraw
|
|
|
|
bool requested_redraw = false;
|
|
|
|
|
|
|
|
if( m_3d_render )
|
|
|
|
{
|
2020-11-03 00:13:31 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_3d_render->SetCurWindowSize( clientSize );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-10-24 17:30:40 +00:00
|
|
|
bool reloadRaytracingForCalculations = false;
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL
|
2021-10-21 13:29:19 +00:00
|
|
|
&& m_3d_render_opengl->IsReloadRequestPending() )
|
2020-11-29 20:00:16 +00:00
|
|
|
{
|
2021-10-24 17:30:40 +00:00
|
|
|
reloadRaytracingForCalculations = true;
|
2020-11-29 20:00:16 +00:00
|
|
|
}
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2020-11-29 20:00:16 +00:00
|
|
|
requested_redraw = m_3d_render->Redraw( m_mouse_was_moved || m_camera_is_moving,
|
|
|
|
&activityReporter, &warningReporter );
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2021-10-24 17:30:40 +00:00
|
|
|
// Raytracer renderer is responsible for some features also used by the OpenGL
|
|
|
|
// renderer.
|
|
|
|
// FIXME: Presumably because raytracing renderer reload is called only after current
|
|
|
|
// renderer redraw, the old zoom value stays for a single frame. This is ugly, but only
|
|
|
|
// cosmetic, so I'm not fixing that for now: I don't know how to do this without
|
|
|
|
// reloading twice (maybe it's not too bad of an idea?) or doing a complicated
|
|
|
|
// refactor.
|
|
|
|
if( reloadRaytracingForCalculations )
|
2020-11-03 00:13:31 +00:00
|
|
|
m_3d_render_raytracing->Reload( nullptr, nullptr, true );
|
|
|
|
}
|
2021-02-20 16:50:10 +00:00
|
|
|
catch( std::runtime_error& )
|
2020-11-03 00:13:31 +00:00
|
|
|
{
|
|
|
|
m_is_opengl_version_supported = false;
|
|
|
|
m_opengl_supports_raytracing = false;
|
|
|
|
m_is_opengl_initialized = false;
|
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
|
|
|
m_is_currently_painting.clear();
|
|
|
|
return;
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_render_pivot )
|
|
|
|
{
|
2021-10-24 17:30:40 +00:00
|
|
|
const float scale = glm::min( m_camera.GetZoom(), 1.0f );
|
2021-12-18 16:30:18 +00:00
|
|
|
render_pivot( curtime_delta_s, scale );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 16:44:22 +00:00
|
|
|
// This will only be enabled by the 3d mouse plugin, so we can leave
|
|
|
|
// it as a simple if statement
|
|
|
|
if( m_render3dmousePivot )
|
2022-08-11 07:40:08 +00:00
|
|
|
{
|
|
|
|
const float scale = glm::min( m_camera.GetZoom(), 1.0f );
|
|
|
|
render3dmousePivot( scale );
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// "Swaps the double-buffer of this window, making the back-buffer the
|
|
|
|
// front-buffer and vice versa, so that the output of the previous OpenGL
|
|
|
|
// commands is displayed on the window."
|
|
|
|
SwapBuffers();
|
|
|
|
|
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
|
|
|
|
2023-08-23 13:04:31 +00:00
|
|
|
if( m_mouse_was_moved || m_camera_is_moving )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2023-08-23 13:04:31 +00:00
|
|
|
// Calculation time in milliseconds
|
2024-02-05 11:13:45 +00:00
|
|
|
const double calculation_time = (double)( GetRunningMicroSecs() - start_time ) / 1e3;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2023-08-23 13:04:31 +00:00
|
|
|
activityReporter.Report( wxString::Format( _( "Last render time %.0f ms" ),
|
|
|
|
calculation_time ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This will reset the flag of camera parameters changed
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.ParametersChanged();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-06-03 23:00:40 +00:00
|
|
|
warningReporter.Finalize();
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( !err_messages.IsEmpty() )
|
|
|
|
wxLogMessage( err_messages );
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( ( !m_camera_is_moving ) && requested_redraw )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_mouse_was_moved = false;
|
|
|
|
Request_refresh( false );
|
|
|
|
}
|
2020-11-03 00:13:31 +00:00
|
|
|
|
|
|
|
m_is_currently_painting.clear();
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-18 22:48:36 +00:00
|
|
|
void EDA_3D_CANVAS::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
|
|
|
|
{
|
|
|
|
m_eventDispatcher = aEventDispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::OnEvent( wxEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( !m_eventDispatcher )
|
|
|
|
aEvent.Skip();
|
|
|
|
else
|
|
|
|
m_eventDispatcher->DispatchWxEvent( aEvent );
|
|
|
|
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnEraseBackground( wxEraseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnEraseBackground" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
// Do nothing, to avoid flashing.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnMouseWheel" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-06-21 23:38:22 +00:00
|
|
|
OnMouseWheelCamera( event, m_boardAdapter.m_MousewheelPanning );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-06-21 23:38:22 +00:00
|
|
|
if( m_mouse_was_moved )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
DisplayStatus();
|
|
|
|
Request_refresh();
|
|
|
|
restart_editingTimeOut_Timer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event )
|
|
|
|
{
|
2018-10-12 11:41:44 +00:00
|
|
|
SetFocus();
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( m_camera_is_moving )
|
|
|
|
return;
|
|
|
|
|
|
|
|
//m_is_moving_mouse = true;
|
|
|
|
restart_editingTimeOut_Timer();
|
|
|
|
|
|
|
|
float magnification = ( event.GetMagnification() + 1.0f );
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.Zoom( magnification );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
DisplayStatus();
|
|
|
|
Request_refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2023-11-09 17:52:37 +00:00
|
|
|
if( m_3d_render && m_3d_render->IsReloadRequestPending() )
|
|
|
|
return; // Prevents using invalid m_3d_render_raytracing data
|
|
|
|
|
2022-07-30 09:38:31 +00:00
|
|
|
if( m_camera_is_moving )
|
|
|
|
return;
|
|
|
|
|
2022-06-21 23:38:22 +00:00
|
|
|
OnMouseMoveCamera( event );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-06-21 23:38:22 +00:00
|
|
|
if( m_mouse_was_moved )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
DisplayStatus();
|
|
|
|
Request_refresh();
|
2022-07-30 09:38:31 +00:00
|
|
|
// *Do not* reactivate the timer here during the mouse move command:
|
|
|
|
// OnMiddleUp() will do it at the end of mouse drag/move command
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
if( !event.Dragging() && m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
|
2020-09-04 00:00:56 +00:00
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
STATUSBAR_REPORTER reporter( m_parentStatusBar, EDA_3D_VIEWER_STATUSBAR::HOVERED_ITEM );
|
|
|
|
RAY mouseRay = getRayAtCurrentMousePosition();
|
|
|
|
BOARD_ITEM* rollOverItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2022-07-30 10:32:22 +00:00
|
|
|
auto printNetInfo =
|
|
|
|
[]( BOARD_CONNECTED_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return wxString::Format( _( "Net %s\tNet class %s" ),
|
|
|
|
aItem->GetNet()->GetNetname(),
|
2022-08-14 11:03:18 +00:00
|
|
|
aItem->GetNet()->GetNetClass()->GetName() );
|
2022-07-30 10:32:22 +00:00
|
|
|
};
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2021-05-11 19:52:28 +00:00
|
|
|
if( rollOverItem )
|
2020-09-04 00:00:56 +00:00
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2021-05-11 19:52:28 +00:00
|
|
|
if( rollOverItem != m_currentRollOverItem )
|
2020-09-04 00:00:56 +00:00
|
|
|
{
|
2021-10-21 13:29:19 +00:00
|
|
|
m_3d_render_opengl->SetCurrentRollOverItem( rollOverItem );
|
2021-05-11 19:52:28 +00:00
|
|
|
m_currentRollOverItem = rollOverItem;
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2020-09-04 00:25:49 +00:00
|
|
|
Request_refresh();
|
2020-09-04 00:00:56 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 19:52:28 +00:00
|
|
|
switch( rollOverItem->Type() )
|
2020-09-04 00:00:56 +00:00
|
|
|
{
|
2020-12-16 22:10:42 +00:00
|
|
|
case PCB_PAD_T:
|
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
PAD* pad = static_cast<PAD*>( rollOverItem );
|
|
|
|
|
|
|
|
if( !pad->GetNumber().IsEmpty() )
|
|
|
|
msg += wxString::Format( _( "Pad %s\t" ), pad->GetNumber() );
|
|
|
|
|
|
|
|
if( pad->IsOnCopperLayer() )
|
|
|
|
msg += printNetInfo( pad );
|
2020-12-16 22:10:42 +00:00
|
|
|
|
2020-09-04 00:00:56 +00:00
|
|
|
break;
|
2022-07-30 10:32:22 +00:00
|
|
|
}
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( rollOverItem );
|
|
|
|
msg += footprint->GetReference();
|
2020-09-04 00:00:56 +00:00
|
|
|
break;
|
2022-07-30 10:32:22 +00:00
|
|
|
}
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
|
|
|
case PCB_ARC_T:
|
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
PCB_TRACK* track = static_cast<PCB_TRACK*>( rollOverItem );
|
|
|
|
msg += printNetInfo( track );
|
2020-09-04 00:00:56 +00:00
|
|
|
break;
|
2022-07-30 10:32:22 +00:00
|
|
|
}
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
case PCB_ZONE_T:
|
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
ZONE* zone = static_cast<ZONE*>( rollOverItem );
|
2020-12-16 22:10:42 +00:00
|
|
|
|
2022-07-30 10:32:22 +00:00
|
|
|
if( !zone->GetZoneName().IsEmpty() )
|
2020-09-04 00:00:56 +00:00
|
|
|
{
|
2022-07-30 10:32:22 +00:00
|
|
|
if( zone->GetIsRuleArea() )
|
|
|
|
msg += wxString::Format( _( "Rule area %s\t" ), zone->GetZoneName() );
|
|
|
|
else
|
|
|
|
msg += wxString::Format( _( "Zone %s\t" ), zone->GetZoneName() );
|
2020-09-04 00:00:56 +00:00
|
|
|
}
|
2022-07-30 10:32:22 +00:00
|
|
|
|
|
|
|
if( zone->IsOnCopperLayer() )
|
|
|
|
msg += printNetInfo( zone );
|
|
|
|
|
2020-09-04 00:00:56 +00:00
|
|
|
break;
|
2022-07-30 10:32:22 +00:00
|
|
|
}
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
default:
|
2020-09-04 00:00:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-07-30 10:32:22 +00:00
|
|
|
|
|
|
|
reporter.Report( msg );
|
2020-09-04 00:00:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-30 20:30:18 +00:00
|
|
|
if( m_currentRollOverItem
|
|
|
|
&& m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
|
2020-09-04 00:00:56 +00:00
|
|
|
{
|
2021-10-21 13:29:19 +00:00
|
|
|
m_3d_render_opengl->SetCurrentRollOverItem( nullptr );
|
2020-09-04 00:00:56 +00:00
|
|
|
Request_refresh();
|
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
reporter.Report( wxEmptyString );
|
2020-09-04 00:00:56 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 19:52:28 +00:00
|
|
|
m_currentRollOverItem = nullptr;
|
2020-09-04 00:00:56 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnLeftDown( wxMouseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-10-12 11:41:44 +00:00
|
|
|
SetFocus();
|
2016-07-19 17:35:25 +00:00
|
|
|
stop_editingTimeOut_Timer();
|
2020-09-04 00:00:56 +00:00
|
|
|
|
|
|
|
if( !event.Dragging() && ( m_3d_render_raytracing != nullptr ) )
|
|
|
|
{
|
2021-06-11 10:57:15 +00:00
|
|
|
RAY mouseRay = getRayAtCurrentMousePosition();
|
2020-09-04 00:00:56 +00:00
|
|
|
|
|
|
|
BOARD_ITEM *intersectedBoardItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
|
|
|
|
|
|
|
|
// !TODO: send a selection item to pcbnew, eg: via kiway?
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnLeftUp( wxMouseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
if( m_camera_is_moving )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( m_mouse_is_moving )
|
|
|
|
{
|
|
|
|
m_mouse_is_moving = false;
|
|
|
|
restart_editingTimeOut_Timer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnMiddleDown( wxMouseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-10-12 11:41:44 +00:00
|
|
|
SetFocus();
|
2016-07-19 17:35:25 +00:00
|
|
|
stop_editingTimeOut_Timer();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void EDA_3D_CANVAS::OnMiddleUp( wxMouseEvent& event )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
if( m_camera_is_moving )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( m_mouse_is_moving )
|
|
|
|
{
|
|
|
|
m_mouse_is_moving = false;
|
|
|
|
restart_editingTimeOut_Timer();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
move_pivot_based_on_cur_mouse_position();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-22 20:57:51 +00:00
|
|
|
void EDA_3D_CANVAS::OnTimerTimeout_Editing( wxTimerEvent& aEvent )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2022-10-22 20:57:51 +00:00
|
|
|
if( aEvent.GetId() != m_editing_timeout_timer.GetId() )
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
m_mouse_is_moving = false;
|
|
|
|
m_mouse_was_moved = false;
|
|
|
|
|
|
|
|
Request_refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::stop_editingTimeOut_Timer()
|
|
|
|
{
|
|
|
|
m_editing_timeout_timer.Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::restart_editingTimeOut_Timer()
|
|
|
|
{
|
2020-11-03 00:13:31 +00:00
|
|
|
if( m_3d_render )
|
|
|
|
m_editing_timeout_timer.Start( m_3d_render->GetWaitForEditingTimeOut(), wxTIMER_ONE_SHOT );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-22 20:57:51 +00:00
|
|
|
void EDA_3D_CANVAS::OnTimerTimeout_Redraw( wxTimerEvent& aEvent )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2022-10-22 20:57:51 +00:00
|
|
|
if( aEvent.GetId() != m_redraw_trigger_timer.GetId() )
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-14 13:52:01 +00:00
|
|
|
Request_refresh( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::OnRefreshRequest( wxEvent& aEvent )
|
|
|
|
{
|
2024-02-08 12:19:54 +00:00
|
|
|
Refresh();
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::Request_refresh( bool aRedrawImmediately )
|
|
|
|
{
|
|
|
|
if( aRedrawImmediately )
|
|
|
|
{
|
2020-07-14 13:52:01 +00:00
|
|
|
// Just calling Refresh() does not work always
|
|
|
|
// Using an event to call DoRepaint ensure the repaint code will be executed,
|
|
|
|
// and PostEvent will take priority to other events like mouse movements, keys, etc.
|
|
|
|
// and is executed during the next idle time
|
|
|
|
wxCommandEvent redrawEvent( wxEVT_REFRESH_CUSTOM_COMMAND, ID_CUSTOM_EVENT_1 );
|
2016-07-19 17:35:25 +00:00
|
|
|
wxPostEvent( this, redrawEvent );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Schedule a timed redraw
|
|
|
|
m_redraw_trigger_timer.Start( 10 , wxTIMER_ONE_SHOT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::request_start_moving_camera( float aMovingSpeed, bool aRenderPivot )
|
|
|
|
{
|
|
|
|
wxASSERT( aMovingSpeed > FLT_EPSILON );
|
|
|
|
|
2020-04-24 23:58:50 +00:00
|
|
|
// Fast forward the animation if the animation is disabled
|
|
|
|
if( !m_animation_enabled )
|
|
|
|
{
|
|
|
|
m_camera.Interpolate( 1.0f );
|
|
|
|
DisplayStatus();
|
|
|
|
Request_refresh();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
// Map speed multiplier option to actual multiplier value
|
2020-04-24 23:58:50 +00:00
|
|
|
// [1,2,3,4,5] -> [0.25, 0.5, 1, 2, 4]
|
|
|
|
aMovingSpeed *= ( 1 << m_moving_speed_multiplier ) / 8.0f;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
m_render_pivot = aRenderPivot;
|
|
|
|
m_camera_moving_speed = aMovingSpeed;
|
|
|
|
|
|
|
|
stop_editingTimeOut_Timer();
|
|
|
|
|
|
|
|
DisplayStatus();
|
|
|
|
Request_refresh();
|
|
|
|
|
|
|
|
m_camera_is_moving = true;
|
|
|
|
|
|
|
|
m_strtime_camera_movement = GetRunningMicroSecs();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position()
|
|
|
|
{
|
2021-06-11 10:57:15 +00:00
|
|
|
RAY mouseRay = getRayAtCurrentMousePosition();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
float hit_t;
|
|
|
|
|
|
|
|
// Test it with the board bounding box
|
2021-01-05 22:19:00 +00:00
|
|
|
if( m_boardAdapter.GetBBox().Intersect( mouseRay, &hit_t ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.SetLookAtPos_T1( mouseRay.at( hit_t ) );
|
|
|
|
m_camera.ResetXYpos_T1();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
request_start_moving_camera();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
bool EDA_3D_CANVAS::SetView3D( VIEW3D_TYPE aRequestedView )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
if( m_camera_is_moving )
|
2018-04-15 12:07:33 +00:00
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-10-24 17:30:40 +00:00
|
|
|
const float delta_move = m_delta_move_step_factor * m_camera.GetZoom();
|
2016-07-19 17:35:25 +00:00
|
|
|
const float arrow_moving_time_speed = 8.0f;
|
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
switch( aRequestedView )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_PIVOT_CENTER:
|
2016-07-19 17:35:25 +00:00
|
|
|
move_pivot_based_on_cur_mouse_position();
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_PAN_LEFT:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Pan_T1( SFVEC3F( -delta_move, 0.0f, 0.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera( arrow_moving_time_speed, false );
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_PAN_RIGHT:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Pan_T1( SFVEC3F( +delta_move, 0.0f, 0.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera( arrow_moving_time_speed, false );
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_PAN_UP:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Pan_T1( SFVEC3F( 0.0f, +delta_move, 0.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera( arrow_moving_time_speed, false );
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_PAN_DOWN:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Pan_T1( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera( arrow_moving_time_speed, false );
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_FIT_SCREEN:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Reset_T1();
|
2021-10-24 17:30:40 +00:00
|
|
|
request_start_moving_camera( glm::min( glm::max( m_camera.GetZoom(), 1 / 1.26f ), 1.26f ) );
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_ZOOM_IN:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
2018-04-15 12:07:33 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( m_camera.Zoom_T1( 1.26f ) ) // 3 steps per doubling
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera( 3.0f );
|
2018-04-15 12:07:33 +00:00
|
|
|
|
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_ZOOM_OUT:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
2018-04-15 12:07:33 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( m_camera.Zoom_T1( 1/1.26f ) ) // 3 steps per halving
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera( 3.0f );
|
|
|
|
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_RIGHT:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Reset_T1();
|
|
|
|
m_camera.RotateZ_T1( glm::radians( -90.0f ) );
|
|
|
|
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera();
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_LEFT:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Reset_T1();
|
|
|
|
m_camera.RotateZ_T1( glm::radians( 90.0f ) );
|
|
|
|
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera();
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_FRONT:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Reset_T1();
|
|
|
|
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera();
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_BACK:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Reset_T1();
|
2020-03-31 15:35:45 +00:00
|
|
|
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
2021-01-07 19:33:43 +00:00
|
|
|
|
2020-03-31 15:35:45 +00:00
|
|
|
// The rotation angle should be 180.
|
|
|
|
// We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when
|
|
|
|
// using 180 deg if the previous rotated position was already 180 deg
|
|
|
|
m_camera.RotateZ_T1( glm::radians( 179.999f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
request_start_moving_camera();
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_TOP:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Reset_T1();
|
2021-10-24 17:30:40 +00:00
|
|
|
request_start_moving_camera( glm::min( glm::max( m_camera.GetZoom(), 0.5f ), 1.125f ) );
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_BOTTOM:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.Reset_T1();
|
2020-03-31 15:35:45 +00:00
|
|
|
m_camera.RotateY_T1( glm::radians( 179.999f ) ); // Rotation = 180 - epsilon
|
2021-10-24 17:30:40 +00:00
|
|
|
request_start_moving_camera( glm::min( glm::max( m_camera.GetZoom(), 0.5f ), 1.125f ) );
|
2018-04-15 12:07:33 +00:00
|
|
|
return true;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-09-28 23:18:50 +00:00
|
|
|
case VIEW3D_TYPE::VIEW3D_FLIP:
|
2020-06-08 21:35:40 +00:00
|
|
|
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
|
|
|
m_camera.SetT0_and_T1_current_T();
|
|
|
|
m_camera.RotateY_T1( glm::radians( 179.999f ) );
|
|
|
|
request_start_moving_camera();
|
|
|
|
return true;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
default:
|
2018-04-15 12:07:33 +00:00
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_CANVAS::RenderEngineChanged()
|
|
|
|
{
|
2021-08-30 20:30:18 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
|
|
|
|
|
|
|
switch( cfg->m_Render.engine )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-10-21 13:29:19 +00:00
|
|
|
case RENDER_ENGINE::OPENGL: m_3d_render = m_3d_render_opengl; break;
|
|
|
|
case RENDER_ENGINE::RAYTRACING: m_3d_render = m_3d_render_raytracing; break;
|
|
|
|
default: m_3d_render = nullptr; break;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_3d_render )
|
|
|
|
m_3d_render->ReloadRequest();
|
|
|
|
|
|
|
|
m_mouse_was_moved = false;
|
|
|
|
|
|
|
|
Request_refresh();
|
|
|
|
}
|
2020-09-04 00:00:56 +00:00
|
|
|
|
|
|
|
|
2021-06-11 10:57:15 +00:00
|
|
|
RAY EDA_3D_CANVAS::getRayAtCurrentMousePosition()
|
2020-09-04 00:00:56 +00:00
|
|
|
{
|
|
|
|
SFVEC3F rayOrigin;
|
|
|
|
SFVEC3F rayDir;
|
|
|
|
|
|
|
|
// Generate a ray origin and direction based on current mouser position and camera
|
2021-06-11 10:57:15 +00:00
|
|
|
m_camera.MakeRayAtCurrentMousePosition( rayOrigin, rayDir );
|
2020-09-04 00:00:56 +00:00
|
|
|
|
|
|
|
RAY mouseRay;
|
|
|
|
mouseRay.Init( rayOrigin, rayDir );
|
|
|
|
|
|
|
|
return mouseRay;
|
|
|
|
}
|