MorphoGraphX  2.0-1-227
CameraPath.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef CAMERAPATH_HPP
12 #define CAMERAPATH_HPP
13 
14 #include <Config.hpp>
15 
16 #include <Misc.hpp>
17 
18 #include <QObject>
19 #include <QTimer>
20 #include <QPointer>
21 #include <QList>
22 
23 class MGXCamera;
24 
25 class CameraPath : public QObject
26 {
27  Q_OBJECT
28 public:
29  CameraPath(QObject* parent);
30  ~CameraPath();
31  void addFrame(MGXCamera* camera, float time = 1.0);
32  void addRotation(const mgx::Point3f& axis, double angle, float time = 2.0);
33 
34  void animatePath(MGXCamera* camera, float dt);
35 
36 protected slots:
37  void nextFrame();
38 
39 signals:
40  void endPath();
41  void frameUpdated();
42 
43 protected:
44  struct Action : public QObject
45  {
46  Action(float t, QObject* parent = 0) : QObject(parent), time(t) {}
47 
48  // Returns true when the end is reached
49  virtual bool startInterpolation(MGXCamera* camera) = 0;
50  virtual bool interpolateFrame(MGXCamera* camera, float t) = 0;
51  float time;
52  };
53 
54  struct ToPosition : public Action {
55  ToPosition(const mgx::Point3f& c, const mgx::Point3f& p,
56  const mgx::Point3f& d, float z, float t, QObject* parent = 0)
57  : Action(t, parent), center(c), position(p), direction(d), zoom(z) {}
58 
59  virtual bool startInterpolation(MGXCamera* camera);
60  virtual bool interpolateFrame(MGXCamera* camera, float t);
64  float zoom;
65 
66  // Quaternions for camera orientation
68  // Quaternions for camera position
70  };
71 
72  struct Rotation : public Action
73  {
74  Rotation(const mgx::Point3f& c, const mgx::Point3f& ax, float an, float t, QObject* parent = 0)
75  : Action(t, parent), center(c), axis(ax), angle(an) {}
76  virtual bool startInterpolation(MGXCamera*) { return true; }
77  virtual bool interpolateFrame(MGXCamera*, float) { return true; }
80  double angle;
81  };
82 
83  QList<QPointer<Action> > frames;
85  float dt;
86  float current_time;
88  QTimer* timer;
89 };
90 
91 #endif
CameraPath::~CameraPath
~CameraPath()
CameraPath::addRotation
void addRotation(const mgx::Point3f &axis, double angle, float time=2.0)
CameraPath::Action::time
float time
Definition: CameraPath.hpp:51
CameraPath::current_time
float current_time
Definition: CameraPath.hpp:86
CameraPath::ToPosition::pq2
qglviewer::Quaternion pq2
Definition: CameraPath.hpp:69
qglviewer::Quaternion
CameraPath::current_index
int current_index
Definition: CameraPath.hpp:87
CameraPath::nextFrame
void nextFrame()
CameraPath::ToPosition::interpolateFrame
virtual bool interpolateFrame(MGXCamera *camera, float t)
CameraPath::Action::interpolateFrame
virtual bool interpolateFrame(MGXCamera *camera, float t)=0
CameraPath::ToPosition::center
mgx::Point3f center
Definition: CameraPath.hpp:61
CameraPath::ToPosition::oq1
qglviewer::Quaternion oq1
Definition: CameraPath.hpp:67
CameraPath::Rotation::interpolateFrame
virtual bool interpolateFrame(MGXCamera *, float)
Definition: CameraPath.hpp:77
CameraPath::ToPosition::ToPosition
ToPosition(const mgx::Point3f &c, const mgx::Point3f &p, const mgx::Point3f &d, float z, float t, QObject *parent=0)
Definition: CameraPath.hpp:55
CameraPath::Rotation::axis
mgx::Point3f axis
Definition: CameraPath.hpp:79
CameraPath::Rotation
Definition: CameraPath.hpp:72
CameraPath::Action::Action
Action(float t, QObject *parent=0)
Definition: CameraPath.hpp:46
CameraPath::frameUpdated
void frameUpdated()
CameraPath::ToPosition::position
mgx::Point3f position
Definition: CameraPath.hpp:62
CameraPath::ToPosition::zoom
float zoom
Definition: CameraPath.hpp:64
CameraPath::ToPosition::startInterpolation
virtual bool startInterpolation(MGXCamera *camera)
CameraPath
Definition: CameraPath.hpp:25
CameraPath::endPath
void endPath()
MGXCamera
Definition: MGXCamera.hpp:34
CameraPath::CameraPath
CameraPath(QObject *parent)
CameraPath::ToPosition::direction
mgx::Point3f direction
Definition: CameraPath.hpp:63
CameraPath::camera
MGXCamera * camera
Definition: CameraPath.hpp:84
Misc.hpp
CameraPath::Rotation::angle
double angle
Definition: CameraPath.hpp:80
CameraPath::dt
float dt
Definition: CameraPath.hpp:85
mgx::Vector< 3, float >
CameraPath::timer
QTimer * timer
Definition: CameraPath.hpp:88
CameraPath::Action
Definition: CameraPath.hpp:44
CameraPath::Rotation::center
mgx::Point3f center
Definition: CameraPath.hpp:78
CameraPath::Action::startInterpolation
virtual bool startInterpolation(MGXCamera *camera)=0
CameraPath::Rotation::Rotation
Rotation(const mgx::Point3f &c, const mgx::Point3f &ax, float an, float t, QObject *parent=0)
Definition: CameraPath.hpp:74
CameraPath::ToPosition::pq1
qglviewer::Quaternion pq1
Definition: CameraPath.hpp:69
CameraPath::ToPosition
Definition: CameraPath.hpp:54
CameraPath::frames
QList< QPointer< Action > > frames
Definition: CameraPath.hpp:83
CameraPath::ToPosition::oq2
qglviewer::Quaternion oq2
Definition: CameraPath.hpp:67
CameraPath::animatePath
void animatePath(MGXCamera *camera, float dt)
CameraPath::Rotation::startInterpolation
virtual bool startInterpolation(MGXCamera *)
Definition: CameraPath.hpp:76
CameraPath::addFrame
void addFrame(MGXCamera *camera, float time=1.0)