All Classes Namespaces Functions Variables Enumerations Properties Pages
camera.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2012-2020 Matthew Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 
17 #ifndef CAMERA_H
18 #define CAMERA_H
19 
20 #include <QTransform>
21 #include "keyframe.h"
22 #include "cameraeasingtype.h"
23 
24 class Camera : public KeyFrame
25 {
26 public:
27  explicit Camera();
28  explicit Camera(QPointF translation, qreal rotation, qreal scaling, CameraEasingType type);
29  explicit Camera(const Camera&);
30  ~Camera() override;
31 
32  Camera* clone() const override;
33 
34  QTransform getView();
35  void reset();
36  void updateViewTransform();
37  void assign(const Camera& rhs);
38 
39  void translate(qreal dx, qreal dy);
40  void translate(const QPointF);
41  QPointF translation() { return mTranslate; }
42 
43  void rotate(qreal degree);
44  qreal rotation() { return mRotate; }
45 
46  void scale(qreal scaleValue);
47  void scaleWithOffset(qreal scaleValue, QPointF offset); // for zooming at the mouse position
48  qreal scaling() { return mScale; }
49 
50  QTransform view;
51 
52  bool operator==(const Camera& rhs) const;
53 
54  void setEasingType(CameraEasingType type) { mEasingType = type; }
55  CameraEasingType getEasingType() const { return mEasingType; }
56 
57 private:
58  QPointF mTranslate;
59  qreal mRotate = 0.;
60  qreal mScale = 1.;
61  bool mNeedUpdateView = true;
62 
63  CameraEasingType mEasingType = CameraEasingType::LINEAR;
64 };
65 
66 #endif // CAMERA_H
Definition: camera.h:24