Skip to content

Commit

Permalink
#228 Pre-merge (non official API) cosmetic.
Browse files Browse the repository at this point in the history
Signed-off-by: cneben <benoit@destrat.io>
  • Loading branch information
cneben committed Aug 13, 2024
1 parent 92a8cb4 commit ec1faff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions samples/layouts/layouts.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ ApplicationWindow {

let n121 = graph.insertNode()
n121.label = "n121"; n121.item.x=125; n121.item.y= 225
let n122 = graph.insertNode()
n122.label = "n122"; n122.item.x=225; n122.item.y= 225

let n1211 = graph.insertNode()
n1211.label = "n1211"; n1211.item.x=125; n1211.item.y= 225
Expand All @@ -69,6 +71,7 @@ ApplicationWindow {
graph.insertEdge(n1, n12);
graph.insertEdge(n1, n13);
graph.insertEdge(n12, n121);
graph.insertEdge(n12, n122);
graph.insertEdge(n121, n1211);

orgTreeLayout.layout(n1);
Expand Down
13 changes: 6 additions & 7 deletions samples/layouts/qanOrgTreeLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ NaiveTreeLayout::NaiveTreeLayout(QObject* parent) noexcept :
QObject{parent}
{
}

NaiveTreeLayout::~NaiveTreeLayout() { }

void NaiveTreeLayout::layout(qan::Node& root) noexcept
Expand Down Expand Up @@ -122,7 +121,7 @@ void NaiveTreeLayout::layout(qan::Node& root) noexcept
auto nodes = levels[level];

// 2.1
const double y = level * ySpacing; // FIXME, be smarter here...
const double y = level * ySpacing; // FIXME, be smarter on shift here...

// 2.2
double x = 0.;
Expand Down Expand Up @@ -150,14 +149,14 @@ OrgTreeLayout::OrgTreeLayout(QObject* parent) noexcept :
QObject{parent}
{
}

OrgTreeLayout::~OrgTreeLayout()
{
}
OrgTreeLayout::~OrgTreeLayout() { }

void OrgTreeLayout::layout(qan::Node& root) noexcept
{
// Pre-condition: root must be a tree subgraph, this is not enforced in this methodod.
// FIXME #228: Variant / naive Reingold-Tilford algorithm

// Pre-condition: root must be a tree subgraph, this is not enforced in this algorithm,
// any circuit will lead to intinite recursion...

// Algorithm:
// Traverse graph DFS aligning child nodes vertically
Expand Down
8 changes: 4 additions & 4 deletions samples/layouts/qanOrgTreeLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class NaiveTreeLayout : public QObject
NaiveTreeLayout& operator=(NaiveTreeLayout&&) = delete;

public:
// FIXME
// FIXME #228
void layout(qan::Node& root) noexcept;

//! QML invokable version of layout().
Expand All @@ -91,12 +91,12 @@ class OrgTreeLayout : public QObject
OrgTreeLayout& operator=(OrgTreeLayout&&) = delete;

public:
/*! \brief Apply an "organisational chart tree layout algorithm" to subgraph \c root.
/*! \brief Apply a vertical "organisational chart tree layout algorithm" to subgraph \c root.
*
* OrgChart layout _will preserve_ node orders.
*
* While the current implementation is not "space optimal" it run in O(n), n beeing the
* number of nodes in root "tree subgraph".
* This naive implementation is recursive and not "space optimal" while it run in O(n),
* n beeing the number of nodes in root "tree subgraph".
*
* \note \c root must be a tree subgraph, this method will not enforce this condition,
* running this algorithm on a non tree subgraph might lead to inifinite recursions or
Expand Down

0 comments on commit ec1faff

Please sign in to comment.