KiCad PCB EDA Suite
3d_model_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) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
33 #ifndef _C3D_MODEL_VIEWER_H_
34 #define _C3D_MODEL_VIEWER_H_
35 
37 #include <gal/hidpi_gl_canvas.h>
38 
39 class S3D_CACHE;
40 class MODEL_3D;
41 
46 {
47 public:
54  C3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList = 0,
55  S3D_CACHE* aCacheManager = nullptr );
56 
58 
64  void Set3DModel( const S3DMODEL& a3DModel );
65 
71  void Set3DModel( wxString const& aModelPathName );
72 
76  void Clear3DModel();
77 
78 private:
79  void ogl_initialize();
81 
82  void OnPaint( wxPaintEvent& event );
83 
84  void OnEraseBackground( wxEraseEvent& event );
85 
86  void OnMouseWheel( wxMouseEvent& event );
87 
88 #ifdef USE_OSX_MAGNIFY_EVENT
89  void OnMagnify( wxMouseEvent& event );
90 #endif
91 
92  void OnMouseMove( wxMouseEvent& event );
93 
94  void OnLeftDown( wxMouseEvent& event );
95 
96  void OnLeftUp( wxMouseEvent& event );
97 
98  void OnMiddleUp( wxMouseEvent& event );
99 
100  void OnMiddleDown( wxMouseEvent& event );
101 
102  void OnRightClick( wxMouseEvent& event );
103 
104  DECLARE_EVENT_TABLE()
105 
106 
107  wxGLContext* m_glRC;
108 
111 
114 
117 
120 
123 
128 
131 
138  static const wxChar* m_logTrace;
139 };
140 
141 #endif // _C3D_MODEL_VIEWER_H_
const S3DMODEL * m_3d_model
Original 3d model data.
bool m_reload_is_needed
Flag that we have a new model and it need to be reloaded when the paint is called.
wxGLContext * m_glRC
openGL context
void OnMiddleDown(wxMouseEvent &event)
void OnLeftDown(wxMouseEvent &event)
void OnMouseWheel(wxMouseEvent &event)
wxGLCanvas wrapper for HiDPI/Retina support.
MODEL_3D * m_ogl_3dmodel
Class holder for 3d model to display on openGL.
void OnMiddleUp(wxMouseEvent &event)
Cache for storing the 3D shapes.
Definition: 3d_cache.h:52
Implement a canvas based on a wxGLCanvas.
C3D_MODEL_VIEWER(wxWindow *aParent, const int *aAttribList=0, S3D_CACHE *aCacheManager=nullptr)
Create a new 3D Canvas with a attribute list.
void OnRightClick(wxMouseEvent &event)
void Set3DModel(const S3DMODEL &a3DModel)
Set this model to be displayed.
S3D_CACHE * m_cacheManager
Optional cache manager.
double m_BiuTo3dUnits
factor to convert the model or any other items to keep it in relation to the +/-RANGE_SCALE_3D (it is...
TRACK_BALL m_trackBallCamera
Camera used in this canvas.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
void OnLeftUp(wxMouseEvent &event)
void OnEraseBackground(wxEraseEvent &event)
void OnMouseMove(wxMouseEvent &event)
Store the a model based on meshes and materials.
Definition: c3dmodel.h:90
void Clear3DModel()
Unload the displayed 3D model.
bool m_ogl_initialized
Flag if open gl was initialized.
void OnPaint(wxPaintEvent &event)
Declaration for a track ball camera.