Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
viewmanager.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2017 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU 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 
25 class ViewManager : public BaseManager
26 {
27  Q_OBJECT
28 
29 public:
30  explicit ViewManager( QObject* parent = 0 );
31 
32  bool init() override;
33  Status load( Object* ) override;
34  Status save( Object* ) override;
35 
36  QTransform getView();
37  void resetView();
38 
39  QPointF mapCanvasToScreen( QPointF p );
40  QPointF mapScreenToCanvas( QPointF p );
41 
42  QRectF mapCanvasToScreen( const QRectF& rect );
43  QRectF mapScreenToCanvas( const QRectF& rect );
44 
45  QPainterPath mapCanvasToScreen( const QPainterPath& path );
46  QPainterPath mapScreenToCanvas( const QPainterPath& path );
47 
48  QPointF translation() { return mTranslate; }
49  void translate( float dx, float dy );
50  void translate( QPointF offset );
51 
52  float rotation() { return mRotate; }
53  void rotate( float degree );
54 
55  float scaling() { return mScale; }
56  void scale( float scaleValue );
57  void scaleUp();
58  void scaleDown();
59 
60  void flipHorizontal( bool b );
61  void flipVertical( bool b );
62 
63  bool isFlipHorizontal() { return mIsFlipHorizontal; }
64  bool isFlipVertical() { return mIsFlipVertical; }
65 
66  void setCanvasSize( QSize size );
67 
68  Q_SIGNAL void viewChanged();
69 
70 private:
71  void updateViewTransforms();
72 
73  QTransform mView;
74  QTransform mViewInverse;
75  QTransform mViewCanvas;
76  QTransform mViewCanvasInverse;
77  QTransform mCentre;
78 
79  QPointF mTranslate;
80  float mRotate = 0.f;
81  float mScale = 1.f;
82 
83  QSize mCanvasSize = { 1, 1 };
84 
85  bool mIsFlipHorizontal = false;
86  bool mIsFlipVertical = false;
87 };
88 
89 #endif // VIEWMANAGER_H
Definition: object.h:71