a fairly decent node auto-positioning algorithm, not perfect, but a good start
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#define NODEVIEW_H
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QTimer>
|
||||
|
||||
#include "node/graph.h"
|
||||
#include "widget/nodeview/nodeviewedge.h"
|
||||
@@ -88,16 +89,22 @@ signals:
|
||||
void SelectionChanged(QList<Node*> selected_nodes);
|
||||
|
||||
private:
|
||||
QList<Node*> GetNodeDirectDescendants(Node* n, const QList<Node*> connected_nodes, QList<Node*>& processed_nodes);
|
||||
|
||||
void PlaceNode(NodeViewItem* n, const QPointF& pos);
|
||||
|
||||
void ReorganizeInternal(NodeViewItem *src_item, QList<Node *> &positioned_nodes);
|
||||
int FindWeightsInternal(Node* node, QHash<Node*, int>& weights, QList<Node*>& weighted_nodes);
|
||||
|
||||
void Reorganize();
|
||||
void ReorganizeInternal(NodeViewItem *src_item, QHash<Node*, int>& weights, QList<Node *> &positioned_nodes);
|
||||
|
||||
void QueueReorganize();
|
||||
|
||||
NodeGraph* graph_;
|
||||
|
||||
QGraphicsScene scene_;
|
||||
|
||||
QTimer reorganize_timer_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Slot when a Node is added to a graph (SetGraph() connects this)
|
||||
@@ -153,6 +160,11 @@ private slots:
|
||||
*/
|
||||
void CreateNodeSlot(QAction* action);
|
||||
|
||||
/**
|
||||
* @brief Automatically reposition the nodes based on their connections
|
||||
*/
|
||||
void Reorganize();
|
||||
|
||||
};
|
||||
|
||||
#endif // NODEVIEW_H
|
||||
|
||||
Reference in New Issue
Block a user