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
  • tool
cameratool.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
18#ifndef CAMERATOOL_H
19#define CAMERATOOL_H
20
21#include <QCursor>
22
23#include "basetool.h"
24#include "camerafieldoption.h"
25#include "preferencemanager.h"
26
27#include <QPen>
28
29enum class CameraMoveType {
30 PATH,
31 TOPLEFT,
32 TOPRIGHT,
33 BOTTOMLEFT,
34 BOTTOMRIGHT,
35 ROTATION,
36 CENTER,
37 NONE
38};
39
40class PointerEvent;
41class LayerCamera;
42class Camera;
43
44class CameraTool : public BaseTool
45{
46 Q_OBJECT
47public:
48 explicit CameraTool(QObject* object);
49 ~CameraTool() override;
50
51 QCursor cursor() override;
52 ToolType type() override { return ToolType::CAMERA; }
53
54 void paint(QPainter& painter, const QRect&) override;
55
56 void loadSettings() override;
57 void saveSettings() override;
58
59 void pointerPressEvent(PointerEvent* event) override;
60 void pointerReleaseEvent(PointerEvent* event) override;
61 void pointerMoveEvent(PointerEvent* event) override;
62
63 void setShowCameraPath(const bool showCameraPath) override;
64 void resetCameraPath() override;
65 void setPathDotColorType(const DotColorType pathDotColor) override;
66 void resetTransform(CameraFieldOption option);
67
68 void transformView(LayerCamera* layerCamera, CameraMoveType mode, const QPointF& point, const QPointF& offset, qreal angle, int frameNumber) const;
69
70private:
71
72 QPointF localRotationHandlePoint(const QPoint& origin, const QTransform& localT, const qreal objectScale, float worldScale) const;
73 QPointF worldRotationHandlePoint(const QPoint& origin, const QTransform& localT, const qreal objectScale, const QTransform& worldT, float worldScale) const;
74
75 void paintHandles(QPainter& painter, const QTransform& worldTransform, const QTransform& camTransform, const QRect& cameraRect, const QPointF translation, const qreal scale, const qreal rotation, bool hollowHandles) const;
76 void paintInterpolations(QPainter& painter, const QTransform& worldTransform, int currentFrame, const LayerCamera* cameraLayer, const Camera* keyframe, bool isPlaying) const;
77 void paintControlPoint(QPainter& painter, const QTransform& worldTransform, const LayerCamera* cameraLayer, const int frameIndex, const QPointF& pathPoint, bool hollowHandle) const;
78
79 void updateMoveMode(const QPointF& pos);
80 void transformCamera(const QPointF& pos, Qt::KeyboardModifiers keyMod);
81 void transformCameraPath(const QPointF& pos);
82 void updateSettings(const SETTING setting);
83 int constrainedRotation(const qreal rotatedAngle, const int rotationIncrement) const;
84
85 void updateProperties();
86 void updateUIAssists(const Layer* layer);
87
88 qreal getAngleBetween(const QPointF& pos1, const QPointF& pos2) const;
89
90 CameraMoveType getCameraMoveMode(const QPointF& point, qreal tolerance) const;
91 CameraMoveType getPathMoveMode(const LayerCamera* layerCamera, int frameNumber, const QPointF& point, qreal tolerance) const;
92
93 QPointF mTransformOffset;
94 CameraMoveType mCamMoveMode = CameraMoveType::NONE;
95 int mDragPathFrame = 1;
96 int mRotationIncrement = 0;
97
98 QRectF mCameraRect;
99 QPolygonF mCameraPolygon;
100 QPointF mRotationHandlePoint;
101
102 qreal mStartAngle = 0;
103 qreal mCurrentAngle = 0;
104
105 const int mDotWidth = 6;
106 const int mHandleWidth = 12;
107 const qreal mRotationHandleOffsetPercentage = 0.05;
108
109 QPen mHandlePen;
110 QColor mHandleColor;
111 QColor mHandleDisabledColor;
112 QColor mHandleTextColor;
113};
114
115#endif // CAMERATOOL_H
BaseTool
Definition: basetool.h:70
Camera
Definition: camera.h:25
CameraTool
Definition: cameratool.h:45
LayerCamera
Definition: layercamera.h:30
Layer
Definition: layer.h:33
PointerEvent
Definition: pointerevent.h:8
QColor
QCursor
QObject
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::event
virtual bool event(QEvent *e)
QPainter
QPen
QPoint
QPointF
QPolygonF
QRect
QRectF
Qt::KeyboardModifiers
typedef KeyboardModifiers
QTransform
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39