mirror of
https://github.com/leozide/leocad
synced 2024-11-16 07:47:27 +01:00
Moved view manipulator to a separate class.
This commit is contained in:
parent
bd12ad5842
commit
c236ea02bb
7 changed files with 1126 additions and 1036 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include "texfont.h"
|
#include "texfont.h"
|
||||||
#include "lc_view.h"
|
#include "lc_view.h"
|
||||||
#include "lc_viewsphere.h"
|
#include "lc_viewsphere.h"
|
||||||
|
#include "lc_viewmanipulator.h"
|
||||||
#include "lc_stringcache.h"
|
#include "lc_stringcache.h"
|
||||||
#include "lc_partselectionwidget.h"
|
#include "lc_partselectionwidget.h"
|
||||||
#include <QOpenGLFunctions_3_2_Core>
|
#include <QOpenGLFunctions_3_2_Core>
|
||||||
|
@ -94,6 +95,7 @@ bool lcContext::InitializeRenderer()
|
||||||
|
|
||||||
Context->CreateResources();
|
Context->CreateResources();
|
||||||
lcView::CreateResources(Context);
|
lcView::CreateResources(Context);
|
||||||
|
lcViewManipulator::CreateResources(Context);
|
||||||
lcViewSphere::CreateResources(Context);
|
lcViewSphere::CreateResources(Context);
|
||||||
|
|
||||||
if (!gSupportsShaderObjects && lcGetPreferences().mShadingMode == lcShadingMode::DefaultLights)
|
if (!gSupportsShaderObjects && lcGetPreferences().mShadingMode == lcShadingMode::DefaultLights)
|
||||||
|
@ -121,6 +123,7 @@ void lcContext::ShutdownRenderer()
|
||||||
|
|
||||||
lcView::DestroyResources(Context);
|
lcView::DestroyResources(Context);
|
||||||
Context->DestroyResources();
|
Context->DestroyResources();
|
||||||
|
lcViewManipulator::DestroyResources(Context);
|
||||||
lcViewSphere::DestroyResources(Context);
|
lcViewSphere::DestroyResources(Context);
|
||||||
|
|
||||||
mGlobalOffscreenContext.reset();
|
mGlobalOffscreenContext.reset();
|
||||||
|
|
|
@ -97,8 +97,11 @@ struct lcRenderMesh;
|
||||||
struct lcObjectSection;
|
struct lcObjectSection;
|
||||||
class lcTexture;
|
class lcTexture;
|
||||||
class lcScene;
|
class lcScene;
|
||||||
|
class lcViewManipulator;
|
||||||
class lcViewSphere;
|
class lcViewSphere;
|
||||||
enum class lcRenderMeshState : int;
|
enum class lcRenderMeshState : int;
|
||||||
|
enum class lcTrackTool;
|
||||||
|
enum class lcTrackButton;
|
||||||
|
|
||||||
class lcFile;
|
class lcFile;
|
||||||
class lcMemFile;
|
class lcMemFile;
|
||||||
|
|
1038
common/lc_view.cpp
1038
common/lc_view.cpp
File diff suppressed because it is too large
Load diff
|
@ -182,6 +182,11 @@ public:
|
||||||
mBackgroundColor = BackgroundColor;
|
mBackgroundColor = BackgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lcMatrix44 GetActiveSubmodelTransform() const
|
||||||
|
{
|
||||||
|
return mActiveSubmodelTransform;
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<lcView*> GetModelViews(const lcModel* Model);
|
static std::vector<lcView*> GetModelViews(const lcModel* Model);
|
||||||
static void UpdateProjectViews(const Project* Project);
|
static void UpdateProjectViews(const Project* Project);
|
||||||
static void UpdateAllViews();
|
static void UpdateAllViews();
|
||||||
|
@ -243,6 +248,7 @@ public:
|
||||||
bool CloseFindReplaceDialog();
|
bool CloseFindReplaceDialog();
|
||||||
void ShowFindReplaceWidget(bool Replace);
|
void ShowFindReplaceWidget(bool Replace);
|
||||||
|
|
||||||
|
float GetOverlayScale() const;
|
||||||
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
|
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
|
||||||
lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const;
|
lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const;
|
||||||
lcVector3 GetCameraLightInsertPosition() const;
|
lcVector3 GetCameraLightInsertPosition() const;
|
||||||
|
@ -250,6 +256,11 @@ public:
|
||||||
lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const;
|
lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const;
|
||||||
lcArray<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
|
lcArray<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
|
||||||
|
|
||||||
|
lcVector3 ProjectPoint(const lcVector3& Point) const;
|
||||||
|
lcVector3 UnprojectPoint(const lcVector3& Point) const;
|
||||||
|
void UnprojectPoints(lcVector3* Points, int NumPoints) const;
|
||||||
|
lcMatrix44 GetProjectionMatrix() const;
|
||||||
|
|
||||||
bool BeginRenderToImage(int Width, int Height);
|
bool BeginRenderToImage(int Width, int Height);
|
||||||
void EndRenderToImage();
|
void EndRenderToImage();
|
||||||
QImage GetRenderImage() const;
|
QImage GetRenderImage() const;
|
||||||
|
@ -266,31 +277,21 @@ signals:
|
||||||
void CameraChanged();
|
void CameraChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void CreateSelectMoveOverlayMesh(lcContext* Context);
|
|
||||||
|
|
||||||
void DrawBackground() const;
|
void DrawBackground() const;
|
||||||
void DrawViewport() const;
|
void DrawViewport() const;
|
||||||
void DrawAxes() const;
|
void DrawAxes() const;
|
||||||
|
|
||||||
void DrawSelectMoveOverlay();
|
|
||||||
void DrawRotateOverlay();
|
|
||||||
void DrawSelectZoomRegionOverlay();
|
void DrawSelectZoomRegionOverlay();
|
||||||
void DrawRotateViewOverlay();
|
void DrawRotateViewOverlay();
|
||||||
void DrawGrid();
|
void DrawGrid();
|
||||||
|
|
||||||
lcVector3 ProjectPoint(const lcVector3& Point) const;
|
|
||||||
lcVector3 UnprojectPoint(const lcVector3& Point) const;
|
|
||||||
void UnprojectPoints(lcVector3* Points, int NumPoints) const;
|
|
||||||
lcMatrix44 GetProjectionMatrix() const;
|
|
||||||
lcMatrix44 GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int CurrentTileWidth, int CurrentTileHeight) const;
|
lcMatrix44 GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int CurrentTileWidth, int CurrentTileHeight) const;
|
||||||
|
|
||||||
lcCursor GetCursor() const;
|
lcCursor GetCursor() const;
|
||||||
void SetCursor(lcCursor Cursor);
|
void SetCursor(lcCursor Cursor);
|
||||||
lcTool GetCurrentTool() const;
|
lcTool GetCurrentTool() const;
|
||||||
void UpdateTrackTool();
|
void UpdateTrackTool();
|
||||||
bool IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms) const;
|
|
||||||
lcTrackTool GetOverrideTrackTool(Qt::MouseButton Button) const;
|
lcTrackTool GetOverrideTrackTool(Qt::MouseButton Button) const;
|
||||||
float GetOverlayScale() const;
|
|
||||||
void StartTracking(lcTrackButton TrackButton);
|
void StartTracking(lcTrackButton TrackButton);
|
||||||
void StopTracking(bool Accept);
|
void StopTracking(bool Accept);
|
||||||
void OnButtonDown(lcTrackButton TrackButton);
|
void OnButtonDown(lcTrackButton TrackButton);
|
||||||
|
@ -324,6 +325,7 @@ protected:
|
||||||
quint32 mBackgroundColor = 0;
|
quint32 mBackgroundColor = 0;
|
||||||
|
|
||||||
std::unique_ptr<lcScene> mScene;
|
std::unique_ptr<lcScene> mScene;
|
||||||
|
std::unique_ptr<lcViewManipulator> mViewManipulator;
|
||||||
std::unique_ptr<lcViewSphere> mViewSphere;
|
std::unique_ptr<lcViewSphere> mViewSphere;
|
||||||
|
|
||||||
lcModel* mModel = nullptr;
|
lcModel* mModel = nullptr;
|
||||||
|
@ -340,7 +342,4 @@ protected:
|
||||||
|
|
||||||
static lcView* mLastFocusedView;
|
static lcView* mLastFocusedView;
|
||||||
static std::vector<lcView*> mViews;
|
static std::vector<lcView*> mViews;
|
||||||
|
|
||||||
static lcVertexBuffer mRotateMoveVertexBuffer;
|
|
||||||
static lcIndexBuffer mRotateMoveIndexBuffer;
|
|
||||||
};
|
};
|
||||||
|
|
1065
common/lc_viewmanipulator.cpp
Normal file
1065
common/lc_viewmanipulator.cpp
Normal file
File diff suppressed because it is too large
Load diff
26
common/lc_viewmanipulator.h
Normal file
26
common/lc_viewmanipulator.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lc_context.h"
|
||||||
|
|
||||||
|
class lcViewManipulator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
lcViewManipulator(lcView* View);
|
||||||
|
|
||||||
|
void DrawSelectMove(lcTrackButton TrackButton, lcTrackTool TrackTool);
|
||||||
|
void DrawRotate(lcTrackButton TrackButton, lcTrackTool TrackTool);
|
||||||
|
|
||||||
|
lcTrackTool UpdateSelectMove();
|
||||||
|
lcTrackTool UpdateRotate();
|
||||||
|
|
||||||
|
static void CreateResources(lcContext* Context);
|
||||||
|
static void DestroyResources(lcContext* Context);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static bool IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms);
|
||||||
|
|
||||||
|
lcView* mView = nullptr;
|
||||||
|
|
||||||
|
static lcVertexBuffer mRotateMoveVertexBuffer;
|
||||||
|
static lcIndexBuffer mRotateMoveIndexBuffer;
|
||||||
|
};
|
|
@ -197,6 +197,7 @@ SOURCES += \
|
||||||
common/lc_texture.cpp \
|
common/lc_texture.cpp \
|
||||||
common/lc_timelinewidget.cpp \
|
common/lc_timelinewidget.cpp \
|
||||||
common/lc_view.cpp \
|
common/lc_view.cpp \
|
||||||
|
common/lc_viewsmanipulator.cpp \
|
||||||
common/lc_viewsphere.cpp \
|
common/lc_viewsphere.cpp \
|
||||||
common/lc_viewwidget.cpp \
|
common/lc_viewwidget.cpp \
|
||||||
common/lc_zipfile.cpp \
|
common/lc_zipfile.cpp \
|
||||||
|
@ -265,6 +266,7 @@ HEADERS += \
|
||||||
common/lc_synth.h \
|
common/lc_synth.h \
|
||||||
common/lc_texture.h \
|
common/lc_texture.h \
|
||||||
common/lc_view.h \
|
common/lc_view.h \
|
||||||
|
common/lc_viewsmanipulator.h \
|
||||||
common/lc_viewsphere.h \
|
common/lc_viewsphere.h \
|
||||||
common/lc_viewwidget.h \
|
common/lc_viewwidget.h \
|
||||||
common/lc_zipfile.h \
|
common/lc_zipfile.h \
|
||||||
|
|
Loading…
Reference in a new issue