Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Yingdi Yu |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 9 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 10 | */ |
| 11 | |
Zhenkai Zhu | 5c6ad57 | 2012-06-04 19:50:08 -0700 | [diff] [blame] | 12 | #include "treelayout.h" |
| 13 | |
| 14 | void |
| 15 | OneLevelTreeLayout::setOneLevelLayout(std::vector<Coordinate> &childNodesCo) |
| 16 | { |
| 17 | if (childNodesCo.empty()) |
| 18 | { |
| 19 | return; |
| 20 | } |
| 21 | double y = getLevelDistance(); |
| 22 | double sd = getSiblingDistance(); |
| 23 | int n = childNodesCo.size(); |
| 24 | double x = - (n - 1) * sd / 2; |
| 25 | for (int i = 0; i < n; i++) |
| 26 | { |
| 27 | childNodesCo[i].x = x; |
| 28 | childNodesCo[i].y = y; |
| 29 | x += sd; |
| 30 | } |
| 31 | } |