A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
layout_base.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2017 Lucas Czech
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lucas.czech@h-its.org>
20  Exelixis Lab, Heidelberg Institute for Theoretical Studies
21  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22 */
23 
32 
33 namespace genesis {
34 namespace tree {
35 
36 // =================================================================================================
37 // Tree
38 // =================================================================================================
39 
40 void LayoutBase::tree( Tree const& orig_tree )
41 {
42  tree_ = orig_tree.clone_topology();
43  init_tree_( orig_tree );
44 }
45 
47 {
48  return tree_;
49 }
50 
51 Tree const& LayoutBase::tree() const
52 {
53  return tree_;
54 }
55 
56 void LayoutBase::set_edge_strokes( std::vector< utils::SvgStroke > const& strokes )
57 {
58  if( strokes.size() != tree_.edge_count() ) {
59  throw std::runtime_error( "Edge stroke vector has wrong size." );
60  }
61  for( size_t i = 0; i < tree_.edge_count(); ++i ) {
62  tree_.edge_at(i).data<LayoutEdgeData>().stroke = strokes[ i ];
63  }
64 }
65 
66 void LayoutBase::set_node_shapes( std::vector< utils::SvgGroup> const& shapes )
67 {
68  if( shapes.size() != tree_.node_count() ) {
69  throw std::runtime_error( "Node shape vector has wrong size." );
70  }
71  for( size_t i = 0; i < tree_.node_count(); ++i ) {
72  tree_.node_at(i).data<LayoutNodeData>().shape = shapes[ i ];
73  }
74 }
75 
76 // =================================================================================================
77 // Options
78 // =================================================================================================
79 
81 {
82  text_template_ = tt;
83 }
84 
86 {
87  return text_template_;
88 }
89 
91 {
92  return text_template_;
93 }
94 
95 void LayoutBase::type( Type const drawing_type )
96 {
97  type_ = drawing_type;
98 }
99 
101 {
102  return type_;
103 }
104 
105 } // namespace tree
106 } // namespace genesis
virtual void init_tree_(Tree const &orig_tree)=0
void set_edge_strokes(std::vector< utils::SvgStroke > const &strokes)
Definition: layout_base.cpp:56
TreeNode & node_at(size_t index)
Return the TreeNode at a certain index.
Definition: tree/tree.cpp:304
size_t node_count() const
Return the number of TreeNodes of the Tree.
Definition: tree/tree.cpp:350
Data class for LayoutTreeEdges.
Tree const & tree() const
Definition: layout_base.cpp:51
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:95
Tree clone_topology() const
Return a Tree with the same topology, but without any data.
Definition: tree/tree.cpp:137
void set_node_shapes(std::vector< utils::SvgGroup > const &shapes)
Definition: layout_base.cpp:66
size_t edge_count() const
Return the number of TreeEdges of the Tree.
Definition: tree/tree.cpp:358
TreeEdge & edge_at(size_t index)
Return the TreeEdge at a certain index.
Definition: tree/tree.cpp:324
NodeDataType & data()
Definition: node.hpp:108
Data class for LayoutTreeNodes.
Definition: layout_tree.hpp:80
EdgeDataType & data()
Definition: edge.hpp:118
utils::SvgText & text_template()
Definition: layout_base.cpp:85