leocad/common/view.h

116 lines
3.1 KiB
C
Raw Normal View History

#pragma once
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
#include "lc_glwidget.h"
2014-05-03 23:16:48 +02:00
#include "camera.h"
2018-10-29 01:59:01 +01:00
#include "lc_viewsphere.h"
2013-08-09 06:57:18 +02:00
class View : public lcGLWidget
2011-09-07 23:06:51 +02:00
{
public:
View(lcModel* Model);
~View();
2012-02-05 03:50:57 +01:00
2020-05-04 00:39:39 +02:00
View(const View&) = delete;
View(View&&) = delete;
View& operator=(const View&) = delete;
View& operator=(View&&) = delete;
void Clear()
{
mModel = nullptr;
mActiveSubmodelInstance = nullptr;
}
lcModel* GetModel() const
{
return mModel;
}
void SetTopSubmodelActive();
void SetSelectedSubmodelActive();
static void CreateResources(lcContext* Context);
static void DestroyResources(lcContext* Context);
void OnDraw() override;
void OnInitialUpdate() 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 21:47:55 +01:00
void BeginDrag(lcDragState DragState) override;
void EndDrag(bool Accept) override;
2011-09-07 23:06:51 +02:00
void StartOrbitTracking();
2014-11-29 03:55:58 +01:00
void CancelTrackingOrClearSelection();
void SetProjection(bool Ortho);
void LookAt();
2014-11-08 02:05:17 +01:00
void ZoomExtents();
void MoveCamera(const lcVector3& Direction);
void Zoom(float Amount);
2014-05-27 00:58:08 +02:00
void RemoveCamera();
2014-11-08 02:05:17 +01:00
void SetCamera(lcCamera* Camera, bool ForceCopy);
void SetCamera(const char* CameraName);
void SetCameraIndex(int Index);
2014-11-08 02:05:17 +01:00
void SetViewpoint(lcViewpoint Viewpoint);
2018-08-20 05:27:58 +02:00
void SetViewpoint(const lcVector3& Position);
void SetCameraAngles(float Latitude, float Longitude);
2012-08-20 06:05:56 +02:00
void SetDefaultCamera();
2015-12-04 21:32:10 +01:00
void ShowContextMenu() const;
2011-09-07 23:06:51 +02:00
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
2017-11-13 04:38:07 +01:00
lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const;
void GetRayUnderPointer(lcVector3& Start, lcVector3& End) const;
2017-11-13 04:38:07 +01:00
lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const;
2014-11-29 03:55:58 +01:00
lcArray<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
2014-05-03 18:59:57 +02:00
bool BeginRenderToImage(int Width, int Height);
void EndRenderToImage();
QImage GetRenderImage() const
{
return mRenderImage;
}
protected:
static void CreateSelectMoveOverlayMesh(lcContext* Context);
void DrawSelectMoveOverlay();
void DrawRotateOverlay();
void DrawSelectZoomRegionOverlay();
void DrawRotateViewOverlay();
void DrawGrid();
void UpdateTrackTool();
2017-12-02 21:22:04 +01:00
bool IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms) const;
2016-04-23 02:17:33 +02:00
lcTrackTool GetOverrideTrackTool(Qt::MouseButton Button) const;
float GetOverlayScale() const;
void StopTracking(bool Accept);
void OnButtonDown(lcTrackButton TrackButton);
lcMatrix44 GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int CurrentTileWidth, int CurrentTileHeight) const;
2014-05-27 00:58:08 +02:00
lcDragState mDragState;
bool mTrackToolFromOverlay;
2017-11-13 04:38:07 +01:00
lcVector3 mMouseDownPosition;
PieceInfo* mMouseDownPiece;
QImage mRenderImage;
std::pair<lcFramebuffer, lcFramebuffer> mRenderFramebuffer;
2018-10-29 01:59:01 +01:00
lcViewSphere mViewSphere;
2015-04-14 06:14:10 +02:00
lcVertexBuffer mGridBuffer;
2015-04-14 06:14:10 +02:00
int mGridSettings[7];
static lcVertexBuffer mRotateMoveVertexBuffer;
static lcIndexBuffer mRotateMoveIndexBuffer;
2011-09-07 23:06:51 +02:00
};