A library for working with phylogenetic and population genetic data.
v0.27.0
image.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_FORMATS_SVG_IMAGE_H_
2 #define GENESIS_UTILS_FORMATS_SVG_IMAGE_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 
36 
37 #include <iosfwd>
38 #include <string>
39 
40 namespace genesis {
41 namespace utils {
42 
43 // =================================================================================================
44 // Svg Image
45 // =================================================================================================
46 
47 struct SvgImage
48 {
49 public:
50 
51  // -------------------------------------------------------------
52  // Typedefs and Enums
53  // -------------------------------------------------------------
54 
56 
63  enum class ImageRendering
64  {
65  kNone,
66  kAuto,
69  kSmooth,
71  kPixelated,
72  kInherit,
73  kInitial,
74  kUnset
75  };
76 
77  // -------------------------------------------------------------
78  // Constructors and Rule of Five
79  // -------------------------------------------------------------
80 
81  SvgImage(
82  std::string const& href
83  );
84 
85  SvgImage(
86  std::string const& href,
87  SvgPoint const& position
88  );
89 
90  SvgImage(
91  std::string const& href,
92  SvgPoint const& position,
93  SvgSize const& size
94  );
95 
96  SvgImage(
97  std::string const& href,
98  double x, double y,
99  double w, double h
100  );
101 
102  ~SvgImage() = default;
103 
104  SvgImage( SvgImage const& ) = default;
105  SvgImage( SvgImage&& ) = default;
106 
107  SvgImage& operator= ( SvgImage const& ) = default;
108  SvgImage& operator= ( SvgImage&& ) = default;
109 
110  // -------------------------------------------------------------
111  // Drawing Function
112  // -------------------------------------------------------------
113 
114  SvgBox bounding_box() const;
115 
116  void write(
117  std::ostream& out,
118  size_t indent = 0,
119  SvgDrawingOptions const& options = SvgDrawingOptions()
120  ) const;
121 
122  // -------------------------------------------------------------
123  // Properties
124  // -------------------------------------------------------------
125 
126  std::string id;
127 
128  std::string href;
129 
132 
135 
136 };
137 
138 } // namespace utils
139 } // namespace genesis
140 
141 #endif // include guard
genesis::utils::SvgImage
Definition: image.hpp:47
genesis::utils::SvgImage::ImageRendering::kAuto
@ kAuto
helper.hpp
genesis::utils::indent
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:522
genesis::utils::SvgBox
Definition: utils/formats/svg/helper.hpp:116
genesis::utils::SvgImage::size
SvgSize size
Definition: image.hpp:131
genesis::utils::SvgImage::write
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
Definition: image.cpp:93
genesis::utils::SvgPoint
Definition: utils/formats/svg/helper.hpp:51
genesis::utils::SvgImage::ImageRendering::kSmooth
@ kSmooth
genesis::utils::SvgImage::ImageRendering::kOptimizeSpeed
@ kOptimizeSpeed
genesis::utils::SvgImage::ImageRendering::kPixelated
@ kPixelated
genesis::utils::SvgImage::SvgImage
SvgImage(std::string const &href)
Definition: image.cpp:50
genesis::utils::SvgImage::id
std::string id
Definition: image.hpp:126
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::SvgImage::rendering
ImageRendering rendering
Definition: image.hpp:134
genesis::utils::SvgImage::ImageRendering::kUnset
@ kUnset
genesis::utils::SvgImage::href
std::string href
Definition: image.hpp:128
genesis::utils::SvgImage::ImageRendering::kInherit
@ kInherit
genesis::utils::SvgTransform
Definition: attributes.hpp:238
genesis::utils::SvgSize
Definition: utils/formats/svg/helper.hpp:66
genesis::utils::SvgImage::~SvgImage
~SvgImage()=default
attributes.hpp
genesis::utils::SvgImage::ImageRendering::kOptimizeQuality
@ kOptimizeQuality
genesis::utils::SvgImage::bounding_box
SvgBox bounding_box() const
Definition: image.cpp:88
genesis::utils::SvgImage::ImageRendering
ImageRendering
Rendering modes for SVG embedded images.
Definition: image.hpp:63
genesis::utils::SvgImage::operator=
SvgImage & operator=(SvgImage const &)=default
genesis::utils::SvgImage::ImageRendering::kCrispEdges
@ kCrispEdges
genesis::utils::SvgImage::ImageRendering::kInitial
@ kInitial
genesis::utils::SvgDrawingOptions
Definition: utils/formats/svg/helper.hpp:202
genesis::utils::SvgImage::transform
SvgTransform transform
Definition: image.hpp:133
genesis::utils::SvgImage::ImageRendering::kNone
@ kNone
genesis::utils::SvgImage::position
SvgPoint position
Definition: image.hpp:130