KiCad PCB EDA Suite
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) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
32#ifndef EDA_3D_VIEWER_H
33#define EDA_3D_VIEWER_H
34
38#include <kiway_player.h>
39#include <wx/colourdata.h>
40#include <dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition
41
42
45#define KICAD7_3DMODEL_DIR wxT( "KICAD7_3DMODEL_DIR" )
46
47
48#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
49
50// Forward declarations
52
54{
59};
60
65{
66public:
67 EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle,
69
71
72 PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
73
74 BOARD* GetBoard() { return Parent()->GetBoard(); }
75
76 wxWindow* GetToolCanvas() const override { return m_canvas; }
77
86 void ReloadRequest();
87
88 // !TODO: review this function: it need a way to tell what changed,
89 // to only reload/rebuild things that have really changed
100 void NewDisplay( bool aForceImmediateRedraw = false );
101
102 void Redraw();
103
106
108
109 std::vector<VIEWPORT3D> GetUserViewports() const;
110 void SetUserViewports( std::vector<VIEWPORT3D>& aViewportList );
111
112 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
113 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
114
121 void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
122
123protected:
124 void setupUIConditions() override;
125
126 void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
127
132 void applyViewport( const wxString& aViewportName );
133
134private:
136 void Exit3DFrame( wxCommandEvent& event );
137
138 void OnCloseWindow( wxCloseEvent& event );
139
140 bool TryBefore( wxEvent& aEvent ) override;
141
142 void Process_Special_Functions( wxCommandEvent& event );
143
144 void onRenderEngineSelection( wxCommandEvent& event );
145 void onDisableRayTracing( wxCommandEvent& aEvent );
146 void onViewportChanged( wxCommandEvent& aEvent );
147 void onUpdateViewportsCb( wxUpdateUIEvent& aEvent );
148
149 void OnActivate( wxActivateEvent& event );
150 void OnSetFocus( wxFocusEvent& event );
151 void passOnFocus();
152
153 void CreateMenuBar();
154 void ReCreateMainToolbar();
155
160 void takeScreenshot( wxCommandEvent& event );
161
165 void RenderEngineChanged();
166
167 void refreshRender();
168
169 DECLARE_EVENT_TABLE()
170
171
174 void loadCommonSettings();
175
176private:
178
180 wxStaticText* m_viewportsLabel;
181 wxChoice* m_cbViewports;
186
188
190
191 std::map<wxString, VIEWPORT3D> m_viewports;
193 wxArrayString m_viewportMRU;
194
201 static const wxChar *m_logTrace;
202
203};
204
205#endif // EDA_3D_VIEWER_H
Define the structure of a toolbar with buttons that invoke ACTIONs.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:69
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
A class used to derive camera objects from.
Definition: camera.h:78
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
wxWindow * GetToolCanvas() const override
Canvas access.
void OnSetFocus(wxFocusEvent &event)
void onDisableRayTracing(wxCommandEvent &aEvent)
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.
void onViewportChanged(wxCommandEvent &aEvent)
ACTION_TOOLBAR * m_mainToolBar
BOARD_ADAPTER & GetAdapter() override
PCB_BASE_FRAME * Parent() const
void SetUserViewports(std::vector< VIEWPORT3D > &aViewportList)
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 setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void onUpdateViewportsCb(wxUpdateUIEvent &aEvent)
void OnActivate(wxActivateEvent &event)
bool TryBefore(wxEvent &aEvent) override
EDA_3D_CANVAS * m_canvas
wxStaticText * m_viewportsLabel
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
BOARD_ADAPTER m_boardAdapter
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
void Process_Special_Functions(wxCommandEvent &event)
void OnCloseWindow(wxCloseEvent &event)
void ReCreateMainToolbar()
Definition: 3d_toolbar.cpp:38
EDA_3D_VIEWER_FRAME(KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle, long style=KICAD_DEFAULT_3D_DRAWFRAME_STYLE)
CAMERA & GetCurrentCamera() override
void ReloadRequest()
Request reloading the 3D view.
wxFileName m_defaultSaveScreenshotFileName
VIEWPORT3D * m_lastSelectedViewport
EDA_3D_CANVAS * GetCanvas()
void onRenderEngineSelection(wxCommandEvent &event)
std::map< wxString, VIEWPORT3D > m_viewports
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
NL_3D_VIEWER_PLUGIN * m_spaceMouse
void applyViewport(const wxString &aViewportName)
switch to a given predefined 3D viewport
void loadCommonSettings()
Load configuration from common settings.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
std::vector< VIEWPORT3D > GetUserViewports() const
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
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
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE
EDA_3D_VIEWER_STATUSBAR
@ ACTIVITY
@ HOVERED_ITEM
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: bitmap.cpp:65
Declaration for a track ball camera.