KiCad PCB EDA Suite
c3d_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-2019 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 
32 #ifndef _C3D_MODEL_VIEWER_H_
33 #define _C3D_MODEL_VIEWER_H_
34 
36 #include <wx/glcanvas.h>
37 
38 class S3D_CACHE;
39 class C_OGL_3DMODEL;
40 
45 class C3D_MODEL_VIEWER : public wxGLCanvas
46 {
47 
48 public:
49 
50 
57  C3D_MODEL_VIEWER( wxWindow *aParent,
58  const int *aAttribList = 0,
59  S3D_CACHE *aCacheManager = NULL );
60 
62 
67  void Set3DModel( const S3DMODEL &a3DModel );
68 
73  void Set3DModel( wxString const& aModelPathName );
74 
78  void Clear3DModel();
79 
80 private:
81  void ogl_initialize();
83 
84 private:
85 
86  void OnPaint( wxPaintEvent &event );
87 
88  void OnEraseBackground( wxEraseEvent &event );
89 
90  void OnMouseWheel( wxMouseEvent &event );
91 
92 #ifdef USE_OSX_MAGNIFY_EVENT
93  void OnMagnify( wxMouseEvent& event );
94 #endif
95 
96  void OnMouseMove( wxMouseEvent &event );
97 
98  void OnLeftDown( wxMouseEvent &event );
99 
100  void OnLeftUp( wxMouseEvent &event );
101 
102  void OnMiddleUp( wxMouseEvent &event );
103 
104  void OnMiddleDown( wxMouseEvent &event );
105 
106  void OnRightClick( wxMouseEvent &event );
107 
108  DECLARE_EVENT_TABLE()
109 
110 
111 private:
113  wxGLContext *m_glRC;
114 
117 
120 
123 
126 
129 
134 
137 
144  static const wxChar *m_logTrace;
145 };
146 
147 #endif // _C3D_MODEL_VIEWER_H_
const S3DMODEL * m_3d_model
Original 3d model data.
Declaration for a track ball camera.
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)
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
void OnLeftDown(wxMouseEvent &event)
void OnMouseWheel(wxMouseEvent &event)
void OnMiddleUp(wxMouseEvent &event)
Class C3D_MODEL_VIEWER Implement a canvas based on a wxGLCanvas.
C3D_MODEL_VIEWER(wxWindow *aParent, const int *aAttribList=0, S3D_CACHE *aCacheManager=NULL)
Creates a new 3D Canvas with a attribute list.
void OnRightClick(wxMouseEvent &event)
void Set3DModel(const S3DMODEL &a3DModel)
Set3DModel - Set this model to be displayed.
double m_BiuTo3Dunits
factor to convert the model or any other items to keep it in relation to the +/-RANGE_SCALE_3D (it is...
S3D_CACHE * m_cacheManager
Optional cache manager.
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()
Clear3DModel - Unloads the displayed 3d model.
bool m_ogl_initialized
Flag if open gl was initialized.
void OnPaint(wxPaintEvent &event)
C_OGL_3DMODEL * m_ogl_3dmodel
Class holder for 3d model to display on openGL.
CTRACK_BALL m_trackBallCamera
Camera used in this canvas.