v2.0.0
Loading...
Searching...
No Matches
cameracontroller.h
Go to the documentation of this file.
1//=============================================================================================================
24
25#ifndef CAMERACONTROLLER_H
26#define CAMERACONTROLLER_H
27
28//=============================================================================================================
29// INCLUDES
30//=============================================================================================================
31
32#include "../disp3D_global.h"
33
34#include "core/viewstate.h"
35
36#include <QMatrix4x4>
37#include <QQuaternion>
38#include <QVector3D>
39#include <QVector2D>
40#include <QPoint>
41#include <QSize>
42
43namespace DISP3DLIB
44{
45
46//=============================================================================================================
54{
55 QMatrix4x4 projection;
56 QMatrix4x4 view;
57 QMatrix4x4 model;
58 QVector3D cameraPos;
59 QVector3D upVector;
60 QVector3D lookAt;
61 float distance = 0.0f;
62};
63
64//=============================================================================================================
75{
76public:
77 //=========================================================================================================
81 CameraController() = default;
82
83 // ── Scene geometry ─────────────────────────────────────────────────
84
90 void setSceneCenter(const QVector3D& center)
91 {
92 m_sceneCenter = center;
93 }
94
100 void setSceneSize(float size)
101 {
102 m_sceneSize = (size > 0.01f) ? size : 0.3f;
103 }
104
105 QVector3D sceneCenter() const
106 {
107 return m_sceneCenter;
108 }
109 float sceneSize() const
110 {
111 return m_sceneSize;
112 }
113
114 // ── Single-view camera state ───────────────────────────────────────
115
121 void setRotation(const QQuaternion& q)
122 {
123 m_cameraRotation = q;
124 }
125 QQuaternion rotation() const
126 {
127 return m_cameraRotation;
128 }
129
135 void setZoom(float z)
136 {
137 m_zoom = z;
138 }
139 float zoom() const
140 {
141 return m_zoom;
142 }
143
146 {
147 m_cameraRotation = QQuaternion();
148 }
149
150 // ── Matrix computation ─────────────────────────────────────────────
151
158 CameraResult computeSingleView(float aspectRatio) const;
159
167 CameraResult computeMultiView(const SubView& subView, float aspectRatio) const;
168
169 // ── Mouse interaction ──────────────────────────────────────────────
170
178 static void applyMouseRotation(const QPoint& delta,
179 QQuaternion& rotation,
180 float speed = 0.5f);
181
189 static void applyMousePan(const QPoint& delta,
190 QVector2D& pan,
191 float sceneSize);
192
193private:
194 CameraResult computeForRotation(const QQuaternion& effectiveRotation,
195 float zoom,
196 const QVector2D& pan,
197 bool applyPan,
198 float aspectRatio) const;
199
200 QQuaternion m_cameraRotation;
201 QVector3D m_sceneCenter = QVector3D(0, 0, 0);
202 float m_sceneSize = 0.3f;
203 float m_zoom = 0.0f;
204};
205
206} // namespace DISP3DLIB
207
208#endif // CAMERACONTROLLER_H
Library export/import macros and namespace marker for the disp3D library.
#define DISP3DSHARED_EXPORT
Per-viewport state (camera preset, zoom, pan, visibility filter) and serialisation helpers.
3-D brain visualisation using the Qt RHI rendering backend.
Viewport subdivision holding its own camera, projection, and scissor rectangle.
Definition viewstate.h:143
Computed camera matrices (projection, view, model) and vectors for a single viewport.
void setSceneCenter(const QVector3D &center)
void setRotation(const QQuaternion &q)