diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 37b7ec68..72801c5c 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -9,6 +9,7 @@ #include "lc_partselectionwidget.h" #include "lc_shortcuts.h" #include "view.h" +#include "camera.h" #include "lc_previewwidget.h" lcApplication* gApplication; diff --git a/common/lc_global.h b/common/lc_global.h index 260c347f..efa3f762 100644 --- a/common/lc_global.h +++ b/common/lc_global.h @@ -80,8 +80,10 @@ class lcContext; class lcMesh; struct lcMeshSection; struct lcRenderMesh; +struct lcObjectSection; class lcTexture; class lcScene; +class lcViewSphere; enum class lcRenderMeshState : int; class lcFile; diff --git a/common/lc_glwidget.cpp b/common/lc_glwidget.cpp index cc4805f0..f385e362 100644 --- a/common/lc_glwidget.cpp +++ b/common/lc_glwidget.cpp @@ -8,6 +8,7 @@ #include "texfont.h" #include "lc_model.h" #include "lc_scene.h" +#include "lc_viewsphere.h" lcGLWidget* lcGLWidget::mLastFocusedView; std::vector lcGLWidget::mViews; diff --git a/common/lc_glwidget.h b/common/lc_glwidget.h index 44daf3e6..9efbce08 100644 --- a/common/lc_glwidget.h +++ b/common/lc_glwidget.h @@ -218,6 +218,7 @@ protected: lcCursor mCursor = lcCursor::Default; std::unique_ptr mScene; + std::unique_ptr mViewSphere; lcModel* mModel = nullptr; lcPiece* mActiveSubmodelInstance = nullptr; diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index c9f613b4..0a39e13f 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -19,6 +19,7 @@ #include "view.h" #include "project.h" #include "piece.h" +#include "camera.h" #include "group.h" #include "pieceinf.h" #include "lc_library.h" diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index 6ec20bc4..fad59687 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -6,6 +6,7 @@ #include "lc_model.h" #include "camera.h" #include "lc_library.h" +#include "lc_viewsphere.h" #include "lc_qglwidget.h" @@ -80,8 +81,9 @@ void lcPreviewDockWidget::SetPreviewLock() } lcPreviewWidget::lcPreviewWidget() - : lcGLWidget(nullptr), mLoader(new Project(true)), mViewSphere(this) + : lcGLWidget(nullptr), mLoader(new Project(true)) { + mViewSphere = std::unique_ptr(new lcViewSphere(this)); mLoader->SetActiveModel(0); mModel = mLoader->GetActiveModel(); @@ -286,7 +288,7 @@ void lcPreviewWidget::OnDraw() DrawAxes(); if (Preferences.mDrawPreviewViewSphere) - mViewSphere.Draw(); + mViewSphere->Draw(); DrawViewport(); } @@ -301,7 +303,7 @@ void lcPreviewWidget::OnLeftButtonDown() return; } - if (mViewSphere.OnLeftButtonDown()) + if (mViewSphere->OnLeftButtonDown()) return; lcTrackTool OverrideTool = lcTrackTool::OrbitXY; @@ -319,7 +321,8 @@ void lcPreviewWidget::OnLeftButtonUp() { StopTracking(mTrackButton == lcTrackButton::Left); - if (mViewSphere.OnLeftButtonUp()) { + if (mViewSphere->OnLeftButtonUp()) + { ZoomExtents(); return; } @@ -390,9 +393,9 @@ void lcPreviewWidget::OnMouseMove() if (mTrackButton == lcTrackButton::None) { - if (mViewSphere.OnMouseMove()) + if (mViewSphere->OnMouseMove()) { - lcTrackTool NewTrackTool = mViewSphere.IsDragging() ? lcTrackTool::OrbitXY : lcTrackTool::None; + lcTrackTool NewTrackTool = mViewSphere->IsDragging() ? lcTrackTool::OrbitXY : lcTrackTool::None; if (NewTrackTool != mTrackTool) { diff --git a/common/lc_previewwidget.h b/common/lc_previewwidget.h index 187fd86e..4e3b0b3f 100644 --- a/common/lc_previewwidget.h +++ b/common/lc_previewwidget.h @@ -2,7 +2,6 @@ #include "lc_glwidget.h" #include "lc_scene.h" -#include "lc_viewsphere.h" #include "lc_commands.h" class lcQGLWidget; @@ -66,7 +65,6 @@ protected: void OnButtonDown(lcTrackButton TrackButton); Project* mLoader; - lcViewSphere mViewSphere; QString mDescription; bool mIsModel; diff --git a/common/lc_viewsphere.cpp b/common/lc_viewsphere.cpp index 69244be3..0fc05e89 100644 --- a/common/lc_viewsphere.cpp +++ b/common/lc_viewsphere.cpp @@ -2,7 +2,7 @@ #include "lc_viewsphere.h" #include "view.h" #include "lc_previewwidget.h" - +#include "camera.h" #include "lc_context.h" #include "lc_stringcache.h" #include "lc_application.h" diff --git a/common/view.cpp b/common/view.cpp index a565d24a..9b1bb355 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -9,13 +9,16 @@ #include "pieceinf.h" #include "lc_synth.h" #include "lc_scene.h" +#include "lc_context.h" +#include "lc_viewsphere.h" lcVertexBuffer View::mRotateMoveVertexBuffer; lcIndexBuffer View::mRotateMoveIndexBuffer; View::View(lcModel* Model) - : lcGLWidget(Model), mViewSphere(this) + : lcGLWidget(Model) { + mViewSphere = std::unique_ptr(new lcViewSphere(this)); memset(mGridSettings, 0, sizeof(mGridSettings)); mDragState = lcDragState::None; @@ -731,7 +734,7 @@ void View::OnDraw() else if (Tool == lcTool::RotateView && mTrackButton == lcTrackButton::None) DrawRotateViewOverlay(); - mViewSphere.Draw(); + mViewSphere->Draw(); DrawViewport(); } @@ -2425,7 +2428,7 @@ void View::OnLeftButtonDown() return; } - if (mViewSphere.OnLeftButtonDown()) + if (mViewSphere->OnLeftButtonDown()) return; lcTrackTool OverrideTool = GetOverrideTrackTool(Qt::LeftButton); @@ -2443,7 +2446,7 @@ void View::OnLeftButtonUp() { StopTracking(mTrackButton == lcTrackButton::Left); - if (mViewSphere.OnLeftButtonUp()) + if (mViewSphere->OnLeftButtonUp()) return; } @@ -2534,9 +2537,9 @@ void View::OnMouseMove() if (mTrackButton == lcTrackButton::None) { - if (mViewSphere.OnMouseMove()) + if (mViewSphere->OnMouseMove()) { - lcTrackTool NewTrackTool = mViewSphere.IsDragging() ? lcTrackTool::OrbitXY : lcTrackTool::None; + lcTrackTool NewTrackTool = mViewSphere->IsDragging() ? lcTrackTool::OrbitXY : lcTrackTool::None; if (NewTrackTool != mTrackTool) { diff --git a/common/view.h b/common/view.h index f7c54cf9..9b692bd8 100644 --- a/common/view.h +++ b/common/view.h @@ -1,8 +1,7 @@ #pragma once #include "lc_glwidget.h" -#include "camera.h" -#include "lc_viewsphere.h" +#include "lc_context.h" class View : public lcGLWidget { @@ -95,7 +94,6 @@ protected: PieceInfo* mMouseDownPiece; QImage mRenderImage; std::pair mRenderFramebuffer; - lcViewSphere mViewSphere; lcVertexBuffer mGridBuffer; int mGridSettings[7];