86 auto constructDAG = [&](std::shared_ptr<dyno::Module> m) ->
void
88 auto outId = m->objectId();
90 auto fieldOut = m->getOutputFields();
92 for (
int i = 0; i < fieldOut.size(); i++)
94 auto& sinks = fieldOut[i]->getSinks();
95 for (
auto sink : sinks)
99 auto parSrc = sink->parent();
100 if (parSrc !=
nullptr)
104 if (nodeSrc !=
nullptr)
118 for (
auto it = mlists.begin(); it != mlists.end(); it++)
126 std::map<dyno::ObjectId, WtNode*> wtNodeMapper;
127 std::map<dyno::ObjectId, dyno::Module*> moduleMapper;
128 for (
auto const& _node :
_nodes)
130 auto const& wtNode = _node.second;
131 auto model = wtNode->nodeDataModel();
135 if (model !=
nullptr)
137 auto m = nodeData->getModule();
140 wtNodeMapper[m->objectId()] = wtNode.get();
141 moduleMapper[m->objectId()] = m.get();
146 float offsetX = 0.0f;
149 auto& xc = layout.
layer(l);
151 float offsetY = 0.0f;
153 for (
size_t index = 0; index < xc.size(); index++)
156 if (wtNodeMapper.find(
id) != wtNodeMapper.end())
158 WtNode* wtNode = wtNodeMapper[id];
161 float w = geo.
width();
164 xMax = std::max(xMax, w);
166 Module* node = moduleMapper[id];
170 offsetY += (h +
mDy);
174 offsetX += (xMax +
mDx);
185 wtNodeMapper.clear();
186 moduleMapper.clear();
198 auto& mlist = node->getModuleList();
200 std::map<dyno::ObjectId, WtNode*> moduleMap;
208 auto addModuleWidget = [&](std::shared_ptr<dyno::Module> m) ->
void
210 auto mId = m->objectId();
212 auto type = std::make_unique<WtModuleWidget>(m);
218 moduleMap[mId] = &node;
222 Wt::WPointF posView(m->bx(), m->by());
224 node.nodeGraphicsObject().setPos(posView);
229 mStates = std::make_shared<dyno::WtStates>();
231 auto& fields = node->getAllFields();
232 for (
auto field : fields)
237 mStates->addOutputField(field);
242 mStates->setBlockCoord(pos.x(), pos.y());
246 for (
auto m : modules)
248 addModuleWidget(m.second);
251 auto createModuleConnections = [&](std::shared_ptr<dyno::Module> m)->
void
253 auto inId = m->objectId();
255 if (moduleMap.find(inId) != moduleMap.end())
257 auto inBlock = moduleMap[m->objectId()];
259 auto fieldIn = m->getInputFields();
261 for (
int i = 0; i < fieldIn.size(); i++)
263 auto fieldSrc = fieldIn[i]->getSource();
264 if (fieldSrc !=
nullptr)
266 auto parSrc = fieldSrc->parent();
267 if (parSrc !=
nullptr)
270 if (nodeSrc ==
nullptr)
276 unsigned int outFieldIndex = 0;
277 bool fieldFound =
false;
278 for (
auto f : fieldsOut)
288 if (fieldFound && moduleMap.find(outId) != moduleMap.end())
290 auto outBlock = moduleMap[outId];
299 for (
auto m : modules)
301 createModuleConnections(m.second);