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 <../common/dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition
41 
42 
45 #define KISYS3DMOD wxT( "KISYS3DMOD" )
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 {
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 
80  wxWindow* GetToolCanvas() const override { return m_canvas; }
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 
104  void Redraw();
105 
106  BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
107  CCAMERA& GetCurrentCamera() override { return m_currentCamera; }
108 
110 
118  bool Set3DColorFromUser( SFVEC4F &aColor, const wxString& aTitle,
119  CUSTOM_COLORS_LIST* aPredefinedColors,
120  bool aAllowOpacityControl = false,
121  KIGFX::COLOR4D aDefaultColor = KIGFX::COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
122 
128 
134 
140 
146 
152 
159  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
160 
161 
163 
164 protected:
165  void setupUIConditions() override;
166 
167 private:
169  void Exit3DFrame( wxCommandEvent &event );
170 
171  void OnCloseWindow( wxCloseEvent &event );
172 
173  void Process_Special_Functions( wxCommandEvent &event );
174 
175  void OnRenderEngineSelection( wxCommandEvent &event );
176  void OnDisableRayTracing( wxCommandEvent& aEvent );
177 
178  void OnActivate( wxActivateEvent &event );
179 
180  void OnSetFocus( wxFocusEvent &event );
181 
182  void Install3DViewOptionDialog( wxCommandEvent &event );
183 
184  void CreateMenuBar();
185  void ReCreateMainToolbar();
186 
187  void SaveSettings( APP_SETTINGS_BASE *aCfg ) override;
188 
189  void LoadSettings( APP_SETTINGS_BASE *aCfg ) override;
190 
195  void takeScreenshot( wxCommandEvent& event );
196 
200  void RenderEngineChanged();
201 
202  void refreshRender();
203 
204  DECLARE_EVENT_TABLE()
205 
206  private:
207 
211  void loadCommonSettings();
212 
214 
220 
222 
229  static const wxChar *m_logTrace;
230 
231 };
232 
233 #endif // EDA_3D_VIEWER_H
Declaration for a track ball camera.
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:61
void Install3DViewOptionDialog(wxCommandEvent &event)
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
CTRACK_BALL m_trackBallCamera
Class CCAMERA is a virtual class used to derive CCAMERA objects from.
Definition: ccamera.h:79
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
Saves 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:80
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
CCAMERA & m_currentCamera
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
void loadCommonSettings()
Load configuration from common settings.
EDA_3D_CANVAS * m_canvas
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.
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
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 wx colour dialog.
void ReCreateMainToolbar()
Definition: 3d_toolbar.cpp:38
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: class_board.h:186
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:76
void CreateMenuBar()
Definition: 3d_menubar.cpp:37
CCAMERA & GetCurrentCamera() override
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:65
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.
Class BOARD_ADAPTER Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:68
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)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.