Debian Codegraph @

utils/fgqcanvas/fgcanvaspath.h

raw symbols SCIP
1 //
2 // Copyright (C) 2017 James Turner [email protected]
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License as
6 // published by the Free Software Foundation; either version 2 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 #ifndef FGCANVASPATH_H
19 #define FGCANVASPATH_H
20
21 #include "fgcanvaselement.h"
22
23 #include <QPainterPath>
24 #include <QPen>
25
26 class PathQuickItem;
27
28 class FGCanvasPath : public FGCanvasElement
29 {
30 public:
31 FGCanvasPath(FGCanvasGroup* pr, LocalProp* prop);
32
33 void dumpElement() override;
34 protected:
35 virtual void doPaint(FGCanvasPaintContext* context) const override;
36
37 void doPolish() override;
38
39 virtual void markStyleDirty() override;
40
41 CanvasItem* createQuickItem(QQuickItem *parent) override;
42 CanvasItem* quickItem() const override;
43
44 void doDestroy() override;
45
46 private:
47 void markPathDirty();
48 void markStrokeDirty();
49 private:
50 bool onChildAdded(LocalProp *prop) override;
51 bool onChildRemoved(LocalProp* prop) override;
52
53 void rebuildPath() const;
54 void rebuildPen() const;
55
56 void rebuildPathFromCommands(const std::vector<int>& commands, const std::vector<float>& coords) const;
57 bool rebuildFromSVGData(std::vector<int>& commands, std::vector<float>& coords) const;
58 bool rebuildFromRect(std::vector<int> &commands, std::vector<float> &coords) const;
59 private:
60 enum PaintType
61 {
62 Path,
63 Rect,
64 RoundRect
65 };
66
67 mutable bool _pathDirty = true;
68 mutable QPainterPath _painterPath;
69 mutable bool _penDirty = true;
70 mutable QPen _stroke;
71 bool _isRect = false;
72
73 mutable PaintType _paintType = Path;
74 mutable QRectF _rect;
75 mutable QSizeF _roundRectRadius;
76
77 PathQuickItem* _quickPath = nullptr;
78 };
79
80 #endif // FGCANVASPATH_H