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

Description

Definition at line 28 of file camera.h.

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

Classes

struct  Position
 

Signals

void updated (Camera const &)
 

Public Member Functions

 Camera ()
 
const PositiongetPos () const
 
const PositiongetPos3DAxes () const
 
void lookAt (const Position &)
 camera position for 3D object More...
 
void lookAt3DAxes (const Position &)
 camera position for 3D axes More...
 
void set ()
 

Private Member Functions

void endTransform (bool keep)
 
void setAspectRatio (float)
 
void turnBy (QQuaternion const &)
 
void zoomBy (float)
 

Private Attributes

QQuaternion addRot
 
float farPlane
 
Vector3D lightPos1
 
Vector3D lightPosRotated1
 
QMatrix4x4 matModel
 
QMatrix4x4 matModel3DAxes
 
QMatrix4x4 matProj
 
float nearPlane
 
Position pos
 
Position pos3DAxes
 
float vertAngle
 
float zoom
 

Friends

class Canvas
 
class Program
 

Constructor & Destructor Documentation

◆ Camera()

GUI::RealSpace::Camera::Camera ( )

Definition at line 23 of file camera.cpp.

26  , zoom(1)
27  , vertAngle(60)
28  , nearPlane(1)
29  , farPlane(10000)
30  , lightPos1(LIGHT1)
32 {
33  setAspectRatio(1);
34 }
Position pos3DAxes
Definition: camera.h:68
Vector3D lightPos1
Definition: camera.h:74
Vector3D lightPosRotated1
Definition: camera.h:74
void setAspectRatio(float)
Definition: camera.cpp:87
const Vector3D LIGHT1
Definition: camera.cpp:19
static Vector3D const _x
Definition: def.h:46
static Vector3D const _z
Definition: def.h:46
static Vector3D const _0
Definition: def.h:46

References setAspectRatio().

Here is the call graph for this function:

Member Function Documentation

◆ endTransform()

void GUI::RealSpace::Camera::endTransform ( bool  keep)
private

Definition at line 105 of file camera.cpp.

106 {
107  if (keep) {
108  pos.rot = (pos.rot * addRot).normalized();
109  pos.eye = pos.eye * zoom; // TODO limit
110 
111  pos3DAxes.rot = (pos3DAxes.rot * addRot).normalized(); // no zooming for 3D axes
112  }
113  addRot = {};
114  zoom = 1;
115  set();
116 }
QQuaternion addRot
Definition: camera.h:77

References addRot, GUI::RealSpace::Camera::Position::eye, pos, pos3DAxes, GUI::RealSpace::Camera::Position::rot, set(), and zoom.

Referenced by GUI::RealSpace::Canvas::defaultView(), GUI::RealSpace::Canvas::horizontalCameraTurn(), GUI::RealSpace::Canvas::mouseReleaseEvent(), GUI::RealSpace::Canvas::sideView(), GUI::RealSpace::Canvas::topView(), GUI::RealSpace::Canvas::verticalCameraTurn(), and GUI::RealSpace::Canvas::wheelEvent().

Here is the call graph for this function:

◆ getPos()

const Position& GUI::RealSpace::Camera::getPos ( ) const
inline

◆ getPos3DAxes()

const Position& GUI::RealSpace::Camera::getPos3DAxes ( ) const
inline

Definition at line 51 of file camera.h.

51 { return pos3DAxes; }

References pos3DAxes.

Referenced by GUI::RealSpace::Canvas::horizontalCameraTurn(), and GUI::RealSpace::Canvas::verticalCameraTurn().

◆ lookAt()

void GUI::RealSpace::Camera::lookAt ( const Position pos_)

camera position for 3D object

Definition at line 51 of file camera.cpp.

52 {
53  pos = pos_;
54  // lightPos = pos.eye;
55  set();
56 }

References pos, and set().

Referenced by GUI::RealSpace::Canvas::defaultView(), GUI::RealSpace::Canvas::horizontalCameraTurn(), GUI::RealSpace::Canvas::setCamera(), GUI::RealSpace::Canvas::sideView(), GUI::RealSpace::Canvas::topView(), and GUI::RealSpace::Canvas::verticalCameraTurn().

Here is the call graph for this function:

◆ lookAt3DAxes()

void GUI::RealSpace::Camera::lookAt3DAxes ( const Position pos3DAxes_)

camera position for 3D axes

Definition at line 58 of file camera.cpp.

59 {
60  pos3DAxes = pos3DAxes_;
61  set();
62 }

References pos3DAxes, and set().

Referenced by GUI::RealSpace::Canvas::defaultView(), GUI::RealSpace::Canvas::horizontalCameraTurn(), GUI::RealSpace::Canvas::sideView(), GUI::RealSpace::Canvas::topView(), and GUI::RealSpace::Canvas::verticalCameraTurn().

Here is the call graph for this function:

◆ set()

void GUI::RealSpace::Camera::set ( )

