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 
57 {
58 
59  public:
60 
61  EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
62  const wxString &aTitle,
63  long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
64 
66 
67  PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
68 
69  BOARD* GetBoard() { return Parent()->GetBoard(); }
70 
79  void ReloadRequest();
80 
81  // !TODO: review this function: it need a way to tell what changed,
82  // to only reload/rebuild things that have really changed
91  void NewDisplay( bool aForceImmediateRedraw = false );
92 
97 
107  bool Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
108  CUSTOM_COLORS_LIST* aPredefinedColors );
109 
116 
123 
130 
137 
144 
152  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
153 
154 
155  void SynchroniseColoursWithBoard( void );
156 
157 private:
159  void Exit3DFrame( wxCommandEvent &event );
160 
161  void OnCloseWindow( wxCloseEvent &event );
162 
163  void Process_Special_Functions( wxCommandEvent &event );
164 
165  void On3DGridSelection( wxCommandEvent &event );
166 
167  void OnRenderEngineSelection( wxCommandEvent &event );
168  void OnDisableRayTracing( wxCommandEvent& aEvent );
169 
170  void ProcessZoom( wxCommandEvent &event );
171 
172  void OnActivate( wxActivateEvent &event );
173 
174  void OnSetFocus( wxFocusEvent &event );
175 
176  void Install3DViewOptionDialog( wxCommandEvent &event );
177 
178  void OnUpdateUIEngine( wxUpdateUIEvent& aEvent );
179  void OnUpdateUIMaterial( wxUpdateUIEvent& aEvent );
180 
181  void CreateMenuBar();
182 
186  void ReCreateMainToolbar();
187 
188  void SaveSettings( wxConfigBase *aCfg ) override;
189 
190  void LoadSettings( wxConfigBase *aCfg ) override;
191 
192  void OnKeyEvent( wxKeyEvent& event );
193 
198  void takeScreenshot( wxCommandEvent& event );
199 
203  void RenderEngineChanged();
204 
205  DECLARE_EVENT_TABLE()
206 
207  private:
208 
212  void loadCommonSettings();
213 
215 
216  wxAuiToolBar* m_mainToolBar;
219 
221 
228  static const wxChar *m_logTrace;
229 
230 };
231 
232 #endif // EDA_3D_VIEWER_H
bool Set3DCopperColorFromUser()
Set the copper color from a set of colors.
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 On3DGridSelection(wxCommandEvent &event)
void Install3DViewOptionDialog(wxCommandEvent &event)
CINFO3D_VISU & GetSettings()
Definition: eda_3d_viewer.h:96
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
void OnKeyEvent(wxKeyEvent &event)
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:60
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)
wxAuiToolBar * m_mainToolBar
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:70
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:274
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
void OnCloseWindow(wxCloseEvent &event)
void ReCreateMainToolbar()
Equivalent of EDA_DRAW_FRAME::ReCreateHToolbar.
Definition: 3d_toolbar.cpp:39
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
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
void ProcessZoom(wxCommandEvent &event)
void OnRenderEngineSelection(wxCommandEvent &event)
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:67
void CreateMenuBar()
Definition: 3d_menubar.cpp:38
void OnSetFocus(wxFocusEvent &event)
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:56
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:69
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.