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>
|
|
|
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-12-08 13:20:32 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-08-11 17:40:13 +00:00
|
|
|
* Copyright (C) 2023 CERN
|
|
|
|
* Copyright (C) 1992-2023 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2023-04-19 11:51:26 +00:00
|
|
|
* @file eda_3d_viewer_frame.h
|
2016-07-19 17:35:25 +00:00
|
|
|
* @brief Declaration of the eda_3d_viewer class
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EDA_3D_VIEWER_H
|
|
|
|
#define EDA_3D_VIEWER_H
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
#include "3d_canvas/board_adapter.h"
|
|
|
|
#include "3d_canvas/eda_3d_canvas.h"
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "3d_rendering/track_ball.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <kiway_player.h>
|
|
|
|
#include <wx/colourdata.h>
|
2020-12-17 16:43:46 +00:00
|
|
|
#include <dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
|
|
|
|
|
2021-06-24 08:47:28 +00:00
|
|
|
// Forward declarations
|
|
|
|
class NL_3D_VIEWER_PLUGIN;
|
2023-08-11 17:40:13 +00:00
|
|
|
class APPEARANCE_CONTROLS_3D;
|
|
|
|
|
2020-02-03 22:09:14 +00:00
|
|
|
|
|
|
|
enum EDA_3D_VIEWER_STATUSBAR
|
|
|
|
{
|
2021-02-15 21:53:49 +00:00
|
|
|
ACTIVITY = 0,
|
|
|
|
HOVERED_ITEM,
|
2020-02-03 22:09:14 +00:00
|
|
|
X_POS,
|
2021-02-15 21:53:49 +00:00
|
|
|
Y_POS,
|
2023-09-01 17:51:50 +00:00
|
|
|
ZOOM_LEVEL,
|
2020-02-03 22:09:14 +00:00
|
|
|
};
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-06-19 17:28:45 +00:00
|
|
|
class EDA_3D_VIEWER_FRAME : public EDA_3D_BOARD_HOLDER, public KIWAY_PLAYER
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-12-16 22:10:42 +00:00
|
|
|
public:
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle,
|
|
|
|
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
~EDA_3D_VIEWER_FRAME();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
|
|
|
|
|
|
|
|
BOARD* GetBoard() { return Parent()->GetBoard(); }
|
|
|
|
|
2020-03-24 01:01:23 +00:00
|
|
|
wxWindow* GetToolCanvas() const override { return m_canvas; }
|
2020-03-18 22:48:36 +00:00
|
|
|
|
2017-05-13 06:17:06 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Request reloading the 3D view.
|
|
|
|
*
|
|
|
|
* However the request will be executed only when the 3D canvas is refreshed. It allows
|
|
|
|
* one to prepare changes and request for 3D rebuild only when all changes are committed.
|
|
|
|
* This is made because the 3D rebuild can take a long time, and this rebuild cannot
|
|
|
|
* always made after each change, for calculation time reason.
|
2017-05-13 06:17:06 +00:00
|
|
|
*/
|
2016-07-19 17:35:25 +00:00
|
|
|
void ReloadRequest();
|
|
|
|
|
2017-05-13 06:17:06 +00:00
|
|
|
// !TODO: review this function: it need a way to tell what changed,
|
|
|
|
// to only reload/rebuild things that have really changed
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Reload and refresh (rebuild) the 3D scene.
|
|
|
|
*
|
|
|
|
* @warning Rebuilding the 3D scene can take a bit of time, so rebuilding the scene can
|
|
|
|
* be immediate, or made later, during the next 3D canvas refresh (on zoom for
|
|
|
|
* instance).
|
|
|
|
*
|
|
|
|
* @param aForceImmediateRedraw true to immediately rebuild the 3D scene or false to wait
|
|
|
|
* refresh later.
|
2017-05-13 06:17:06 +00:00
|
|
|
*/
|
|
|
|
void NewDisplay( bool aForceImmediateRedraw = false );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-09-02 16:54:57 +00:00
|
|
|
void Redraw();
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
|
2021-01-02 21:05:29 +00:00
|
|
|
CAMERA& GetCurrentCamera() override { return m_currentCamera; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-04-24 23:58:50 +00:00
|
|
|
EDA_3D_CANVAS* GetCanvas() { return m_canvas; }
|
|
|
|
|
2021-07-04 12:19:40 +00:00
|
|
|
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
|
|
|
|
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
|
|
|
|
2019-04-08 09:49:18 +00:00
|
|
|
/**
|
|
|
|
* Notification that common settings are updated.
|
|
|
|
*
|
2020-03-18 22:48:36 +00:00
|
|
|
* This would be private (and only called by the Kiway), but we need to do this manually
|
|
|
|
* from the PCB frame because the 3D viewer isn't updated via the #KIWAY.
|
2019-04-08 09:49:18 +00:00
|
|
|
*/
|
2020-07-17 20:04:14 +00:00
|
|
|
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
|
2023-08-23 13:04:31 +00:00
|
|
|
void ShowChangedLanguage() override;
|
2019-04-08 09:49:18 +00:00
|
|
|
|
2023-08-11 17:40:13 +00:00
|
|
|
APPEARANCE_CONTROLS_3D* GetAppearanceManager() { return m_appearancePanel; }
|
|
|
|
|
|
|
|
void ToggleAppearanceManager();
|
|
|
|
|
|
|
|
void OnDarkModeToggle();
|
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
protected:
|
|
|
|
void setupUIConditions() override;
|
|
|
|
|
2022-03-31 19:03:41 +00:00
|
|
|
void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
|
|
|
|
|
2020-01-22 22:38:30 +00:00
|
|
|
private:
|
2017-12-28 08:29:56 +00:00
|
|
|
/// Called when user press the File->Exit
|
2020-12-16 22:10:42 +00:00
|
|
|
void Exit3DFrame( wxCommandEvent& event );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
void OnCloseWindow( wxCloseEvent& event );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-06-06 20:58:00 +00:00
|
|
|
bool TryBefore( wxEvent& aEvent ) override;
|
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
void Process_Special_Functions( wxCommandEvent& event );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-06-06 20:58:00 +00:00
|
|
|
void onRenderEngineSelection( wxCommandEvent& event );
|
|
|
|
void onDisableRayTracing( wxCommandEvent& aEvent );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-16 22:10:42 +00:00
|
|
|
void OnActivate( wxActivateEvent& event );
|
|
|
|
void OnSetFocus( wxFocusEvent& event );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2023-08-23 13:04:31 +00:00
|
|
|
void doReCreateMenuBar() override;
|
2016-07-19 17:35:25 +00:00
|
|
|
void ReCreateMainToolbar();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a Screenshot of the current 3D view.
|
|
|
|
* Output file format is png or jpeg, or image is copied to the clipboard
|
|
|
|
*/
|
|
|
|
void takeScreenshot( wxCommandEvent& event );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged
|
|
|
|
*/
|
|
|
|
void RenderEngineChanged();
|
|
|
|
|
2020-09-29 08:37:00 +00:00
|
|
|
void refreshRender();
|
|
|
|
|
2017-11-02 20:41:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-04-08 09:49:18 +00:00
|
|
|
/**
|
|
|
|
* Load configuration from common settings.
|
|
|
|
*/
|
|
|
|
void loadCommonSettings();
|
|
|
|
|
2022-06-06 20:58:00 +00:00
|
|
|
private:
|
|
|
|
wxFileName m_defaultSaveScreenshotFileName;
|
|
|
|
|
|
|
|
ACTION_TOOLBAR* m_mainToolBar;
|
|
|
|
EDA_3D_CANVAS* m_canvas;
|
|
|
|
BOARD_ADAPTER m_boardAdapter;
|
|
|
|
CAMERA& m_currentCamera;
|
|
|
|
TRACK_BALL m_trackBallCamera;
|
2020-03-18 22:48:36 +00:00
|
|
|
|
2022-06-06 20:58:00 +00:00
|
|
|
bool m_disable_ray_tracing;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-06-06 20:58:00 +00:00
|
|
|
NL_3D_VIEWER_PLUGIN* m_spaceMouse;
|
2019-01-19 13:02:10 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
|
|
|
* Trace mask used to enable or disable the trace output of this class.
|
|
|
|
* The debug output can be turned on by setting the WXTRACE environment variable to
|
|
|
|
* "KI_TRACE_EDA_3D_VIEWER". See the wxWidgets documentation on wxLogTrace for
|
|
|
|
* more information.
|
|
|
|
*/
|
|
|
|
static const wxChar *m_logTrace;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDA_3D_VIEWER_H
|