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
  • managers
viewmanager.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 VIEWMANAGER_H
19#define VIEWMANAGER_H
20
21#include <QTransform>
22#include "basemanager.h"
23
24
25class ViewManager : public BaseManager
26{
27 Q_OBJECT
28
29public:
30 explicit ViewManager(Editor* editor);
31 ~ViewManager() override;
32
33 bool init() override;
34 Status load(Object*) override;
35 Status save(Object*) override;
36
37 QTransform getView() const;
38 QTransform getViewInverse() const;
39
41 qreal getScaleInversed() const;
42
43 void resetView();
44
45 QPointF mapCanvasToScreen(QPointF p) const;
46 QPointF mapScreenToCanvas(QPointF p) const;
47
48 QRectF mapCanvasToScreen(const QRectF& rect) const;
49 QRectF mapScreenToCanvas(const QRectF& rect) const;
50
51 QPolygonF mapPolygonToScreen(const QPolygonF& polygon) const;
52 QPolygonF mapPolygonToCanvas(const QPolygonF& polygon) const;
53
54 QPainterPath mapCanvasToScreen(const QPainterPath& path) const;
55 QPainterPath mapScreenToCanvas(const QPainterPath& path) const;
56
57 QPointF translation() const;
58 void translate(float dx, float dy);
59 void translate(QPointF offset);
60 void centerView();
61
62 float rotation();
63 void rotate(float degree);
64 void rotateRelative(float delta);
65 void resetRotation();
66
67 qreal scaling();
68 void scale(qreal scaleValue);
69 void scaleAtOffset(qreal scaleValue, QPointF offset);
70 void scaleUp();
71 void scaleDown();
72 void scale400();
73 void scale300();
74 void scale200();
75 void scale100();
76 void scale50();
77 void scale33();
78 void scale25();
79
80 void flipHorizontal(bool b);
81 void flipVertical(bool b);
82
83 bool isFlipHorizontal() const { return mIsFlipHorizontal; }
84 bool isFlipVertical() const { return mIsFlipVertical; }
85 void setCanvasSize(QSize size);
86
87 void forceUpdateViewTransform();
88
89signals:
90 void viewChanged();
91 void viewFlipped();
92
93private:
94 void updateViewTransforms();
95 void onCurrentFrameChanged();
96
97 QTransform mView;
98 QTransform mViewInverse;
99 QTransform mViewCanvas;
100 QTransform mViewCanvasInverse;
101 QTransform mCentre;
102
103 QPointF mTranslation = QPointF();
104 qreal mScaling = 1.0;
105 qreal mRotation = 0.0;
106
107 QSize mCanvasSize = { 1, 1 };
108
109 bool mIsFlipHorizontal = false;
110 bool mIsFlipVertical = false;
111};
112
113#endif // VIEWMANAGER_H
BaseManager
Definition: basemanager.h:29
Editor
Definition: editor.h:71
Object
Definition: object.h:42
Status
Definition: pencilerror.h:40
ViewManager
Definition: viewmanager.h:26
ViewManager::getScaleInversed
qreal getScaleInversed() const
Definition: viewmanager.cpp:111
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QPainterPath
QPointF
QPolygonF
QRectF
QSize
QTransform
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39