ShapeGroupElement.h Source File documentation

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 class ShapeGroupElement
25 {
26 boost::optional<ShapeInfo> m_shapeInfo;
27 std::weak_ptr<ShapeGroupElement> m_parent;
28 std::vector<std::shared_ptr<ShapeGroupElement>> m_children;
29 unsigned m_seqNum;
30 ShapeGroupElement &operator=(const ShapeGroupElement &) = delete;
31 ShapeGroupElement(const ShapeGroupElement &) = delete;
32 VectorTransformation2D m_transform;
33 ShapeGroupElement(const std::shared_ptr<ShapeGroupElement> &parent, unsigned seqNum);
34
35 public:
36 ~ShapeGroupElement();
37 static std::shared_ptr<ShapeGroupElement> create(const std::shared_ptr<ShapeGroupElement> &parent, unsigned seqNum = 0);
38
39 void setShapeInfo(const ShapeInfo &shapeInfo);
40 void setup(std::function<void(ShapeGroupElement &self)> visitor);
41 void visit(std::function<
42 std::function<void(void)>
43 (const ShapeInfo &info, const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform, bool isGroup, const VectorTransformation2D &thisTransform)> visitor,
44 const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform) const;
45 void visit(std::function<
46 std::function<void(void)>
47 (const ShapeInfo &info, const Coordinate &relativeTo, const VectorTransformation2D &foldedTransform, bool isGroup, const VectorTransformation2D &thisTransform)> visitor) const;
48 bool isGroup() const;
49 std::shared_ptr<ShapeGroupElement> getParent() const;
50 void setSeqNum(unsigned seqNum);
51 void setTransform(const VectorTransformation2D &transform);
52 unsigned getSeqNum() const;
53 };
54 }
55
56 #endif
57 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libmspub::ShapeGroupElement::setShapeInfo
void setShapeInfo(const ShapeInfo &shapeInfo)
Definition: ShapeGroupElement.cpp:31
libmspub::ShapeGroupElement::create
static std::shared_ptr< ShapeGroupElement > create(const std::shared_ptr< ShapeGroupElement > &parent, unsigned seqNum=0)
Definition: ShapeGroupElement.cpp:23
libmspub::ShapeGroupElement::ShapeGroupElement
ShapeGroupElement(const ShapeGroupElement &)=delete
libmspub::ShapeGroupElement::operator=
ShapeGroupElement & operator=(const ShapeGroupElement &)=delete
libmspub::ShapeGroupElement::visit
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
libmspub::ShapeGroupElement::m_transform
VectorTransformation2D m_transform
Definition: ShapeGroupElement.h:32
libmspub::ShapeGroupElement::setTransform
void setTransform(const VectorTransformation2D &transform)
Definition: ShapeGroupElement.cpp:36
VectorTransformation2D.h
libmspub::ShapeGroupElement::m_parent
std::weak_ptr< ShapeGroupElement > m_parent
Definition: ShapeGroupElement.h:27
libmspub::ShapeGroupElement::m_shapeInfo
boost::optional< ShapeInfo > m_shapeInfo
Definition: ShapeGroupElement.h:26
libmspub::ShapeGroupElement::m_children
std::vector< std::shared_ptr< ShapeGroupElement > > m_children
Definition: ShapeGroupElement.h:28
libmspub::Coordinate
Definition: Coordinate.h:17
libmspub::ShapeGroupElement::~ShapeGroupElement
~ShapeGroupElement()
Definition: ShapeGroupElement.cpp:19
libmspub
Definition: Arrow.h:13
libmspub::ShapeGroupElement::setup
void setup(std::function< void(ShapeGroupElement &self)> visitor)
Definition: ShapeGroupElement.cpp:41
libmspub::VectorTransformation2D
Definition: VectorTransformation2D.h:25
libmspub::ShapeGroupElement::getSeqNum
unsigned getSeqNum() const
Definition: ShapeGroupElement.cpp:98
libmspub::ShapeGroupElement::m_seqNum
unsigned m_seqNum
Definition: ShapeGroupElement.h:29
ShapeInfo.h
libmspub::ShapeGroupElement::getParent
std::shared_ptr< ShapeGroupElement > getParent() const
Definition: ShapeGroupElement.cpp:88
libmspub::ShapeGroupElement
Definition: ShapeGroupElement.h:24
libmspub::ShapeInfo
Definition: ShapeInfo.h:37
libmspub::ShapeGroupElement::isGroup
bool isGroup() const
Definition: ShapeGroupElement.cpp:83
libmspub::ShapeGroupElement::setSeqNum
void setSeqNum(unsigned seqNum)
Definition: ShapeGroupElement.cpp:93