![]() |
KiCad PCB EDA Suite
|
Implement a canvas based on a wxGLCanvas. More...
#include <3d_model_viewer.h>
Public Member Functions | |
C3D_MODEL_VIEWER (wxWindow *aParent, const int *aAttribList=0, S3D_CACHE *aCacheManager=nullptr) | |
Create a new 3D Canvas with a attribute list. More... | |
~C3D_MODEL_VIEWER () | |
void | Set3DModel (const S3DMODEL &a3DModel) |
Set this model to be displayed. More... | |
void | Set3DModel (wxString const &aModelPathName) |
Set this model to be displayed. More... | |
void | Clear3DModel () |
Unload the displayed 3D model. More... | |
virtual wxSize | GetNativePixelSize () const |
void | SetScaleFactor (double aFactor) |
Set the canvas scale factor, probably for a hi-DPI display. More... | |
double | GetScaleFactor () const |
Get the current scale factor. More... | |
Private Member Functions | |
void | ogl_initialize () |
void | ogl_set_arrow_material () |
void | OnPaint (wxPaintEvent &event) |
void | OnEraseBackground (wxEraseEvent &event) |
void | OnMouseWheel (wxMouseEvent &event) |
void | OnMouseMove (wxMouseEvent &event) |
void | OnLeftDown (wxMouseEvent &event) |
void | OnLeftUp (wxMouseEvent &event) |
void | OnMiddleUp (wxMouseEvent &event) |
void | OnMiddleDown (wxMouseEvent &event) |
void | OnRightClick (wxMouseEvent &event) |
Private Attributes | |
wxGLContext * | m_glRC |
openGL context More... | |
TRACK_BALL | m_trackBallCamera |
Camera used in this canvas. More... | |
const S3DMODEL * | m_3d_model |
Original 3d model data. More... | |
MODEL_3D * | m_ogl_3dmodel |
Class holder for 3d model to display on openGL. More... | |
bool | m_reload_is_needed |
Flag that we have a new model and it need to be reloaded when the paint is called. More... | |
bool | m_ogl_initialized |
Flag if open gl was initialized. More... | |
double | m_BiuTo3dUnits |
factor to convert the model or any other items to keep it in relation to the +/-RANGE_SCALE_3D (it is named same as the board render for better understanding proposes) More... | |
S3D_CACHE * | m_cacheManager |
Optional cache manager. More... | |
Static Private Attributes | |
static const wxChar * | m_logTrace = wxT( "KI_TRACE_EDA_3D_MODEL_VIEWER" ) |
Trace mask used to enable or disable the trace output of this class. More... | |
Implement a canvas based on a wxGLCanvas.
Definition at line 45 of file 3d_model_viewer.h.
C3D_MODEL_VIEWER::C3D_MODEL_VIEWER | ( | wxWindow * | aParent, |
const int * | aAttribList = 0 , |
||
S3D_CACHE * | aCacheManager = nullptr |
||
) |
Create a new 3D Canvas with a attribute list.
aParent | the parent creator of this canvas. |
aAttribList | a list of openGL options created by OGL_ATT_LIST::GetAttributesList. |
Definition at line 85 of file 3d_model_viewer.cpp.
References m_3d_model, m_BiuTo3dUnits, m_glRC, m_logTrace, m_ogl_3dmodel, m_ogl_initialized, and m_reload_is_needed.
C3D_MODEL_VIEWER::~C3D_MODEL_VIEWER | ( | ) |
Definition at line 103 of file 3d_model_viewer.cpp.
References GL_CONTEXT_MANAGER::DestroyCtx(), GL_CONTEXT_MANAGER::Get(), GL_CONTEXT_MANAGER::LockCtx(), m_glRC, m_logTrace, m_ogl_3dmodel, and GL_CONTEXT_MANAGER::UnlockCtx().
void C3D_MODEL_VIEWER::Clear3DModel | ( | ) |
Unload the displayed 3D model.
Definition at line 163 of file 3d_model_viewer.cpp.
References m_3d_model, m_ogl_3dmodel, m_reload_is_needed, and Refresh().
Referenced by Set3DModel().
|
virtualinherited |
Definition at line 46 of file hidpi_gl_canvas.cpp.
References HIDPI_GL_CANVAS::GetScaleFactor().
Referenced by EDA_3D_CANVAS::DoRePaint(), EDA_3D_CANVAS::OnMouseMove(), and KIGFX::OPENGL_GAL::OPENGL_GAL().
|
inherited |
Get the current scale factor.
Definition at line 64 of file hidpi_gl_canvas.cpp.
References HIDPI_GL_CANVAS::m_scale_factor.
Referenced by KIGFX::OPENGL_GAL::beginDrawing(), KIGFX::OPENGL_GAL::DrawGrid(), HIDPI_GL_CANVAS::GetNativePixelSize(), KIGFX::OPENGL_GAL::getScreenPixelSize(), KIGFX::OPENGL_GAL::ResizeScreen(), KIGFX::PREVIEW::SetConstantGlyphHeight(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().
|
private |
Definition at line 177 of file 3d_model_viewer.cpp.
References RANGE_SCALE_3D.
Referenced by OnPaint().
|
private |
|
private |
Definition at line 352 of file 3d_model_viewer.cpp.
References m_logTrace.
|
private |
Definition at line 413 of file 3d_model_viewer.cpp.
|
private |
Definition at line 419 of file 3d_model_viewer.cpp.
|
private |
Definition at line 425 of file 3d_model_viewer.cpp.
|
private |
Definition at line 431 of file 3d_model_viewer.cpp.
|
private |
Definition at line 396 of file 3d_model_viewer.cpp.
References TRACK_BALL::Drag(), m_trackBallCamera, Refresh(), CAMERA::SetCurMousePosition(), and CAMERA::SetCurWindowSize().
|
private |
Definition at line 359 of file 3d_model_viewer.cpp.
References m_logTrace, m_trackBallCamera, Refresh(), CAMERA::SetCurMousePosition(), and CAMERA::Zoom().
|
private |
Definition at line 221 of file 3d_model_viewer.cpp.
References MODEL_3D::BeginDrawMulti(), GL_CONTEXT_MANAGER::CreateCtx(), MODEL_3D::DrawOpaque(), DrawRoundArrow(), MODEL_3D::DrawTransparent(), MODEL_3D::EndDrawMulti(), GL_CONTEXT_MANAGER::Get(), MODEL_3D::GetBBox(), BBOX_3D::GetCenter(), BBOX_3D::GetMaxDimension(), CAMERA::GetProjectionMatrix(), CAMERA::GetRotationMatrix(), CAMERA::GetViewMatrix(), GL_CONTEXT_MANAGER::LockCtx(), m_3d_model, m_BiuTo3dUnits, m_glRC, m_logTrace, m_ogl_3dmodel, m_ogl_initialized, m_reload_is_needed, m_trackBallCamera, NORMAL, ogl_initialize(), ogl_set_arrow_material(), RANGE_SCALE_3D, CAMERA::SetCurWindowSize(), UNITS3D_TO_UNITSPCB, and GL_CONTEXT_MANAGER::UnlockCtx().
|
private |
Definition at line 437 of file 3d_model_viewer.cpp.
void C3D_MODEL_VIEWER::Set3DModel | ( | const S3DMODEL & | a3DModel | ) |
Set this model to be displayed.
a3DModel | 3D model data. |
Definition at line 120 of file 3d_model_viewer.cpp.
References m_3d_model, m_logTrace, S3DMODEL::m_Materials, S3DMODEL::m_MaterialsSize, S3DMODEL::m_Meshes, S3DMODEL::m_MeshesSize, m_ogl_3dmodel, m_reload_is_needed, and Refresh().
Referenced by DLG_SELECT_3DMODEL::OnFileActivated(), DLG_SELECT_3DMODEL::OnSelectionChanged(), and Set3DModel().
void C3D_MODEL_VIEWER::Set3DModel | ( | wxString const & | aModelPathName | ) |
Set this model to be displayed.
aModelPathName | 3D model path name. |
Definition at line 147 of file 3d_model_viewer.cpp.
References Clear3DModel(), S3D_CACHE::GetModel(), m_cacheManager, m_logTrace, and Set3DModel().
|
inherited |
Set the canvas scale factor, probably for a hi-DPI display.
Definition at line 58 of file hidpi_gl_canvas.cpp.
References HIDPI_GL_CANVAS::m_scale_factor.
Referenced by PANEL_PREV_3D::loadCommonSettings(), EDA_3D_VIEWER::loadCommonSettings(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().
|
private |
Original 3d model data.
Definition at line 113 of file 3d_model_viewer.h.
Referenced by C3D_MODEL_VIEWER(), Clear3DModel(), OnPaint(), and Set3DModel().
|
private |
factor to convert the model or any other items to keep it in relation to the +/-RANGE_SCALE_3D (it is named same as the board render for better understanding proposes)
Definition at line 127 of file 3d_model_viewer.h.
Referenced by C3D_MODEL_VIEWER(), and OnPaint().
|
private |
Optional cache manager.
Definition at line 130 of file 3d_model_viewer.h.
Referenced by Set3DModel().
|
private |
openGL context
Definition at line 107 of file 3d_model_viewer.h.
Referenced by C3D_MODEL_VIEWER(), OnPaint(), and ~C3D_MODEL_VIEWER().
|
private |
Class holder for 3d model to display on openGL.
Definition at line 116 of file 3d_model_viewer.h.
Referenced by C3D_MODEL_VIEWER(), Clear3DModel(), OnPaint(), Set3DModel(), and ~C3D_MODEL_VIEWER().
|
private |
Flag if open gl was initialized.
Definition at line 122 of file 3d_model_viewer.h.
Referenced by C3D_MODEL_VIEWER(), and OnPaint().
|
private |
Flag that we have a new model and it need to be reloaded when the paint is called.
Definition at line 119 of file 3d_model_viewer.h.
Referenced by C3D_MODEL_VIEWER(), Clear3DModel(), OnPaint(), and Set3DModel().
|
private |
Camera used in this canvas.
Definition at line 110 of file 3d_model_viewer.h.
Referenced by OnMouseMove(), OnMouseWheel(), and OnPaint().