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>
|
2020-03-16 16:45:09 +00:00
|
|
|
* Copyright (C) 1992-2020 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-03-18 22:48:36 +00:00
|
|
|
#include <wx/colordlg.h>
|
|
|
|
#include <wx/colour.h>
|
2020-03-21 20:19:55 +00:00
|
|
|
#include <wx/filename.h>
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/wupdlock.h>
|
|
|
|
#include <wx/clipbrd.h>
|
2016-07-19 17:35:25 +00:00
|
|
|
#include "eda_3d_viewer.h"
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <3d_viewer_settings.h>
|
|
|
|
#include <3d_viewer_id.h>
|
2019-04-08 09:49:18 +00:00
|
|
|
#include "../common_ogl/cogl_att_list.h"
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <3d_viewer/tools/3d_actions.h>
|
2020-03-24 01:01:23 +00:00
|
|
|
#include <3d_viewer/tools/3d_controller.h>
|
2020-07-27 22:42:23 +00:00
|
|
|
#include <3d_viewer/tools/3d_conditions.h>
|
2019-04-08 09:49:18 +00:00
|
|
|
#include <bitmaps.h>
|
2020-01-22 22:38:30 +00:00
|
|
|
#include <board_stackup_manager/class_board_stackup.h>
|
|
|
|
#include <board_stackup_manager/stackup_predefined_prms.h>
|
|
|
|
#include <class_board.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <layers_id_colors_and_visibility.h>
|
2020-06-19 16:02:46 +00:00
|
|
|
#include <gal/dpi_scaling.h>
|
2019-04-08 09:49:18 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <project.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/common_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-07-27 22:42:23 +00:00
|
|
|
#include <tool/action_manager.h>
|
2019-06-10 22:17:45 +00: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>
|
2020-06-03 23:00:40 +00:00
|
|
|
#include <widgets/infobar.h>
|
2020-01-22 22:38:30 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2018-12-08 13:20:32 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2018-12-08 13:20:32 +00: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 17:35:25 +00:00
|
|
|
*/
|
|
|
|
const wxChar * EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
|
|
|
|
|
|
|
|
EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
|
|
|
|
EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
|
|
|
|
|
2017-12-28 08:29:56 +00:00
|
|
|
EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_MENU_COMMAND_END,
|
2016-07-19 17:35:25 +00:00
|
|
|
EDA_3D_VIEWER::Process_Special_Functions )
|
|
|
|
|
2017-12-28 08:29:56 +00:00
|
|
|
EVT_TOOL( ID_TOOL_SET_VISIBLE_ITEMS, EDA_3D_VIEWER::Install3DViewOptionDialog )
|
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
EVT_MENU( wxID_CLOSE, EDA_3D_VIEWER::Exit3DFrame )
|
2019-01-19 13:02:10 +00:00
|
|
|
EVT_MENU( ID_RENDER_CURRENT_VIEW, EDA_3D_VIEWER::OnRenderEngineSelection )
|
|
|
|
EVT_MENU( ID_DISABLE_RAY_TRACING, EDA_3D_VIEWER::OnDisableRayTracing )
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2020-03-18 22:48:36 +00:00
|
|
|
EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle,
|
|
|
|
long style ) :
|
|
|
|
KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition,
|
|
|
|
wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) ),
|
|
|
|
m_mainToolBar( nullptr ),
|
|
|
|
m_canvas( nullptr ),
|
2020-03-26 14:05:20 +00:00
|
|
|
m_currentCamera( m_trackBallCamera ),
|
2020-03-28 17:52:26 +00:00
|
|
|
m_trackBallCamera( RANGE_SCALE_3D )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-12-08 13:20:32 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::EDA_3D_VIEWER %s", aTitle );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-01-19 13:02:10 +00:00
|
|
|
m_disable_ray_tracing = false;
|
2019-06-18 19:13:08 +00:00
|
|
|
m_AboutTitle = "3D Viewer";
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Give it an icon
|
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
|
|
|
|
SetIcon( icon );
|
|
|
|
|
|
|
|
// Create the status line
|
2020-06-03 23:00:40 +00:00
|
|
|
static const int status_dims[4] = { -1, 130, 130, 170 };
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
|
|
|
|
SetStatusWidths( arrayDim( status_dims ), status_dims );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-04-17 21:33:23 +00:00
|
|
|
m_canvas = new EDA_3D_CANVAS( this, COGL_ATT_LIST::GetAttributesList( m_boardAdapter.AntiAliasingGet() ),
|
2020-03-26 14:05:20 +00:00
|
|
|
aParent->GetBoard(), m_boardAdapter, m_currentCamera,
|
|
|
|
Prj().Get3DCacheManager() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-04-24 23:58:50 +00:00
|
|
|
auto config = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
|
|
|
LoadSettings( config );
|
|
|
|
|
2019-04-08 09:49:18 +00:00
|
|
|
// Some settings need the canvas
|
|
|
|
loadCommonSettings();
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
// Create the manager
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
2020-06-12 10:58:56 +00:00
|
|
|
m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this );
|
2020-03-18 22:48:36 +00:00
|
|
|
|
|
|
|
m_actions = new EDA_3D_ACTIONS();
|
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
|
|
|
m_canvas->SetEventDispatcher( m_toolDispatcher );
|
2019-06-10 22:17:45 +00: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 22:17:45 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
setupUIConditions();
|
|
|
|
|
2020-06-07 10:42:28 +00:00
|
|
|
if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
|
|
|
|
ctrlTool->SetRotationIncrement( config->m_Camera.rotation_increment );
|
|
|
|
|
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" );
|
|
|
|
|
2019-01-19 13:02:10 +00:00
|
|
|
CreateMenuBar();
|
|
|
|
ReCreateMainToolbar();
|
|
|
|
|
2020-06-03 23:00:40 +00:00
|
|
|
// Create the infobar
|
|
|
|
m_infoBar = new WX_INFOBAR( this, &m_auimgr );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2020-06-03 23:00:40 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar,
|
|
|
|
EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
|
|
|
|
m_auimgr.AddPane( m_infoBar,
|
|
|
|
EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
|
|
|
|
m_auimgr.AddPane( m_canvas,
|
|
|
|
EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-06-03 23:00:40 +00:00
|
|
|
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
|
|
|
|
// hidding it.
|
2016-07-19 17:35:25 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
|
2020-06-03 23:00:40 +00:00
|
|
|
// We don't want the infobar displayed right away
|
|
|
|
m_auimgr.GetPane( "InfoBar" ).Hide();
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
if( m_canvas )
|
|
|
|
{
|
|
|
|
m_canvas->SetInfoBar( m_infoBar );
|
|
|
|
m_canvas->SetStatusBar( status_bar );
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00: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.
|
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDA_3D_VIEWER::~EDA_3D_VIEWER()
|
|
|
|
{
|
2020-03-18 22:48:36 +00:00
|
|
|
m_canvas->SetEventDispatcher( nullptr );
|
2018-05-10 10:49:20 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
m_auimgr.UnInit();
|
|
|
|
|
|
|
|
// m_canvas delete will be called by wxWidget manager
|
|
|
|
//delete m_canvas;
|
2019-07-11 23:28:46 +00:00
|
|
|
//m_canvas = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2017-05-13 06:17:06 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
void EDA_3D_VIEWER::setupUIConditions()
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
EDA_3D_CONDITIONS cond( &m_boardAdapter );
|
|
|
|
|
|
|
|
// Helper to define check conditions
|
2020-08-05 22:00:26 +00:00
|
|
|
#define MaterialCheck( x ) ACTION_CONDITIONS().Check( cond.MaterialMode( x ) )
|
|
|
|
#define FlagCheck( x ) ACTION_CONDITIONS().Check( cond.Flag( x ) )
|
|
|
|
#define GridSizeCheck( x ) ACTION_CONDITIONS().Check( cond.GridSize( x ) )
|
2020-07-27 22:42:23 +00:00
|
|
|
|
|
|
|
auto raytracingCondition = [this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_boardAdapter.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY;
|
|
|
|
};
|
|
|
|
|
|
|
|
RegisterUIUpdateHandler( ID_RENDER_CURRENT_VIEW,
|
2020-08-05 22:00:26 +00:00
|
|
|
ACTION_CONDITIONS().Check( raytracingCondition ) );
|
2020-07-27 22:42:23 +00:00
|
|
|
|
2020-07-27 23:16:21 +00:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::materialNormal,
|
2020-07-27 22:42:23 +00:00
|
|
|
MaterialCheck( MATERIAL_MODE::NORMAL ) );
|
2020-07-27 23:16:21 +00:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::materialDiffuse,
|
2020-07-27 22:42:23 +00:00
|
|
|
MaterialCheck( MATERIAL_MODE::DIFFUSE_ONLY ) );
|
2020-07-27 23:16:21 +00:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::materialCAD,
|
2020-07-27 22:42:23 +00:00
|
|
|
MaterialCheck( MATERIAL_MODE::CAD_MODE ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::renderShadows,
|
|
|
|
FlagCheck( FL_RENDER_RAYTRACING_SHADOWS ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::proceduralTextures,
|
|
|
|
FlagCheck( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::addFloor,
|
|
|
|
FlagCheck( FL_RENDER_RAYTRACING_BACKFLOOR ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showRefractions,
|
|
|
|
FlagCheck( FL_RENDER_RAYTRACING_REFRACTIONS ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showReflections,
|
|
|
|
FlagCheck( FL_RENDER_RAYTRACING_REFLECTIONS ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::antiAliasing,
|
|
|
|
FlagCheck( FL_RENDER_RAYTRACING_ANTI_ALIASING ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::postProcessing,
|
|
|
|
FlagCheck( FL_RENDER_RAYTRACING_POST_PROCESSING ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showBoundingBoxes,
|
|
|
|
FlagCheck( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) );
|
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::showAxis,
|
|
|
|
FlagCheck( FL_AXIS ) );
|
|
|
|
|
|
|
|
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 ) );
|
|
|
|
|
|
|
|
|
|
|
|
auto orthoCondition =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_currentCamera.GetProjection() == PROJECTION_TYPE::ORTHO;
|
|
|
|
};
|
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( orthoCondition ) );
|
2020-07-27 22:42:23 +00:00
|
|
|
|
|
|
|
#undef MaterialCheck
|
|
|
|
#undef FlagCheck
|
|
|
|
#undef GridSizeCheck
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
void EDA_3D_VIEWER::ReloadRequest()
|
|
|
|
{
|
|
|
|
// This will schedule a request to load later
|
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
|
2017-05-13 06:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
|
|
|
|
{
|
|
|
|
ReloadRequest();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2017-05-13 06:17:06 +00:00
|
|
|
// After the ReloadRequest call, the refresh often takes a bit of time,
|
|
|
|
// and it is made here only on request.
|
|
|
|
if( aForceImmediateRedraw )
|
|
|
|
m_canvas->Refresh();
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
|
|
|
|
{
|
2018-12-08 13:20:32 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Exit3DFrame" );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
Close( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
|
|
|
|
{
|
2018-12-08 13:20:32 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnCloseWindow" );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->Close();
|
|
|
|
|
|
|
|
// m_canvas delete will be called by wxWidget manager
|
|
|
|
//delete m_canvas;
|
2019-07-11 23:28:46 +00:00
|
|
|
//m_canvas = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
|
|
|
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
Destroy();
|
|
|
|
event.Skip( true );
|
|
|
|
}
|
|
|
|
|
2020-03-16 16:45:09 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
bool isChecked = event.IsChecked();
|
|
|
|
|
2020-03-24 01:01:23 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Process_Special_Functions id %d isChecked %d",
|
2016-07-19 17:35:25 +00:00
|
|
|
id, isChecked );
|
|
|
|
|
|
|
|
if( m_canvas == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_RELOAD3D_BOARD:
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2016-07-19 17:35:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TOOL_SCREENCOPY_TOCLIBBOARD:
|
|
|
|
case ID_MENU_SCREENCOPY_PNG:
|
|
|
|
case ID_MENU_SCREENCOPY_JPEG:
|
|
|
|
takeScreenshot( event );
|
|
|
|
return;
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
case ID_MENU3D_BGCOLOR_BOTTOM:
|
2020-03-26 14:05:20 +00:00
|
|
|
if( Set3DColorFromUser( m_boardAdapter.m_BgColorBot, _( "Background Color, Bottom" ),
|
2018-12-08 13:20:32 +00:00
|
|
|
nullptr ) )
|
2016-10-02 08:11:00 +00:00
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
2016-10-02 08:11:00 +00:00
|
|
|
m_canvas->Request_refresh();
|
|
|
|
else
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2016-10-02 08:11:00 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
return;
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
case ID_MENU3D_BGCOLOR_TOP:
|
2020-03-26 14:05:20 +00:00
|
|
|
if( Set3DColorFromUser( m_boardAdapter.m_BgColorTop, _( "Background Color, Top" ), nullptr ) )
|
2016-10-02 08:11:00 +00:00
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
2016-10-02 08:11:00 +00:00
|
|
|
m_canvas->Request_refresh();
|
|
|
|
else
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2016-10-02 08:11:00 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
return;
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
case ID_MENU3D_SILKSCREEN_COLOR:
|
2016-07-19 17:35:25 +00:00
|
|
|
Set3DSilkScreenColorFromUser();
|
|
|
|
return;
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
case ID_MENU3D_SOLDERMASK_COLOR:
|
2016-07-19 17:35:25 +00:00
|
|
|
Set3DSolderMaskColorFromUser();
|
|
|
|
return;
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
case ID_MENU3D_SOLDERPASTE_COLOR:
|
2016-07-19 17:35:25 +00:00
|
|
|
Set3DSolderPasteColorFromUser();
|
|
|
|
return;
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
case ID_MENU3D_COPPER_COLOR:
|
2016-07-19 17:35:25 +00:00
|
|
|
Set3DCopperColorFromUser();
|
|
|
|
break;
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
case ID_MENU3D_PCB_BODY_COLOR:
|
2016-07-19 17:35:25 +00:00
|
|
|
Set3DBoardBodyColorFromUser();
|
|
|
|
break;
|
|
|
|
|
2020-01-22 22:38:30 +00:00
|
|
|
case ID_MENU3D_STACKUP_COLORS:
|
|
|
|
SynchroniseColoursWithBoard();
|
|
|
|
NewDisplay( true );
|
|
|
|
break;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
case ID_MENU3D_RESET_DEFAULTS:
|
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
|
|
|
cfg->ResetToDefaults();
|
|
|
|
LoadSettings( cfg );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-04-06 16:00:58 +00:00
|
|
|
// Tell canvas that we (may have) changed the render engine
|
2016-07-19 17:35:25 +00:00
|
|
|
RenderEngineChanged();
|
|
|
|
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2019-01-13 19:04:34 +00:00
|
|
|
wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
|
2016-07-19 17:35:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
|
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
const RENDER_ENGINE old_engine = m_boardAdapter.RenderEngineGet();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-12-30 13:01:06 +00:00
|
|
|
if( old_engine == RENDER_ENGINE::OPENGL_LEGACY )
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::RAYTRACING );
|
2019-01-19 13:02:10 +00:00
|
|
|
else
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-01-19 13:02:10 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
|
2020-03-26 14:05:20 +00:00
|
|
|
( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
|
|
|
|
"OpenGL Legacy" );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( old_engine != m_boardAdapter.RenderEngineGet() )
|
2016-07-19 17:35:25 +00:00
|
|
|
RenderEngineChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-19 13:02:10 +00:00
|
|
|
void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ );
|
|
|
|
|
|
|
|
m_disable_ray_tracing = true;
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY );
|
2019-01-19 13:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
void EDA_3D_VIEWER::OnActivate( wxActivateEvent &event )
|
|
|
|
{
|
2018-12-08 13:20:32 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnActivate" );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( m_canvas )
|
|
|
|
{
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip(); // required under wxMAC
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
|
|
|
|
{
|
|
|
|
// Activates again the focus of the canvas so it will catch mouse and key events
|
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->SetFocus();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
EDA_3D_VIEWER_SETTINGS* cfg = dynamic_cast<EDA_3D_VIEWER_SETTINGS*>( aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
wxASSERT( cfg );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-08-15 08:41:34 +00:00
|
|
|
auto set_color =
|
|
|
|
[] ( const COLOR4D& aColor, SFVEC3D& aTarget )
|
|
|
|
{
|
|
|
|
aTarget.r = aColor.r;
|
|
|
|
aTarget.g = aColor.g;
|
|
|
|
aTarget.b = aColor.b;
|
|
|
|
};
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
set_color( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), m_boardAdapter.m_BgColorBot );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_boardAdapter.m_BgColorTop );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_BOARD ), m_boardAdapter.m_BoardBodyColor );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_COPPER ), m_boardAdapter.m_CopperColor );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ), m_boardAdapter.m_SilkScreenColorBot );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ), m_boardAdapter.m_SilkScreenColorTop );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_boardAdapter.m_SolderMaskColorBot );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_boardAdapter.m_SolderMaskColorTop );
|
|
|
|
set_color( colors->GetColor( LAYER_3D_SOLDERPASTE ), m_boardAdapter.m_SolderPasteColor );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
if( cfg )
|
|
|
|
{
|
2020-08-15 08:41:34 +00:00
|
|
|
m_boardAdapter.m_raytrace_lightColorCamera = m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorCamera );
|
|
|
|
m_boardAdapter.m_raytrace_lightColorTop = m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorTop );
|
|
|
|
m_boardAdapter.m_raytrace_lightColorBottom = m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorBottom );
|
|
|
|
|
|
|
|
m_boardAdapter.m_raytrace_lightColor.resize( cfg->m_Render.raytrace_lightColor.size() );
|
|
|
|
m_boardAdapter.m_raytrace_lightSphericalCoords.resize( cfg->m_Render.raytrace_lightColor.size() );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
|
|
|
|
{
|
|
|
|
m_boardAdapter.m_raytrace_lightColor[i] = m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColor[i] );
|
|
|
|
|
|
|
|
SFVEC2F sphericalCoord = SFVEC2F( ( cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
|
|
|
|
cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
|
|
|
|
|
|
|
|
sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
|
|
|
|
sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
|
|
|
|
|
|
|
|
m_boardAdapter.m_raytrace_lightSphericalCoords[i] = sphericalCoord;
|
|
|
|
}
|
|
|
|
|
2020-04-17 21:33:23 +00:00
|
|
|
#define TRANSFER_SETTING( flag, field ) m_boardAdapter.SetFlag( flag, cfg->m_Render.field )
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2020-04-17 21:33:23 +00:00
|
|
|
TRANSFER_SETTING( FL_USE_REALISTIC_MODE, realistic );
|
|
|
|
TRANSFER_SETTING( FL_SUBTRACT_MASK_FROM_SILK, subtract_mask_from_silk );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
|
|
|
// OpenGL options
|
2020-04-17 21:33:23 +00:00
|
|
|
TRANSFER_SETTING( FL_RENDER_OPENGL_COPPER_THICKNESS, opengl_copper_thickness );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, opengl_show_model_bbox );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, opengl_AA_disableOnMove );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE, opengl_thickness_disableOnMove );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, opengl_vias_disableOnMove );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, opengl_holes_disableOnMove );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
|
|
|
// Raytracing options
|
2020-04-17 21:33:23 +00:00
|
|
|
TRANSFER_SETTING( FL_RENDER_RAYTRACING_SHADOWS, raytrace_shadows );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_RAYTRACING_BACKFLOOR, raytrace_backfloor );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFRACTIONS, raytrace_refractions );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFLECTIONS, raytrace_reflections );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_RAYTRACING_POST_PROCESSING, raytrace_post_processing );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_RAYTRACING_ANTI_ALIASING, raytrace_anti_aliasing );
|
|
|
|
TRANSFER_SETTING( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, raytrace_procedural_textures );
|
|
|
|
|
|
|
|
TRANSFER_SETTING( FL_AXIS, show_axis );
|
|
|
|
TRANSFER_SETTING( FL_MODULE_ATTRIBUTES_NORMAL, show_footprints_normal );
|
|
|
|
TRANSFER_SETTING( FL_MODULE_ATTRIBUTES_NORMAL_INSERT, show_footprints_insert );
|
|
|
|
TRANSFER_SETTING( FL_MODULE_ATTRIBUTES_VIRTUAL, show_footprints_virtual );
|
|
|
|
TRANSFER_SETTING( FL_ZONE, show_zones );
|
|
|
|
TRANSFER_SETTING( FL_ADHESIVE, show_adhesive );
|
|
|
|
TRANSFER_SETTING( FL_SILKSCREEN, show_silkscreen );
|
|
|
|
TRANSFER_SETTING( FL_SOLDERMASK, show_soldermask );
|
|
|
|
TRANSFER_SETTING( FL_SOLDERPASTE, show_solderpaste );
|
|
|
|
TRANSFER_SETTING( FL_COMMENTS, show_comments );
|
|
|
|
TRANSFER_SETTING( FL_ECO, show_eco );
|
|
|
|
TRANSFER_SETTING( FL_SHOW_BOARD_BODY, show_board_body );
|
2020-07-16 22:36:06 +00:00
|
|
|
TRANSFER_SETTING( FL_CLIP_SILK_ON_VIA_ANNULUS, clip_silk_on_via_annulus );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
|
2020-04-17 21:33:23 +00:00
|
|
|
m_boardAdapter.AntiAliasingSet( static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2020-05-16 11:17:49 +00:00
|
|
|
// When opening the 3D viewer, we use the opengl mode, not the ray tracing engine
|
|
|
|
// because the ray tracing is very time consumming, and can be seen as not working
|
|
|
|
// (freeze window) with large boards.
|
|
|
|
#if 0
|
2020-03-25 13:13:03 +00:00
|
|
|
RENDER_ENGINE engine = static_cast<RENDER_ENGINE>( cfg->m_Render.engine );
|
|
|
|
wxLogTrace( m_logTrace, engine == RENDER_ENGINE::RAYTRACING ?
|
|
|
|
"EDA_3D_VIEWER::LoadSettings render setting Ray Trace" :
|
|
|
|
"EDA_3D_VIEWER::LoadSettings render setting OpenGL" );
|
2020-05-16 11:17:49 +00:00
|
|
|
#else
|
|
|
|
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY );
|
|
|
|
#endif
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.MaterialModeSet( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2020-04-24 23:58:50 +00:00
|
|
|
m_canvas->AnimationEnabledSet( cfg->m_Camera.animation_enabled );
|
|
|
|
m_canvas->MovingSpeedMultiplierSet( cfg->m_Camera.moving_speed_multiplier );
|
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
#undef TRANSFER_SETTING
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
EDA_BASE_FRAME::SaveSettings( cfg );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
2020-01-22 22:38:30 +00:00
|
|
|
|
2020-08-15 08:41:34 +00:00
|
|
|
auto save_color =
|
|
|
|
[colors] ( SFVEC3D& aSource, LAYER_3D_ID aTarget )
|
|
|
|
{
|
|
|
|
colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 ) );
|
|
|
|
};
|
2020-01-22 22:38:30 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
save_color( m_boardAdapter.m_BgColorBot, LAYER_3D_BACKGROUND_BOTTOM );
|
|
|
|
save_color( m_boardAdapter.m_BgColorTop, LAYER_3D_BACKGROUND_TOP );
|
|
|
|
save_color( m_boardAdapter.m_BoardBodyColor, LAYER_3D_BOARD );
|
|
|
|
save_color( m_boardAdapter.m_CopperColor, LAYER_3D_COPPER );
|
|
|
|
save_color( m_boardAdapter.m_SilkScreenColorBot, LAYER_3D_SILKSCREEN_BOTTOM );
|
|
|
|
save_color( m_boardAdapter.m_SilkScreenColorTop, LAYER_3D_SILKSCREEN_TOP );
|
|
|
|
save_color( m_boardAdapter.m_SolderMaskColorTop, LAYER_3D_SOLDERMASK );
|
|
|
|
save_color( m_boardAdapter.m_SolderPasteColor, LAYER_3D_SOLDERPASTE );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
wxLogTrace( m_logTrace, m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ?
|
2020-03-25 13:13:03 +00:00
|
|
|
"EDA_3D_VIEWER::SaveSettings render setting Ray Trace" :
|
|
|
|
"EDA_3D_VIEWER::SaveSettings render setting OpenGL" );
|
|
|
|
|
|
|
|
if( cfg )
|
|
|
|
{
|
2020-08-15 08:41:34 +00:00
|
|
|
|
|
|
|
auto save_color =
|
|
|
|
[] ( const SFVEC3F& aSource, COLOR4D& aTarget )
|
|
|
|
{
|
|
|
|
aTarget = COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
save_color( m_boardAdapter.m_raytrace_lightColorCamera, cfg->m_Render.raytrace_lightColorCamera );
|
|
|
|
|
|
|
|
save_color( m_boardAdapter.m_raytrace_lightColorTop, cfg->m_Render.raytrace_lightColorTop );
|
|
|
|
save_color( m_boardAdapter.m_raytrace_lightColorBottom, cfg->m_Render.raytrace_lightColorBottom );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
|
|
|
|
{
|
|
|
|
save_color( m_boardAdapter.m_raytrace_lightColor[i], cfg->m_Render.raytrace_lightColor[i] );
|
|
|
|
|
|
|
|
cfg->m_Render.raytrace_lightElevation[i] = (int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].x * 180.0f - 90.0f );
|
|
|
|
cfg->m_Render.raytrace_lightAzimuth[i] = (int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].y * 180.0f );
|
|
|
|
}
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
#define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2020-04-17 21:33:23 +00:00
|
|
|
cfg->m_Render.engine = static_cast<int>( m_boardAdapter.RenderEngineGet() );
|
|
|
|
cfg->m_Render.grid_type = static_cast<int>( m_boardAdapter.GridGet() );
|
|
|
|
cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.MaterialModeGet() );
|
|
|
|
cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.AntiAliasingGet() );
|
|
|
|
|
2020-04-24 23:58:50 +00:00
|
|
|
cfg->m_Camera.animation_enabled = m_canvas->AnimationEnabledGet();
|
|
|
|
cfg->m_Camera.moving_speed_multiplier = m_canvas->MovingSpeedMultiplierGet();
|
|
|
|
|
2020-06-07 10:42:28 +00:00
|
|
|
if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
|
|
|
|
cfg->m_Camera.rotation_increment = ctrlTool->GetRotationIncrement();
|
|
|
|
|
2020-04-17 21:33:23 +00:00
|
|
|
TRANSFER_SETTING( opengl_AA_disableOnMove, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE );
|
|
|
|
TRANSFER_SETTING( opengl_copper_thickness, FL_RENDER_OPENGL_COPPER_THICKNESS );
|
|
|
|
TRANSFER_SETTING( opengl_show_model_bbox, FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
|
|
|
|
TRANSFER_SETTING( opengl_thickness_disableOnMove, FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE );
|
|
|
|
TRANSFER_SETTING( opengl_vias_disableOnMove, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE );
|
|
|
|
TRANSFER_SETTING( opengl_holes_disableOnMove, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
|
|
|
TRANSFER_SETTING( raytrace_anti_aliasing, FL_RENDER_RAYTRACING_ANTI_ALIASING );
|
|
|
|
TRANSFER_SETTING( raytrace_backfloor, FL_RENDER_RAYTRACING_BACKFLOOR );
|
|
|
|
TRANSFER_SETTING( raytrace_post_processing, FL_RENDER_RAYTRACING_POST_PROCESSING );
|
|
|
|
TRANSFER_SETTING( raytrace_procedural_textures, FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES );
|
|
|
|
TRANSFER_SETTING( raytrace_reflections, FL_RENDER_RAYTRACING_REFLECTIONS );
|
|
|
|
TRANSFER_SETTING( raytrace_refractions, FL_RENDER_RAYTRACING_REFRACTIONS );
|
|
|
|
TRANSFER_SETTING( raytrace_shadows, FL_RENDER_RAYTRACING_SHADOWS );
|
|
|
|
|
2020-07-16 22:36:06 +00:00
|
|
|
TRANSFER_SETTING( realistic, FL_USE_REALISTIC_MODE );
|
|
|
|
TRANSFER_SETTING( show_adhesive, FL_ADHESIVE );
|
|
|
|
TRANSFER_SETTING( show_axis, FL_AXIS );
|
|
|
|
TRANSFER_SETTING( show_board_body, FL_SHOW_BOARD_BODY );
|
|
|
|
TRANSFER_SETTING( clip_silk_on_via_annulus, FL_CLIP_SILK_ON_VIA_ANNULUS );
|
|
|
|
TRANSFER_SETTING( show_comments, FL_COMMENTS );
|
|
|
|
TRANSFER_SETTING( show_eco, FL_ECO );
|
|
|
|
TRANSFER_SETTING( show_footprints_insert, FL_MODULE_ATTRIBUTES_NORMAL_INSERT );
|
|
|
|
TRANSFER_SETTING( show_footprints_normal, FL_MODULE_ATTRIBUTES_NORMAL );
|
|
|
|
TRANSFER_SETTING( show_footprints_virtual, FL_MODULE_ATTRIBUTES_VIRTUAL );
|
|
|
|
TRANSFER_SETTING( show_silkscreen, FL_SILKSCREEN );
|
|
|
|
TRANSFER_SETTING( show_soldermask, FL_SOLDERMASK );
|
|
|
|
TRANSFER_SETTING( show_solderpaste, FL_SOLDERPASTE );
|
|
|
|
TRANSFER_SETTING( show_zones, FL_ZONE );
|
|
|
|
TRANSFER_SETTING( subtract_mask_from_silk, FL_SUBTRACT_MASK_FROM_SILK );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2020-04-17 21:33:23 +00:00
|
|
|
#undef TRANSFER_SETTING
|
2020-03-25 13:13:03 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
void EDA_3D_VIEWER::SynchroniseColoursWithBoard()
|
2020-01-22 22:38:30 +00:00
|
|
|
{
|
|
|
|
BOARD* brd = GetBoard();
|
|
|
|
const FAB_LAYER_COLOR* stdColors = GetColorStandardList();
|
|
|
|
wxColour color;
|
|
|
|
if( brd )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP stckp = brd->GetDesignSettings().GetStackupDescriptor();
|
|
|
|
|
|
|
|
for( BOARD_STACKUP_ITEM* stckpItem : stckp.GetList() )
|
|
|
|
{
|
|
|
|
wxString colorName = stckpItem->GetColor();
|
|
|
|
|
|
|
|
if( colorName.StartsWith( "#" ) ) // This is a user defined color.
|
|
|
|
{
|
|
|
|
color.Set( colorName );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( int i = 0; i < GetColorStandardListCount(); i++ )
|
|
|
|
{
|
|
|
|
if( stdColors[i].m_ColorName == colorName )
|
|
|
|
{
|
|
|
|
color = stdColors[i].m_Color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( color.IsOk() )
|
|
|
|
{
|
|
|
|
switch( stckpItem->GetBrdLayerId() )
|
|
|
|
{
|
|
|
|
case F_SilkS:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.m_SilkScreenColorTop.r = color.Red() / 255.0;
|
|
|
|
m_boardAdapter.m_SilkScreenColorTop.g = color.Green() / 255.0;
|
|
|
|
m_boardAdapter.m_SilkScreenColorTop.b = color.Blue() / 255.0;
|
2020-01-22 22:38:30 +00:00
|
|
|
break;
|
|
|
|
case B_SilkS:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.m_SilkScreenColorBot.r = color.Red() / 255.0;
|
|
|
|
m_boardAdapter.m_SilkScreenColorBot.g = color.Green() / 255.0;
|
|
|
|
m_boardAdapter.m_SilkScreenColorBot.b = color.Blue() / 255.0;
|
2020-01-22 22:38:30 +00:00
|
|
|
break;
|
|
|
|
case F_Mask:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0;
|
|
|
|
m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0;
|
|
|
|
m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0;
|
2020-01-22 22:38:30 +00:00
|
|
|
break;
|
|
|
|
case B_Mask:
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0;
|
|
|
|
m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0;
|
|
|
|
m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0;
|
2020-01-22 22:38:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-16 16:45:09 +00:00
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void EDA_3D_VIEWER::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2019-04-08 09:49:18 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CommonSettingsChanged" );
|
|
|
|
|
|
|
|
// Regen menu bars, etc
|
2020-07-17 20:04:14 +00:00
|
|
|
EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2019-04-08 09:49:18 +00:00
|
|
|
|
2019-04-08 12:19:17 +00:00
|
|
|
// There is no base class that handles toolbars for this frame
|
|
|
|
ReCreateMainToolbar();
|
|
|
|
|
2019-04-08 09:49:18 +00:00
|
|
|
loadCommonSettings();
|
|
|
|
|
|
|
|
NewDisplay( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxString fullFileName;
|
|
|
|
bool fmt_is_jpeg = false;
|
|
|
|
|
|
|
|
if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
|
|
|
|
fmt_is_jpeg = true;
|
|
|
|
|
|
|
|
if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
|
|
|
|
{
|
|
|
|
// Remember path between saves during this session only.
|
2018-12-08 13:20:32 +00:00
|
|
|
const wxString wildcard = fmt_is_jpeg ? JpegFileWildcard() : PngFileWildcard();
|
|
|
|
const wxString ext = fmt_is_jpeg ? JpegFileExtension : PngFileExtension;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// First time path is set to the project path.
|
2018-12-08 13:20:32 +00:00
|
|
|
if( !m_defaultSaveScreenshotFileName.IsOk() )
|
|
|
|
m_defaultSaveScreenshotFileName = Parent()->Prj().GetProjectFullName();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-12-08 13:20:32 +00:00
|
|
|
m_defaultSaveScreenshotFileName.SetExt( ext );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-12-08 13:20:32 +00:00
|
|
|
wxFileDialog dlg( this, _( "3D Image File Name" ),
|
|
|
|
m_defaultSaveScreenshotFileName.GetPath(),
|
|
|
|
m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-12-08 13:20:32 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2016-07-19 17:35:25 +00:00
|
|
|
return;
|
|
|
|
|
2018-12-08 13:20:32 +00:00
|
|
|
m_defaultSaveScreenshotFileName = dlg.GetPath();
|
|
|
|
|
|
|
|
if( m_defaultSaveScreenshotFileName.GetExt().IsEmpty() )
|
|
|
|
m_defaultSaveScreenshotFileName.SetExt( ext );
|
|
|
|
|
|
|
|
fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-21 20:19:55 +00:00
|
|
|
wxFileName fn = fullFileName;
|
|
|
|
|
|
|
|
if( !fn.IsDirWritable() )
|
2020-03-16 16:45:09 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg.Printf( _( "Insufficient permissions required to save file\n%s" ), fullFileName );
|
|
|
|
wxMessageBox( msg, _( "Error" ), wxOK | wxICON_ERROR, this );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Be sure the screen area destroyed by the file dialog is redrawn
|
|
|
|
// before making a screen copy.
|
|
|
|
// Without this call, under Linux the screen refresh is made to late.
|
|
|
|
wxYield();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Be sure we have the latest 3D view (remember 3D view is buffered)
|
2019-04-09 05:45:31 +00:00
|
|
|
m_canvas->Request_refresh( true );
|
2016-07-19 17:35:25 +00:00
|
|
|
wxYield();
|
|
|
|
|
|
|
|
// Build image from the 3D buffer
|
|
|
|
wxWindowUpdateLocker noUpdates( this );
|
|
|
|
|
|
|
|
wxImage screenshotImage;
|
|
|
|
|
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->GetScreenshot( screenshotImage );
|
|
|
|
|
|
|
|
if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
|
|
|
|
{
|
|
|
|
wxBitmap bitmap( screenshotImage );
|
|
|
|
|
|
|
|
if( wxTheClipboard->Open() )
|
|
|
|
{
|
|
|
|
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
|
|
|
|
|
|
|
|
if( !wxTheClipboard->SetData( dobjBmp ) )
|
|
|
|
wxMessageBox( _( "Failed to copy image to clipboard" ) );
|
|
|
|
|
|
|
|
wxTheClipboard->Flush(); /* the data in clipboard will stay
|
|
|
|
* available after the application exits */
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !screenshotImage.SaveFile( fullFileName,
|
|
|
|
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
|
|
|
|
wxMessageBox( _( "Can't save file" ) );
|
|
|
|
|
|
|
|
screenshotImage.Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER::RenderEngineChanged()
|
|
|
|
{
|
2019-01-13 19:04:34 +00:00
|
|
|
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->RenderEngineChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
|
2018-10-12 19:02:11 +00:00
|
|
|
CUSTOM_COLORS_LIST* aPredefinedColors )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-10-12 19:02:11 +00:00
|
|
|
KIGFX::COLOR4D newcolor;
|
|
|
|
KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, 1.0 );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-10-12 19:02:11 +00:00
|
|
|
DIALOG_COLOR_PICKER picker( this, oldcolor, false, aPredefinedColors );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-10-12 19:02:11 +00:00
|
|
|
if( picker.ShowModal() != wxID_OK )
|
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-10-12 19:02:11 +00:00
|
|
|
newcolor = picker.GetColor();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-10-12 19:02:11 +00:00
|
|
|
if( newcolor == oldcolor )
|
2016-07-19 17:35:25 +00:00
|
|
|
return false;
|
|
|
|
|
2018-10-12 19:02:11 +00:00
|
|
|
aColor.r = newcolor.r;
|
|
|
|
aColor.g = newcolor.g;
|
|
|
|
aColor.b = newcolor.b;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_3D_VIEWER::Set3DSilkScreenColorFromUser()
|
|
|
|
{
|
2019-06-10 22:17:45 +00:00
|
|
|
CUSTOM_COLORS_LIST colors;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( Set3DColorFromUser( m_boardAdapter.m_SilkScreenColorTop, _( "Silkscreen Color" ), &colors ) )
|
2019-06-10 22:17:45 +00:00
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.m_SilkScreenColorBot = m_boardAdapter.m_SilkScreenColorTop;
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2019-06-10 22:17:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_3D_VIEWER::Set3DSolderMaskColorFromUser()
|
|
|
|
{
|
2019-06-10 22:17:45 +00:00
|
|
|
CUSTOM_COLORS_LIST colors;
|
|
|
|
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, "Green" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, "Light Green" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0, "Saturated Green" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, "Red" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0, "Red Light Orange" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, "Red 2" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, "Blue" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, "Light blue 1" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, "Light blue 2" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0, "Green blue (dark)" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, "Black" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, "White" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, "Purple" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, "Purple Dark" ) );
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( Set3DColorFromUser( m_boardAdapter.m_SolderMaskColorTop, _( "Solder Mask Color" ), &colors ) )
|
2019-06-10 22:17:45 +00:00
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
m_boardAdapter.m_SolderMaskColorBot = m_boardAdapter.m_SolderMaskColorTop;
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2019-06-10 22:17:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_3D_VIEWER::Set3DCopperColorFromUser()
|
|
|
|
{
|
2019-06-10 22:17:45 +00:00
|
|
|
CUSTOM_COLORS_LIST colors;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 184/255.0, 115/255.0, 50/255.0, "Copper" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 178/255.0, 156/255.0, 0.0, "Gold" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( Set3DColorFromUser( m_boardAdapter.m_CopperColor, _( "Copper Color" ), &colors ) )
|
2019-06-10 22:17:45 +00:00
|
|
|
{
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2019-06-10 22:17:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_3D_VIEWER::Set3DBoardBodyColorFromUser()
|
|
|
|
{
|
2019-06-10 22:17:45 +00:00
|
|
|
CUSTOM_COLORS_LIST colors;
|
|
|
|
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0, "FR4 natural, dark" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, "FR4 natural" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, "brown/red" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 1" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, "brown 2" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 3" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, "green 1" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, "green 2" ) );
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( Set3DColorFromUser( m_boardAdapter.m_BoardBodyColor, _( "Board Body Color" ), &colors ) )
|
2019-06-10 22:17:45 +00:00
|
|
|
{
|
2018-04-06 16:00:58 +00:00
|
|
|
NewDisplay( true );
|
2019-06-10 22:17:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_3D_VIEWER::Set3DSolderPasteColorFromUser()
|
|
|
|
{
|
2019-06-10 22:17:45 +00:00
|
|
|
CUSTOM_COLORS_LIST colors;
|
2019-01-13 19:04:34 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 128/255.0, 128/255.0, 128/255.0, "grey" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
|
|
|
|
colors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) );
|
2019-01-13 19:04:34 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
if( Set3DColorFromUser( m_boardAdapter.m_SolderPasteColor, _( "Solder Paste Color" ), &colors ) )
|
2019-01-13 19:04:34 +00:00
|
|
|
{
|
2019-06-10 22:17:45 +00:00
|
|
|
NewDisplay( true );
|
|
|
|
return true;
|
2019-01-13 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
return false;
|
2019-01-13 19:04:34 +00:00
|
|
|
}
|
2019-04-08 09:49:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
void EDA_3D_VIEWER::loadCommonSettings()
|
|
|
|
{
|
|
|
|
wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
2019-04-08 09:49:18 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
const DPI_SCALING dpi{ settings, this };
|
|
|
|
m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
|
2020-05-17 00:19:48 +00:00
|
|
|
// TODO(JE) use all control options
|
|
|
|
m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.scroll_modifier_zoom != 0 );
|
2019-04-09 05:45:31 +00:00
|
|
|
}
|