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-2019 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 
35 #include "../3d_canvas/cinfo3d_visu.h"
36 #include "../3d_canvas/eda_3d_canvas.h"
37 #include <kiway_player.h>
38 #include <wx/colourdata.h>
39 #include <../common/dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition
40 
41 
44 #define KISYS3DMOD wxT( "KISYS3DMOD" )
45 
46 
47 #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
48 
49 #define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )
50 #define QUALIFIED_VIEWER3D_FRAMENAME( parent ) \
51  ( wxString( VIEWER3D_FRAMENAME ) + wxT( ":" ) + parent->GetName() )
52 
53 
55 {
60 };
61 
66 {
67 
68  public:
69 
70  EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
71  const wxString &aTitle,
72  long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
73 
75 
76  PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
77 
78  BOARD* GetBoard() { return Parent()->GetBoard(); }
79 
81 
90  void ReloadRequest();
91 
92  // !TODO: review this function: it need a way to tell what changed,
93  // to only reload/rebuild things that have really changed
102  void NewDisplay( bool aForceImmediateRedraw = false );
103 
108 
116  bool Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
117  CUSTOM_COLORS_LIST* aPredefinedColors );
118 
124 
130 
136 
142 
148 
155  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
156 
157 
158  void SynchroniseColoursWithBoard( void );
159 
160 private:
162  void Exit3DFrame( wxCommandEvent &event );
163 
164  void OnCloseWindow( wxCloseEvent &event );
165 
166  void Process_Special_Functions( wxCommandEvent &event );
167 
168  void OnRenderEngineSelection( wxCommandEvent &event );
169  void OnDisableRayTracing( wxCommandEvent& aEvent );
170 
171  void OnActivate( wxActivateEvent &event );
172 
173  void OnSetFocus( wxFocusEvent &event );
174 
175  void Install3DViewOptionDialog( wxCommandEvent &event );
176 
177  void OnUpdateUIEngine( wxUpdateUIEvent& aEvent );
178  void OnUpdateUIMaterial( wxUpdateUIEvent& aEvent );
179 
180  void CreateMenuBar();
181  void ReCreateMainToolbar();
182  void SyncToolbars() override;
183 
184  void SaveSettings( APP_SETTINGS_BASE *aCfg ) override;
185 
186  void LoadSettings( APP_SETTINGS_BASE *aCfg ) override;
187 
192  void takeScreenshot( wxCommandEvent& event );
193 
197  void RenderEngineChanged();
198 
199  DECLARE_EVENT_TABLE()
200 
201  private:
202 
206  void loadCommonSettings();
207 
209 
213 
215 
217 
224  static const wxChar *m_logTrace;
225 
226 };
227 
228 #endif // EDA_3D_VIEWER_H
TOOL_DISPATCHER * m_toolDispatcher
bool Set3DCopperColorFromUser()
Set the copper color from a set of colors.
ACTION_TOOLBAR.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification that common settings are updated.
CINFO3D_VISU m_settings
void Install3DViewOptionDialog(wxCommandEvent &event)
CINFO3D_VISU & GetSettings()
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:46
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
Definition: 3d_toolbar.cpp:103
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
bool Set3DColorFromUser(SFVEC3D &aColor, const wxString &aTitle, CUSTOM_COLORS_LIST *aPredefinedColors)
Get a SFVEC3D from a wx colour dialog.
EDA_3D_VIEWER(KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle, long style=KICAD_DEFAULT_3D_DRAWFRAME_STYLE)
void OnActivate(wxActivateEvent &event)
void OnUpdateUIMaterial(wxUpdateUIEvent &aEvent)
void OnDisableRayTracing(wxCommandEvent &aEvent)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:75
EDA_3D_CANVAS * GetCanvas()
Definition: eda_3d_viewer.h:80
bool Set3DSilkScreenColorFromUser()
Set the silkscreen color from a set of colors.
void OnUpdateUIEngine(wxUpdateUIEvent &aEvent)
Class CINFO3D_VISU Helper class to handle information needed to display 3D board.
Definition: cinfo3d_visu.h:73
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
void OnCloseWindow(wxCloseEvent &event)
void ReCreateMainToolbar()
Definition: 3d_toolbar.cpp:39
bool Set3DSolderPasteColorFromUser()
Set the solder mask color from a set of colors.
TOOL_DISPATCHER.
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
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
void OnRenderEngineSelection(wxCommandEvent &event)
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:76
void CreateMenuBar()
Definition: 3d_menubar.cpp:37
void OnSetFocus(wxFocusEvent &event)
EDA_3D_VIEWER_STATUSBAR
Definition: eda_3d_viewer.h:54
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:65
ACTION_TOOLBAR * m_mainToolBar
void SynchroniseColoursWithBoard(void)
BOARD * GetBoard() const
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE
Definition: eda_3d_viewer.h:47
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard()
Definition: eda_3d_viewer.h:78
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)
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.