Pencil2D Animation
Download Community News Docs Contribute

core_lib/src/structure/layercamera.h Source File

  • Main Page
  • Related Pages
  • Classes
  • Files
  •  
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • structure
layercamera.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17#ifndef LAYERCAMERA_H
18#define LAYERCAMERA_H
19
20#include <QRect>
21#include <QColor>
22#include "layer.h"
23#include "camerafieldoption.h"
24#include "cameraeasingtype.h"
25#include "pencildef.h"
26
27class Camera;
28
29class LayerCamera : public Layer
30{
31public:
32 explicit LayerCamera(Object* object);
33 ~LayerCamera() override;
34
35 void loadImageAtFrame(int frame, qreal dx, qreal dy, qreal rotate, qreal scale, CameraEasingType easing, const QPointF& pathPoint, bool pathMoved);
36
37 QDomElement createDomElement(QDomDocument& doc) const override;
38 void loadDomElement(const QDomElement& element, QString dataDirPath, ProgressCallback progressStep) override;
39
40 bool addKeyFrame(int position, KeyFrame* pKeyFrame) override;
41 bool removeKeyFrame(int position) override;
42
43 Camera* getCameraAtFrame(int frameNumber) const;
44 Camera* getLastCameraAtFrame(int frameNumber, int increment) const;
45 QTransform getViewAtFrame(int frameNumber) const;
46
47 QRect getViewRect() const;
48 QSize getViewSize() const;
49 void setViewRect(QRect newViewRect);
50
51 // Functions for camera path
52 void setShowCameraPath(bool show) { mShowPath = show; }
53 bool getShowCameraPath() const { return mShowPath; }
54 void setCameraEasingAtFrame(CameraEasingType type, int frame) const;
55 void resetCameraAtFrame(CameraFieldOption type, int frame) const;
56 void updateDotColor(DotColorType color);
57 QColor getDotColor() const { return mDotColor; }
58 DotColorType getDotColorType() const { return mDotColorType; }
59
60 QString getInterpolationTextAtFrame(int frame) const;
61 QPointF getPathControlPointAtFrame(int frame) const;
62 bool hasSameTranslation(int frame1, int frame2) const;
63 QList<QPointF> getBezierPointsAtFrame(int frame) const;
64 QPointF getCenteredPathPoint(int frame) const;
65 void updatePathControlPointAtFrame(const QPointF& point, int frame) const;
66 void setPathMovedAtFrame(int frame, bool moved) const;
67
68 void splitControlPointIfNeeded(int frame) const;
69 void mergeControlPointIfNeeded(int frame) const;
70
71protected:
72 Status saveKeyFrameFile(KeyFrame*, QString path) override;
73 KeyFrame* createKeyFrame(int position, Object*) override;
74
75private:
76 void linearInterpolateTransform(Camera*);
77 qreal getInterpolationPercent(CameraEasingType type, qreal percent) const;
78 QPointF getBezierPoint(const QPointF& first, const QPointF& last, const QPointF& pathPoint, qreal percent) const;
79
80 int mFieldW = 800;
81 int mFieldH = 600;
82 QRect viewRect;
83
84 bool mShowPath = false;
85 QColor mDotColor = Qt::red;
86 DotColorType mDotColorType = DotColorType::RED;
87
88 const int mControlPointMergeThreshold = 2000;
89};
90
91#endif
Camera
Definition: camera.h:25
KeyFrame
Definition: keyframe.h:30
LayerCamera
Definition: layercamera.h:30
Layer
Definition: layer.h:38
Object
Definition: object.h:42
Status
Definition: pencilerror.h:40
QColor
QDomDocument
QDomElement
QList
QPointF
QRect
QSize
QString
Qt::red
red
QTransform
Generated on Sun Sep 24 2023 19:39:34 for Pencil2D by doxygen 1.9.6 based on revision 1395c86cb17dafbb32de44cbabe1f4c58636468d