diff --git a/samples/layouts/layouts.qml b/samples/layouts/layouts.qml index 0861d77f..5f95b5ff 100644 --- a/samples/layouts/layouts.qml +++ b/samples/layouts/layouts.qml @@ -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 @@ -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); diff --git a/samples/layouts/qanOrgTreeLayout.cpp b/samples/layouts/qanOrgTreeLayout.cpp index 0715c9ab..95998150 100644 --- a/samples/layouts/qanOrgTreeLayout.cpp +++ b/samples/layouts/qanOrgTreeLayout.cpp @@ -55,7 +55,6 @@ NaiveTreeLayout::NaiveTreeLayout(QObject* parent) noexcept : QObject{parent} { } - NaiveTreeLayout::~NaiveTreeLayout() { } void NaiveTreeLayout::layout(qan::Node& root) noexcept @@ -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.; @@ -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 diff --git a/samples/layouts/qanOrgTreeLayout.h b/samples/layouts/qanOrgTreeLayout.h index d0314f71..3365f1a4 100644 --- a/samples/layouts/qanOrgTreeLayout.h +++ b/samples/layouts/qanOrgTreeLayout.h @@ -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(). @@ -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