A library for working with phylogenetic and population genetic data.
v0.27.0
genome_heatmap.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_FUNCTIONS_GENOME_HEATMAP_H_
2 #define GENESIS_POPULATION_FUNCTIONS_GENOME_HEATMAP_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 
39 
40 #include <string>
41 
42 namespace genesis {
43 namespace population {
44 
45 // =================================================================================================
46 // Drawing
47 // =================================================================================================
48 
50 {
51 public:
52 
53  // -------------------------------------------------------------------------
54  // Typedefs and Enums
55  // -------------------------------------------------------------------------
56 
57  enum class TextPosition
58  {
59  kTop,
60  kBottom,
61  kLeft,
62  kRight
63  };
64 
65  // -------------------------------------------------------------------------
66  // Constructors and Rule of Five
67  // -------------------------------------------------------------------------
68 
69  GenomeHeatmap() = default;
70  ~GenomeHeatmap() = default;
71 
72  GenomeHeatmap( GenomeHeatmap const& ) = default;
73  GenomeHeatmap( GenomeHeatmap&& ) = default;
74 
75  GenomeHeatmap& operator= ( GenomeHeatmap const& ) = default;
76  GenomeHeatmap& operator= ( GenomeHeatmap&& ) = default;
77 
78  // -------------------------------------------------------------------------
79  // Settings
80  // -------------------------------------------------------------------------
81 
82  double horizontal_scaling() const
83  {
84  return h_scaling_;
85  }
86 
88  {
89  h_scaling_ = value;
90  return *this;
91  }
92 
93  double vertical_scaling() const
94  {
95  return v_scaling_;
96  }
97 
99  {
100  v_scaling_ = value;
101  return *this;
102  }
103 
105  {
106  return text_position_;
107  }
108 
110  {
111  text_position_ = value;
112  return *this;
113  }
114 
115  void text_template( utils::SvgText const& tt );
117  utils::SvgText const& text_template() const;
118 
119  // -------------------------------------------------------------------------
120  // Drawing
121  // -------------------------------------------------------------------------
122 
123  void add( std::string const& label, utils::Matrix<utils::Color> const& heatmap );
124 
125  void write( std::shared_ptr<utils::BaseOutputTarget> target ) const;
126 
128  {
129  return document_;
130  }
131 
132  // -------------------------------------------------------------------------
133  // Data Members
134  // -------------------------------------------------------------------------
135 
136 private:
137 
138  double h_scaling_ = 1.0;
139  double v_scaling_ = 1.0;
140 
141  double current_y_ = 0.0;
142  utils::SvgDocument document_;
143 
144  utils::SvgText text_template_ = utils::SvgText();
145  TextPosition text_position_ = TextPosition::kTop;
146 
147 };
148 
149 } // namespace population
150 } // namespace genesis
151 
152 #endif // include guard
genesis::population::GenomeHeatmap::text_position
GenomeHeatmap & text_position(TextPosition value)
Definition: genome_heatmap.hpp:109
genesis::population::GenomeHeatmap::TextPosition::kBottom
@ kBottom
genesis::population::GenomeHeatmap::vertical_scaling
double vertical_scaling() const
Definition: genome_heatmap.hpp:93
genesis::population::GenomeHeatmap
Definition: genome_heatmap.hpp:49
map.hpp
genesis::population::GenomeHeatmap::GenomeHeatmap
GenomeHeatmap()=default
genesis::population::GenomeHeatmap::text_position
TextPosition text_position() const
Definition: genome_heatmap.hpp:104
genesis::population::GenomeHeatmap::~GenomeHeatmap
~GenomeHeatmap()=default
genesis::utils::Matrix
Definition: placement/function/emd.hpp:53
genesis::population::GenomeHeatmap::operator=
GenomeHeatmap & operator=(GenomeHeatmap const &)=default
genesis::population::GenomeHeatmap::text_template
utils::SvgText & text_template()
genesis::population::GenomeHeatmap::horizontal_scaling
GenomeHeatmap & horizontal_scaling(double value)
Definition: genome_heatmap.hpp:87
genesis::population::GenomeHeatmap::document
utils::SvgDocument const & document() const
Definition: genome_heatmap.hpp:127
matrix.hpp
genesis::population::GenomeHeatmap::vertical_scaling
GenomeHeatmap & vertical_scaling(double value)
Definition: genome_heatmap.hpp:98
genesis::population::GenomeHeatmap::write
void write(std::shared_ptr< utils::BaseOutputTarget > target) const
Definition: genome_heatmap.cpp:106
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
color.hpp
Header of Color class.
genesis::utils::SvgDocument
Definition: svg/document.hpp:49
genesis::utils::SvgText
Definition: text.hpp:47
svg.hpp
genesis::population::GenomeHeatmap::TextPosition
TextPosition
Definition: genome_heatmap.hpp:57
output_target.hpp
genesis::population::GenomeHeatmap::horizontal_scaling
double horizontal_scaling() const
Definition: genome_heatmap.hpp:82
genesis::population::GenomeHeatmap::add
void add(std::string const &label, utils::Matrix< utils::Color > const &heatmap)
Definition: genome_heatmap.cpp:44
genesis::population::GenomeHeatmap::TextPosition::kRight
@ kRight
genesis::population::GenomeHeatmap::TextPosition::kTop
@ kTop
genesis::population::GenomeHeatmap::TextPosition::kLeft
@ kLeft