Swiftray  1.0
group-shape.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <shape/shape.h>
4 #include <canvas/cache-stack.h>
5 
6 // We may need to change the group to cross-layer group instead of a shape object in the future
7 // This group implementation is downward compatible with other vector design software's paradigm
8 class GroupShape : public Shape {
9 public:
10  GroupShape();
11 
12  GroupShape(QList<ShapePtr> &children);
13 
14  bool hitTest(QPointF global_coord, qreal tolerance) const override;
15 
16  bool hitTest(QRectF global_coord_rect) const override;
17 
18  void paint(QPainter *painter) const override;
19 
20  ShapePtr clone() const override;
21 
22  Shape::Type type() const override;
23 
24  const QList<ShapePtr> &children() const;
25 
26  friend class DocumentSerializer;
27 
28  friend class CacheStack;
29 
30 protected:
31 
32  CacheStack &cacheStack() const;
33 
34 private:
35 
36  void calcBoundingBox() const override;
37 
38  void cache() const;
39 
40 
41  QList<ShapePtr> children_;
42  mutable unique_ptr<CacheStack> cache_;
43 };
Definition: cache-stack.h:14
Save and load documents as binary format.
Definition: document-serializer.h:18
Definition: group-shape.h:8
Shape::Type type() const override
Definition: group-shape.cpp:97
bool hitTest(QPointF global_coord, qreal tolerance) const override
Definition: group-shape.cpp:16
const QList< ShapePtr > & children() const
Definition: group-shape.cpp:95
ShapePtr clone() const override
Definition: group-shape.cpp:81
GroupShape()
Definition: group-shape.cpp:5
CacheStack & cacheStack() const
Definition: group-shape.cpp:99
void paint(QPainter *painter) const override
Definition: group-shape.cpp:75
A base class for shape objects that contains transform and parent information.
Definition: shape.h:17
Type
Definition: shape.h:19
shared_ptr< Shape > ShapePtr
Definition: shape.h:137