MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / restoreConnection

Method restoreConnection

QtNodeEditor/src/FlowScene.cpp:135–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133
134
135std::shared_ptr<Connection>
136FlowScene::
137restoreConnection(QJsonObject const &connectionJson)
138{
139 QUuid nodeInId = QUuid(connectionJson["in_id"].toString());
140 QUuid nodeOutId = QUuid(connectionJson["out_id"].toString());
141
142 PortIndex portIndexIn = connectionJson["in_index"].toInt();
143 PortIndex portIndexOut = connectionJson["out_index"].toInt();
144
145 auto nodeIn = _nodes[nodeInId].get();
146 auto nodeOut = _nodes[nodeOutId].get();
147
148 auto getConverter = [&]()
149 {
150 QJsonValue converterVal = connectionJson["converter"];
151
152 if (!converterVal.isUndefined())
153 {
154 QJsonObject converterJson = converterVal.toObject();
155
156 NodeDataType inType { converterJson["in"].toObject()["id"].toString(),
157 converterJson["in"].toObject()["name"].toString() };
158
159 NodeDataType outType { converterJson["out"].toObject()["id"].toString(),
160 converterJson["out"].toObject()["name"].toString() };
161
162 auto converter =
163 registry().getTypeConverter(outType, inType);
164
165 if (converter)
166 return converter;
167 }
168
169 return TypeConverter{};
170 };
171
172 if( !nodeIn || !nodeOut)
173 {
174 qDebug() << "ERROR: invalid connection with UIDS "
175 << nodeInId << " and " << nodeOutId;
176
177 return std::shared_ptr<Connection>();
178 }
179
180 std::shared_ptr<Connection> connection =
181 createConnection(*nodeIn, portIndexIn,
182 *nodeOut, portIndexOut,
183 getConverter());
184
185 connectionCreated(*connection);
186
187 connection->connectionGeometry().setPortLayout( layout() );
188 return connection;
189}
190
191
192void

Callers

nothing calls this directly

Calls 1

setPortLayoutMethod · 0.45

Tested by

no test coverage detected