BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::RealSpace::Canvas Class Reference

Description

Definition at line 34 of file canvas.h.

Inheritance diagram for GUI::RealSpace::Canvas:
[legend]
Collaboration diagram for GUI::RealSpace::Canvas:
[legend]

Public Member Functions

 Canvas ()
 
 ~Canvas () override
 
Cameracam ()
 
void defaultView ()
 
ModelgetModel ()
 
void horizontalCameraTurn (float angle)
 
void setBgColor (QColor const &)
 
void setCamera (Camera *)
 
void setModel (Model *)
 
void setProgram (Program *)
 
void sideView ()
 
void topView ()
 
void verticalCameraTurn (float angle)
 

Private Types

enum  { btnNONE , btnTURN , btnZOOM }
 

Private Member Functions

void cleanup ()
 
void draw (QColor const &, QMatrix4x4 const &, Geometry const &)
 
void initializeGL () override
 
bool isInitialized () const
 
void mouseMoveEvent (QMouseEvent *) override
 
void mousePressEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 
void paintGL () override
 
void releaseBuffer (Geometry const *)
 
void releaseBuffers ()
 
void resizeGL (int, int) override
 
void setCamera (bool full=true)
 
QVector3D unproject (QPoint const &)
 
void wheelEvent (QWheelEvent *) override
 

Private Attributes

float aspectRatio
 
QHash< Geometry const *, Buffer * > buffers
 
Cameracamera
 
float colorBgB
 
float colorBgG
 
float colorBgR
 
int currentZoomLevel
 
QPoint e_last
 
bool m_isInitializedGL
 
QMatrix4x4 matModel
 
QMatrix4x4 matProj
 
Modelmodel
 
QMetaObject::Connection modelUpdated
 
enum GUI::RealSpace::Canvas:: { ... }  mouseButton
 
Programprogram
 
QRect viewport
 

Friends

class Object
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
btnNONE 
btnTURN 
btnZOOM 

Definition at line 76 of file canvas.h.

Constructor & Destructor Documentation

◆ Canvas()

GUI::RealSpace::Canvas::Canvas ( )

Definition at line 53 of file canvas.cpp.

54  : aspectRatio(1)
55  , colorBgR(1)
56  , colorBgG(1)
57  , colorBgB(1)
58  , currentZoomLevel(0)
59  , camera(nullptr)
60  , program(nullptr)
61  , model(nullptr)
62  , m_isInitializedGL(false)
63 {
65 }
Program * program
Definition: canvas.h:83
void releaseBuffer(Geometry const *)
Definition: canvas.cpp:270
void deletingGeometry(Geometry const *)
GeometryStore & geometryStore()
Definition: geometry.cpp:176

References GUI::RealSpace::GeometryStore::deletingGeometry(), GUI::RealSpace::geometryStore(), and releaseBuffer().

Here is the call graph for this function:

◆ ~Canvas()

GUI::RealSpace::Canvas::~Canvas ( )
override

Definition at line 67 of file canvas.cpp.

68 {
69  cleanup();
70 }

References cleanup().

Here is the call graph for this function:

Member Function Documentation

◆ cam()

Camera* GUI::RealSpace::Canvas::cam ( )
inline

Definition at line 59 of file canvas.h.

59 { return camera; }

References camera.

Referenced by GUI::RealSpace::Widget3D::cam(), and RealSpaceCanvas::updateScene().

◆ cleanup()

void GUI::RealSpace::Canvas::cleanup ( )
private

Definition at line 297 of file canvas.cpp.

298 {
299  makeCurrent();
300 
301  releaseBuffers();
302 
303  delete camera;
304  camera = nullptr;
305  delete program;
306  program = nullptr;
307 
308  m_isInitializedGL = false;
309  doneCurrent();
310 }

References camera, m_isInitializedGL, program, and releaseBuffers().

Referenced by ~Canvas(), and initializeGL().

Here is the call graph for this function:

◆ defaultView()

void GUI::RealSpace::Canvas::defaultView ( )

Definition at line 317 of file canvas.cpp.

