KiCad PCB EDA Suite
eda_3d_viewer.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 <mrluzeiro@ua.pt>
5  * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2020 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 KICAD6_3DMODEL_DIR wxT( "KICAD6_3DMODEL_DIR" )
46 
47 
48 #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
49 
50 #define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )
51 #define QUALIFIED_VIEWER3D_FRAMENAME( parent ) \
52  ( wxString( VIEWER3D_FRAMENAME ) + wxT( ":" ) + parent->GetName() )
53 
54 
56 {
57  ACTIVITY = 0,
61 };
62 
67 {
68 public:
69  EDA_3D_VIEWER( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle,
70  long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
71 
73 
74  PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
75 
76  BOARD* GetBoard() { return Parent()->GetBoard(); }
77 
78  wxWindow* GetToolCanvas() const override { return m_canvas; }
79 
88  void ReloadRequest();
89 
90  // !TODO: review this function: it need a way to tell what changed,
91  // to only reload/rebuild things that have really changed
102  void NewDisplay( bool aForceImmediateRedraw = false );
103 
104  void Redraw();
105 
106  BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
107  CAMERA& GetCurrentCamera() override { return m_currentCamera; }
108 
110 
119  bool Set3DColorFromUser( SFVEC4F& aColor, const wxString& aTitle,
120  CUSTOM_COLORS_LIST* aPredefinedColors,
121  bool aAllowOpacityControl = false,
122  KIGFX::COLOR4D aDefaultColor = KIGFX::COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
123 
130 
137 
144 
151 
158 
165  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
166 
167 
169 
170 protected:
171  void setupUIConditions() override;
172 
173 private:
175  void Exit3DFrame( wxCommandEvent& event );
176 
177  void OnCloseWindow( wxCloseEvent& event );
178 
179  void Process_Special_Functions( wxCommandEvent& event );
180 
181  void OnRenderEngineSelection( wxCommandEvent& event );
182  void OnDisableRayTracing( wxCommandEvent& aEvent );
183 
184  void OnActivate( wxActivateEvent& event );
185 
186  void OnSetFocus( wxFocusEvent& event );
187 
188  void Install3DViewOptionDialog( wxCommandEvent& event );
189 
190  void CreateMenuBar();
191  void ReCreateMainToolbar();
192 
193  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
194 
195  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
196 
201  void takeScreenshot( wxCommandEvent& event );
202 
206  void RenderEngineChanged();
207 
208  void refreshRender();
209 
210  DECLARE_EVENT_TABLE()
211 
212 
215  void loadCommonSettings();
216 
218 
224 
226 
233  static const wxChar *m_logTrace;
234 
235 };
236 
237 #endif // EDA_3D_VIEWER_H
CAMERA & GetCurrentCamera() override
bool Set3DCopperColorFromUser()
Set the copper color from a set of colors.
Define the structure of a toolbar with buttons that invoke ACTIONs.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
void Install3DViewOptionDialog(wxCommandEvent &event)
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
EDA_3D_VIEWER(KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle, long style=KICAD_DEFAULT_3D_DRAWFRAME_STYLE)
BOARD_ADAPTER & GetAdapter() override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
void SynchroniseColoursWithBoard()
wxWindow * GetToolCanvas() const override
Canvas access.
Definition: eda_3d_viewer.h:78
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
void loadCommonSettings()
Load configuration from common settings.
EDA_3D_CANVAS * m_canvas
A class used to derive camera objects from.
Definition: camera.h:77
void OnActivate(wxActivateEvent &event)
BOARD_ADAPTER m_boardAdapter
void OnDisableRayTracing(wxCommandEvent &aEvent)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
EDA_3D_CANVAS * GetCanvas()
bool Set3DSilkScreenColorFromUser()
Set the silkscreen color from a set of colors.
CAMERA & m_currentCamera
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void OnCloseWindow(wxCloseEvent &event)
bool Set3DColorFromUser(SFVEC4F &aColor, const wxString &aTitle, CUSTOM_COLORS_LIST *aPredefinedColors, bool aAllowOpacityControl=false, KIGFX::COLOR4D aDefaultColor=KIGFX::COLOR4D(1.0, 1.0, 1.0, 1.0))
Get a SFVEC3D from a color dialog.
void ReCreateMainToolbar()
Definition: 3d_toolbar.cpp:36
bool Set3DSolderPasteColorFromUser()
Set the solder mask color from a set of colors.
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
wxFileName m_defaultSaveScreenshotFileName
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void OnRenderEngineSelection(wxCommandEvent &event)
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:74
void CreateMenuBar()
Definition: 3d_menubar.cpp:38
void OnSetFocus(wxFocusEvent &event)
EDA_3D_VIEWER_STATUSBAR
Definition: eda_3d_viewer.h:55
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:66
ACTION_TOOLBAR * m_mainToolBar
BOARD * GetBoard() const
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE
Definition: eda_3d_viewer.h:48
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
TRACK_BALL m_trackBallCamera
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:67
Declaration for a track ball camera.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard()
Definition: eda_3d_viewer.h:76
bool m_disable_ray_tracing
bool Set3DBoardBodyColorFromUser()
Set the copper color from a set of colors.
void ReloadRequest()
Request reloading the 3D view.
void Process_Special_Functions(wxCommandEvent &event)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.