Definition at line 65 of file camera.cpp.

66 {
67  // For 3D object
68  matModel.setToIdentity();
69  matModel.lookAt((pos.eye - pos.ctr) * zoom + pos.ctr, pos.ctr, pos.up);
70  QQuaternion rt(pos.rot * addRot);
71  matModel.translate(+pos.ctr);
72  matModel.rotate(rt);
73  matModel.translate(-pos.ctr);
74 
75  // For 3D axes
76  matModel3DAxes.setToIdentity(); //
78  pos3DAxes.up); //
79  QQuaternion rt3DAxes(pos3DAxes.rot * addRot);
80  matModel3DAxes.rotate(rt3DAxes);
81 
82  lightPosRotated1 = rt.inverted().rotatedVector(lightPos1);
83 
84  emit updated(*this);
85 }
void updated(Camera const &)
QMatrix4x4 matModel
Definition: camera.h:78
QMatrix4x4 matModel3DAxes
Definition: camera.h:79

References addRot, GUI::RealSpace::Camera::Position::ctr, GUI::RealSpace::Camera::Position::eye, lightPos1, lightPosRotated1, matModel, matModel3DAxes, pos, pos3DAxes, GUI::RealSpace::Camera::Position::rot, GUI::RealSpace::Camera::Position::up, updated(), and zoom.

Referenced by endTransform(), lookAt(), lookAt3DAxes(), GUI::RealSpace::Canvas::setModel(), turnBy(), and zoomBy().

◆ setAspectRatio()

void GUI::RealSpace::Camera::setAspectRatio ( float  ratio)
private

Definition at line 87 of file camera.cpp.

88 {
89  matProj.setToIdentity();
90  matProj.perspective(vertAngle, ratio, nearPlane, farPlane);
91 }
QMatrix4x4 matProj
Definition: camera.h:78

References farPlane, matProj, nearPlane, and vertAngle.

Referenced by Camera(), and GUI::RealSpace::Canvas::setCamera().

◆ turnBy()

void GUI::RealSpace::Camera::turnBy ( QQuaternion const &  rot)
private

Definition at line 93 of file camera.cpp.

94 {
95  addRot = rot;
96  set();
97 }

References addRot, and set().

Here is the call graph for this function:

◆ updated

void GUI::RealSpace::Camera::updated ( Camera const &  )
signal

Referenced by set().

◆ zoomBy()

void GUI::RealSpace::Camera::zoomBy ( float  zoom_)
private

Definition at line 99 of file camera.cpp.

100 {
101  zoom = zoom_;
102  set();
103 }

References set(), and zoom.

Referenced by GUI::RealSpace::Canvas::mouseMoveEvent(), and GUI::RealSpace::Canvas::wheelEvent().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Canvas

friend class Canvas
friend

Definition at line 30 of file camera.h.

◆ Program

friend class Program
friend

Definition at line 31 of file camera.h.

Member Data Documentation

◆ addRot

QQuaternion GUI::RealSpace::Camera::addRot
private

Definition at line 77 of file camera.h.

Referenced by endTransform(), set(), and turnBy().

◆ farPlane

float GUI::RealSpace::Camera::farPlane
private

Definition at line 71 of file camera.h.

Referenced by setAspectRatio().

◆ lightPos1

Vector3D GUI::RealSpace::Camera::lightPos1
private

Definition at line 74 of file camera.h.

Referenced by set().

◆ lightPosRotated1

Vector3D GUI::RealSpace::Camera::lightPosRotated1
private

Definition at line 74 of file camera.h.

Referenced by set(), and GUI::RealSpace::Program::set().

◆ matModel

QMatrix4x4 GUI::RealSpace::Camera::matModel
private

◆ matModel3DAxes

QMatrix4x4 GUI::RealSpace::Camera::matModel3DAxes
private

Definition at line 79 of file camera.h.

Referenced by GUI::RealSpace::Canvas::paintGL(), and set().

◆ matProj

QMatrix4x4 GUI::RealSpace::Camera::matProj
private

◆ nearPlane

float GUI::RealSpace::Camera::nearPlane
private

Definition at line 71 of file camera.h.

Referenced by setAspectRatio().

◆ pos

Position GUI::RealSpace::Camera::pos
private

Definition at line 67 of file camera.h.

Referenced by endTransform(), getPos(), lookAt(), and set().

◆ pos3DAxes

Position GUI::RealSpace::Camera::pos3DAxes
private

Definition at line 68 of file camera.h.

Referenced by endTransform(), getPos3DAxes(), lookAt3DAxes(), and set().

◆ vertAngle

float GUI::RealSpace::Camera::vertAngle
private

Definition at line 71 of file camera.h.

Referenced by setAspectRatio().

◆ zoom

float GUI::RealSpace::Camera::zoom
private

Definition at line 70 of file camera.h.

Referenced by endTransform(), set(), and zoomBy().


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