ShapeGroupElement.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libmspub project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_SHAPEGROUPELEMENT_H
11 #define INCLUDED_SHAPEGROUPELEMENT_H
12 
13 #include <functional>
14 #include <memory>
15 #include <vector>
16 
17 #include <boost/optional.hpp>
18 
19 #include "ShapeInfo.h"
20 #include "VectorTransformation2D.h"
21 
22 namespace libmspub
23 {
24 
25 struct Coordinate;
26 
28 {
29  boost::optional<ShapeInfo> m_shapeInfo;
30  std::weak_ptr<ShapeGroupElement> m_parent;
31  std::vector<std::shared_ptr<ShapeGroupElement>> m_children;
32  unsigned m_seqNum;
34  ShapeGroupElement(const ShapeGroupElement &) = delete;
36  ShapeGroupElement(const std::shared_ptr<ShapeGroupElement> &parent, unsigned seqNum);
37 
38 public:
40  static std::shared_ptr<ShapeGroupElement> create(const std::shared_ptr<ShapeGroupElement> &parent, unsigned seqNum = 0);
41 
42  void setShapeInfo(const ShapeInfo &shapeInfo);
43  void setup(std::function<void(ShapeGroupElement &self)> visitor);
44  void visit(std::function<
45  std::function<void(void)>
46  (const ShapeInfo &info, const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform, bool isGroup, const VectorTransformation2D &thisTransform)> visitor,
47  const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform) const;
48  void visit(std::function<
49  std::function<void(void)>
50  (const ShapeInfo &info, const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform, bool isGroup, const VectorTransformation2D &thisTransform)> visitor) const;
51  bool isGroup() const;
52  std::shared_ptr<ShapeGroupElement> getParent() const;
53  void setSeqNum(unsigned seqNum);
54  void setTransform(const VectorTransformation2D &transform);
55  unsigned getSeqNum() const;
56 };
57 }
58 
59 #endif
60 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
void setShapeInfo(const ShapeInfo &shapeInfo)
Definition: ShapeGroupElement.cpp:36
static std::shared_ptr< ShapeGroupElement > create(const std::shared_ptr< ShapeGroupElement > &parent, unsigned seqNum=0)
Definition: ShapeGroupElement.cpp:28
ShapeGroupElement(const ShapeGroupElement &)=delete
ShapeGroupElement & operator=(const ShapeGroupElement &)=delete
void visit(std::function< std::function< void(void)>(const ShapeInfo &info, const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform, bool isGroup, const VectorTransformation2D &thisTransform)> visitor, const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform) const
VectorTransformation2D m_transform
Definition: ShapeGroupElement.h:35
void setTransform(const VectorTransformation2D &transform)
Definition: ShapeGroupElement.cpp:41
std::weak_ptr< ShapeGroupElement > m_parent
Definition: ShapeGroupElement.h:30
boost::optional< ShapeInfo > m_shapeInfo
Definition: ShapeGroupElement.h:29
std::vector< std::shared_ptr< ShapeGroupElement > > m_children
Definition: ShapeGroupElement.h:31
Definition: Coordinate.h:17
~ShapeGroupElement()
Definition: ShapeGroupElement.cpp:24
Definition: Arrow.h:13
void setup(std::function< void(ShapeGroupElement &self)> visitor)
Definition: ShapeGroupElement.cpp:46
Definition: VectorTransformation2D.h:25
unsigned getSeqNum() const
Definition: ShapeGroupElement.cpp:103
unsigned m_seqNum
Definition: ShapeGroupElement.h:32
std::shared_ptr< ShapeGroupElement > getParent() const
Definition: ShapeGroupElement.cpp:93
Definition: ShapeGroupElement.h:27
Definition: ShapeInfo.h:37
bool isGroup() const
Definition: ShapeGroupElement.cpp:88
void setSeqNum(unsigned seqNum)
Definition: ShapeGroupElement.cpp:98

Generated for libmspub by doxygen 1.8.13