75 using namespace utils;
102 for(
auto const& node :
tree().nodes() ) {
104 auto const& node_data = node.data<LayoutNodeData>();
105 auto const& prnt_data =
tree().
node_at( node_data.parent_index ).
data<LayoutNodeData>();
107 auto const node_x = node_data.distance *
width;
108 auto const node_y = node_data.spreading *
height;
111 auto edge_ptr =
edge_between( node,
tree().node_at( node_data.parent_index ) );
115 auto const& edge_data = edge_ptr->data<LayoutEdgeData>();
118 auto spreading_stroke = edge_data.spreading_stroke;
119 auto distance_stroke = edge_data.distance_stroke;
124 auto const dist_start_x = prnt_data.distance *
width;
125 auto const dist_start_y = node_y;
128 tree_lines << SvgLine(
129 prnt_data.distance *
width, prnt_data.spreading *
height,
130 dist_start_x, dist_start_y,
133 tree_lines << SvgLine(
134 dist_start_x, dist_start_y,
140 if( ! edge_data.shape.empty() ) {
141 auto const shape_x = ( dist_start_x + node_x ) / 2.0;
142 auto const shape_y = ( dist_start_y + node_y ) / 2.0;
144 auto es = edge_data.shape;
145 es.transform.append( SvgTransform::Translate( shape_x, shape_y ));
146 edge_shapes << std::move( es );
158 auto label_dist = node_x;
168 auto label_path = SvgPath( node_data.spacer_stroke, SvgFill( SvgFill::Type::kNone ));
169 label_path.elements.push_back(
172 label_path.elements.push_back(
175 taxa_lines << label_path;
184 if( node_data.name !=
"" ) {
192 label.text = node_data.name;
193 label.alignment_baseline = SvgText::AlignmentBaseline::kMiddle;
196 label.transform.append( SvgTransform::Translate( label_dist + 5, node_y ));
197 taxa_names << std::move( label );
202 if( ! node_data.shape.empty() ) {
203 auto ns = node_data.shape;
204 ns.transform.append( SvgTransform::Translate( node_x, node_y ));
205 node_shapes << std::move( ns );
211 tree_lines.reverse();
219 doc << std::move( tree_lines );
220 if( ! taxa_lines.empty() ) {
221 doc << std::move( taxa_lines );
223 if( ! taxa_names.empty() ) {
224 doc << std::move( taxa_names );
226 if( ! edge_shapes.empty() ) {
227 doc << std::move( edge_shapes );
229 if( ! node_shapes.empty() ) {
230 doc << std::move( node_shapes );