started parameter editor
This commit is contained in:
@@ -29,6 +29,7 @@ NodeView::NodeView(QWidget *parent) :
|
||||
setDragMode(RubberBandDrag);
|
||||
|
||||
connect(&scene_, SIGNAL(changed(const QList<QRectF>&)), this, SLOT(ItemsChanged()));
|
||||
connect(&scene_, SIGNAL(selectionChanged()), this, SLOT(SceneSelectionChangedSlot()));
|
||||
}
|
||||
|
||||
void NodeView::SetGraph(NodeGraph *graph)
|
||||
@@ -149,3 +150,22 @@ void NodeView::ItemsChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeView::SceneSelectionChangedSlot()
|
||||
{
|
||||
// Get the scene's selected items and convert it into a list of selected nodes
|
||||
QList<QGraphicsItem*> selected_items = scene_.selectedItems();
|
||||
|
||||
QList<Node*> selected_nodes;
|
||||
|
||||
for (int i=0;i<selected_items.size();i++) {
|
||||
// Try to dynamically cast to a widget holding a Node
|
||||
NodeViewItem* item = dynamic_cast<NodeViewItem*>(selected_items.at(i));
|
||||
|
||||
if (item != nullptr) {
|
||||
selected_nodes.append(item->node());
|
||||
}
|
||||
}
|
||||
|
||||
emit SelectionChanged(selected_nodes);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,12 @@ public:
|
||||
*/
|
||||
NodeViewEdge* EdgeToUIObject(NodeEdgePtr n);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the selected nodes have changed
|
||||
*/
|
||||
void SelectionChanged(QList<Node*> selected_nodes);
|
||||
|
||||
private:
|
||||
NodeGraph* graph_;
|
||||
|
||||
@@ -103,6 +109,11 @@ private slots:
|
||||
*/
|
||||
void ItemsChanged();
|
||||
|
||||
/**
|
||||
* @brief Receiver for when the scene's selected items change
|
||||
*/
|
||||
void SceneSelectionChangedSlot();
|
||||
|
||||
};
|
||||
|
||||
#endif // NODEVIEW_H
|
||||
|
||||
Reference in New Issue
Block a user