A library for working with phylogenetic and population genetic data.
v0.27.0
svg/document.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_FORMATS_SVG_DOCUMENT_H_
2 #define GENESIS_UTILS_FORMATS_SVG_DOCUMENT_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2020 Lucas Czech
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 #include <vector>
41 
42 namespace genesis {
43 namespace utils {
44 
45 // =================================================================================================
46 // Svg Document
47 // =================================================================================================
48 
50 {
51 public:
52 
53  // -------------------------------------------------------------
54  // Typedefs and Enums
55  // -------------------------------------------------------------
56 
58 
59  static std::string indentation_string;
60 
61  enum class Overflow
62  {
63  kNone,
64  kVisible,
65  kHidden,
66  kScroll,
67  kAuto,
68  kInherit
69  };
70 
71  // -------------------------------------------------------------
72  // Constructors and Rule of Five
73  // -------------------------------------------------------------
74 
75  SvgDocument() = default;
76  ~SvgDocument() = default;
77 
78  SvgDocument( SvgDocument const& ) = default;
79  SvgDocument( SvgDocument&& ) = default;
80 
81  SvgDocument& operator= ( SvgDocument const& ) = default;
82  SvgDocument& operator= ( SvgDocument&& ) = default;
83 
84  // -------------------------------------------------------------
85  // Members
86  // -------------------------------------------------------------
87 
88  SvgBox bounding_box() const;
89 
90  void write( std::ostream& out ) const;
91 
97  self_type& add( SvgObject const& object );
98  self_type& add( SvgObject&& object );
99 
103  self_type& operator << ( SvgObject const& object );
104  self_type& operator << ( SvgObject&& object );
105 
106  // -------------------------------------------------------------
107  // Helper Functions
108  // -------------------------------------------------------------
109 
110 private:
111 
112  static std::string overflow_to_string( Overflow value );
113 
114  // -------------------------------------------------------------
115  // Data Members
116  // -------------------------------------------------------------
117 
118 public:
119 
122 
123  std::vector< SvgDefinitions > defs;
124  Color background_color = Color( 1.0, 1.0, 1.0, 1.0 );
125 
126 private:
127 
128  std::vector< SvgObject > content_;
129 
130 };
131 
132 } // namespace utils
133 } // namespace genesis
134 
135 #endif // include guard
genesis::utils::SvgDocument::~SvgDocument
~SvgDocument()=default
genesis::utils::Color
Definition: color.hpp:47
genesis::utils::SvgDocument::Overflow::kInherit
@ kInherit
genesis::utils::SvgDocument::margin
SvgMargin margin
Definition: svg/document.hpp:120
genesis::utils::SvgBox
Definition: utils/formats/svg/helper.hpp:116
genesis::utils::SvgMargin
Definition: utils/formats/svg/helper.hpp:81
genesis::utils::SvgDocument::write
void write(std::ostream &out) const
Write the SvgDocument to an output stream.
Definition: svg/document.cpp:70
genesis::utils::SvgDocument::overflow
Overflow overflow
Definition: svg/document.hpp:121
genesis::utils::SvgDocument::indentation_string
static std::string indentation_string
Definition: svg/document.hpp:59
genesis::utils::SvgDocument::operator<<
self_type & operator<<(SvgObject const &object)
Shortcut operator for add(), which allows an even more fluent interface.
Definition: svg/document.cpp:158
genesis::utils::SvgDocument::add
self_type & add(SvgObject const &object)
Add an SvgObject to the document.
Definition: svg/document.cpp:146
genesis::utils::SvgDocument::SvgDocument
SvgDocument()=default
gradient.hpp
genesis::utils::SvgDocument::background_color
Color background_color
Definition: svg/document.hpp:124
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::utils::SvgDocument::Overflow::kAuto
@ kAuto
definitions.hpp
color.hpp
Header of Color class.
genesis::utils::SvgDocument
Definition: svg/document.hpp:49
genesis::utils::SvgDocument::defs
std::vector< SvgDefinitions > defs
Definition: svg/document.hpp:123
genesis::utils::SvgDocument::Overflow::kNone
@ kNone
genesis::utils::SvgDocument::self_type
SvgDocument self_type
Definition: svg/document.hpp:57
genesis::utils::SvgDocument::bounding_box
SvgBox bounding_box() const
Definition: svg/document.cpp:57
genesis::utils::SvgDocument::Overflow::kVisible
@ kVisible
genesis::utils::SvgDocument::operator=
SvgDocument & operator=(SvgDocument const &)=default
genesis::utils::SvgObject
Definition: object.hpp:46
object.hpp
genesis::utils::SvgDocument::Overflow::kScroll
@ kScroll
genesis::utils::SvgDocument::Overflow
Overflow
Definition: svg/document.hpp:61
genesis::utils::SvgDocument::Overflow::kHidden
@ kHidden