All Classes Namespaces Functions Variables Enumerations Properties Pages
overlaymanager.h
1 #ifndef OVERLAYMANAGER_H
2 #define OVERLAYMANAGER_H
3 
4 #include "pencildef.h"
5 #include "movemode.h"
6 #include "basemanager.h"
7 #include "overlaypainter.h"
8 
9 #include <QPointF>
10 #include <QPainter>
11 
12 class Editor;
13 class ViewManager;
14 
16 {
17  Q_OBJECT
18 
19 public:
20  explicit OverlayManager(Editor* editor);
21  ~OverlayManager() override;
22 
23  bool init() override;
24  Status load(Object *o) override;
25  Status save(Object *o) override;
26 
27  void workingLayerChanged(Layer *) override;
28 
29  MoveMode getMoveModeForOverlayAnchor(const QPointF& pos);
30  double selectionTolerance();
31 
32  void initPerspOverlay();
33  void updatePerspOverlay(const int persp);
34  void updatePerspOverlay(const QPointF& point);
35 
36  void setOverlayCenter(bool b);
37  void setOverlayThirds(bool b);
38  void setOverlayGoldenRatio(bool b);
39  void setOverlaySafeAreas(bool b);
40  void setOverlayPerspective1(bool b);
41  void setOverlayPerspective2(bool b);
42  void setOverlayPerspective3(bool b);
43 
44  bool getOverlayCenter() { return mOverlayCenter; }
45  bool getOverlayThirds() { return mOverlayThirds; }
46  bool getOverlayGoldenRatio() { return mOverlayGoldenRatio; }
47  bool getOverlaySafeAreas() { return mOverlaySafeAreas; }
48  bool getOverlayPerspective1() { return mOverlayPerspective1; }
49  bool getOverlayPerspective2() { return mOverlayPerspective2; }
50  bool getOverlayPerspective3() { return mOverlayPerspective3; }
51 
52  MoveMode getMoveMode() const { return op.getMoveMode(); }
53  void setMoveMode(MoveMode mode);
54  void setSinglePerspPoint(QPointF point);
55  QPointF getSinglePerspPoint() const;
56  void setLeftPerspPoint(QPointF point);
57  QPointF getLeftPerspPoint() const;
58  void setRightPerspPoint(QPointF point);
59  QPointF getRightPerspPoint() const;
60  void setMiddlePerspPoint(QPointF point);
61  QPointF getMiddlePerspPoint() const;
62 
63  void setPerpsOverlayActive(int perspType) { mActivePerspOverlays.append(perspType); }
64  void removePerspOverlayActive(int perspType) { mActivePerspOverlays.removeOne(perspType); }
65  QList<int> getActivePerspOverlays() { return mActivePerspOverlays; }
66  bool isPerspOverlaysActive() { return !mActivePerspOverlays.isEmpty(); }
67  void updatePerspOverlayActiveList();
68 
69 private:
70  Editor* mEditor = nullptr;
71  OverlayPainter op;
72 
73  QPointF mSinglePerspPoint; // for single point perspective.
74  QPointF mLeftPerspPoint;
75  QPointF mRightPerspPoint; // Left, right and middle are for
76  QPointF mMiddlePerspPoint; // two and three point perspective
77 
78  QPointF mLastLeftPoint;
79  QPointF mLastRightPoint;
80  QPointF mLastMiddlePoint;
81 
82  bool mOverlayCenter = false;
83  bool mOverlayThirds = false;
84  bool mOverlayGoldenRatio = false;
85  bool mOverlaySafeAreas = false;
86  bool mOverlayPerspective1 = false;
87  bool mOverlayPerspective2 = false;
88  bool mOverlayPerspective3 = false;
89 
90  QList<int> mActivePerspOverlays;
91  const qreal mSelectionTolerance = 8.0;
92 };
93 
94 #endif // OVERLAYMANAGER_H
void append(const T &value)
Q_OBJECTQ_OBJECT
bool isEmpty() const const
Definition: layer.h:38
Definition: object.h:41
Definition: editor.h:55
bool removeOne(const T &value)