nodeview: support multiple flow directions

This commit is contained in:
itsmattkc
2020-04-27 16:08:48 +10:00
parent 690bdb6581
commit b947b2224a
16 changed files with 338 additions and 176 deletions
+13 -17
View File
@@ -25,8 +25,8 @@
#include <QTimer>
#include "node/graph.h"
#include "widget/nodeview/nodeviewedge.h"
#include "widget/nodeview/nodeviewitem.h"
#include "nodeviewedge.h"
#include "nodeviewitem.h"
OLIVE_NAMESPACE_ENTER
@@ -69,6 +69,16 @@ public:
const QHash<Node*, NodeViewItem*>& item_map() const;
const QHash<NodeEdge*, NodeViewEdge*>& edge_map() const;
Qt::Orientation GetFlowOrientation() const;
NodeViewCommon::FlowDirection GetFlowDirection() const;
void SetFlowDirection(NodeViewCommon::FlowDirection direction);
/**
* @brief Automatically reposition the nodes based on their connections
*/
void ReorganizeFrom(Node* n);
public slots:
/**
* @brief Slot when a Node is added to a graph (SetGraph() connects this)
@@ -103,27 +113,13 @@ public slots:
void RemoveEdge(NodeEdgePtr edge);
private:
void QueueReorganize();
QList<Node*> GetNodeDirectDescendants(Node* n, const QList<Node*> connected_nodes, QList<Node*>& processed_nodes);
int FindWeightsInternal(Node* node, QHash<Node*, int>& weights, QList<Node*>& weighted_nodes);
void ReorganizeInternal(NodeViewItem *src_item, QHash<Node*, int>& weights, QList<Node *> &positioned_nodes);
QHash<Node*, NodeViewItem*> item_map_;
QHash<NodeEdge*, NodeViewEdge*> edge_map_;
QTimer reorganize_timer_;
NodeGraph* graph_;
private slots:
/**
* @brief Automatically reposition the nodes based on their connections
*/
void Reorganize();
NodeViewCommon::FlowDirection direction_;
};