BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
camera.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/ba3d/view/camera.h
6 //! @brief Defines Camera class
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_BA3D_VIEW_CAMERA_H
16 #define BORNAGAIN_GUI_BA3D_VIEW_CAMERA_H
17 
18 #include "GUI/ba3d/def.h"
19 #include <QColor>
20 #include <QMatrix4x4>
21 #include <QQuaternion>
22 
23 namespace GUI::RealSpace {
24 
25 class Canvas;
26 class Program;
27 
28 class Camera : public QObject {
29  Q_OBJECT
30  friend class Canvas;
31  friend class Program;
32 
33 public:
34  Camera();
35 
36  struct Position {
38  Position(const Vector3D& eye, const Vector3D& ctr, const Vector3D& up,
39  const QQuaternion& = {});
40 
42  QQuaternion rot;
43 
44  Position interpolateTo(const Position&, float) const;
45  };
46 
47  void lookAt(const Position&); //!< camera position for 3D object
48  void lookAt3DAxes(const Position&); //!< camera position for 3D axes
49 
50  const Position& getPos() const { return pos; }
51  const Position& getPos3DAxes() const { return pos3DAxes; }
52 
53  void set();
54 
55 signals:
56  void updated(Camera const&);
57 
58 private:
59  void setAspectRatio(float);
60 
61  // additional transformation
62  void turnBy(QQuaternion const&);
63  void zoomBy(float);
64  void endTransform(bool keep);
65 
66  // camera setup
69 
70  float zoom;
72 
73  // light
75 
76  // transformation
77  QQuaternion addRot; // rotation, additional rotation
78  QMatrix4x4 matModel, matProj;
79  QMatrix4x4 matModel3DAxes;
80 };
81 
82 } // namespace GUI::RealSpace
83 
84 #endif // BORNAGAIN_GUI_BA3D_VIEW_CAMERA_H
void updated(Camera const &)
void endTransform(bool keep)
Definition: camera.cpp:105
QQuaternion addRot
Definition: camera.h:77
QMatrix4x4 matModel
Definition: camera.h:78
Position pos3DAxes
Definition: camera.h:68
Vector3D lightPos1
Definition: camera.h:74
void lookAt(const Position &)
camera position for 3D object
Definition: camera.cpp:51
void turnBy(QQuaternion const &)
Definition: camera.cpp:93
void zoomBy(float)
Definition: camera.cpp:99
Vector3D lightPosRotated1
Definition: camera.h:74
QMatrix4x4 matModel3DAxes
Definition: camera.h:79
const Position & getPos() const
Definition: camera.h:50
void lookAt3DAxes(const Position &)
camera position for 3D axes
Definition: camera.cpp:58
QMatrix4x4 matProj
Definition: camera.h:78
const Position & getPos3DAxes() const
Definition: camera.h:51
void setAspectRatio(float)
Definition: camera.cpp:87
Definitions in namespace GUI::RealSpace.
Position interpolateTo(const Position &, float) const
Definition: camera.cpp:45