318 {
319  // Default view
320  if (isInitialized()) {
322  GUI::RealSpace::Vector3D(0, cameraDefaultPosY, cameraDefaultPosZ), // eye
323  GUI::RealSpace::Vector3D(0, 0, 0), // center
325 
326  // Default position of camera for 3D axes and object are the same
327  camera->lookAt3DAxes(defPos);
328  camera->lookAt(defPos);
329  camera->endTransform(true);
330 
331  currentZoomLevel = 0; // reset zoom level to default value
332  update();
333  }
334 }
void endTransform(bool keep)
Definition: camera.cpp:105
void lookAt(const Position &)
camera position for 3D object
Definition: camera.cpp:51
void lookAt3DAxes(const Position &)
camera position for 3D axes
Definition: camera.cpp:58
bool isInitialized() const
Definition: canvas.cpp:312
static Vector3D const _z
Definition: def.h:46

References GUI::RealSpace::Vector3D::_z, camera, currentZoomLevel, GUI::RealSpace::Camera::endTransform(), isInitialized(), GUI::RealSpace::Camera::lookAt(), and GUI::RealSpace::Camera::lookAt3DAxes().

Referenced by GUI::RealSpace::Widget3D::defaultView(), RealSpaceCanvas::defaultView(), and RealSpaceCanvas::showEvent().

Here is the call graph for this function:

◆ draw()

void GUI::RealSpace::Canvas::draw ( QColor const &  color,
QMatrix4x4 const &  mat,
Geometry const &  geo 
)
private

Definition at line 282 of file canvas.cpp.

283 {
284  auto it = buffers.find(&geo);
285  Buffer* buf;
286  if (buffers.end() == it)
287  buffers.insert(&geo, buf = new Buffer(geo)); // created on demand
288  else
289  buf = *it;
290 
291  ASSERT(program);
292  program->set(color);
293  program->set(mat);
294  buf->draw();
295 }
QHash< Geometry const *, Buffer * > buffers
Definition: canvas.h:88
void set(Camera const &)
Definition: program.cpp:77

References buffers, GUI::RealSpace::Buffer::draw(), program, and GUI::RealSpace::Program::set().

Referenced by GUI::RealSpace::Object::draw().

Here is the call graph for this function:

◆ getModel()

Model * GUI::RealSpace::Canvas::getModel ( )

Definition at line 112 of file canvas.cpp.

113 {
114  return model;
115 }

References model.

Referenced by GUI::RealSpace::Widget3D::model().

◆ horizontalCameraTurn()

void GUI::RealSpace::Canvas::horizontalCameraTurn ( float  angle)

Definition at line 391 of file canvas.cpp.

392 {
393  if (isInitialized()) {
394  float theta = angle * static_cast<float>(M_PI / 180.0); // in radians
395 
396  // Horizontal camera turn for 3D axes
397  Camera::Position initial_pos3DAxes = camera->getPos3DAxes();
398 
399  GUI::RealSpace::Vector3D v_eye3DAxes = initial_pos3DAxes.eye; // camera's position vector
400  GUI::RealSpace::Vector3D v_ctr3DAxes = initial_pos3DAxes.ctr;
401  GUI::RealSpace::Vector3D v_up3DAxes = initial_pos3DAxes.up;
402 
403  GUI::RealSpace::Vector3D v_axis3DAxes = v_up3DAxes.normalized(); // normalized rotation axis
404 
405  // Rotating camera's position (eye) about up vector
406  GUI::RealSpace::Vector3D v_rot_eye3DAxes =
407  v_up3DAxes * (1 - std::cos(theta)) * dot(v_axis3DAxes, v_eye3DAxes)
408  + v_eye3DAxes * std::cos(theta) + cross(v_axis3DAxes, v_eye3DAxes) * std::sin(theta);
409 
410  Camera::Position rotated_pos3DAxes(v_rot_eye3DAxes, v_ctr3DAxes, v_up3DAxes);
411 
412  camera->lookAt3DAxes(rotated_pos3DAxes);
413 
414  // Horizontal camera turn for 3D object
415  Camera::Position initial_pos = camera->getPos();
416 
417  GUI::RealSpace::Vector3D v_eye = initial_pos.eye; // camera's position vector
418  GUI::RealSpace::Vector3D v_ctr = initial_pos.ctr;
419  GUI::RealSpace::Vector3D v_up = initial_pos.up;
420 
421  GUI::RealSpace::Vector3D v_axis = v_up.normalized(); // normalized rotation axis
422 
423  // Rotating camera's position (eye) about up vector
424  GUI::RealSpace::Vector3D v_rot_eye = v_up * (1 - std::cos(theta)) * dot(v_axis, v_eye)
425  + v_eye * std::cos(theta)
426  + cross(v_axis, v_eye) * std::sin(theta);
427 
428  Camera::Position rotated_pos(v_rot_eye, v_ctr, v_up);
429 
430  camera->lookAt(rotated_pos);
431 
432  camera->endTransform(true);
433  }
434 }
const Position & getPos() const
Definition: camera.h:50
const Position & getPos3DAxes() const
Definition: camera.h:51
Vector3D cross(const Vector3D &v1, const Vector3D &v2)
Definition: def.cpp:67
float dot(const Vector3D &v1, const Vector3D &v2)
Definition: def.cpp:72
Vector3D normalized() const
Definition: def.cpp:49

