A library for working with phylogenetic and population genetic data.
v0.27.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
genesis::tree::LayoutNodeData::spreading
double spreading
Position of the node along the second axis.
Definition: layout_tree.hpp:144
genesis::tree::LayoutEdgeData::shape
utils::SvgGroup shape
Definition: layout_tree.hpp:211
genesis::tree::LayoutNodeData::shape
utils::SvgGroup shape
Definition: layout_tree.hpp:148
genesis::tree::LayoutNodeData::~LayoutNodeData
virtual ~LayoutNodeData() override=default
genesis::tree::LayoutEdgeData::distance_stroke
utils::SvgStroke distance_stroke
Definition: layout_tree.hpp:209
genesis::tree::LayoutEdgeData::LayoutEdgeData
LayoutEdgeData()=default
tree.hpp
Header of Tree class.
genesis::tree::LayoutEdgeData::create
static std::unique_ptr< LayoutEdgeData > create()
Definition: layout_tree.hpp:187
genesis::tree::LayoutEdgeData
Data class for LayoutTreeEdges.
Definition: layout_tree.hpp:163
genesis::utils::SvgStroke
Definition: attributes.hpp:49
genesis::tree::LayoutNodeData::create
static std::unique_ptr< LayoutNodeData > create()
Definition: layout_tree.hpp:104
genesis::tree::Tree
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:97
genesis::tree::LayoutNodeData::clone
virtual std::unique_ptr< BaseNodeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
Definition: layout_tree.hpp:114
genesis::tree::LayoutNodeData::distance
double distance
Distance of the node to the root.
Definition: layout_tree.hpp:132
genesis::tree::LayoutEdgeData::spreading_stroke
utils::SvgStroke spreading_stroke
Definition: layout_tree.hpp:208
genesis::tree::TreeEdge
Definition: edge.hpp:60
genesis::tree::TreeNode
Definition: tree/tree/node.hpp:58
genesis::utils::SvgStroke::Type::kNone
@ kNone
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::tree::LayoutEdgeData::~LayoutEdgeData
virtual ~LayoutEdgeData() override=default
tree.hpp
genesis::tree::LayoutEdgeData::clone
virtual std::unique_ptr< BaseEdgeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
Definition: layout_tree.hpp:197
genesis::tree::LayoutNodeData::recreate
virtual std::unique_ptr< BaseNodeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
Definition: layout_tree.hpp:109
genesis::tree::CommonEdgeData
Common class containing the commonly needed data for tree edges.
Definition: tree/common_tree/tree.hpp:144
svg.hpp
genesis::tree::CommonNodeData
Common class containing the commonly needed data for tree nodes.
Definition: tree/common_tree/tree.hpp:79
genesis::tree::LayoutEdgeData::recreate
virtual std::unique_ptr< BaseEdgeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
Definition: layout_tree.hpp:192
genesis::tree::LayoutEdgeData::operator=
LayoutEdgeData & operator=(LayoutEdgeData &&)=delete
genesis::tree::LayoutNodeData::parent_index
long parent_index
Definition: layout_tree.hpp:146
genesis::utils::SvgGroup
Definition: group.hpp:50
genesis::tree::LayoutNodeData::LayoutNodeData
LayoutNodeData()=default
genesis::tree::LayoutNodeData
Data class for LayoutTreeNodes.
Definition: layout_tree.hpp:80
genesis::tree::LayoutNodeData::spacer_stroke
utils::SvgStroke spacer_stroke
Definition: layout_tree.hpp:149
genesis::tree::LayoutNodeData::operator=
LayoutNodeData & operator=(LayoutNodeData &&)=delete