A library for working with phylogenetic and population genetic data.
v0.27.0
bitmap.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_SEQUENCE_PRINTERS_BITMAP_H_
2 #define GENESIS_SEQUENCE_PRINTERS_BITMAP_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 <map>
39 #include <string>
40 
41 // =================================================================================================
42 // Forward Declarations
43 // =================================================================================================
44 
45 namespace genesis {
46 namespace utils {
47 
48  template<typename T>
49  class Matrix;
50 
51 } // namespace utils
52 
53 namespace sequence {
54 
55  class Sequence;
56 
57  class SequenceSet;
58 } // namespace sequence
59 } // namespace genesis
60 
61 // =================================================================================================
62 // Printer Bitmap
63 // =================================================================================================
64 
65 namespace genesis {
66 namespace sequence {
67 
76 {
77 public:
78 
79  // -------------------------------------------------------------------------
80  // Constructors and Rule of Five
81  // -------------------------------------------------------------------------
82 
83  PrinterBitmap() = default;
84  ~PrinterBitmap() = default;
85 
86  PrinterBitmap( PrinterBitmap const& ) = default;
87  PrinterBitmap( PrinterBitmap&& ) = default;
88 
89  PrinterBitmap& operator= ( PrinterBitmap const& ) = default;
90  PrinterBitmap& operator= ( PrinterBitmap&& ) = default;
91 
92  // -------------------------------------------------------------------------
93  // Print
94  // -------------------------------------------------------------------------
95 
96  void write( SequenceSet const& set, std::shared_ptr<utils::BaseOutputTarget> target ) const;
97 
98  // -------------------------------------------------------------------------
99  // Properties
100  // -------------------------------------------------------------------------
101 
111  PrinterBitmap& color_map( std::map<char, utils::Color> const& value );
112 
118  std::map<char, utils::Color> const& color_map() const;
119 
120  PrinterBitmap& pixel_height_per_char( size_t value );
121 
122  size_t pixel_height_per_char() const;
123 
124  PrinterBitmap& pixel_width_per_char( size_t value );
125 
126  size_t pixel_width_per_char() const;
127 
128  // -------------------------------------------------------------------------
129  // Interal Helper Functions
130  // -------------------------------------------------------------------------
131 
132 private:
133 
134  utils::Matrix<utils::Color> make_image_( SequenceSet const& set ) const;
135 
136  // -------------------------------------------------------------------------
137  // Data Members
138  // -------------------------------------------------------------------------
139 
140 private:
141 
142  std::map<char, utils::Color> color_map_;
143 
144  size_t pixel_height_ = 1;
145  size_t pixel_width_ = 1;
146 
147 };
148 
149 } // namespace sequence
150 } // namespace genesis
151 
152 #endif // include guard
genesis::sequence::PrinterBitmap::PrinterBitmap
PrinterBitmap()=default
genesis::sequence::PrinterBitmap::operator=
PrinterBitmap & operator=(PrinterBitmap const &)=default
genesis::sequence::PrinterBitmap::~PrinterBitmap
~PrinterBitmap()=default
genesis::sequence::PrinterBitmap::pixel_height_per_char
size_t pixel_height_per_char() const
Definition: bitmap.cpp:126
genesis::utils::Matrix
Definition: placement/function/emd.hpp:53
genesis::sequence::PrinterBitmap::write
void write(SequenceSet const &set, std::shared_ptr< utils::BaseOutputTarget > target) const
Definition: bitmap.cpp:52
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::sequence::SequenceSet
Store a set of Sequences.
Definition: sequence_set.hpp:59
genesis::sequence::PrinterBitmap::pixel_width_per_char
size_t pixel_width_per_char() const
Definition: bitmap.cpp:140
color.hpp
Header of Color class.
genesis::sequence::PrinterBitmap::color_map
std::map< char, utils::Color > const & color_map() const
Get the currently set list of Colors for each Sequence character.
Definition: bitmap.cpp:112
output_target.hpp
genesis::sequence::PrinterBitmap
Print the sites of a SequenceSet as pixels in a bitmap.
Definition: bitmap.hpp:75