References camera, GUI::RealSpace::cross(), GUI::RealSpace::Camera::Position::ctr, GUI::RealSpace::dot(), GUI::RealSpace::Camera::endTransform(), GUI::RealSpace::Camera::Position::eye, GUI::RealSpace::Camera::getPos(), GUI::RealSpace::Camera::getPos3DAxes(), isInitialized(), GUI::RealSpace::Camera::lookAt(), GUI::RealSpace::Camera::lookAt3DAxes(), GUI::RealSpace::Vector3D::normalized(), and GUI::RealSpace::Camera::Position::up.

Referenced by mouseMoveEvent().

Here is the call graph for this function:

◆ initializeGL()

void GUI::RealSpace::Canvas::initializeGL ( )
overrideprivate

Definition at line 128 of file canvas.cpp.

129 {
130  setCamera((camera = new Camera));
131  setProgram((program = new Program));
132 
133  connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &Canvas::cleanup);
134 
135  initializeOpenGLFunctions();
136  glEnable(GL_DEPTH_TEST);
137  glEnable(GL_CULL_FACE);
138  m_isInitializedGL = true;
139 }
void setCamera(Camera *)
Definition: canvas.cpp:80
void setProgram(Program *)
Definition: canvas.cpp:86

References camera, cleanup(), m_isInitializedGL, program, setCamera(), and setProgram().

Here is the call graph for this function:

◆ isInitialized()

bool GUI::RealSpace::Canvas::isInitialized ( ) const
private

Definition at line 312 of file canvas.cpp.

313 {
314  return m_isInitializedGL && model != nullptr;
315 }

References m_isInitializedGL, and model.

Referenced by defaultView(), horizontalCameraTurn(), sideView(), topView(), and verticalCameraTurn().

◆ mouseMoveEvent()

void GUI::RealSpace::Canvas::mouseMoveEvent ( QMouseEvent *  e)
overrideprivate

Definition at line 214 of file canvas.cpp.

215 {
216  if (camera) {
217  float delta_x = e->pos().x() - e_last.x();
218  float delta_y = e->pos().y() - e_last.y();
219 
220  switch (mouseButton) {
221  case btnTURN: {
222  if (delta_x != 0)
223  horizontalCameraTurn(-delta_x * rot_speed_h); // -ve for consistency with Blender
224 
225  if (delta_y != 0)
226  verticalCameraTurn(-delta_y * rot_speed_v); // -ve for consistency with Blender
227 
228  e_last = e->pos();
229  break;
230  }
231  case btnZOOM: {
232  float d = (e->y() - e_last.y()) / float(viewport.height());
233  camera->zoomBy(1 + d);
234  break;
235  }
236  default:
237  break;
238  }
239 
240  update();
241  }
242 }
void zoomBy(float)
Definition: camera.cpp:99
void verticalCameraTurn(float angle)
Definition: canvas.cpp:436
void horizontalCameraTurn(float angle)
Definition: canvas.cpp:391

References btnTURN, btnZOOM, camera, e_last, horizontalCameraTurn(), mouseButton, verticalCameraTurn(), viewport, and GUI::RealSpace::Camera::zoomBy().

Here is the call graph for this function:

◆ mousePressEvent()

void GUI::RealSpace::Canvas::mousePressEvent ( QMouseEvent *  e)
overrideprivate

