KiCad PCB EDA Suite
|
Implement a canvas based on a wxGLCanvas. More...
#include <eda_3d_model_viewer.h>
Public Member Functions | |
EDA_3D_MODEL_VIEWER (wxWindow *aParent, const wxGLAttributes &aGLAttribs, S3D_CACHE *aCacheManager=nullptr) | |
Create a new 3D Canvas with a attribute list. | |
~EDA_3D_MODEL_VIEWER () | |
void | Set3DModel (const S3DMODEL &a3DModel) |
Set this model to be displayed. | |
void | Set3DModel (const wxString &aModelPathName) |
Set this model to be displayed. | |
void | Clear3DModel () |
Unload the displayed 3D model. | |
virtual wxSize | GetNativePixelSize () const |
wxPoint | GetNativePosition (const wxPoint &aPoint) const |
Convert the given point from client coordinates to native pixel coordinates. | |
double | GetScaleFactor () const |
Get the current scale factor. | |
void | SetVcSettings (const KIGFX::VC_SETTINGS &aVcSettings) |
Protected Attributes | |
KIGFX::VC_SETTINGS | m_settings |
< Current VIEW_CONTROLS settings. | |
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 | |
TRACK_BALL | m_trackBallCamera |
Camera used in this canvas. | |
const S3DMODEL * | m_3d_model |
Original 3d model data. | |
MODEL_3D * | m_ogl_3dmodel |
Class holder for 3d model to display on openGL. | |
bool | m_reload_is_needed |
Flag that we have a new model and it need to be reloaded when the paint is called. | |
bool | m_ogl_initialized |
Flag if open gl was initialized. | |
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) | |
S3D_CACHE * | m_cacheManager |
Optional cache manager. | |
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. | |
Implement a canvas based on a wxGLCanvas.
Definition at line 45 of file eda_3d_model_viewer.h.
EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER | ( | wxWindow * | aParent, |
const wxGLAttributes & | aGLAttribs, | ||
S3D_CACHE * | aCacheManager = nullptr |
||
) |
Create a new 3D Canvas with a attribute list.
aParent | the parent creator of this canvas. |
aGLAttribs | openGL attributes created by OGL_ATT_LIST::GetAttributesList. |
Definition at line 89 of file eda_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.
EDA_3D_MODEL_VIEWER::~EDA_3D_MODEL_VIEWER | ( | ) |
Definition at line 109 of file eda_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 EDA_3D_MODEL_VIEWER::Clear3DModel | ( | ) |
Unload the displayed 3D model.
Definition at line 169 of file eda_3d_model_viewer.cpp.
References m_3d_model, m_ogl_3dmodel, m_reload_is_needed, and Refresh().
Referenced by Set3DModel().
|
virtualinherited |
Definition at line 42 of file hidpi_gl_canvas.cpp.
References HIDPI_GL_CANVAS::GetScaleFactor().
Referenced by EDA_3D_CANVAS::DoRePaint(), OnMouseMove(), HIDPI_GL_3D_CANVAS::OnMouseMoveCamera(), OnPaint(), and KIGFX::OPENGL_GAL::OPENGL_GAL().
|
inherited |
Convert the given point from client coordinates to native pixel coordinates.
Definition at line 54 of file hidpi_gl_canvas.cpp.
References HIDPI_GL_CANVAS::GetScaleFactor().
Referenced by OnMouseMove(), HIDPI_GL_3D_CANVAS::OnMouseMoveCamera(), and HIDPI_GL_3D_CANVAS::OnMouseWheelCamera().
|
inherited |
Get the current scale factor.
Definition at line 66 of file hidpi_gl_canvas.cpp.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::PREVIEW::GetConstantGlyphHeight(), HIDPI_GL_CANVAS::GetNativePixelSize(), HIDPI_GL_CANVAS::GetNativePosition(), KIGFX::OPENGL_GAL::getScreenPixelSize(), and KIGFX::OPENGL_GAL::ResizeScreen().
|
private |
Definition at line 183 of file eda_3d_model_viewer.cpp.
References From_UTF8(), m_logTrace, RANGE_SCALE_3D, and SetOpenGLInfo().
Referenced by OnPaint().
|
private |
Definition at line 232 of file eda_3d_model_viewer.cpp.
Referenced by OnPaint().
|
private |
Definition at line 390 of file eda_3d_model_viewer.cpp.
References m_logTrace.
|
private |
Definition at line 454 of file eda_3d_model_viewer.cpp.
|
private |
Definition at line 460 of file eda_3d_model_viewer.cpp.
|
private |
Definition at line 466 of file eda_3d_model_viewer.cpp.
|
private |
Definition at line 472 of file eda_3d_model_viewer.cpp.
|
private |
Definition at line 434 of file eda_3d_model_viewer.cpp.
References TRACK_BALL::Drag(), HIDPI_GL_CANVAS::GetNativePixelSize(), HIDPI_GL_CANVAS::GetNativePosition(), m_trackBallCamera, Refresh(), CAMERA::SetCurMousePosition(), and CAMERA::SetCurWindowSize().
|
private |
Definition at line 397 of file eda_3d_model_viewer.cpp.
References m_logTrace, m_trackBallCamera, Refresh(), CAMERA::SetCurMousePosition(), and CAMERA::Zoom().
|
private |
Definition at line 244 of file eda_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(), HIDPI_GL_CANVAS::GetNativePixelSize(), 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, ogl_initialize(), ogl_set_arrow_material(), RANGE_SCALE_3D, CAMERA::SetCurWindowSize(), UNITS3D_TO_UNITSPCB, and GL_CONTEXT_MANAGER::UnlockCtx().
|
private |
Definition at line 478 of file eda_3d_model_viewer.cpp.
void EDA_3D_MODEL_VIEWER::Set3DModel | ( | const S3DMODEL & | a3DModel | ) |
Set this model to be displayed.
a3DModel | 3D model data. |
Definition at line 126 of file eda_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 DIALOG_SELECT_3DMODEL::OnFileActivated(), DIALOG_SELECT_3DMODEL::OnSelectionChanged(), and Set3DModel().
void EDA_3D_MODEL_VIEWER::Set3DModel | ( | const wxString & | aModelPathName | ) |
Set this model to be displayed.
N.B. This will not load a model from the internal cache. Only from on disk.
aModelPathName | 3D model path name. Must be a file on disk. |
Definition at line 153 of file eda_3d_model_viewer.cpp.
References Clear3DModel(), S3D_CACHE::GetModel(), m_cacheManager, m_logTrace, and Set3DModel().
|
inlineinherited |
Definition at line 62 of file hidpi_gl_canvas.h.
Referenced by EDA_3D_VIEWER_FRAME::applySettings().
|
private |
Original 3d model data.
Definition at line 115 of file eda_3d_model_viewer.h.
Referenced by Clear3DModel(), EDA_3D_MODEL_VIEWER(), 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 129 of file eda_3d_model_viewer.h.
Referenced by EDA_3D_MODEL_VIEWER(), and OnPaint().
|
private |
Optional cache manager.
Definition at line 132 of file eda_3d_model_viewer.h.
Referenced by Set3DModel().
|
private |
openGL context
Definition at line 109 of file eda_3d_model_viewer.h.
Referenced by EDA_3D_MODEL_VIEWER(), OnPaint(), and ~EDA_3D_MODEL_VIEWER().
|
private |
Class holder for 3d model to display on openGL.
Definition at line 118 of file eda_3d_model_viewer.h.
Referenced by Clear3DModel(), EDA_3D_MODEL_VIEWER(), OnPaint(), Set3DModel(), and ~EDA_3D_MODEL_VIEWER().
|
private |
Flag if open gl was initialized.
Definition at line 124 of file eda_3d_model_viewer.h.
Referenced by EDA_3D_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 121 of file eda_3d_model_viewer.h.
Referenced by Clear3DModel(), EDA_3D_MODEL_VIEWER(), OnPaint(), and Set3DModel().
|
protectedinherited |
< Current VIEW_CONTROLS settings.
Definition at line 66 of file hidpi_gl_canvas.h.
Referenced by HIDPI_GL_3D_CANVAS::OnMouseWheelCamera().
|
private |
Camera used in this canvas.
Definition at line 112 of file eda_3d_model_viewer.h.
Referenced by OnMouseMove(), OnMouseWheel(), and OnPaint().