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-2018 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 
42 #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
43 
44 #define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )
45 
50 {
51 
52  public:
53 
54  EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
55  const wxString &aTitle,
56  long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
57 
59 
60  PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
61 
62  BOARD* GetBoard() { return Parent()->GetBoard(); }
63 
72  void ReloadRequest();
73 
74  // !TODO: review this function: it need a way to tell what changed,
75  // to only reload/rebuild things that have really changed
84  void NewDisplay( bool aForceImmediateRedraw = false );
85 
90  void SetDefaultFileName( const wxString& aFn )
91  {
93  }
94 
98  const wxFileName& GetDefaultFileName() const { return m_defaultSaveScreenshotFileName; }
99 
104 
114  bool Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
115  CUSTOM_COLORS_LIST* aPredefinedColors );
116 
123 
130 
137 
144 
151 
152  private:
154  void Exit3DFrame( wxCommandEvent &event );
155 
156  void OnCloseWindow( wxCloseEvent &event );
157 
158  void Process_Special_Functions( wxCommandEvent &event );
159 
160  void On3DGridSelection( wxCommandEvent &event );
161 
162  void OnRenderEngineSelection( wxCommandEvent &event );
163 
164  void OnUpdateMenus(wxUpdateUIEvent& event);
165 
166  void ProcessZoom( wxCommandEvent &event );
167 
168  void OnActivate( wxActivateEvent &event );
169 
170  void OnSetFocus( wxFocusEvent &event );
171 
172  void Install3DViewOptionDialog( wxCommandEvent &event );
173 
174  void CreateMenuBar();
175 
176  void DisplayHotKeys();
177 
181  void SetMenuBarOptionsState();
182 
183  void ReCreateMainToolbar();
184 
185  void SetToolbars();
186 
187  void SaveSettings( wxConfigBase *aCfg ) override;
188 
189  void LoadSettings( wxConfigBase *aCfg ) override;
190 
191  void OnLeftClick( wxDC *DC, const wxPoint &MousePos );
192  void OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu );
193  void OnKeyEvent( wxKeyEvent& event );
194 
195  void RedrawActiveWindow( wxDC *DC, bool EraseBg );
196 
201  void takeScreenshot( wxCommandEvent& event );
202 
206  void RenderEngineChanged();
207 
208  DECLARE_EVENT_TABLE()
209 
210  private:
211 
216 
221 
226 
233  static const wxChar *m_logTrace;
234 
235 };
236 
237 #endif // EDA_3D_VIEWER_H
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:60
bool Set3DCopperColorFromUser()
Set the copper color from a set of colors.
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
CINFO3D_VISU m_settings
Store all the settings and options to be used by the renders.
void On3DGridSelection(wxCommandEvent &event)
void Install3DViewOptionDialog(wxCommandEvent &event)
const wxFileName & GetDefaultFileName() const
Definition: eda_3d_viewer.h:98
CINFO3D_VISU & GetSettings()
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void OnKeyEvent(wxKeyEvent &event)
void SetMenuBarOptionsState()
Set the state of toggle menus according to the current display options.
Definition: 3d_menubar.cpp:350
void RedrawActiveWindow(wxDC *DC, bool EraseBg)
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Class EDA_3D_CANVAS Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:53
BOARD * GetBoard() const
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
EDA_3D_CANVAS * m_canvas
The canvas where the openGL context will be rendered.
bool Set3DColorFromUser(SFVEC3D &aColor, const wxString &aTitle, CUSTOM_COLORS_LIST *aPredefinedColors)
Get a SFVEC3D from a wx colour dialog.
void OnActivate(wxActivateEvent &event)
void OnUpdateMenus(wxUpdateUIEvent &event)
bool Set3DSilkScreenColorFromUser()
Set the silkscreen color from a set of colors.
EDA_3D_VIEWER(KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle, long style=KICAD_DEFAULT_3D_DRAWFRAME_STYLE)
Class CINFO3D_VISU Helper class to handle information needed to display 3D board. ...
Definition: cinfo3d_visu.h:70
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
void OnLeftClick(wxDC *DC, const wxPoint &MousePos)
void OnCloseWindow(wxCloseEvent &event)
void ReCreateMainToolbar()
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
Filename to propose for save a screenshot.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:171
void SetToolbars()
Definition: 3d_toolbar.cpp:138
void ProcessZoom(wxCommandEvent &event)
void OnRenderEngineSelection(wxCommandEvent &event)
void CreateMenuBar()
Definition: 3d_menubar.cpp:41
void OnSetFocus(wxFocusEvent &event)
void OnRightClick(const wxPoint &MousePos, wxMenu *PopMenu)
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard. ...
Definition: eda_3d_viewer.h:49
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE
Definition: eda_3d_viewer.h:42
void SetDefaultFileName(const wxString &aFn)
Set the default file name (eg: to be suggested to a screenshot)
Definition: eda_3d_viewer.h:90
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
BOARD * GetBoard()
Definition: eda_3d_viewer.h:62
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.