A toolkit for working with phylogenetic data.
v0.24.0
layout_tree.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_DRAWING_LAYOUT_TREE_H_
2 #define GENESIS_TREE_DRAWING_LAYOUT_TREE_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2019 Lucas Czech and HITS gGmbH
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 #include "genesis/tree/tree.hpp"
37 
38 #include <string>
39 #include <vector>
40 
41 namespace genesis {
42 namespace tree {
43 
44 // =================================================================================================
45 // Typedefs
46 // =================================================================================================
47 
52 
58 
64 
69 
70 // =================================================================================================
71 // Layout Tree Node Data
72 // =================================================================================================
73 
81 {
82  // -------------------------------------------------------------------
83  // Constructor and Rule of Five
84  // -------------------------------------------------------------------
85 
86 public:
87 
88  virtual ~LayoutNodeData() override = default;
89 
90  // Move ctor and assignment.
91  LayoutNodeData( LayoutNodeData&& ) = delete;
93 
94 protected:
95 
96  LayoutNodeData() = default;
97 
98  // Copy ctor and assignment.
99  LayoutNodeData( LayoutNodeData const& ) = default;
100  LayoutNodeData& operator= ( LayoutNodeData const& ) = default;
101 
102 public:
103 
104  static std::unique_ptr< LayoutNodeData > create()
105  {
106  return std::unique_ptr< LayoutNodeData >( new LayoutNodeData() );
107  }
108 
109  virtual std::unique_ptr< BaseNodeData > recreate() const override
110  {
111  return std::unique_ptr< LayoutNodeData >( new LayoutNodeData() );
112  }
113 
114  virtual std::unique_ptr< BaseNodeData > clone() const override
115  {
116  return std::unique_ptr< LayoutNodeData >( new LayoutNodeData( *this ));
117  }
118 
119  // -----------------------------------------------------
120  // Data Members
121  // -----------------------------------------------------
122 
123 public:
124 
132  double distance = -1.0;
133 
144  double spreading = -1.0;
145 
146  long parent_index = -1;
147 
150 
151 };
152 
153 // =================================================================================================
154 // Layout Tree Edge Data
155 // =================================================================================================
156 
164 {
165  // -------------------------------------------------------------------
166  // Constructor and Rule of Five
167  // -------------------------------------------------------------------
168 
169 public:
170 
171  virtual ~LayoutEdgeData() override = default;
172 
173  // Move ctor and assignment.
174  LayoutEdgeData( LayoutEdgeData&& ) = delete;
176 
177 protected:
178 
179  LayoutEdgeData() = default;
180 
181  // Copy ctor and assignment.
182  LayoutEdgeData( LayoutEdgeData const& ) = default;
183  LayoutEdgeData& operator= ( LayoutEdgeData const& ) = default;
184 
185 public:
186 
187  static std::unique_ptr< LayoutEdgeData > create()
188  {
189  return std::unique_ptr< LayoutEdgeData >( new LayoutEdgeData() );
190  }
191 
192  virtual std::unique_ptr< BaseEdgeData > recreate() const override
193  {
194  return std::unique_ptr< LayoutEdgeData >( new LayoutEdgeData() );
195  }
196 
197  virtual std::unique_ptr< BaseEdgeData > clone() const override
198  {
199  return std::unique_ptr< LayoutEdgeData >( new LayoutEdgeData( *this ));
200  }
201 
202  // -----------------------------------------------------
203  // Data Members
204  // -----------------------------------------------------
205 
206 public:
207 
210 
212 
213 };
214 
215 } // namespace tree
216 } // namespace genesis
217 
218 #endif // include guard
double distance
Distance of the node to the root.
virtual std::unique_ptr< BaseNodeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
LayoutNodeData & operator=(LayoutNodeData &&)=delete
static std::unique_ptr< LayoutNodeData > create()
utils::SvgStroke distance_stroke
static std::unique_ptr< LayoutEdgeData > create()
utils::SvgStroke spacer_stroke
virtual std::unique_ptr< BaseNodeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
Data class for LayoutTreeEdges.
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:97
utils::SvgStroke spreading_stroke
virtual ~LayoutNodeData() override=default
double spreading
Position of the node along the second axis.
Common class containing the commonly needed data for tree nodes.
Data class for LayoutTreeNodes.
Definition: layout_tree.hpp:80
Header of Tree class.
Common class containing the commonly needed data for tree edges.
virtual std::unique_ptr< BaseEdgeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
virtual std::unique_ptr< BaseEdgeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.