| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 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 |