2016-07-19 13:35:25 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2023-08-11 18:40:13 +01:00
|
|
|
* Copyright (C) 2023 CERN
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2016-07-19 13:35:25 -04: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-03-21 16:19:55 -04:00
|
|
|
#include <wx/filename.h>
|
2021-06-06 08:41:16 -04:00
|
|
|
#include <wx/msgdlg.h>
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/wupdlock.h>
|
|
|
|
#include <wx/clipbrd.h>
|
2021-06-11 10:17:52 +01:00
|
|
|
#include <wx/filedlg.h>
|
2022-06-06 21:58:00 +01:00
|
|
|
#include <wx/dialog.h>
|
2021-08-05 13:03:59 +01:00
|
|
|
#include "eda_3d_viewer_frame.h"
|
2023-08-11 18:40:13 +01:00
|
|
|
#include "dialogs/appearance_controls_3D.h"
|
2022-06-06 21:58:00 +01:00
|
|
|
#include <dialogs/eda_view_switcher.h>
|
2021-06-19 18:28:45 +01:00
|
|
|
#include <eda_3d_viewer_settings.h>
|
2025-08-02 12:32:31 -07:00
|
|
|
#include <3d_rendering/raytracing/render_3d_raytrace_ram.h>
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <3d_viewer_id.h>
|
2021-06-19 18:28:45 +01:00
|
|
|
#include <3d_viewer/tools/eda_3d_actions.h>
|
|
|
|
#include <3d_viewer/tools/eda_3d_controller.h>
|
|
|
|
#include <3d_viewer/tools/eda_3d_conditions.h>
|
2024-04-27 22:57:24 +03:00
|
|
|
#include <board.h>
|
2023-04-07 10:08:43 -07:00
|
|
|
#include <advanced_config.h>
|
2019-04-08 10:49:18 +01:00
|
|
|
#include <bitmaps.h>
|
2021-06-06 15:03:10 -04:00
|
|
|
#include <board_design_settings.h>
|
2020-11-17 20:21:04 -05:00
|
|
|
#include <core/arraydim.h>
|
2023-09-22 23:17:53 -04:00
|
|
|
#include <dpi_scaling_common.h>
|
2019-04-08 10:49:18 +01:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <project.h>
|
2022-06-06 21:58:00 +01:00
|
|
|
#include <project/project_file.h>
|
2020-01-12 20:44:19 -05:00
|
|
|
#include <settings/common_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-07-27 23:42:23 +01:00
|
|
|
#include <tool/action_manager.h>
|
2019-06-10 23:17:45 +01:00
|
|
|
#include <tool/common_control.h>
|
2020-01-22 22:38:30 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/action_toolbar.h>
|
2022-12-28 22:03:03 +00:00
|
|
|
#include <widgets/wx_infobar.h>
|
2023-08-11 18:40:13 +01:00
|
|
|
#include <widgets/wx_aui_utils.h>
|
2020-01-22 22:38:30 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2023-09-27 23:15:54 -04:00
|
|
|
#include <project_pcb.h>
|
2025-02-26 03:22:49 +00:00
|
|
|
#include <toolbars_3d.h>
|
2018-12-08 08:20:32 -05:00
|
|
|
|
2021-06-24 10:47:28 +02:00
|
|
|
#include <3d_navlib/nl_3d_viewer_plugin.h>
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
/**
|
2018-12-08 08:20:32 -05:00
|
|
|
* Flag to enable 3D viewer main frame window debug tracing.
|
|
|
|
*
|
|
|
|
* Use "KI_TRACE_EDA_3D_VIEWER" to enable.
|
|
|
|
*
|
|
|
|
* @ingroup trace_env_vars
|
2016-07-19 13:35:25 -04:00
|
|
|
*/
|
2021-06-19 18:28:45 +01:00
|
|
|
const wxChar* EDA_3D_VIEWER_FRAME::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
|
2023-01-28 14:08:38 -05:00
|
|
|
BEGIN_EVENT_TABLE( EDA_3D_VIEWER_FRAME, KIWAY_PLAYER )
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
EVT_ACTIVATE( EDA_3D_VIEWER_FRAME::OnActivate )
|
|
|
|
EVT_SET_FOCUS( EDA_3D_VIEWER_FRAME::OnSetFocus )
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2017-12-28 09:29:56 +01:00
|
|
|
EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_MENU_COMMAND_END,
|
2021-06-19 18:28:45 +01:00
|
|
|
EDA_3D_VIEWER_FRAME::Process_Special_Functions )
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
EVT_MENU( wxID_CLOSE, EDA_3D_VIEWER_FRAME::Exit3DFrame )
|
2022-06-06 21:58:00 +01:00
|
|
|
EVT_MENU( ID_DISABLE_RAY_TRACING, EDA_3D_VIEWER_FRAME::onDisableRayTracing )
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
EVT_CLOSE( EDA_3D_VIEWER_FRAME::OnCloseWindow )
|
2016-07-19 13:35:25 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2021-06-24 10:47:28 +02:00
|
|
|
EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent,
|
|
|
|
const wxString& aTitle, long style ) :
|
2020-03-18 22:48:36 +00:00
|
|
|
KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition,
|
2022-09-19 17:09:59 +01:00
|
|
|
wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ), unityScale ),
|
2023-08-11 18:40:13 +01:00
|
|
|
m_canvas( nullptr ),
|
|
|
|
m_currentCamera( m_trackBallCamera ),
|
2024-12-30 15:41:42 -08:00
|
|
|
m_trackBallCamera( 2 * RANGE_SCALE_3D )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME %s" ), aTitle );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2019-01-19 08:02:10 -05:00
|
|
|
m_disable_ray_tracing = false;
|
2022-12-31 18:39:04 -05:00
|
|
|
m_aboutTitle = _HKI( "KiCad 3D Viewer" );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
// Give it an icon
|
|
|
|
wxIcon icon;
|
2021-03-07 21:59:07 -05:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_3d ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
SetIcon( icon );
|
|
|
|
|
|
|
|
// Create the status line
|
2023-09-01 17:51:50 +00:00
|
|
|
static const int status_dims[5] = { -1, 170, 130, 130, 130 };
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2019-01-06 08:43:12 -08:00
|
|
|
wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
|
|
|
|
SetStatusWidths( arrayDim( status_dims ), status_dims );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
ANTIALIASING_MODE aaMode = ANTIALIASING_MODE::AA_NONE;
|
|
|
|
EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
if( cfg )
|
|
|
|
aaMode = static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode );
|
|
|
|
|
|
|
|
m_canvas = new EDA_3D_CANVAS( this, OGL_ATT_LIST::GetAttributesList( aaMode, true ), m_boardAdapter,
|
|
|
|
m_currentCamera, PROJECT_PCB::Get3DCacheManager( &Prj() ) );
|
2023-08-11 18:40:13 +01:00
|
|
|
|
|
|
|
m_appearancePanel = new APPEARANCE_CONTROLS_3D( this, GetCanvas() );
|
2020-04-24 23:58:50 +00:00
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
LoadSettings( GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) );
|
2019-04-08 10:49:18 +01:00
|
|
|
loadCommonSettings();
|
|
|
|
|
2023-08-11 18:40:13 +01:00
|
|
|
m_appearancePanel->SetUserViewports( Prj().GetProjectFile().m_Viewports3D );
|
2022-06-06 21:58:00 +01:00
|
|
|
|
2019-06-10 23:17:45 +01:00
|
|
|
// Create the manager
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
2025-06-14 19:35:35 +01:00
|
|
|
m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr,
|
|
|
|
GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ), this );
|
2020-03-18 22:48:36 +00:00
|
|
|
|
|
|
|
m_actions = new EDA_3D_ACTIONS();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2020-03-18 22:48:36 +00:00
|
|
|
m_canvas->SetEventDispatcher( m_toolDispatcher );
|
2019-06-10 23:17:45 +01:00
|
|
|
|
|
|
|
// Register tools
|
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2020-03-24 01:01:23 +00:00
|
|
|
m_toolManager->RegisterTool( new EDA_3D_CONTROLLER );
|
2019-06-10 23:17:45 +01:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
2020-07-27 23:42:23 +01:00
|
|
|
setupUIConditions();
|
|
|
|
|
2020-06-07 11:42:28 +01:00
|
|
|
if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
|
2025-06-14 19:35:35 +01:00
|
|
|
ctrlTool->SetRotationIncrement( cfg ? cfg->m_Camera.rotation_increment : 10.0 );
|
2020-06-07 11:42:28 +01:00
|
|
|
|
2020-03-18 22:48:36 +00:00
|
|
|
// Run the viewer control tool, it is supposed to be always active
|
|
|
|
m_toolManager->InvokeTool( "3DViewer.Control" );
|
|
|
|
|
2023-08-23 14:04:31 +01:00
|
|
|
ReCreateMenuBar();
|
2025-02-26 03:22:49 +00:00
|
|
|
|
2025-02-27 02:51:29 +00:00
|
|
|
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<EDA_3D_VIEWER_TOOLBAR_SETTINGS>( "3d_viewer-toolbars" );
|
2025-02-20 02:53:15 +00:00
|
|
|
configureToolbars();
|
|
|
|
RecreateToolbars();
|
2019-01-19 08:02:10 -05:00
|
|
|
|
2020-12-26 22:59:47 +00:00
|
|
|
m_infoBar = new WX_INFOBAR( this, &m_auimgr );
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( wxS( "TopMainToolbar" ) )
|
2023-08-11 18:40:13 +01:00
|
|
|
.Top().Layer( 6 ) );
|
|
|
|
m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( wxS( "InfoBar" ) )
|
|
|
|
.Top().Layer( 1 ) );
|
|
|
|
m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
|
|
|
|
.Right().Layer( 3 )
|
|
|
|
.Caption( _( "Appearance" ) ).PaneBorder( false )
|
|
|
|
.MinSize( 180, -1 ).BestSize( 190, -1 ) );
|
|
|
|
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
|
|
|
|
.Center() );
|
|
|
|
|
|
|
|
wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
|
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
if( cfg && cfg->m_AuiPanels.right_panel_width > 0 )
|
2023-08-11 18:40:13 +01:00
|
|
|
SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 );
|
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
if( cfg )
|
|
|
|
layersManager.Show( cfg->m_AuiPanels.show_layer_manager );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2020-12-26 22:59:47 +00:00
|
|
|
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
|
2021-06-09 19:32:58 +00:00
|
|
|
// hiding it.
|
2020-12-26 22:59:47 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// We don't want the infobar displayed right away
|
2023-01-16 19:07:41 -05:00
|
|
|
m_auimgr.GetPane( wxS( "InfoBar" ) ).Hide();
|
2020-12-26 22:59:47 +00:00
|
|
|
m_auimgr.Update();
|
2020-06-04 00:00:40 +01:00
|
|
|
|
2020-12-11 12:09:37 +00:00
|
|
|
m_canvas->SetInfoBar( m_infoBar );
|
|
|
|
m_canvas->SetStatusBar( status_bar );
|
2020-06-04 00:00:40 +01:00
|
|
|
|
2023-06-13 09:44:22 -07:00
|
|
|
try
|
2021-07-02 11:29:22 +02:00
|
|
|
{
|
2024-12-30 15:41:42 -08:00
|
|
|
m_spaceMouse = std::make_unique<NL_3D_VIEWER_PLUGIN>( m_canvas );
|
2023-06-13 09:44:22 -07:00
|
|
|
}
|
|
|
|
catch( const std::system_error& e )
|
|
|
|
{
|
|
|
|
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
|
2021-07-02 11:29:22 +02:00
|
|
|
}
|
2021-06-24 10:47:28 +02:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
// Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
|
|
|
|
// in order to receive mouse events. Otherwise, the user has to click somewhere on
|
|
|
|
// the canvas before it will respond to mouse wheel events.
|
2020-12-16 23:54:17 +00:00
|
|
|
m_canvas->SetFocus();
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
EDA_3D_VIEWER_FRAME::~EDA_3D_VIEWER_FRAME()
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2023-08-11 18:40:13 +01:00
|
|
|
Prj().GetProjectFile().m_Viewports3D = m_appearancePanel->GetUserViewports();
|
2022-06-06 21:58:00 +01:00
|
|
|
|
2020-03-18 22:48:36 +00:00
|
|
|
m_canvas->SetEventDispatcher( nullptr );
|
2018-05-10 12:49:20 +02:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
m_auimgr.UnInit();
|
|
|
|
}
|
|
|
|
|
2017-05-13 08:17:06 +02:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::setupUIConditions()
|
2020-07-27 23:42:23 +01:00
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
EDA_3D_CONDITIONS cond( &m_boardAdapter );
|
|
|
|
|
|
|
|
// Helper to define check conditions
|
2020-08-05 23:00:26 +01:00
|
|
|
#define GridSizeCheck( x ) ACTION_CONDITIONS().Check( cond.GridSize( x ) )
|
2020-07-27 23:42:23 +01:00
|
|
|
|
2021-08-30 21:30:18 +01:00
|
|
|
auto raytracing =
|
2021-08-05 13:03:59 +01:00
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
2021-08-30 21:30:18 +01:00
|
|
|
return m_boardAdapter.m_Cfg->m_Render.engine != RENDER_ENGINE::OPENGL;
|
|
|
|
};
|
|
|
|
auto showTH =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_boardAdapter.m_Cfg->m_Render.show_footprints_normal;
|
|
|
|
};
|
|
|
|
auto showSMD =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_boardAdapter.m_Cfg->m_Render.show_footprints_insert;
|
|
|
|
};
|
|
|
|
auto showVirtual =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_boardAdapter.m_Cfg->m_Render.show_footprints_virtual;
|
|
|
|
};
|
2022-09-24 11:25:02 +02:00
|
|
|
auto show_NotInPosfile =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_boardAdapter.m_Cfg->m_Render.show_footprints_not_in_posfile;
|
|
|
|
};
|
2023-04-10 13:10:42 -04:00
|
|
|
auto show_DNP =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_boardAdapter.m_Cfg->m_Render.show_footprints_dnp;
|
|
|
|
};
|
2021-08-30 21:30:18 +01:00
|
|
|
auto showBBoxes =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
2023-09-21 13:07:10 +01:00
|
|
|
return m_boardAdapter.m_Cfg->m_Render.show_model_bbox;
|
2021-08-30 21:30:18 +01:00
|
|
|
};
|
2025-06-09 19:29:34 +02:00
|
|
|
auto showNavig = [this]( const SELECTION& aSel )
|
2021-08-30 21:30:18 +01:00
|
|
|
{
|
2025-06-09 19:29:34 +02:00
|
|
|
return m_boardAdapter.m_Cfg->m_Render.show_navigator;
|
2021-08-30 21:30:18 +01:00
|
|
|
};
|
|
|
|
auto ortho =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_currentCamera.GetProjection() == PROJECTION_TYPE::ORTHO;
|
2021-08-05 13:03:59 +01:00
|
|
|
};
|
2020-07-27 23:42:23 +01:00
|
|
|
|
2023-08-20 17:58:38 +01:00
|
|
|
auto appearances =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_boardAdapter.m_Cfg->m_AuiPanels.show_layer_manager;
|
|
|
|
};
|
2020-07-27 23:42:23 +01:00
|
|
|
|
2025-02-20 13:44:29 +00:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::toggleRaytacing, ACTION_CONDITIONS().Check( raytracing ) );
|
2022-09-24 11:25:02 +02:00
|
|
|
|
2025-01-10 20:30:25 -05:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showTHT, ACTION_CONDITIONS().Check( showTH ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showSMD, ACTION_CONDITIONS().Check( showSMD ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showVirtual, ACTION_CONDITIONS().Check( showVirtual ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showNotInPosFile,
|
|
|
|
ACTION_CONDITIONS().Check( show_NotInPosfile ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showDNP, ACTION_CONDITIONS().Check( show_DNP ) );
|
2021-07-21 17:55:27 +02:00
|
|
|
|
2025-01-10 20:30:25 -05:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showBBoxes, ACTION_CONDITIONS().Check( showBBoxes ) );
|
2025-06-09 19:29:34 +02:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showNavigator, ACTION_CONDITIONS().Check( showNavig ) );
|
2020-07-27 23:42:23 +01:00
|
|
|
|
2025-01-10 20:30:25 -05:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::noGrid, GridSizeCheck( GRID3D_TYPE::NONE ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::show10mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_10MM ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::show5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_5MM ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::show2_5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_2P5MM ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::show1mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_1MM ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( ortho ) );
|
2023-08-20 17:58:38 +01:00
|
|
|
|
2025-01-10 20:30:25 -05:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showLayersManager,
|
|
|
|
ACTION_CONDITIONS().Check( appearances ) );
|
2020-07-27 23:42:23 +01:00
|
|
|
|
|
|
|
#undef GridSizeCheck
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-06 21:58:00 +01:00
|
|
|
bool EDA_3D_VIEWER_FRAME::TryBefore( wxEvent& aEvent )
|
|
|
|
{
|
2023-08-11 18:40:13 +01:00
|
|
|
static bool s_presetSwitcherShown = false;
|
2022-06-06 21:58:00 +01:00
|
|
|
static bool s_viewportSwitcherShown = false;
|
|
|
|
|
2022-10-27 11:32:52 +01:00
|
|
|
// wxWidgets generates no key events for the tab key when the ctrl key is held down. One
|
|
|
|
// way around this is to look at all events and inspect the keyboard state of the tab key.
|
|
|
|
// However, this runs into issues on some linux VMs where querying the keyboard state is
|
|
|
|
// very slow. Fortunately we only use ctrl-tab on Mac, so we implement this lovely hack:
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
if( wxGetKeyState( WXK_TAB ) )
|
|
|
|
#else
|
|
|
|
if( ( aEvent.GetEventType() == wxEVT_CHAR || aEvent.GetEventType() == wxEVT_CHAR_HOOK )
|
|
|
|
&& static_cast<wxKeyEvent&>( aEvent ).GetKeyCode() == WXK_TAB )
|
|
|
|
#endif
|
2022-06-06 21:58:00 +01:00
|
|
|
{
|
2023-08-11 18:40:13 +01:00
|
|
|
if( !s_presetSwitcherShown && wxGetKeyState( PRESET_SWITCH_KEY ) )
|
|
|
|
{
|
|
|
|
if( m_appearancePanel && this->IsActive() )
|
|
|
|
{
|
|
|
|
wxArrayString mru = m_appearancePanel->GetLayerPresetsMRU();
|
|
|
|
|
|
|
|
if( mru.size() > 0 )
|
|
|
|
{
|
|
|
|
for( wxString& str : mru )
|
|
|
|
{
|
|
|
|
if( str == FOLLOW_PCB )
|
|
|
|
str = _( "Follow PCB Editor" );
|
|
|
|
else if( str == FOLLOW_PLOT_SETTINGS )
|
|
|
|
str = _( "Follow PCB Plot Settings" );
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_VIEW_SWITCHER switcher( this, mru, PRESET_SWITCH_KEY );
|
|
|
|
|
|
|
|
s_presetSwitcherShown = true;
|
|
|
|
switcher.ShowModal();
|
|
|
|
s_presetSwitcherShown = false;
|
|
|
|
|
|
|
|
int idx = switcher.GetSelection();
|
|
|
|
|
|
|
|
if( idx >= 0 && idx < (int) mru.size() )
|
|
|
|
{
|
|
|
|
wxString internalName = m_appearancePanel->GetLayerPresetsMRU()[idx];
|
|
|
|
m_appearancePanel->ApplyLayerPreset( internalName );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( !s_viewportSwitcherShown && wxGetKeyState( VIEWPORT_SWITCH_KEY ) )
|
2022-06-06 21:58:00 +01:00
|
|
|
{
|
2022-10-27 11:32:52 +01:00
|
|
|
if( this->IsActive() )
|
2022-06-06 21:58:00 +01:00
|
|
|
{
|
2023-08-11 18:40:13 +01:00
|
|
|
const wxArrayString& viewportMRU = m_appearancePanel->GetViewportsMRU();
|
|
|
|
|
|
|
|
if( viewportMRU.size() > 0 )
|
2022-10-27 11:32:52 +01:00
|
|
|
{
|
2023-08-11 18:40:13 +01:00
|
|
|
EDA_VIEW_SWITCHER switcher( this, viewportMRU, VIEWPORT_SWITCH_KEY );
|
2022-06-06 21:58:00 +01:00
|
|
|
|
2022-10-27 11:32:52 +01:00
|
|
|
s_viewportSwitcherShown = true;
|
|
|
|
switcher.ShowModal();
|
|
|
|
s_viewportSwitcherShown = false;
|
2022-06-06 21:58:00 +01:00
|
|
|
|
2022-10-27 11:32:52 +01:00
|
|
|
int idx = switcher.GetSelection();
|
2022-06-06 21:58:00 +01:00
|
|
|
|
2023-08-11 18:40:13 +01:00
|
|
|
if( idx >= 0 && idx < (int) viewportMRU.size() )
|
|
|
|
m_appearancePanel->ApplyViewport( viewportMRU[idx] );
|
2022-06-06 21:58:00 +01:00
|
|
|
|
2022-10-27 11:32:52 +01:00
|
|
|
return true;
|
|
|
|
}
|
2022-06-06 21:58:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxFrame::TryBefore( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-31 19:03:41 +00:00
|
|
|
void EDA_3D_VIEWER_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
KIWAY_PLAYER::handleIconizeEvent( aEvent );
|
|
|
|
|
2023-06-13 09:44:22 -07:00
|
|
|
if( m_spaceMouse && aEvent.IsIconized() )
|
2022-03-31 19:03:41 +00:00
|
|
|
m_spaceMouse->SetFocus( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::ReloadRequest()
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
|
|
|
// This will schedule a request to load later
|
2024-01-28 16:04:02 -05:00
|
|
|
// ReloadRequest also updates the board pointer so always call it first
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_canvas )
|
2023-09-27 23:15:54 -04:00
|
|
|
m_canvas->ReloadRequest( GetBoard(), PROJECT_PCB::Get3DCacheManager( &Prj() ) );
|
2024-01-28 16:04:02 -05:00
|
|
|
|
|
|
|
if( m_appearancePanel )
|
|
|
|
m_appearancePanel->UpdateLayerCtls();
|
2017-05-13 08:17:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::NewDisplay( bool aForceImmediateRedraw )
|
2017-05-13 08:17:06 +02:00
|
|
|
{
|
2023-08-11 18:40:13 +01:00
|
|
|
if( m_canvas )
|
2023-09-27 23:15:54 -04:00
|
|
|
m_canvas->ReloadRequest( GetBoard(), PROJECT_PCB::Get3DCacheManager( &Prj() ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2017-05-13 08:17:06 +02:00
|
|
|
// After the ReloadRequest call, the refresh often takes a bit of time,
|
|
|
|
// and it is made here only on request.
|
2023-08-17 10:06:02 +02:00
|
|
|
if( m_canvas && aForceImmediateRedraw )
|
2017-05-13 08:17:06 +02:00
|
|
|
m_canvas->Refresh();
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
2020-12-16 17:10:42 -05:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::Redraw()
|
2020-09-02 17:54:57 +01:00
|
|
|
{
|
|
|
|
// Only update in OpenGL for an interactive interaction
|
2021-08-30 21:30:18 +01:00
|
|
|
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
|
2020-09-04 01:00:56 +01:00
|
|
|
m_canvas->Request_refresh( true );
|
2020-09-02 17:54:57 +01:00
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2020-12-16 17:10:42 -05:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::refreshRender()
|
2020-09-29 09:37:00 +01:00
|
|
|
{
|
2021-08-30 21:30:18 +01:00
|
|
|
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
|
2020-09-29 09:37:00 +01:00
|
|
|
m_canvas->Request_refresh();
|
|
|
|
else
|
|
|
|
NewDisplay( true );
|
|
|
|
}
|
|
|
|
|
2020-12-16 17:10:42 -05:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::Exit3DFrame( wxCommandEvent &event )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::Exit3DFrame" ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
Close( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::OnCloseWindow( wxCloseEvent &event )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::OnCloseWindow" ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2021-08-19 22:28:54 +01:00
|
|
|
// Do not show the layer manager during closing to avoid flicker on some platforms (Windows)
|
|
|
|
// that generate useless redraw of items in the Layer Manager
|
2023-08-20 17:58:38 +01:00
|
|
|
if( m_auimgr.GetPane( wxS( "LayersManager" ) ).IsShown() )
|
2023-08-11 18:40:13 +01:00
|
|
|
m_auimgr.GetPane( wxS( "LayersManager" ) ).Show( false );
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->Close();
|
|
|
|
|
|
|
|
Destroy();
|
|
|
|
event.Skip( true );
|
|
|
|
}
|
|
|
|
|
2020-03-16 12:45:09 -04:00
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::Process_Special_Functions( wxCommandEvent &event )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2021-01-02 16:05:29 -05:00
|
|
|
if( m_canvas == nullptr )
|
2016-07-19 13:35:25 -04:00
|
|
|
return;
|
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
switch( event.GetId() )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
|
|
|
case ID_MENU3D_RESET_DEFAULTS:
|
|
|
|
{
|
2025-04-18 12:35:56 +01:00
|
|
|
m_boardAdapter.SetLayerColors( m_boardAdapter.GetDefaultColors() );
|
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
if( EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) )
|
|
|
|
cfg->ResetToDefaults();
|
|
|
|
|
|
|
|
LoadSettings( GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2018-04-06 17:00:58 +01:00
|
|
|
// Tell canvas that we (may have) changed the render engine
|
2016-07-19 13:35:25 -04:00
|
|
|
RenderEngineChanged();
|
2018-04-06 17:00:58 +01:00
|
|
|
NewDisplay( true );
|
2016-07-19 13:35:25 -04:00
|
|
|
return;
|
2025-06-14 19:35:35 +01:00
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
default:
|
2022-02-04 20:21:07 +00:00
|
|
|
wxFAIL_MSG( wxT( "Invalid event in EDA_3D_VIEWER_FRAME::Process_Special_Functions()" ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-06 21:58:00 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::onDisableRayTracing( wxCommandEvent& aEvent )
|
2019-01-19 08:02:10 -05:00
|
|
|
{
|
2025-06-14 19:35:35 +01:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::%s disabling ray tracing." ), __WXFUNCTION__ );
|
2019-01-19 08:02:10 -05:00
|
|
|
|
|
|
|
m_disable_ray_tracing = true;
|
2021-08-30 21:30:18 +01:00
|
|
|
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::OPENGL;
|
2019-01-19 08:02:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::OnActivate( wxActivateEvent &aEvent )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::OnActivate" ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2020-10-27 19:35:55 -04:00
|
|
|
if( aEvent.GetActive() && m_canvas )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
|
|
|
// Reload data if 3D frame shows a board,
|
|
|
|
// because it can be changed since last frame activation
|
|
|
|
if( m_canvas->IsReloadRequestPending() )
|
|
|
|
m_canvas->Request_refresh();
|
|
|
|
|
|
|
|
// Activates again the focus of the canvas so it will catch mouse and key events
|
|
|
|
m_canvas->SetFocus();
|
|
|
|
}
|
|
|
|
|
2023-06-13 09:44:22 -07:00
|
|
|
if( m_spaceMouse )
|
2021-06-24 10:47:28 +02:00
|
|
|
m_spaceMouse->SetFocus( aEvent.GetActive() );
|
|
|
|
|
2020-10-27 19:35:55 -04:00
|
|
|
aEvent.Skip(); // required under wxMAC
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::OnSetFocus( wxFocusEvent& aEvent )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
|
|
|
// Activates again the focus of the canvas so it will catch mouse and key events
|
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->SetFocus();
|
|
|
|
|
2020-10-27 19:35:55 -04:00
|
|
|
aEvent.Skip();
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE *aCfg )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2024-09-04 17:23:31 +01:00
|
|
|
// Dynamic_cast here will fail on Mac when called from CvPCB.
|
|
|
|
EDA_3D_VIEWER_SETTINGS* cfg = static_cast<EDA_3D_VIEWER_SETTINGS*>( aCfg );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::LoadSettings" ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
if( cfg )
|
|
|
|
{
|
2024-03-03 21:18:36 +03:00
|
|
|
applySettings( cfg );
|
|
|
|
|
2023-08-11 18:40:13 +01:00
|
|
|
m_boardAdapter.SetBoard( GetBoard() );
|
2020-09-04 15:12:01 +00:00
|
|
|
|
2022-03-04 10:07:10 -05:00
|
|
|
// When opening the 3D viewer, we use the OpenGL mode, never the ray tracing engine
|
|
|
|
// because the ray tracing is very time consuming, and can be seen as not working
|
2020-05-16 13:17:49 +02:00
|
|
|
// (freeze window) with large boards.
|
2021-08-30 21:30:18 +01:00
|
|
|
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::OPENGL;
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2023-08-11 18:40:13 +01:00
|
|
|
if( cfg->m_CurrentPreset == LEGACY_PRESET_FLAG )
|
|
|
|
{
|
2023-08-23 14:04:31 +01:00
|
|
|
wxString legacyColorsPresetName = _( "legacy colors" );
|
2023-08-11 18:40:13 +01:00
|
|
|
|
2024-02-23 16:06:23 +00:00
|
|
|
cfg->m_UseStackupColors = false;
|
|
|
|
|
2023-08-23 14:04:31 +01:00
|
|
|
if( !cfg->FindPreset( legacyColorsPresetName ) )
|
2023-08-11 18:40:13 +01:00
|
|
|
{
|
2023-08-23 14:04:31 +01:00
|
|
|
cfg->m_LayerPresets.emplace_back( legacyColorsPresetName,
|
2024-02-23 16:06:23 +00:00
|
|
|
GetAdapter().GetDefaultVisibleLayers(),
|
|
|
|
GetAdapter().GetDefaultColors() );
|
2023-08-11 18:40:13 +01:00
|
|
|
}
|
2023-08-23 14:04:31 +01:00
|
|
|
|
2024-06-29 21:52:39 +01:00
|
|
|
cfg->m_CurrentPreset = FOLLOW_PLOT_SETTINGS;
|
2023-08-11 18:40:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_boardAdapter.InitSettings( nullptr, nullptr );
|
|
|
|
|
|
|
|
if( m_appearancePanel )
|
|
|
|
m_appearancePanel->CommonSettingsChanged();
|
2020-03-25 13:13:03 +00:00
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE *aCfg )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2025-06-14 19:35:35 +01:00
|
|
|
EDA_BASE_FRAME::SaveSettings( GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
if( EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) )
|
2020-03-25 13:13:03 +00:00
|
|
|
{
|
2023-08-11 18:40:13 +01:00
|
|
|
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
|
|
|
|
|
2021-06-17 12:21:06 +01:00
|
|
|
cfg->m_Camera.animation_enabled = m_canvas->GetAnimationEnabled();
|
|
|
|
cfg->m_Camera.moving_speed_multiplier = m_canvas->GetMovingSpeedMultiplier();
|
|
|
|
cfg->m_Camera.projection_mode = m_canvas->GetProjectionMode();
|
2020-04-24 23:58:50 +00:00
|
|
|
|
2020-06-07 11:42:28 +01:00
|
|
|
if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
|
|
|
|
cfg->m_Camera.rotation_increment = ctrlTool->GetRotationIncrement();
|
2020-03-25 13:13:03 +00:00
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-02-01 20:00:40 +00:00
|
|
|
void EDA_3D_VIEWER_FRAME::CommonSettingsChanged( int aFlags )
|
2019-04-08 10:49:18 +01:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::CommonSettingsChanged" ) );
|
2019-04-08 10:49:18 +01:00
|
|
|
|
|
|
|
// Regen menu bars, etc
|
2025-02-01 20:00:40 +00:00
|
|
|
EDA_BASE_FRAME::CommonSettingsChanged( aFlags );
|
2019-04-08 10:49:18 +01:00
|
|
|
|
|
|
|
loadCommonSettings();
|
2025-06-14 19:35:35 +01:00
|
|
|
applySettings( GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) );
|
2019-04-08 10:49:18 +01:00
|
|
|
|
2023-08-11 18:40:13 +01:00
|
|
|
m_appearancePanel->CommonSettingsChanged();
|
|
|
|
|
2019-04-08 10:49:18 +01:00
|
|
|
NewDisplay( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-23 14:04:31 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::ShowChangedLanguage();
|
|
|
|
|
|
|
|
SetTitle( _( "3D Viewer" ) );
|
2025-02-20 02:53:15 +00:00
|
|
|
RecreateToolbars();
|
2023-08-23 14:04:31 +01:00
|
|
|
|
|
|
|
if( m_appearancePanel )
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
|
|
|
|
lm_pane_info.Caption( _( "Appearance" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
SetStatusText( wxEmptyString, ACTIVITY );
|
|
|
|
SetStatusText( wxEmptyString, HOVERED_ITEM );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-11 18:40:13 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::ToggleAppearanceManager()
|
|
|
|
{
|
2025-06-14 19:35:35 +01:00
|
|
|
wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
|
2023-08-11 18:40:13 +01:00
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
if( EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) )
|
|
|
|
{
|
|
|
|
// show auxiliary Vertical layers and visibility manager toolbar
|
|
|
|
cfg->m_AuiPanels.show_layer_manager = !cfg->m_AuiPanels.show_layer_manager;
|
2023-08-11 18:40:13 +01:00
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
layersManager.Show( cfg->m_AuiPanels.show_layer_manager );
|
2023-08-11 18:40:13 +01:00
|
|
|
|
2025-06-14 19:35:35 +01:00
|
|
|
if( cfg->m_AuiPanels.show_layer_manager )
|
|
|
|
{
|
|
|
|
SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
2023-08-11 18:40:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::OnDarkModeToggle()
|
|
|
|
{
|
|
|
|
if( m_appearancePanel )
|
|
|
|
m_appearancePanel->OnDarkModeToggle();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-02-20 13:44:29 +00:00
|
|
|
void EDA_3D_VIEWER_FRAME::TakeScreenshot( EDA_3D_VIEWER_EXPORT_FORMAT aFormat )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2025-08-02 12:32:31 -07:00
|
|
|
wxString fullFileName;
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-02-20 13:44:29 +00:00
|
|
|
if( aFormat != EDA_3D_VIEWER_EXPORT_FORMAT::CLIPBOARD )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2025-08-02 12:32:31 -07:00
|
|
|
if( !getExportFileName( aFormat, fullFileName ) )
|
|
|
|
return;
|
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
wxImage screenshotImage = captureCurrentViewScreenshot();
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
if( screenshotImage.IsOk() )
|
|
|
|
{
|
|
|
|
saveOrCopyImage( screenshotImage, aFormat, fullFileName );
|
|
|
|
}
|
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
wxImage EDA_3D_VIEWER_FRAME::captureCurrentViewScreenshot()
|
|
|
|
{
|
|
|
|
// Ensure we have the latest 3D view (remember 3D view is buffered)
|
|
|
|
// Also ensure any highlighted item is not highlighted when creating screen shot
|
|
|
|
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render;
|
|
|
|
bool original_highlight = cfg.highlight_on_rollover;
|
|
|
|
cfg.highlight_on_rollover = false;
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
m_canvas->DoRePaint(); // init first buffer
|
|
|
|
m_canvas->DoRePaint(); // init second buffer
|
2018-12-08 08:20:32 -05:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
wxImage screenshotImage;
|
2018-12-08 08:20:32 -05:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
if( m_canvas )
|
|
|
|
{
|
|
|
|
// Build image from the 3D buffer
|
|
|
|
wxWindowUpdateLocker noUpdates( this );
|
|
|
|
m_canvas->GetScreenshot( screenshotImage );
|
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
// Restore highlight setting
|
|
|
|
cfg.highlight_on_rollover = original_highlight;
|
2020-03-21 16:19:55 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
return screenshotImage;
|
|
|
|
}
|
2020-03-16 12:45:09 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::ExportImage( EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxSize& aSize )
|
|
|
|
{
|
|
|
|
wxString fullFileName;
|
|
|
|
|
|
|
|
if( aFormat != EDA_3D_VIEWER_EXPORT_FORMAT::CLIPBOARD )
|
|
|
|
{
|
|
|
|
if( !getExportFileName( aFormat, fullFileName ) )
|
2020-03-16 12:45:09 -04:00
|
|
|
return;
|
2025-08-02 12:32:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
wxImage screenshotImage = captureScreenshot( aSize );
|
2020-03-16 12:45:09 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
if( screenshotImage.IsOk() )
|
|
|
|
{
|
|
|
|
saveOrCopyImage( screenshotImage, aFormat, fullFileName );
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
2025-08-02 12:32:31 -07:00
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2024-02-19 16:28:38 +01:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
bool EDA_3D_VIEWER_FRAME::getExportFileName( EDA_3D_VIEWER_EXPORT_FORMAT& aFormat, wxString& fullFileName )
|
|
|
|
{
|
|
|
|
// Create combined wildcard for both formats
|
|
|
|
const wxString wildcard = FILEEXT::JpegFileWildcard() + "|" + FILEEXT::PngFileWildcard();
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
if( !m_defaultSaveScreenshotFileName.IsOk() )
|
|
|
|
m_defaultSaveScreenshotFileName = Parent()->Prj().GetProjectFullName();
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
// Set default extension based on current format
|
|
|
|
const wxString defaultExt = ( aFormat == EDA_3D_VIEWER_EXPORT_FORMAT::JPEG ) ?
|
|
|
|
FILEEXT::JpegFileExtension : FILEEXT::PngFileExtension;
|
|
|
|
m_defaultSaveScreenshotFileName.SetExt( defaultExt );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
wxFileDialog dlg( this, _( "3D Image File Name" ),
|
|
|
|
m_defaultSaveScreenshotFileName.GetPath(),
|
|
|
|
m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
// Set initial filter index based on current format
|
|
|
|
dlg.SetFilterIndex( ( aFormat == EDA_3D_VIEWER_EXPORT_FORMAT::JPEG ) ? 0 : 1 );
|
2024-02-19 16:28:38 +01:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_defaultSaveScreenshotFileName = dlg.GetPath();
|
|
|
|
|
|
|
|
// Determine format based on file extension first
|
|
|
|
wxString fileExt = m_defaultSaveScreenshotFileName.GetExt().Lower();
|
|
|
|
EDA_3D_VIEWER_EXPORT_FORMAT detectedFormat;
|
|
|
|
bool formatDetected = false;
|
|
|
|
|
|
|
|
if( fileExt == wxT("jpg") || fileExt == wxT("jpeg") )
|
|
|
|
{
|
|
|
|
detectedFormat = EDA_3D_VIEWER_EXPORT_FORMAT::JPEG;
|
|
|
|
formatDetected = true;
|
|
|
|
}
|
|
|
|
else if( fileExt == wxT("png") )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2025-08-02 12:32:31 -07:00
|
|
|
detectedFormat = EDA_3D_VIEWER_EXPORT_FORMAT::PNG;
|
|
|
|
formatDetected = true;
|
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
// If format can't be determined from extension, use dropdown selection
|
|
|
|
if( !formatDetected )
|
|
|
|
{
|
|
|
|
int filterIndex = dlg.GetFilterIndex();
|
|
|
|
detectedFormat = ( filterIndex == 0 ) ? EDA_3D_VIEWER_EXPORT_FORMAT::JPEG :
|
|
|
|
EDA_3D_VIEWER_EXPORT_FORMAT::PNG;
|
2021-01-29 19:13:12 +00:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
// Append appropriate extension
|
|
|
|
const wxString ext = ( detectedFormat == EDA_3D_VIEWER_EXPORT_FORMAT::JPEG ) ?
|
|
|
|
FILEEXT::JpegFileExtension : FILEEXT::PngFileExtension;
|
|
|
|
m_defaultSaveScreenshotFileName.SetExt( ext );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the format parameter
|
|
|
|
aFormat = detectedFormat;
|
|
|
|
|
|
|
|
// Check directory permissions using the updated filename
|
|
|
|
wxFileName fn = m_defaultSaveScreenshotFileName;
|
|
|
|
|
|
|
|
if( !fn.IsDirWritable() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Insufficient permissions to save file '%s'." ),
|
|
|
|
m_defaultSaveScreenshotFileName.GetFullPath() );
|
|
|
|
wxMessageBox( msg, _( "Error" ), wxOK | wxICON_ERROR, this );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxImage EDA_3D_VIEWER_FRAME::captureScreenshot( const wxSize& aSize )
|
|
|
|
{
|
|
|
|
TRACK_BALL camera = m_trackBallCamera;
|
|
|
|
camera.SetCurWindowSize( aSize );
|
|
|
|
|
|
|
|
EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" );
|
|
|
|
EDA_3D_VIEWER_SETTINGS* backupCfg = m_boardAdapter.m_Cfg;
|
|
|
|
|
|
|
|
auto configRestorer = std::unique_ptr<void, std::function<void(void*)>>(
|
|
|
|
reinterpret_cast<void*>(1),
|
|
|
|
[&](void*) { m_boardAdapter.m_Cfg = backupCfg; }
|
|
|
|
);
|
|
|
|
|
|
|
|
if( cfg )
|
|
|
|
m_boardAdapter.m_Cfg = cfg;
|
|
|
|
|
|
|
|
if( cfg && cfg->m_Render.engine == RENDER_ENGINE::RAYTRACING )
|
|
|
|
return captureRaytracingScreenshot( m_boardAdapter, camera, aSize );
|
|
|
|
else
|
|
|
|
return captureOpenGLScreenshot( m_boardAdapter, camera, aSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::setupRenderingConfig( BOARD_ADAPTER& aAdapter )
|
|
|
|
{
|
|
|
|
EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" );
|
|
|
|
|
|
|
|
if( cfg )
|
|
|
|
aAdapter.m_Cfg = cfg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxImage EDA_3D_VIEWER_FRAME::captureRaytracingScreenshot( BOARD_ADAPTER& aAdapter, TRACK_BALL& aCamera, const wxSize& aSize )
|
|
|
|
{
|
|
|
|
BOARD_ADAPTER tempadapter;
|
|
|
|
tempadapter.SetBoard( GetBoard() );
|
|
|
|
tempadapter.m_Cfg = aAdapter.m_Cfg;
|
|
|
|
tempadapter.InitSettings( nullptr, nullptr );
|
|
|
|
tempadapter.Set3dCacheManager( aAdapter.Get3dCacheManager() );
|
|
|
|
|
|
|
|
RENDER_3D_RAYTRACE_RAM raytrace( tempadapter, aCamera );
|
|
|
|
raytrace.SetCurWindowSize( aSize );
|
|
|
|
|
|
|
|
while( raytrace.Redraw( false, nullptr, nullptr ) );
|
|
|
|
|
|
|
|
uint8_t* rgbaBuffer = raytrace.GetBuffer();
|
|
|
|
wxSize realSize = raytrace.GetRealBufferSize();
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
if( !rgbaBuffer )
|
|
|
|
return wxImage();
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
return convertRGBAToImage( rgbaBuffer, realSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxImage EDA_3D_VIEWER_FRAME::convertRGBAToImage( uint8_t* aRGBABuffer, const wxSize& aRealSize )
|
|
|
|
{
|
|
|
|
const unsigned int wxh = aRealSize.x * aRealSize.y;
|
|
|
|
|
|
|
|
unsigned char* rgbBuffer = (unsigned char*) malloc( wxh * 3 );
|
|
|
|
unsigned char* alphaBuffer = (unsigned char*) malloc( wxh );
|
|
|
|
|
|
|
|
unsigned char* rgbaPtr = aRGBABuffer;
|
|
|
|
unsigned char* rgbPtr = rgbBuffer;
|
|
|
|
unsigned char* alphaPtr = alphaBuffer;
|
|
|
|
|
|
|
|
for( int y = 0; y < aRealSize.y; y++ )
|
|
|
|
{
|
|
|
|
for( int x = 0; x < aRealSize.x; x++ )
|
|
|
|
{
|
|
|
|
rgbPtr[0] = rgbaPtr[0];
|
|
|
|
rgbPtr[1] = rgbaPtr[1];
|
|
|
|
rgbPtr[2] = rgbaPtr[2];
|
|
|
|
alphaPtr[0] = rgbaPtr[3];
|
|
|
|
|
|
|
|
rgbaPtr += 4;
|
|
|
|
rgbPtr += 3;
|
|
|
|
alphaPtr += 1;
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
}
|
2025-08-02 12:32:31 -07:00
|
|
|
|
|
|
|
wxImage screenshotImage;
|
|
|
|
screenshotImage.Create( aRealSize );
|
|
|
|
screenshotImage.SetData( rgbBuffer );
|
|
|
|
screenshotImage.SetAlpha( alphaBuffer );
|
|
|
|
return screenshotImage.Mirror( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxImage EDA_3D_VIEWER_FRAME::captureOpenGLScreenshot( BOARD_ADAPTER& aAdapter, TRACK_BALL& aCamera, const wxSize& aSize )
|
|
|
|
{
|
|
|
|
EDA_3D_VIEWER_SETTINGS* cfg = aAdapter.m_Cfg;
|
|
|
|
ANTIALIASING_MODE aaMode = cfg ? static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode )
|
|
|
|
: ANTIALIASING_MODE::AA_NONE;
|
|
|
|
|
|
|
|
wxFrame temp( this, wxID_ANY, wxEmptyString, wxDefaultPosition, aSize, wxFRAME_NO_TASKBAR );
|
|
|
|
temp.Hide();
|
|
|
|
BOARD_ADAPTER tempadapter;
|
|
|
|
tempadapter.SetBoard( GetBoard() );
|
|
|
|
tempadapter.m_Cfg = aAdapter.m_Cfg;
|
|
|
|
tempadapter.InitSettings( nullptr, nullptr );
|
|
|
|
tempadapter.Set3dCacheManager( aAdapter.Get3dCacheManager() );
|
|
|
|
|
|
|
|
auto canvas = std::make_unique<EDA_3D_CANVAS>( &temp,
|
|
|
|
OGL_ATT_LIST::GetAttributesList( aaMode, true ),
|
|
|
|
tempadapter, aCamera,
|
|
|
|
aAdapter.Get3dCacheManager() );
|
|
|
|
|
|
|
|
canvas->SetSize( aSize );
|
|
|
|
configureCanvas( canvas, cfg );
|
|
|
|
wxWindowUpdateLocker noUpdates( this );
|
|
|
|
|
|
|
|
// Temporarily disable highlight during screenshot
|
|
|
|
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& renderCfg = aAdapter.m_Cfg->m_Render;
|
|
|
|
bool original_highlight = renderCfg.highlight_on_rollover;
|
|
|
|
bool original_navigator = renderCfg.show_navigator;
|
|
|
|
renderCfg.show_navigator = false;
|
|
|
|
renderCfg.highlight_on_rollover = false;
|
|
|
|
|
|
|
|
std::vector<unsigned char> buffer(aSize.x * aSize.y * 4); // RGBA format
|
|
|
|
canvas->RenderToFrameBuffer( buffer.data(), aSize.x, aSize.y );
|
|
|
|
wxImage result = convertRGBAToImage( buffer.data(), aSize );
|
|
|
|
|
|
|
|
// Restore highlight setting
|
|
|
|
renderCfg.highlight_on_rollover = original_highlight;
|
|
|
|
renderCfg.show_navigator = original_navigator;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::configureCanvas( std::unique_ptr<EDA_3D_CANVAS>& aCanvas, EDA_3D_VIEWER_SETTINGS* aCfg )
|
|
|
|
{
|
|
|
|
if( aCfg )
|
|
|
|
{
|
|
|
|
aCanvas->SetAnimationEnabled( aCfg->m_Camera.animation_enabled );
|
|
|
|
aCanvas->SetMovingSpeedMultiplier( aCfg->m_Camera.moving_speed_multiplier );
|
|
|
|
aCanvas->SetProjectionMode( aCfg->m_Camera.projection_mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
aCanvas->SetVcSettings( EDA_DRAW_PANEL_GAL::GetVcSettings() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::saveOrCopyImage( const wxImage& aScreenshotImage, EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxString& aFullFileName )
|
|
|
|
{
|
|
|
|
if( aFormat == EDA_3D_VIEWER_EXPORT_FORMAT::CLIPBOARD )
|
|
|
|
{
|
|
|
|
copyImageToClipboard( aScreenshotImage );
|
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
else
|
|
|
|
{
|
2025-08-02 12:32:31 -07:00
|
|
|
saveImageToFile( aScreenshotImage, aFormat, aFullFileName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::copyImageToClipboard( const wxImage& aScreenshotImage )
|
|
|
|
{
|
|
|
|
wxBitmap bitmap( aScreenshotImage );
|
|
|
|
wxLogNull doNotLog;
|
|
|
|
|
|
|
|
if( wxTheClipboard->Open() )
|
|
|
|
{
|
|
|
|
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2025-08-02 12:32:31 -07:00
|
|
|
if( !wxTheClipboard->SetData( dobjBmp ) )
|
|
|
|
wxMessageBox( _( "Failed to copy image to clipboard" ) );
|
|
|
|
|
|
|
|
wxTheClipboard->Flush();
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::saveImageToFile( const wxImage& aScreenshotImage, EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxString& aFullFileName )
|
|
|
|
{
|
|
|
|
bool fmt_is_jpeg = ( aFormat == EDA_3D_VIEWER_EXPORT_FORMAT::JPEG );
|
|
|
|
|
|
|
|
if( !aScreenshotImage.SaveFile( aFullFileName, fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Can't save file" ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::RenderEngineChanged()
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::RenderEngineChanged()" ) );
|
2019-01-13 14:04:34 -05:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->RenderEngineChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 18:28:45 +01:00
|
|
|
void EDA_3D_VIEWER_FRAME::loadCommonSettings()
|
2019-04-08 10:49:18 +01:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxCHECK_RET( m_canvas, wxT( "Cannot load settings to null canvas" ) );
|
2019-04-08 10:49:18 +01:00
|
|
|
|
2020-01-12 20:44:19 -05:00
|
|
|
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
2019-04-08 10:49:18 +01:00
|
|
|
|
2020-05-16 20:19:48 -04:00
|
|
|
// TODO(JE) use all control options
|
2021-08-30 21:30:18 +01:00
|
|
|
m_boardAdapter.m_MousewheelPanning = settings->m_Input.scroll_modifier_zoom != 0;
|
2019-04-08 22:45:31 -07:00
|
|
|
}
|
2024-03-03 21:18:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER_FRAME::applySettings( EDA_3D_VIEWER_SETTINGS* cfg )
|
|
|
|
{
|
|
|
|
m_boardAdapter.m_Cfg = cfg;
|
|
|
|
|
|
|
|
m_canvas->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
|
|
|
|
m_canvas->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
|
|
|
|
m_canvas->SetProjectionMode( cfg->m_Camera.projection_mode );
|
|
|
|
|
|
|
|
m_canvas->SetVcSettings( EDA_DRAW_PANEL_GAL::GetVcSettings() );
|
|
|
|
}
|