Definition at line 193 of file canvas.cpp.

194 {
195  switch (e->button()) {
196  case Qt::LeftButton:
198  break;
199  case Qt::RightButton:
201  break;
202  default:
204  break;
205  }
206 
207  if (camera) {
210  e_last = e->pos();
211  }
212 }
QMatrix4x4 matModel
Definition: camera.h:78
QMatrix4x4 matProj
Definition: camera.h:78
QMatrix4x4 matModel
Definition: canvas.h:73
QMatrix4x4 matProj
Definition: canvas.h:73

References btnNONE, btnTURN, btnZOOM, camera, e_last, GUI::RealSpace::Camera::matModel, matModel, GUI::RealSpace::Camera::matProj, matProj, and mouseButton.

◆ mouseReleaseEvent()

void GUI::RealSpace::Canvas::mouseReleaseEvent ( QMouseEvent *  )
overrideprivate

Definition at line 244 of file canvas.cpp.

245 {
246  if (camera) {
247  camera->endTransform(true);
248  update();
249  }
250 }

References camera, and GUI::RealSpace::Camera::endTransform().

Here is the call graph for this function:

◆ paintGL()

void GUI::RealSpace::Canvas::paintGL ( )
overrideprivate

Definition at line 149 of file canvas.cpp.

150 {
151  glClearColor(colorBgR, colorBgG, colorBgB, 1);
152  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
153 
154  if (camera && program && model) {
155  program->init();
156  program->bind();
157  program->set(*camera);
158  program->setAxis(false);
159 
160  // opaque objects
161  model->draw(*this);
162 
163  // transparent objects
164  glEnable(GL_BLEND);
165  glDepthMask(false);
166  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
167  model->drawBlend(*this);
168  glDisable(GL_BLEND);
169  glDepthMask(true);
170 
171  if (!model->modelIsEmpty()) {
172  // Draw 3D coordinate axes in lower left corner
173  glViewport(0, 0, viewport.width() / 9, viewport.height() / 5);
174  QMatrix4x4 matObject3DAxes;
175  matObject3DAxes.setToIdentity(); // 3D axes transformation matrix is Identity
176  program->set(matObject3DAxes);
178  program->setAxis(true);
179  std::unique_ptr<Buffer3DAxes> buf3DAxes(new Buffer3DAxes());
180  buf3DAxes->draw3DAxes();
181  }
182 
183  program->release();
184  }
185 }
QMatrix4x4 matModel3DAxes
Definition: camera.h:79
void draw(Canvas &) const
Definition: model.cpp:170
void drawBlend(Canvas &) const
Definition: model.cpp:176
void setAxis(bool const &)
Definition: program.cpp:101
void setMatModel(QMatrix4x4 const &)
Definition: program.cpp:96

References camera, colorBgB, colorBgG, colorBgR, GUI::RealSpace::Model::draw(), GUI::RealSpace::Model::drawBlend(), GUI::RealSpace::Program::init(), GUI::RealSpace::Camera::matModel3DAxes, model, GUI::RealSpace::Model::modelIsEmpty(), program, GUI::RealSpace::Program::set(), GUI::RealSpace::Program::setAxis(), GUI::RealSpace::Program::setMatModel(), and viewport.

Here is the call graph for this function:

◆ releaseBuffer()

void GUI::RealSpace::Canvas::releaseBuffer ( Geometry const *  g)
private

Definition at line 270 of file canvas.cpp.

271 {
272  delete buffers.take(g);
273 }

References buffers.

Referenced by Canvas().

◆ releaseBuffers()

void GUI::RealSpace::Canvas::releaseBuffers ( )
private

Definition at line 275 of file canvas.cpp.

276 {
277  for (auto* b : buffers.values())
278  delete b;
279  buffers.clear();
280 }

References buffers.

Referenced by cleanup(), and setModel().

◆ resizeGL()

void GUI::RealSpace::Canvas::resizeGL ( int  w,
int  h 
)
overrideprivate

Definition at line 141 of file canvas.cpp.

142 {
143  int w1 = qMax(1, w), h1 = qMax(1, h);
144  viewport.setRect(0, 0, w1, h1);
145  aspectRatio = float(w1) / float(h1);
146  setCamera(false);
147 }

References aspectRatio, setCamera(), and viewport.

