A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
group.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_FORMATS_SVG_GROUP_H_
2 #define GENESIS_UTILS_FORMATS_SVG_GROUP_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
38 
39 #include <iosfwd>
40 
41 namespace genesis {
42 namespace utils {
43 
44 // =================================================================================================
45 // Svg Group
46 // =================================================================================================
47 
48 struct SvgGroup
49 {
50 public:
51 
52  // -------------------------------------------------------------
53  // Typedefs and Enums
54  // -------------------------------------------------------------
55 
57 
58  // -------------------------------------------------------------
59  // Constructors and Rule of Five
60  // -------------------------------------------------------------
61 
62  SvgGroup() = default;
63  ~SvgGroup() = default;
64 
65  SvgGroup( SvgGroup const& ) = default;
66  SvgGroup( SvgGroup&& ) = default;
67 
68  SvgGroup& operator= ( SvgGroup const& ) = default;
69  SvgGroup& operator= ( SvgGroup&& ) = default;
70 
71  // -------------------------------------------------------------
72  // Drawing Function
73  // -------------------------------------------------------------
74 
75  SvgBox bounding_box() const;
76 
77  void write(
78  std::ostream& out,
79  size_t indent = 0,
80  SvgDrawingOptions const& options = SvgDrawingOptions()
81  ) const;
82 
88  self_type& add( SvgObject const& object );
89  self_type& add( SvgObject&& object );
90 
94  self_type& reverse();
95 
99  self_type& operator << ( SvgObject const& object );
100  self_type& operator << ( SvgObject&& object );
101 
102  bool empty() const
103  {
104  return content_.empty();
105  }
106 
107  void clear()
108  {
109  id = "";
110  content_.clear();
111  transform.clear();
112  }
113 
114  // -------------------------------------------------------------
115  // Properties
116  // -------------------------------------------------------------
117 
118  std::string id;
119  std::vector< SvgObject > content_;
121 
122 };
123 
124 } // namespace utils
125 } // namespace genesis
126 
127 #endif // include guard
std::vector< SvgObject > content_
Definition: group.hpp:119
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
Definition: group.cpp:60
SvgBox bounding_box() const
Definition: group.cpp:50
Provides some valuable additions to STD.
SvgGroup & operator=(SvgGroup const &)=default
self_type & add(SvgObject const &object)
Add an SvgObject to the document.
Definition: group.cpp:81
std::string indent(std::string const &text, std::string const &indentation)
Indent each line of text with indentation and return the result.
Definition: string.cpp:231
SvgTransform transform
Definition: group.hpp:120
self_type & reverse()
Reverse the order to the stored SvgObjects.
Definition: group.cpp:93
bool empty() const
Definition: group.hpp:102
self_type & operator<<(SvgObject const &object)
Shortcut operator for add(), which allows an even more fluent interface.
Definition: group.cpp:99