Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • 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{
31 Q_DECLARE_TR_FUNCTIONS(LayerCamera)
32public:
33 explicit LayerCamera(int id);
34 ~LayerCamera() override;
35
36 void loadImageAtFrame(int frame, qreal dx, qreal dy, qreal rotate, qreal scale, CameraEasingType easing, const QPointF& pathPoint, bool pathMoved);
37
38 QDomElement createDomElement(QDomDocument& doc) const override;
39 void loadDomElement(const QDomElement& element, QString dataDirPath, ProgressCallback progressStep) override;
40
41 bool addKeyFrame(int position, KeyFrame* pKeyFrame) override;
42 bool removeKeyFrame(int position) override;
43 void replaceKeyFrame(const KeyFrame* camera) override;
44
45 Camera* getCameraAtFrame(int frameNumber) const;
46 Camera* getLastCameraAtFrame(int frameNumber, int increment) const;
47 QTransform getViewAtFrame(int frameNumber) const;
48
49 QRect getViewRect() const;
50 QSize getViewSize() const;
51 void setViewRect(QRect newViewRect);
52
53 // Functions for camera path
54 void setShowCameraPath(bool show) { mShowPath = show; }
55 bool getShowCameraPath() const { return mShowPath; }
56 void setCameraEasingAtFrame(CameraEasingType type, int frame) const;
57 void resetCameraAtFrame(CameraFieldOption type, int frame) const;
58 void updateDotColor(DotColorType color);
59 QColor getDotColor() const { return mDotColor; }
60 DotColorType getDotColorType() const { return mDotColorType; }
61
62 QString getInterpolationTextAtFrame(int frame) const;
63 QPointF getPathControlPointAtFrame(int frame) const;
64 bool hasSameTranslation(int frame1, int frame2) const;
65 QList<QPointF> getBezierPointsAtFrame(int frame) const;
66 QPointF getCenteredPathPoint(int frame) const;
67 void updatePathControlPointAtFrame(const QPointF& point, int frame) const;
68 void setPathMovedAtFrame(int frame, bool moved) const;
69
70 void splitControlPointIfNeeded(int frame) const;
71 void mergeControlPointIfNeeded(int frame) const;
72
73protected:
74 Status saveKeyFrameFile(KeyFrame*, QString path) override;
75 KeyFrame* createKeyFrame(int position) override;
76
77private:
78 void linearInterpolateTransform(Camera*);
79 qreal getInterpolationPercent(CameraEasingType type, qreal percent) const;
80 QPointF getBezierPoint(const QPointF& first, const QPointF& last, const QPointF& pathPoint, qreal percent) const;
81
82 int mFieldW = 800;
83 int mFieldH = 600;
84 QRect viewRect;
85
86 bool mShowPath = false;
87 QColor mDotColor = Qt::red;
88 DotColorType mDotColorType = DotColorType::RED;
89
90 const int mControlPointMergeThreshold = 2000;
91};
92
93#endif
Camera
Definition: camera.h:25
KeyFrame
Definition: keyframe.h:30
LayerCamera
Definition: layercamera.h:30
LayerCamera::addKeyFrame
bool addKeyFrame(int position, KeyFrame *pKeyFrame) override
Adds a keyframe at the given position, unless one already exists.
Definition: layercamera.cpp:44
Layer
Definition: layer.h:33
Status
Definition: pencilerror.h:40
QColor
QDomDocument
QDomElement
QList
QPointF
QRect
QSize
QString
Qt::red
red
QTransform
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39