Here is the call graph for this function:

◆ setBgColor()

void GUI::RealSpace::Canvas::setBgColor ( QColor const &  c)

Definition at line 72 of file canvas.cpp.

73 {
74  colorBgR = float(c.redF());
75  colorBgG = float(c.greenF());
76  colorBgB = float(c.blueF());
77  update();
78 }

References colorBgB, colorBgG, and colorBgR.

Referenced by GUI::RealSpace::Widget3D::setBackground().

◆ setCamera() [1/2]

void GUI::RealSpace::Canvas::setCamera ( bool  full = true)
private

Definition at line 117 of file canvas.cpp.

118 {
119  if (camera) {
121  if (full && model)
123  }
124 
125  update();
126 }
void setAspectRatio(float)
Definition: camera.cpp:87
Camera::Position defCamPos
default camera params
Definition: model.h:52

References aspectRatio, camera, GUI::RealSpace::Model::defCamPos, GUI::RealSpace::Camera::lookAt(), model, and GUI::RealSpace::Camera::setAspectRatio().

Here is the call graph for this function:

◆ setCamera() [2/2]

void GUI::RealSpace::Canvas::setCamera ( Camera c)

Definition at line 80 of file canvas.cpp.

81 {
82  camera = c;
83  setCamera();
84 }

References camera.

Referenced by initializeGL(), resizeGL(), and setModel().

◆ setModel()

void GUI::RealSpace::Canvas::setModel ( Model m)

Definition at line 94 of file canvas.cpp.

95 {
97 
98  disconnect(modelUpdated);
99  model = m;
100  modelUpdated = connect(model, &Model::updated, [this](bool withEye) {
101  if (withEye)
102  setCamera();
103  else
104  update();
105  });
106 
107  setCamera();
108  // connect(camera, &GUI::RealSpace::Camera::updated, model, &Model::cameraUpdated);
109  camera->set();
110 }
QMetaObject::Connection modelUpdated
Definition: canvas.h:86
void updated(bool withEye)

References camera, model, modelUpdated, releaseBuffers(), GUI::RealSpace::Camera::set(), setCamera(), and GUI::RealSpace::Model::updated().

Referenced by RealSpaceCanvas::resetScene(), GUI::RealSpace::Widget3D::setModel(), and RealSpaceCanvas::updateScene().

Here is the call graph for this function:

◆ setProgram()

void GUI::RealSpace::Canvas::setProgram ( Program p)

Definition at line 86 of file canvas.cpp.

87 {
88  program = p;
89  if (program)
90  program->needsInit();
91  update();
92 }

References GUI::RealSpace::Program::needsInit(), and program.

Referenced by initializeGL().

Here is the call graph for this function:

◆ sideView()

void GUI::RealSpace::Canvas::sideView ( )

Definition at line 336 of file canvas.cpp.

337 {
338  // Side view at current zoom level
339  if (isInitialized()) {
340  GUI::RealSpace::Vector3D eye(0, cameraDefaultPosY, 0);
341 
342  // Side view 3D axes is zoom scale independent
345  GUI::RealSpace::Vector3D(0, 0, 0), // center
347 
348  // Side view 3D object is zoom scale dependent
349  if (currentZoomLevel >= 0)
350  eye.y *= std::pow(ZoomInScale(), std::abs(currentZoomLevel));
351  else
352  eye.y *= std::pow(ZoomOutScale(), std::abs(currentZoomLevel));
353 
355  GUI::RealSpace::Vector3D(0, 0, 0), // center
357 
358  camera->endTransform(true);
359  update();
360  }
361 }

References GUI::RealSpace::Vector3D::_z, camera, currentZoomLevel, GUI::RealSpace::Camera::endTransform(), isInitialized(), GUI::RealSpace::Camera::lookAt(), GUI::RealSpace::Camera::lookAt3DAxes(), and GUI::RealSpace::Vector3D::y.

Referenced by GUI::RealSpace::Widget3D::sideView(), and RealSpaceCanvas::sideView().

Here is the call graph for this function:

◆ topView()

void GUI::RealSpace::Canvas::topView ( )

Definition at line 363 of file canvas.cpp.

