Skip to content

Commit 6aeec6c

Browse files
committed
Add code for dataInvalidated signal to the Node
1 parent 3b124f3 commit 6aeec6c

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

include/nodes/internal/Node.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,25 @@ public Q_SLOTS: // data propagation
9898
void
9999
onDataUpdated(PortIndex index);
100100

101+
/// Propagates empty data to the attached connection.
102+
void
103+
onDataInvalidated(PortIndex index);
104+
101105
/// update the graphic part if the size of the embeddedwidget changes
102106
void
103107
onNodeSizeUpdated();
104108

105109
private:
106110

107111
// addressing
108-
109112
QUuid _uid;
110113

111114
// data
112-
113115
std::unique_ptr<NodeDataModel> _nodeDataModel;
114116

115117
NodeState _nodeState;
116118

117119
// painting
118-
119120
NodeGeometry _nodeGeometry;
120121

121122
std::unique_ptr<NodeGraphicsObject> _nodeGraphicsObject;

src/Node.cpp

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Node(std::unique_ptr<NodeDataModel> && dataModel)
3737
connect(_nodeDataModel.get(), &NodeDataModel::dataUpdated,
3838
this, &Node::onDataUpdated);
3939

40+
connect(_nodeDataModel.get(), &NodeDataModel::dataInvalidated,
41+
this, &Node::onDataInvalidated);
42+
4043
connect(_nodeDataModel.get(), &NodeDataModel::embeddedWidgetSizeUpdated,
4144
this, &Node::onNodeSizeUpdated );
4245
}
@@ -190,7 +193,9 @@ propagateData(std::shared_ptr<NodeData> nodeData,
190193
{
191194
_nodeDataModel->setInData(std::move(nodeData), inPortIndex, connectionId);
192195

193-
//Recalculate the nodes visuals. A data change can result in the node taking more space than before, so this forces a recalculate+repaint on the affected node
196+
// Recalculate the nodes visuals. A data change can result in the
197+
// node taking more space than before, so this forces a
198+
// recalculate+repaint on the affected node.
194199
_nodeGraphicsObject->setGeometryChanged();
195200
_nodeGeometry.recalculateSize();
196201
_nodeGraphicsObject->update();
@@ -204,31 +209,43 @@ onDataUpdated(PortIndex index)
204209
{
205210
auto nodeData = _nodeDataModel->outData(index);
206211

207-
auto connections =
212+
auto const &connections =
208213
_nodeState.connections(PortType::Out, index);
209214

210215
for (auto const & c : connections)
211216
c.second->propagateData(nodeData);
212217
}
213218

219+
220+
void
221+
Node::
222+
onDataInvalidated(PortIndex index)
223+
{
224+
auto const &connections =
225+
_nodeState.connections(PortType::Out, index);
226+
227+
for (auto const & c : connections)
228+
c.second->propagateEmptyData();
229+
}
230+
214231
void
215232
Node::
216233
onNodeSizeUpdated()
217234
{
218-
if( nodeDataModel()->embeddedWidget() )
219-
{
220-
nodeDataModel()->embeddedWidget()->adjustSize();
221-
}
222-
nodeGeometry().recalculateSize();
223-
for(PortType type: {PortType::In, PortType::Out})
235+
if( nodeDataModel()->embeddedWidget() )
236+
{
237+
nodeDataModel()->embeddedWidget()->adjustSize();
238+
}
239+
nodeGeometry().recalculateSize();
240+
for(PortType type: {PortType::In, PortType::Out})
241+
{
242+
for(auto& conn_set : nodeState().getEntries(type))
224243
{
225-
for(auto& conn_set : nodeState().getEntries(type))
226-
{
227-
for(auto& pair: conn_set)
228-
{
229-
Connection* conn = pair.second;
230-
conn->getConnectionGraphicsObject().move();
231-
}
232-
}
244+
for(auto& pair: conn_set)
245+
{
246+
Connection* conn = pair.second;
247+
conn->getConnectionGraphicsObject().move();
248+
}
233249
}
250+
}
234251
}

0 commit comments

Comments
 (0)