mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
b69121bc0a
(the following is the original commit message) Now, that it's precisely known how much space is needed between each pair of the layers, it's possible to set the vertical coordinates for each of the nodes based on the layer heights (the height of the longest node within said layer) and the number of horizontal lanes required after it.
30 lines
882 B
C++
30 lines
882 B
C++
/// \file VerticalPositions.cpp
|
|
/// \brief
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "Layout.h"
|
|
|
|
void setVerticalCoordinates(const LayerContainer &Layers,
|
|
const LaneContainer &Lanes,
|
|
float MarginSize,
|
|
float EdgeDistance) {
|
|
float LastY = 0;
|
|
for (size_t Index = 0; Index < Layers.size(); ++Index) {
|
|
float MaxHeight = 0;
|
|
for (auto Node : Layers[Index]) {
|
|
auto NodeHeight = Node->size().H;
|
|
if (MaxHeight < NodeHeight)
|
|
MaxHeight = NodeHeight;
|
|
Node->center().Y = LastY - Node->size().H / 2;
|
|
}
|
|
|
|
auto LaneCount = Index < Lanes.Horizontal.size() ?
|
|
Lanes.Horizontal.at(Index).size() :
|
|
0;
|
|
LastY -= MaxHeight + EdgeDistance * LaneCount + MarginSize * 2;
|
|
}
|
|
}
|