364 {
365  // Top view at current zoom level
366  if (isInitialized()) {
367  // Setting a tiny offset in y value of eye such that eye and up vectors are not parallel
368  GUI::RealSpace::Vector3D eye(0, -0.5, -cameraDefaultPosY);
369 
370  // Top view 3D axes is zoom scale independent
373  GUI::RealSpace::Vector3D(0, 0, 0), // center
375 
376  // Top view 3D object is zoom scale dependent
377  if (currentZoomLevel >= 0)
378  eye.z *= std::pow(ZoomInScale(), std::abs(currentZoomLevel));
379  else
380  eye.z *= std::pow(ZoomOutScale(), std::abs(currentZoomLevel));
381 
383  GUI::RealSpace::Vector3D(0, 0, 0), // center
385 
386  camera->endTransform(true);
387  update();
388  }
389 }

References GUI::RealSpace::Vector3D::_z, camera, currentZoomLevel, GUI::RealSpace::Camera::endTransform(), isInitialized(), GUI::RealSpace::Camera::lookAt(), GUI::RealSpace::Camera::lookAt3DAxes(), and GUI::RealSpace::Vector3D::z.

Referenced by GUI::RealSpace::Widget3D::topView(), and RealSpaceCanvas::topView().

Here is the call graph for this function:

◆ unproject()

QVector3D GUI::RealSpace::Canvas::unproject ( QPoint const &  p)
private

Definition at line 187 of file canvas.cpp.

188 {
189  float x = p.x(), y = viewport.height() - p.y();
190  return QVector3D(x, y, 1).unproject(matModel, matProj, viewport);
191 }

References matModel, matProj, and viewport.

◆ verticalCameraTurn()

void GUI::RealSpace::Canvas::verticalCameraTurn ( float  angle)

Definition at line 436 of file canvas.cpp.

437 {
438  if (isInitialized()) {
439  float theta = angle * static_cast<float>(M_PI / 180.0); // in radians
440 
441  // Vertical camera turn for 3D axes
442  Camera::Position initial_pos3DAxes = camera->getPos3DAxes();
443 
444  GUI::RealSpace::Vector3D v_eye3DAxes = initial_pos3DAxes.eye; // camera's position vector
445  GUI::RealSpace::Vector3D v_ctr3DAxes = initial_pos3DAxes.ctr;
446  GUI::RealSpace::Vector3D v_up3DAxes = initial_pos3DAxes.up;
447 
448  GUI::RealSpace::Vector3D v_axis3DAxes =
449  cross(v_up3DAxes, v_eye3DAxes).normalized(); // normalized rotation axis
450 
451  // Rotating camera's position (eye) about an axis perpendicular to up and eye vectors
452  GUI::RealSpace::Vector3D v_rot_eye3DAxes =
453  v_up3DAxes * (1 - std::cos(theta)) * dot(v_axis3DAxes, v_eye3DAxes)
454  + v_eye3DAxes * std::cos(theta) + cross(v_axis3DAxes, v_eye3DAxes) * std::sin(theta);
455 
456  Camera::Position rotated_pos3DAxes(v_rot_eye3DAxes, v_ctr3DAxes, v_up3DAxes);
457 
458  camera->lookAt3DAxes(rotated_pos3DAxes);
459 
460  // Vertical camera turn for 3D object
461  Camera::Position initial_pos = camera->getPos();
462 
463  GUI::RealSpace::Vector3D v_eye = initial_pos.eye; // camera's position vector
464  GUI::RealSpace::Vector3D v_ctr = initial_pos.ctr;
465  GUI::RealSpace::Vector3D v_up = initial_pos.up;
466 
467  GUI::RealSpace::Vector3D v_axis =
468  cross(v_up, v_eye).normalized(); // normalized rotation axis
469 
470  // Rotating camera's position (eye) about an axis perpendicular to up and eye vectors
471  GUI::RealSpace::Vector3D v_rot_eye = v_up * (1 - std::cos(theta)) * dot(v_axis, v_eye)
472  + v_eye * std::cos(theta)
473  + cross(v_axis, v_eye) * std::sin(theta);
474 
475  Camera::Position rotated_pos(v_rot_eye, v_ctr, v_up);
476 
477  camera->lookAt(rotated_pos);
478 
479  camera->endTransform(true);
480  }
481 }

