A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2017 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 
35 
36 #include <iosfwd>
37 #include <map>
38 #include <string>
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 namespace genesis {
45 namespace utils {
46 
47  template<typename T>
48  class Matrix;
49 
50 } // namespace utils
51 
52 namespace sequence {
53 
54  class Sequence;
55 
56  class SequenceSet;
57 } // namespace sequence
58 } // namespace genesis
59 
60 // =================================================================================================
61 // Printer Bitmap
62 // =================================================================================================
63 
64 namespace genesis {
65 namespace sequence {
66 
75 {
76 public:
77 
78  // -------------------------------------------------------------------------
79  // Constructors and Rule of Five
80  // -------------------------------------------------------------------------
81 
82  PrinterBitmap() = default;
83  ~PrinterBitmap() = default;
84 
85  PrinterBitmap( PrinterBitmap const& ) = default;
86  PrinterBitmap( PrinterBitmap&& ) = default;
87 
88  PrinterBitmap& operator= ( PrinterBitmap const& ) = default;
89  PrinterBitmap& operator= ( PrinterBitmap&& ) = default;
90 
91  // -------------------------------------------------------------------------
92  // Print
93  // -------------------------------------------------------------------------
94 
95  void to_stream( SequenceSet const& set, std::ostream& outstream ) const;
96  void to_file( SequenceSet const& set, std::string const& filename ) 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
PrinterBitmap & operator=(PrinterBitmap const &)=default
Print the sites of a SequenceSet as pixels in a bitmap.
Definition: bitmap.hpp:74
size_t pixel_height_per_char() const
Definition: bitmap.cpp:132
Header of Color class.
std::map< char, utils::Color > const & color_map() const
Get the currently set list of Colors for each Sequence character.
Definition: bitmap.cpp:118
Store a set of Sequences.
void to_file(SequenceSet const &set, std::string const &filename) const
Definition: bitmap.cpp:59
void to_stream(SequenceSet const &set, std::ostream &outstream) const
Definition: bitmap.cpp:52
size_t pixel_width_per_char() const
Definition: bitmap.cpp:146