2017-07-19 14:20:32 -07:00
|
|
|
#pragma once
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2013-08-09 04:57:18 +00:00
|
|
|
#include "lc_glwidget.h"
|
2014-05-03 21:16:48 +00:00
|
|
|
#include "camera.h"
|
2017-04-01 16:53:54 -07:00
|
|
|
#include "lc_scene.h"
|
2018-10-28 17:59:01 -07:00
|
|
|
#include "lc_viewsphere.h"
|
2018-08-19 20:27:58 -07:00
|
|
|
#include "lc_commands.h"
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2020-02-15 11:36:06 -08:00
|
|
|
enum class lcTrackButton
|
2014-05-17 23:03:05 +00:00
|
|
|
{
|
2020-02-15 11:36:06 -08:00
|
|
|
None,
|
|
|
|
Left,
|
|
|
|
Middle,
|
|
|
|
Right
|
2014-05-17 23:03:05 +00:00
|
|
|
};
|
|
|
|
|
2020-12-04 16:06:39 -08:00
|
|
|
enum class lcTrackTool
|
2014-05-17 23:03:05 +00:00
|
|
|
{
|
2020-12-04 16:06:39 -08:00
|
|
|
None,
|
|
|
|
Insert,
|
|
|
|
PointLight,
|
|
|
|
SpotLight,
|
|
|
|
Camera,
|
|
|
|
Select,
|
|
|
|
MoveX,
|
|
|
|
MoveY,
|
|
|
|
MoveZ,
|
|
|
|
MoveXY,
|
|
|
|
MoveXZ,
|
|
|
|
MoveYZ,
|
|
|
|
MoveXYZ,
|
|
|
|
RotateX,
|
|
|
|
RotateY,
|
|
|
|
RotateZ,
|
|
|
|
RotateXY,
|
|
|
|
RotateXYZ,
|
|
|
|
ScalePlus,
|
|
|
|
ScaleMinus,
|
|
|
|
Eraser,
|
|
|
|
Paint,
|
|
|
|
ColorPicker,
|
|
|
|
Zoom,
|
|
|
|
Pan,
|
|
|
|
OrbitX,
|
|
|
|
OrbitY,
|
|
|
|
OrbitXY,
|
|
|
|
Roll,
|
|
|
|
ZoomRegion,
|
|
|
|
Count
|
2014-05-17 23:03:05 +00:00
|
|
|
};
|
|
|
|
|
2013-08-09 04:57:18 +00:00
|
|
|
class View : public lcGLWidget
|
2011-09-07 21:06:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-12-08 07:32:39 +00:00
|
|
|
View(lcModel* Model);
|
2020-03-22 15:44:41 -07:00
|
|
|
~View();
|
2012-02-05 02:50:57 +00:00
|
|
|
|
2020-05-03 15:39:39 -07:00
|
|
|
View(const View&) = delete;
|
|
|
|
View(View&&) = delete;
|
|
|
|
View& operator=(const View&) = delete;
|
|
|
|
View& operator=(View&&) = delete;
|
|
|
|
|
2018-03-29 10:20:36 -07:00
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
mModel = nullptr;
|
|
|
|
mActiveSubmodelInstance = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcModel* GetModel() const
|
|
|
|
{
|
|
|
|
return mModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcModel* GetActiveModel() const;
|
2018-10-13 16:45:14 -07:00
|
|
|
void SetTopSubmodelActive();
|
2018-03-29 10:20:36 -07:00
|
|
|
void SetSelectedSubmodelActive();
|
|
|
|
|
2015-04-27 00:47:31 +00:00
|
|
|
static void CreateResources(lcContext* Context);
|
|
|
|
static void DestroyResources(lcContext* Context);
|
|
|
|
|
2020-03-22 15:44:41 -07:00
|
|
|
void OnDraw() override;
|
|
|
|
void OnInitialUpdate() override;
|
|
|
|
void OnUpdateCursor() override;
|
|
|
|
void OnLeftButtonDown() override;
|
|
|
|
void OnLeftButtonUp() override;
|
|
|
|
void OnLeftButtonDoubleClick() override;
|
|
|
|
void OnMiddleButtonDown() override;
|
|
|
|
void OnMiddleButtonUp() override;
|
|
|
|
void OnRightButtonDown() override;
|
|
|
|
void OnRightButtonUp() override;
|
|
|
|
void OnBackButtonUp() override;
|
|
|
|
void OnForwardButtonUp() override;
|
|
|
|
void OnMouseMove() override;
|
|
|
|
void OnMouseWheel(float Direction) override;
|
2020-11-14 12:47:55 -08:00
|
|
|
void BeginDrag(lcDragState DragState) override;
|
|
|
|
void EndDrag(bool Accept) override;
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2018-09-11 16:36:10 -07:00
|
|
|
bool IsTracking() const
|
|
|
|
{
|
2020-02-15 11:36:06 -08:00
|
|
|
return mTrackButton != lcTrackButton::None;
|
2018-09-11 16:36:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void StartOrbitTracking();
|
2014-11-29 02:55:58 +00:00
|
|
|
void CancelTrackingOrClearSelection();
|
2014-11-30 17:53:09 +00:00
|
|
|
|
|
|
|
void SetProjection(bool Ortho);
|
|
|
|
void LookAt();
|
2014-11-08 01:05:17 +00:00
|
|
|
void ZoomExtents();
|
2018-01-15 11:35:15 -08:00
|
|
|
void MoveCamera(const lcVector3& Direction);
|
2019-02-09 16:30:11 -08:00
|
|
|
void Zoom(float Amount);
|
2014-05-26 22:58:08 +00:00
|
|
|
|
2014-11-25 00:51:34 +00:00
|
|
|
void RemoveCamera();
|
2014-11-08 01:05:17 +00:00
|
|
|
void SetCamera(lcCamera* Camera, bool ForceCopy);
|
2017-06-20 21:43:39 -07:00
|
|
|
void SetCamera(const char* CameraName);
|
2014-11-25 00:51:34 +00:00
|
|
|
void SetCameraIndex(int Index);
|
2014-11-08 01:05:17 +00:00
|
|
|
void SetViewpoint(lcViewpoint Viewpoint);
|
2018-08-19 20:27:58 -07:00
|
|
|
void SetViewpoint(const lcVector3& Position);
|
2017-12-13 17:36:35 -08:00
|
|
|
void SetCameraAngles(float Latitude, float Longitude);
|
2012-08-20 04:05:56 +00:00
|
|
|
void SetDefaultCamera();
|
2020-02-15 11:36:06 -08:00
|
|
|
lcCursor GetCursor() const;
|
2015-12-04 20:32:10 +00:00
|
|
|
void ShowContextMenu() const;
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2014-11-30 17:53:09 +00:00
|
|
|
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
|
2017-11-12 19:38:07 -08:00
|
|
|
lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const;
|
2019-08-10 12:31:28 -07:00
|
|
|
lcVector3 GetCameraLightInsertPosition() const;
|
2016-03-03 00:04:49 +00:00
|
|
|
void GetRayUnderPointer(lcVector3& Start, lcVector3& End) const;
|
2017-11-12 19:38:07 -08:00
|
|
|
lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const;
|
2014-11-29 02:55:58 +00:00
|
|
|
lcArray<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
|
2014-05-03 16:59:57 +00:00
|
|
|
|
2017-07-30 14:18:57 -07:00
|
|
|
bool BeginRenderToImage(int Width, int Height);
|
|
|
|
void EndRenderToImage();
|
|
|
|
|
|
|
|
QImage GetRenderImage() const
|
|
|
|
{
|
|
|
|
return mRenderImage;
|
|
|
|
}
|
|
|
|
|
2014-05-17 23:03:05 +00:00
|
|
|
protected:
|
2015-04-27 00:47:31 +00:00
|
|
|
static void CreateSelectMoveOverlayMesh(lcContext* Context);
|
|
|
|
|
2014-05-17 23:03:05 +00:00
|
|
|
void DrawSelectMoveOverlay();
|
|
|
|
void DrawRotateOverlay();
|
|
|
|
void DrawSelectZoomRegionOverlay();
|
|
|
|
void DrawRotateViewOverlay();
|
2014-08-23 22:56:59 +00:00
|
|
|
void DrawGrid();
|
2014-05-17 23:03:05 +00:00
|
|
|
void DrawViewport();
|
|
|
|
|
|
|
|
void UpdateTrackTool();
|
2017-12-02 12:22:04 -08:00
|
|
|
bool IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms) const;
|
2014-05-17 23:03:05 +00:00
|
|
|
lcTool GetCurrentTool() const;
|
2016-04-23 00:17:33 +00:00
|
|
|
lcTrackTool GetOverrideTrackTool(Qt::MouseButton Button) const;
|
2014-05-17 23:03:05 +00:00
|
|
|
float GetOverlayScale() const;
|
|
|
|
void StartTracking(lcTrackButton TrackButton);
|
|
|
|
void StopTracking(bool Accept);
|
2016-05-09 01:59:10 +00:00
|
|
|
void OnButtonDown(lcTrackButton TrackButton);
|
2017-08-05 12:02:45 -07:00
|
|
|
lcMatrix44 GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int CurrentTileWidth, int CurrentTileHeight) const;
|
2014-05-17 23:03:05 +00:00
|
|
|
|
2018-03-29 10:20:36 -07:00
|
|
|
lcModel* mModel;
|
|
|
|
lcPiece* mActiveSubmodelInstance;
|
2018-04-07 17:17:32 -07:00
|
|
|
lcMatrix44 mActiveSubmodelTransform;
|
2018-03-29 10:20:36 -07:00
|
|
|
|
2015-02-08 18:54:51 +00:00
|
|
|
lcScene mScene;
|
2014-05-26 22:58:08 +00:00
|
|
|
lcDragState mDragState;
|
2014-05-17 23:03:05 +00:00
|
|
|
lcTrackButton mTrackButton;
|
|
|
|
lcTrackTool mTrackTool;
|
2018-02-06 14:47:11 -08:00
|
|
|
bool mTrackToolFromOverlay;
|
2016-05-19 21:16:31 +00:00
|
|
|
bool mTrackUpdated;
|
2014-05-17 23:03:05 +00:00
|
|
|
int mMouseDownX;
|
|
|
|
int mMouseDownY;
|
2017-11-12 19:38:07 -08:00
|
|
|
lcVector3 mMouseDownPosition;
|
|
|
|
PieceInfo* mMouseDownPiece;
|
2017-07-30 14:18:57 -07:00
|
|
|
QImage mRenderImage;
|
2017-12-29 06:50:18 -08:00
|
|
|
std::pair<lcFramebuffer, lcFramebuffer> mRenderFramebuffer;
|
2018-10-28 17:59:01 -07:00
|
|
|
lcViewSphere mViewSphere;
|
2015-04-14 04:14:10 +00:00
|
|
|
|
2015-04-26 18:14:33 +00:00
|
|
|
lcVertexBuffer mGridBuffer;
|
2015-04-14 04:14:10 +00:00
|
|
|
int mGridSettings[7];
|
2015-04-27 00:47:31 +00:00
|
|
|
|
|
|
|
static lcVertexBuffer mRotateMoveVertexBuffer;
|
|
|
|
static lcIndexBuffer mRotateMoveIndexBuffer;
|
2011-09-07 21:06:51 +00:00
|
|
|
};
|
|
|
|
|