References camera, GUI::RealSpace::cross(), GUI::RealSpace::Camera::Position::ctr, GUI::RealSpace::dot(), GUI::RealSpace::Camera::endTransform(), GUI::RealSpace::Camera::Position::eye, GUI::RealSpace::Camera::getPos(), GUI::RealSpace::Camera::getPos3DAxes(), isInitialized(), GUI::RealSpace::Camera::lookAt(), GUI::RealSpace::Camera::lookAt3DAxes(), GUI::RealSpace::Vector3D::normalized(), and GUI::RealSpace::Camera::Position::up.

Referenced by mouseMoveEvent().

Here is the call graph for this function:

◆ wheelEvent()

void GUI::RealSpace::Canvas::wheelEvent ( QWheelEvent *  e)
overrideprivate

Definition at line 252 of file canvas.cpp.

253 {
254  if (camera) {
255  if (e->angleDelta().y() < 0) {
256  // Zoom in
257  camera->zoomBy(ZoomInScale());
258  currentZoomLevel += 1;
259  } else {
260  // Zoom out
261  camera->zoomBy(ZoomOutScale());
262  currentZoomLevel -= 1;
263  }
264  camera->endTransform(true);
265  update();
266  }
267  e->accept(); // disabling the event from propagating further to the parent widgets
268 }

References camera, currentZoomLevel, GUI::RealSpace::Camera::endTransform(), and GUI::RealSpace::Camera::zoomBy().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Object

friend class Object
friend

Definition at line 36 of file canvas.h.

Member Data Documentation

◆ aspectRatio

float GUI::RealSpace::Canvas::aspectRatio
private

Definition at line 63 of file canvas.h.

Referenced by resizeGL(), and setCamera().

◆ buffers

QHash<Geometry const*, Buffer*> GUI::RealSpace::Canvas::buffers
private

Definition at line 88 of file canvas.h.

Referenced by draw(), releaseBuffer(), and releaseBuffers().

◆ camera

◆ colorBgB

float GUI::RealSpace::Canvas::colorBgB
private

Definition at line 63 of file canvas.h.

Referenced by paintGL(), and setBgColor().

◆ colorBgG

float GUI::RealSpace::Canvas::colorBgG
private

Definition at line 63 of file canvas.h.

Referenced by paintGL(), and setBgColor().

◆ colorBgR

float GUI::RealSpace::Canvas::colorBgR
private

Definition at line 63 of file canvas.h.

Referenced by paintGL(), and setBgColor().

◆ currentZoomLevel

int GUI::RealSpace::Canvas::currentZoomLevel
private

Definition at line 64 of file canvas.h.

Referenced by defaultView(), sideView(), topView(), and wheelEvent().

◆ e_last

QPoint GUI::RealSpace::Canvas::e_last
private

Definition at line 72 of file canvas.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_isInitializedGL

bool GUI::RealSpace::Canvas::m_isInitializedGL
private

Definition at line 97 of file canvas.h.

Referenced by cleanup(), initializeGL(), and isInitialized().

◆ matModel

QMatrix4x4 GUI::RealSpace::Canvas::matModel
private

Definition at line 73 of file canvas.h.

Referenced by mousePressEvent(), and unproject().

◆ matProj

QMatrix4x4 GUI::RealSpace::Canvas::matProj
private

Definition at line 73 of file canvas.h.

Referenced by mousePressEvent(), and unproject().

◆ model

Model* GUI::RealSpace::Canvas::model
private

Definition at line 84 of file canvas.h.

Referenced by getModel(), isInitialized(), paintGL(), setCamera(), and setModel().

◆ modelUpdated

QMetaObject::Connection GUI::RealSpace::Canvas::modelUpdated
private

Definition at line 86 of file canvas.h.

Referenced by setModel().

◆ 

enum { ... } GUI::RealSpace::Canvas::mouseButton

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ program

Program* GUI::RealSpace::Canvas::program
private

Definition at line 83 of file canvas.h.

Referenced by cleanup(), draw(), initializeGL(), paintGL(), and setProgram().

◆ viewport

QRect GUI::RealSpace::Canvas::viewport
private

Definition at line 62 of file canvas.h.

Referenced by mouseMoveEvent(), paintGL(), resizeGL(), and unproject().


The documentation for this class was generated from the following files: