KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_3d_viewer_frame.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Mario Luzeiro <[email protected]>
5 * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 2023 CERN
8 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
33#ifndef EDA_3D_VIEWER_H
34#define EDA_3D_VIEWER_H
35
39#include <kiway_player.h>
40#include <wx/colourdata.h>
41#include <dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition
42
43
44#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
45
46// Forward declarations
49
50
52{
58};
59
61{
63 IMAGE,
64 PNG,
65 JPEG
66};
67
72{
73public:
74 EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle,
76
78
79 PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
80
81 BOARD* GetBoard() { return Parent()->GetBoard(); }
82
83 wxWindow* GetToolCanvas() const override { return m_canvas; }
84
93 void ReloadRequest();
94
95 // !TODO: review this function: it need a way to tell what changed,
96 // to only reload/rebuild things that have really changed
107 void NewDisplay( bool aForceImmediateRedraw = false );
108
109 void Redraw();
110
113
115
116 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
117 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
118
125 void CommonSettingsChanged( int aFlags ) override;
126 void ShowChangedLanguage() override;
127
129
131
132 void OnDarkModeToggle();
133
139
145 void ExportImage( EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxSize& aSize );
146
147protected:
148 void setupUIConditions() override;
149
150 void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
151
152private:
154 void Exit3DFrame( wxCommandEvent& event );
155
156 void OnCloseWindow( wxCloseEvent& event );
157
158 bool TryBefore( wxEvent& aEvent ) override;
159
160 void Process_Special_Functions( wxCommandEvent& event );
161
162 void onDisableRayTracing( wxCommandEvent& aEvent );
163
164 void OnActivate( wxActivateEvent& event );
165 void OnSetFocus( wxFocusEvent& event );
166
167 void doReCreateMenuBar() override;
168
172 void RenderEngineChanged();
173
174 void refreshRender();
175
176 DECLARE_EVENT_TABLE()
177
178
181 void loadCommonSettings();
182
183 void applySettings( EDA_3D_VIEWER_SETTINGS* aSettings );
184
192 bool getExportFileName( EDA_3D_VIEWER_EXPORT_FORMAT& aFormat, wxString& fullFileName );
193
199 wxImage captureScreenshot( const wxSize& aSize );
200
205 void setupRenderingConfig( BOARD_ADAPTER& adapter );
206
213
221 wxImage captureRaytracingScreenshot( BOARD_ADAPTER& adapter, TRACK_BALL& camera, const wxSize& aSize );
222
229 wxImage convertRGBAToImage( uint8_t* rgbaBuffer, const wxSize& realSize );
230
238 wxImage captureOpenGLScreenshot( BOARD_ADAPTER& adapter, TRACK_BALL& camera, const wxSize& aSize );
239
245 void configureCanvas( std::unique_ptr<EDA_3D_CANVAS>& canvas, EDA_3D_VIEWER_SETTINGS* cfg );
246
253 void saveOrCopyImage( const wxImage& screenshotImage, EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxString& fullFileName );
254
259 void copyImageToClipboard( const wxImage& screenshotImage );
260
267 void saveImageToFile( const wxImage& screenshotImage, EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxString& fullFileName );
268
269private:
271
276
278
280
287 static const wxChar *m_logTrace;
288
289};
290
291#endif // EDA_3D_VIEWER_H
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:108
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:73
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
A class used to derive camera objects from.
Definition: camera.h:103
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:51
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
void saveOrCopyImage(const wxImage &screenshotImage, EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxString &fullFileName)
Save image to file or copy to clipboard based on format.
wxWindow * GetToolCanvas() const override
Canvas access.
void OnSetFocus(wxFocusEvent &event)
void onDisableRayTracing(wxCommandEvent &aEvent)
void CommonSettingsChanged(int aFlags) override
Notification that common settings are updated.
void applySettings(EDA_3D_VIEWER_SETTINGS *aSettings)
PCB_BASE_FRAME * Parent() const
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
void configureCanvas(std::unique_ptr< EDA_3D_CANVAS > &canvas, EDA_3D_VIEWER_SETTINGS *cfg)
Configure canvas settings for screenshot capture.
wxImage captureOpenGLScreenshot(BOARD_ADAPTER &adapter, TRACK_BALL &camera, const wxSize &aSize)
Capture screenshot using OpenGL renderer.
bool getExportFileName(EDA_3D_VIEWER_EXPORT_FORMAT &aFormat, wxString &fullFileName)
Get export filename through file dialog.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void OnActivate(wxActivateEvent &event)
bool TryBefore(wxEvent &aEvent) override
EDA_3D_CANVAS * m_canvas
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
BOARD_ADAPTER m_boardAdapter
std::unique_ptr< NL_3D_VIEWER_PLUGIN > m_spaceMouse
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
void Process_Special_Functions(wxCommandEvent &event)
wxImage captureCurrentViewScreenshot()
Capture screenshot of the current view using the configured renderer.
void OnCloseWindow(wxCloseEvent &event)
void doReCreateMenuBar() override
Definition: 3d_menubar.cpp:38
void ShowChangedLanguage() override
EDA_3D_VIEWER_FRAME(KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle, long style=KICAD_DEFAULT_3D_DRAWFRAME_STYLE)
wxImage captureScreenshot(const wxSize &aSize)
Capture screenshot using appropriate rendering method.
void setupRenderingConfig(BOARD_ADAPTER &adapter)
Setup rendering configuration for screenshot capture.
void ReloadRequest()
Request reloading the 3D view.
wxFileName m_defaultSaveScreenshotFileName
wxImage convertRGBAToImage(uint8_t *rgbaBuffer, const wxSize &realSize)
Convert RGBA buffer to wxImage format.
EDA_3D_CANVAS * GetCanvas()
BOARD_ADAPTER & GetAdapter()
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void saveImageToFile(const wxImage &screenshotImage, EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxString &fullFileName)
Save image to file.
void copyImageToClipboard(const wxImage &screenshotImage)
Copy image to system clipboard.
void loadCommonSettings()
Load configuration from common settings.
APPEARANCE_CONTROLS_3D * GetAppearanceManager()
void ExportImage(EDA_3D_VIEWER_EXPORT_FORMAT aFormat, const wxSize &aSize)
Export 3D viewer image to file or clipboard.
wxImage captureRaytracingScreenshot(BOARD_ADAPTER &adapter, TRACK_BALL &camera, const wxSize &aSize)
Capture screenshot using raytracing renderer.
void TakeScreenshot(EDA_3D_VIEWER_EXPORT_FORMAT aFormat)
Create a Screenshot of the current 3D view.
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
APPEARANCE_CONTROLS_3D * m_appearancePanel
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:286
The class that implements the public interface to the SpaceMouse plug-in.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard() const
EDA_3D_VIEWER_EXPORT_FORMAT
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE
EDA_3D_VIEWER_STATUSBAR
@ ZOOM_LEVEL
@ ACTIVITY
@ HOVERED_ITEM
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
STL namespace.
Declaration for a track ball camera.