A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
layout_base.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_DRAWING_LAYOUT_BASE_H_
2 #define GENESIS_TREE_DRAWING_LAYOUT_BASE_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 
36 
37 #include <string>
38 #include <vector>
39 
40 namespace genesis {
41 namespace tree {
42 
43 // =================================================================================================
44 // Layout Base
45 // =================================================================================================
46 
48 {
49 public:
50 
51  // -------------------------------------------------------------
52  // Typedefs and Enums
53  // -------------------------------------------------------------
54 
55  enum class Type
56  {
57  kPhylogram,
59  };
60 
61  // -------------------------------------------------------------
62  // Constructors and Rule of Five
63  // -------------------------------------------------------------
64 
65  LayoutBase() = default;
66  explicit LayoutBase( Type const drawing_type )
67  : type_( drawing_type )
68  {}
69 
70  virtual ~LayoutBase() = default;
71 
72  LayoutBase( LayoutBase const& ) = default;
73  LayoutBase( LayoutBase&& ) = default;
74 
75  LayoutBase& operator= ( LayoutBase const& ) = default;
76  LayoutBase& operator= ( LayoutBase&& ) = default;
77 
78  // -------------------------------------------------------------
79  // Tree
80  // -------------------------------------------------------------
81 
82  void tree( Tree const& orig_tree );
83  Tree const& tree() const;
84 
85  void set_edge_strokes( std::vector< utils::SvgStroke > const& strokes );
86  void set_node_shapes( std::vector< utils::SvgGroup> const& shapes );
87 
88  // -------------------------------------------------------------
89  // Drawing
90  // -------------------------------------------------------------
91 
93  {
94  return to_svg_document_();
95  }
96 
97  // -------------------------------------------------------------
98  // Options
99  // -------------------------------------------------------------
100 
101  void text_template( utils::SvgText const& tt );
103  utils::SvgText const& text_template() const;
104 
105  void type( Type const drawing_type );
106  Type type() const;
107 
108  // -------------------------------------------------------------
109  // Protected Functions
110  // -------------------------------------------------------------
111 
112 protected:
113 
114  Tree& tree();
115 
116  // -------------------------------------------------------------
117  // Virtual Functions
118  // -------------------------------------------------------------
119 
120 protected:
121 
122  virtual void init_tree_( Tree const& orig_tree ) = 0;
123 
124  virtual utils::SvgDocument to_svg_document_() const = 0;
125 
126  // -------------------------------------------------------------
127  // Data Members
128  // -------------------------------------------------------------
129 
130 private:
131 
132  LayoutTree tree_;
133 
134  Type type_ = Type::kPhylogram;
135 
136  utils::SvgText text_template_ = utils::SvgText();
137 
138 };
139 
140 } // namespace tree
141 } // namespace genesis
142 
143 #endif // include guard
virtual void init_tree_(Tree const &orig_tree)=0
virtual ~LayoutBase()=default
LayoutBase & operator=(LayoutBase const &)=default
void set_edge_strokes(std::vector< utils::SvgStroke > const &strokes)
Definition: layout_base.cpp:56
utils::SvgDocument to_svg_document() const
Definition: layout_base.hpp:92
virtual utils::SvgDocument to_svg_document_() const =0
Tree const & tree() const
Definition: layout_base.cpp:51
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:95
LayoutBase(Type const drawing_type)
Definition: layout_base.hpp:66
void set_node_shapes(std::vector< utils::SvgGroup > const &shapes)
Definition: layout_base.cpp:66
utils::SvgText & text_template()
Definition: layout_base.cpp:85