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@verizon.net>
7  * Copyright (C) 1992-2016 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 
36 #include "../3d_canvas/cinfo3d_visu.h"
37 #include "../3d_canvas/eda_3d_canvas.h"
38 #include <kiway_player.h>
39 #include <wx/colourdata.h>
40 
41 
42 #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
43 
44 #define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )
45 
51 {
52 
53  public:
54 
55  EDA_3D_VIEWER( KIWAY *aKiway,
56  PCB_BASE_FRAME *aParent,
57  const wxString &aTitle,
58  long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
59 
61 
62  PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
63 
64  BOARD* GetBoard() { return Parent()->GetBoard(); }
65 
66  void ReloadRequest();
67 
68  // !TODO: review this function
69  // !TODO: this need a way to tell what changed to the reload will only
70  // change the things on a need base
71  void NewDisplay( int dummy = 0 ) { ReloadRequest(); }
72 
78  void SetDefaultFileName( const wxString &aFn )
79  {
80  wxFileName fn( aFn );
81  m_defaultFileName = fn.GetName();
82  }
83 
88  const wxString &GetDefaultFileName() const { return m_defaultFileName; }
89 
95 
107  bool Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
108  wxColourData* aPredefinedColors = NULL );
109 
117 
125 
133 
141 
149 
150  private:
155  void Exit3DFrame( wxCommandEvent &event );
156 
157  void OnCloseWindow( wxCloseEvent &event );
158 
159  void Process_Special_Functions( wxCommandEvent &event );
160 
161  void On3DGridSelection( wxCommandEvent &event );
162 
163  void OnRenderEngineSelection( wxCommandEvent &event );
164 
165  void OnUpdateMenus(wxUpdateUIEvent& event);
166 
167  void ProcessZoom( wxCommandEvent &event );
168 
169  void OnActivate( wxActivateEvent &event );
170 
171  void OnSetFocus( wxFocusEvent &event );
172 
173  void Install3DViewOptionDialog( wxCommandEvent &event );
174 
175  void CreateMenuBar();
176 
177  void DisplayHotKeys();
178 
182  void SetMenuBarOptionsState();
183 
184  void ReCreateMainToolbar();
185 
186  void SetToolbars();
187 
188  void SaveSettings( wxConfigBase *aCfg ) override;
189 
190  void LoadSettings( wxConfigBase *aCfg ) override;
191 
192  void OnLeftClick( wxDC *DC, const wxPoint &MousePos );
193 
194  void OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu );
195 
196  void RedrawActiveWindow( wxDC *DC, bool EraseBg );
197 
203  void takeScreenshot( wxCommandEvent& event );
204 
208  void RenderEngineChanged();
209 
211 
212  private:
213 
218 
223 
228 
235  static const wxChar *m_logTrace;
236 
237 };
238 
239 #endif // EDA_3D_VIEWER_H
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:62
bool Set3DCopperColorFromUser()
Function 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:111
CINFO3D_VISU m_settings
Store all the settings and options to be used by the renders.
void On3DGridSelection(wxCommandEvent &event)
void Install3DViewOptionDialog(wxCommandEvent &event)
CINFO3D_VISU & GetSettings()
Function GetSettings.
Definition: eda_3d_viewer.h:94
bool Set3DSolderMaskColorFromUser()
Function 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 SetMenuBarOptionsState()
Set the state of toggle menus according to the current display options.
Definition: 3d_toolbar.cpp:414
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
void Exit3DFrame(wxCommandEvent &event)
Exit3DFrame - Called when user press the File->Exit.
const wxString & GetDefaultFileName() const
Function GetDefaultFileName.
Definition: eda_3d_viewer.h:88
EDA_3D_CANVAS * m_canvas
The canvas where the openGL context will be rendered.
void OnActivate(wxActivateEvent &event)
void OnUpdateMenus(wxUpdateUIEvent &event)
bool Set3DSilkScreenColorFromUser()
Function 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:257
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()
Function Set3DSolderPasteColorFromUser Set the solder mask color from a set of colors.
void NewDisplay(int dummy=0)
Definition: eda_3d_viewer.h:71
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
wxString m_defaultFileName
Filename to propose for save a screenshot.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
bool Set3DColorFromUser(SFVEC3D &aColor, const wxString &aTitle, wxColourData *aPredefinedColors=NULL)
Function Set3DColorFromUser Get a SFVEC3D from a wx colour dialog.
void SetToolbars()
Definition: 3d_toolbar.cpp:526
void ProcessZoom(wxCommandEvent &event)
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
void OnRenderEngineSelection(wxCommandEvent &event)
void CreateMenuBar()
Definition: 3d_toolbar.cpp:133
void OnSetFocus(wxFocusEvent &event)
void OnRightClick(const wxPoint &MousePos, wxMenu *PopMenu)
Class EDA_3D_VIEWER Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard...
Definition: eda_3d_viewer.h:50
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE
Definition: eda_3d_viewer.h:42
void SetDefaultFileName(const wxString &aFn)
Function SetDefaultFileName Set the default file name (eg: to be suggested to a screenshot) ...
Definition: eda_3d_viewer.h:78
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
BOARD * GetBoard()
Definition: eda_3d_viewer.h:64
bool Set3DBoardBodyColorFromUser()
Function Set3DBoardBodyBodyColorFromUser Set the copper color from a set of colors.
void Process_Special_Functions(wxCommandEvent &event)
void takeScreenshot(wxCommandEvent &event)
Function TakeScreenshot Create a Screenshot of the current 3D view.