PeriDyno 1.2.1
Loading...
Searching...
No Matches
QtNodeFlowScene.cpp
Go to the documentation of this file.
1#include "QtNodeFlowScene.h"
2#include "QtNodeWidget.h"
3
4#include "nodes/QNode"
5
6#include "Format.h"
7
8#include "Object.h"
9#include "NodeIterator.h"
10#include "NodePort.h"
11#include "Action.h"
13#include "AutoLayoutDAG.h"
14#include "SceneGraphFactory.h"
15
16#include <QtWidgets/QMessageBox>
17#include <QKeySequence>
18#include <QShortcut>
19#include <QMenu>
20#include "iostream"
21
22namespace Qt
23{
24 QtNodeFlowScene::QtNodeFlowScene(std::shared_ptr<QtDataModelRegistry> registry, QObject* parent)
25 : QtFlowScene(registry, parent)
26 {
27 }
28
30 : QtFlowScene(parent)
31 {
32 auto classMap = dyno::Object::getClassMap();
33
34 auto ret = std::make_shared<QtDataModelRegistry>();
35 int id = 0;
36 for (auto const c : *classMap)
37 {
38 id++;
39
40 QString str = QString::fromStdString(c.first);
41 auto obj = dyno::Object::createObject(str.toStdString());
42 std::shared_ptr<dyno::Node> node(dynamic_cast<dyno::Node*>(obj));
43
44 if (node != nullptr)
45 {
46 QtDataModelRegistry::RegistryItemCreator creator = [str]() {
47 auto node_obj = dyno::Object::createObject(str.toStdString());
48 std::shared_ptr<dyno::Node> new_node(dynamic_cast<dyno::Node*>(node_obj));
49 auto dat = std::make_unique<QtNodeWidget>(std::move(new_node));
50 return dat;
51 };
52
53 QString category = dyno::FormatBlockCaptionName(node->getNodeType());
54 ret->registerModel<QtNodeWidget>(category, creator);
55 }
56 }
57
58 this->setRegistry(ret);
59
62
63 connect(this, &QtFlowScene::nodeMoved, this, &QtNodeFlowScene::moveNode);
64 connect(this, &QtFlowScene::nodePlaced, this, &QtNodeFlowScene::addNode);
65 connect(this, &QtFlowScene::nodeDeleted, this, &QtNodeFlowScene::deleteNode);
66
67// connect(this, &QtFlowScene::nodeHotKey0Checked, this, &QtNodeFlowScene::enableRendering);
68// connect(this, &QtFlowScene::nodeHotKey1Checked, this, &QtNodeFlowScene::enablePhysics);
69
70 connect(this, &QtFlowScene::nodeHotKeyClicked, [this](QtNode& n, bool checked, int buttonId) {
71
72 switch (buttonId)
73 {
74 case 0:
75 enableRendering(n, checked);
76 break;
77 case 1:
78 enablePhysics(n, checked);
79 break;
80 case 2:
81 enableAutoSync(n, checked);
82 break;
83 case 3:
84 resetNode(n);
85 break;
86
87 default:
88 break;
89 }
90
91 });
92 //connect(this, &QtFlowScene::nodeHotKey2Checked, this, &QtNodeFlowScene::Key2_Signal);
93
94 connect(this, &QtFlowScene::nodeContextMenu, this, &QtNodeFlowScene::showContextMenu);
95 }
96
98 {
99 clearScene();
100 }
101
103 {
105
106 std::map<dyno::ObjectId, QtNode*> nodeMap;
107
108 //auto root = scn->getRootNode();
109
110 //SceneGraph::Iterator it_end(nullptr);
111
112 auto addNodeWidget = [&](std::shared_ptr<Node> m) -> void
113 {
114 auto mId = m->objectId();
115
116 auto type = std::make_unique<QtNodeWidget>(m);
117
118 auto& node = this->createNode(std::move(type));
119
120 nodeMap[mId] = &node;
121
122 QPointF posView(m->bx(), m->by());
123
124 node.nodeGraphicsObject().setPos(posView);
125
126 //this->nodePlaced(node);
127 };
128
129 for (auto it = scn->begin(); it != scn->end(); it++)
130 {
131 addNodeWidget(it.get());
132 }
133
134 auto createNodeConnections = [&](std::shared_ptr<Node> nd) -> void
135 {
136 auto inId = nd->objectId();
137
138 if (nodeMap.find(inId) != nodeMap.end())
139 {
140 auto inBlock = nodeMap[nd->objectId()];
141
142 auto ports = nd->getImportNodes();
143
144 for (int i = 0; i < ports.size(); i++)
145 {
146 dyno::NodePortType pType = ports[i]->getPortType();
147 if (dyno::Single == pType)
148 {
149 auto node = ports[i]->getNodes()[0];
150 if (node != nullptr)
151 {
152 auto outId = node->objectId();
153 if (nodeMap.find(outId) != nodeMap.end())
154 {
155 auto outBlock = nodeMap[node->objectId()];
156 createConnection(*inBlock, i, *outBlock, 0);
157 }
158 }
159 }
160 else if (dyno::Multiple == pType)
161 {
162 //TODO: a weird problem exist here, if the expression "auto& nodes = ports[i]->getNodes()" is used,
163 //we still have to call clear to avoid memory leak.
164 auto& nodes = ports[i]->getNodes();
165 //ports[i]->clear();
166 for (int j = 0; j < nodes.size(); j++)
167 {
168 if (nodes[j] != nullptr)
169 {
170 auto outId = nodes[j]->objectId();
171 if (nodeMap.find(outId) != nodeMap.end())
172 {
173 auto outBlock = nodeMap[outId];
174 createConnection(*inBlock, i, *outBlock, 0);
175 }
176 }
177 }
178 //nodes.clear();
179 }
180 }
181
182 auto fieldInp = nd->getInputFields();
183 for (int i = 0; i < fieldInp.size(); i++)
184 {
185 std::vector<FBase*> validFields;
186 fieldInp[i]->requestValidSources(validFields);
187 for (auto fieldSrc : validFields)
188 {
189 if (fieldSrc != nullptr) {
190 auto parSrc = fieldSrc->parent();
191 if (parSrc != nullptr)
192 {
193 //To handle fields from node states or outputs
194 dyno::Node* nodeSrc = dynamic_cast<dyno::Node*>(parSrc);
195
196 //To handle fields that are exported from module outputs
197 if (nodeSrc == nullptr)
198 {
199 dyno::Module* moduleSrc = dynamic_cast<dyno::Module*>(parSrc);
200 if (moduleSrc != nullptr)
201 nodeSrc = moduleSrc->getParentNode();
202 }
203
204 if (nodeSrc != nullptr)
205 {
206 auto outId = nodeSrc->objectId();
207 auto fieldsOut = nodeSrc->getOutputFields();
208
209 uint outFieldIndex = 0;
210 bool fieldFound = false;
211 for (auto f : fieldsOut)
212 {
213 if (f == fieldSrc)
214 {
215 fieldFound = true;
216 break;
217 }
218 outFieldIndex++;
219 }
220
221 if (nodeMap[outId]->nodeDataModel()->allowExported()) outFieldIndex++;
222
223 if (fieldFound && nodeMap.find(outId) != nodeMap.end())
224 {
225 auto outBlock = nodeMap[outId];
226 createConnection(*inBlock, i + ports.size(), *outBlock, outFieldIndex);
227 }
228 }
229 }
230 }
231 }
232 validFields.clear();
233 }
234 }
235 };
236
237 for (auto it = scn->begin(); it != scn->end(); it++)
238 {
239 createNodeConnections(it.get());
240 }
241
242 // // clearScene();
243 // //
244 // for (auto it = scn->begin(); it != scn->end(); it++)
245 // {
246 // auto node_ptr = it.get();
247 // std::cout << node_ptr->getClassInfo()->getClassName() << ": " << node_ptr.use_count() << std::endl;
248 // }
249
250 nodeMap.clear();
251 }
252
254 {
256
257 clearScene();
258
260
262 }
263
265 {
267
268 clearScene();
269
270 auto f = status == Qt::Checked ? field->promoteOuput() : field->demoteOuput();
271
273
275 }
276
277 void QtNodeFlowScene::moveNode(QtNode& n, const QPointF& newLocation)
278 {
279 auto nodeData = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
280
281 if (mEditingEnabled && nodeData != nullptr) {
282 auto node = nodeData->getNode();
283 node->setBlockCoord(newLocation.x(), newLocation.y());
284 }
285 }
286
288 {
289 auto nodeData = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
290
291 if (mEditingEnabled && nodeData != nullptr) {
293 scn->addNode(nodeData->getNode());
294 }
295 }
296
297 void QtNodeFlowScene::addNodeByString(std::string NodeName) {
298 std::cout << NodeName << std::endl;
299
300 auto node_obj = dyno::Object::createObject(NodeName);
301 std::shared_ptr<dyno::Node> new_node(dynamic_cast<dyno::Node*>(node_obj));
302 auto dat = std::make_unique<QtNodeWidget>(std::move(new_node));
303
304 if (dat != nullptr) {
306 scn->addNode(dat->getNode());
307 }
308 else {
309 std::cout << "nullptr" << std::endl;
310 }
311 int mId;
312 auto addNodeWidget = [&](std::shared_ptr<Node> m) -> void
313 {
314 mId = m->objectId();
315
316 auto type = std::make_unique<QtNodeWidget>(m);
317
318 auto& node = this->createNode(std::move(type));
319
320 QPointF posView(m->bx(), m->by());
321
322 node.nodeGraphicsObject().setPos(posView);
323
324 this->nodePlaced(node);
325 };
327 int x = 0;
328 for (auto it = scn->begin(); it != scn->end(); it++)
329 {
330 if (x == mId) {
331 addNodeWidget(it.get());
332 break;
333 }
334 x++;
335 }
336 addNodeWidget(dat->getNode());
337 }
338
340 {
341 mEditingEnabled = true;
342
343 auto allNodes = this->allNodes();
344
345 for (auto node : allNodes)
346 {
347 auto model = dynamic_cast<QtNodeWidget*>(node->nodeDataModel());
348 if (model != nullptr)
349 {
350 model->enableEditing();
351 }
352 }
353 }
354
356 {
357 mEditingEnabled = false;
358
359 auto allNodes = this->allNodes();
360
361 for (auto node : allNodes)
362 {
363 auto model = dynamic_cast<QtNodeWidget*>(node->nodeDataModel());
364 if (model != nullptr)
365 {
366 model->disableEditing();
367 }
368 }
369 }
370
372 {
373 auto nodeData = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
374
375 if (mEditingEnabled && nodeData != nullptr) {
377 scn->deleteNode(nodeData->getNode());
378
379 emit this->nodeDeselected();
380 }
381 }
382
383 void QtNodeFlowScene::createQtNode(std::shared_ptr<dyno::Node> node)
384 {
385 if (node == nullptr)
386 return;
387
388 auto qNodeWdiget = std::make_unique<QtNodeWidget>(node);
389 auto& qNode = createNode(std::move(qNodeWdiget));
390
391 //Calculate the position for the newly create node to avoid overlapping
392 auto& _nodes = this->nodes();
393 float y = -10000.0f;
394 for (auto const& _node : _nodes)
395 {
396 NodeGeometry& geo = _node.second->nodeGeometry();
397 QtNodeGraphicsObject& obj = _node.second->nodeGraphicsObject();
398
399 float h = geo.height();
400
401 QPointF pos = obj.pos();
402
403 y = std::max(y, float(pos.y() + h));
404 }
405
406 QPointF posView(0.0f, y + 50.0f);
407
408 qNode.nodeGraphicsObject().setPos(posView);
409
410 emit nodePlaced(qNode);
411 }
412
413 void QtNodeFlowScene::enableRendering(QtNode& n, bool checked)
414 {
415 auto nodeData = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
416
417 if (mEditingEnabled && nodeData != nullptr) {
418 auto node = nodeData->getNode();
419 node->setVisible(!checked);
420 node->graphicsPipeline()->enable();
421 node->graphicsPipeline()->update();
422 }
423 }
424
425 void QtNodeFlowScene::enableAutoSync(QtNode& n, bool checked)
426 {
427 auto nodeData = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
428
429 if (mEditingEnabled && nodeData != nullptr) {
430 auto node = nodeData->getNode();
431 node->setAutoSync(checked);
432 }
433 }
434
435 void QtNodeFlowScene::enablePhysics(QtNode& n, bool checked)
436 {
437 auto nodeData = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
438
439 if (mEditingEnabled && nodeData != nullptr) {
440 auto node = nodeData->getNode();
441 node->setActive(!checked);
442 node->animationPipeline()->update();
443 }
444 }
445
447 {
448 auto nodeData = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
449
450 if (mEditingEnabled && nodeData != nullptr) {
451 auto node = nodeData->getNode();
452 node->reset();
453 }
454 }
455
456 void QtNodeFlowScene::showContextMenu(QtNode& n, const QPointF& pos)
457 {
458
459 auto qDataModel = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
460 auto node = qDataModel->getNode();
461 if (node == nullptr) {
462 return;
463 }
464
465 auto menu = new QMenu;
466 menu->setStyleSheet("QMenu{color:white;border: 1px solid black;} "); //QMenu::item:selected {background-color : #4b586a;}
467
468 auto openAct = new QAction("Open", this);
469
470 auto showAllNodesAct = new QAction("Show All Nodes", this);
471 auto showThisNodeOnlyAct = new QAction("Show This Only", this);
472
473 showAllNodesAct->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_V));
474 showThisNodeOnlyAct->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_H));
475
476 auto delAct = new QAction("Delete", this);
477 auto helpAct = new QAction("Help", this);
478
479 menu->addAction(openAct);
480
481 menu->addSeparator();
482 menu->addAction(showThisNodeOnlyAct);
483 menu->addAction(showAllNodesAct);
484
485
486 auto resetNodeAct = new QAction("Reset This Node", this);
487 auto activateThisNodeOnlyAct = new QAction("Activate This Only", this);
488 auto activateAllNodesAct = new QAction("Activate All Nodes", this);
489 menu->addSeparator();
490 menu->addAction(resetNodeAct);
491
492 menu->addSeparator();
493 menu->addAction(activateThisNodeOnlyAct);
494 menu->addAction(activateAllNodesAct);
495
496 menu->addSeparator();
497 auto autoSyncAct = new QAction("Auto-Sync", this);
498 autoSyncAct->setCheckable(true);
499 autoSyncAct->setChecked(node->isAutoSync());
500
501 auto enableDiscendants = new QAction("Enable Descendants' Auto-Sync(s)", this);
502 auto disableDiscendants = new QAction("Disable Descendants' Auto-Sync(s)", this);
503 auto enableAutoSync = new QAction("Enable All Auto-Sync(s)", this);
504 auto disableAutoSync = new QAction("Disable All Auto-Sync(s)", this);
505 menu->addAction(autoSyncAct);
506 menu->addAction(enableDiscendants);
507 menu->addAction(disableDiscendants);
508 menu->addAction(enableAutoSync);
509 menu->addAction(disableAutoSync);
510
511 menu->addSeparator();
512 menu->addAction(delAct);
513
514 menu->addSeparator();
515 menu->addAction(helpAct);
516
517 connect(openAct, &QAction::triggered, this, [&]() { nodeDoubleClicked(n); });
518
519
520 connect(showAllNodesAct, &QAction::triggered, this, [&]() {
521 showAllNodes();
522 });
523
524 connect(showThisNodeOnlyAct, &QAction::triggered, this, [&]() {
526 });
527
528 connect(resetNodeAct, &QAction::triggered, this, [&]() {
529 resetNode(n);
530 });
531
532 connect(activateAllNodesAct, &QAction::triggered, this, [&]() {
534 });
535
536 connect(activateThisNodeOnlyAct, &QAction::triggered, this, [&]() {
538 });
539
540 connect(autoSyncAct, &QAction::triggered, this, [=](bool checked) {
541 node->setAutoSync(checked);
542 });
543
544 connect(enableDiscendants, &QAction::triggered, this, [&]() {
545 autoSyncAllDescendants(n, true);
546 });
547
548 connect(disableDiscendants, &QAction::triggered, this, [&]() {
549 autoSyncAllDescendants(n, false);
550 });
551
552 connect(enableAutoSync, &QAction::triggered, this, [=]() {
553 autoSyncAllNodes(true);
554 });
555
556 connect(disableAutoSync, &QAction::triggered, this, [=]() {
557 autoSyncAllNodes(false);
558 });
559
560 connect(delAct, &QAction::triggered, this, [&]() { this->removeNode(n); });
561 connect(helpAct, &QAction::triggered, this, [&]() { this->showHelper(n); });
562
563 menu->move(QCursor().pos().x() + 4, QCursor().pos().y() + 4);
564 menu->show();
565 }
566
568 {
569 auto nodes = this->allNodes();
570 for (auto node : nodes)
571 {
572 if (node->id() == n.id())
573 {
574 this->enableRendering(*node, false);
575 }
576 else
577 {
578 this->enableRendering(*node, true);
579 }
580 }
581
582 this->updateNodeGraphView();
583
584 nodes.clear();
585 }
586
588 {
589 auto nodes = this->allNodes();
590 for (auto node : nodes)
591 {
592 this->enableRendering(*node, false);
593 }
594
595 this->updateNodeGraphView();
596
597 nodes.clear();
598 }
599
601 {
602 auto nodes = this->allNodes();
603 for (auto node : nodes)
604 {
605 if (node->id() == n.id())
606 {
607 this->enablePhysics(*node, false);
608 }
609 else
610 {
611 this->enablePhysics(*node, true);
612 }
613 }
614
615 this->updateNodeGraphView();
616
617 nodes.clear();
618 }
619
621 {
622 auto nodes = this->allNodes();
623 for (auto node : nodes)
624 {
625 this->enablePhysics(*node, false);
626 }
627
628 this->updateNodeGraphView();
629
630 nodes.clear();
631 }
632
634 {
635 auto nodes = this->allNodes();
636 for (auto node : nodes)
637 {
638 auto dataModel = dynamic_cast<QtNodeWidget*>(node->nodeDataModel());
639 if (dataModel != nullptr)
640 {
641 auto dNode = dataModel->getNode();
642 dNode->setAutoSync(autoSync);
643 }
644 }
645
646 this->updateNodeGraphView();
647
648 nodes.clear();
649 }
650
651 void QtNodeFlowScene::autoSyncAllDescendants(QtNode& n, bool autoSync)
652 {
654
655 class ToggleAutoSyncAct : public dyno::Action
656 {
657 public:
658 ToggleAutoSyncAct(bool autoSync) { mAutoSync = autoSync; }
659
660 void process(Node* node) override {
661 node->setAutoSync(mAutoSync);
662 }
663
664 private:
665 bool mAutoSync = true;
666 };
667
668 ToggleAutoSyncAct act(autoSync);
669
670 auto dataModel = dynamic_cast<QtNodeWidget*>(n.nodeDataModel());
671 if (dataModel != nullptr)
672 {
673 auto dNode = dataModel->getNode();
674 if (dNode == nullptr) return;
675
676 scn->traverseForward(dNode, &act);
677 }
678
679 this->updateNodeGraphView();
680 }
681
682 //TODO: show a message on how to use this node
684 {
685 QMessageBox::information(nullptr, "Node Info", "Show something about this node");
686 }
687
689 {
691
693
694 auto constructDAG = [&](std::shared_ptr<Node> nd) -> void
695 {
696
697 auto inId = nd->objectId();
698
699 auto ports = nd->getImportNodes();
700
701 graph.addOtherVertices(inId);
702 graph.removeID();
703
704 bool NodeConnection = false;
705 bool FieldConnection = false;
706 for (int i = 0; i < ports.size(); i++)
707 {
708 dyno::NodePortType pType = ports[i]->getPortType();
709 if (dyno::Single == pType)
710 {
711 auto node = ports[i]->getNodes()[0];
712 if (node != nullptr)
713 {
714 auto outId = node->objectId();
715
716 graph.addEdge(outId, inId);
717
718 graph.removeID(outId, inId);
719 }
720 }
721 else if (dyno::Multiple == pType)
722 {
723 auto& nodes = ports[i]->getNodes();
724 for (int j = 0; j < nodes.size(); j++)
725 {
726 if (nodes[j] != nullptr)
727 {
728 auto outId = nodes[j]->objectId();
729
730 graph.addEdge(outId, inId);
731 graph.removeID(outId, inId);
732
733 }
734 }
735 //nodes.clear();
736 }
737
738 }
739
740
741 auto fieldInp = nd->getInputFields();
742 for (int i = 0; i < fieldInp.size(); i++)//����ÿ��Node��Inputfield
743 {
744 std::vector<FBase*> validFields;
745 fieldInp[i]->requestValidSources(validFields);
746 for (auto fieldSrc : validFields)
747 {
748 if (fieldSrc != nullptr) {
749 auto parSrc = fieldSrc->parent();
750 if (parSrc != nullptr)
751 {
752 Node* nodeSrc = dynamic_cast<Node*>(parSrc);
753
754 // Otherwise parSrc is a field of Module
755 if (nodeSrc == nullptr)
756 {
757 dyno::Module* moduleSrc = dynamic_cast<dyno::Module*>(parSrc);
758 if (moduleSrc != nullptr)
759 nodeSrc = moduleSrc->getParentNode();
760 }
761
762 if (nodeSrc != nullptr)
763 {
764 auto outId = nodeSrc->objectId();
765
766 graph.addEdge(outId, inId);
767
768 graph.removeID(outId, inId);
769 }
770 }
771 }
772 }
773 validFields.clear();
774 }
775 };
776 for (auto it = scn->begin(); it != scn->end(); it++)
777 {
778 constructDAG(it.get());
779 }
780
781
782 dyno::AutoLayoutDAG layout(&graph);
783 layout.update();
784
785 //Set up the mapping from ObjectId to QtNode
786 auto& _nodes = this->nodes();
787 std::map<dyno::ObjectId, QtNode*> qtNodeMapper;
788 std::map<dyno::ObjectId, Node*> nodeMapper;
789 for (auto const& _node : _nodes)
790 {
791 auto const& qtNode = _node.second;
792 auto model = qtNode->nodeDataModel();
793
794 auto nodeData = dynamic_cast<QtNodeWidget*>(model);
795
796 if (model != nullptr)
797 {
798 auto node = nodeData->getNode();
799 if (node != nullptr)
800 {
801 qtNodeMapper[node->objectId()] = qtNode.get();
802 nodeMapper[node->objectId()] = node.get();
803 }
804 }
805 }
806 float tempOffsetY = 0.0f;
807
808 float offsetX = 0.0f;
809 for (size_t l = 0; l < layout.layerNumber(); l++)
810 {
811 auto& xc = layout.layer(l);
812
813 float offsetY = 0.0f;
814 float xMax = 0.0f;
815 for (size_t index = 0; index < xc.size(); index++)
816 {
817 dyno::ObjectId id = xc[index];
818 if (qtNodeMapper.find(id) != qtNodeMapper.end())
819 {
820 QtNode* qtNode = qtNodeMapper[id];
821 NodeGeometry& geo = qtNode->nodeGeometry();
822
823 float w = geo.width();
824 float h = geo.height();
825
826 xMax = std::max(xMax, w);
827
828 Node* node = nodeMapper[id];
829
830 node->setBlockCoord(offsetX, offsetY);
831
832 offsetY += (h + mDy);
833
834 }
835 }
836
837 offsetX += (xMax + mDx);
838
839 tempOffsetY = std::max(tempOffsetY, offsetY);
840
841
842
843 }
844
845 //��ɢ�ڵ������
846 auto otherVertices = layout.getOtherVertices();
847 float width = 0;
848 float heigth = 0;
849 std::set<dyno::ObjectId>::iterator it;
850
851 float ofstY = tempOffsetY;
852 float ofstX = 0;
853 for (it = otherVertices.begin(); it != otherVertices.end(); it++)
854 {
855 dyno::ObjectId id = *it;
856 if (qtNodeMapper.find(id) != qtNodeMapper.end())
857 {
858 QtNode* qtNode = qtNodeMapper[id];
859 NodeGeometry& geo = qtNode->nodeGeometry();
860 width = geo.width();
861 heigth = geo.height();
862
863 Node* node = nodeMapper[id];
864
865
866 node->setBlockCoord(ofstX, ofstY);
867 ofstX += width + mDx;
868
869 }
870
871 }
872
873
874 qtNodeMapper.clear();
875 nodeMapper.clear();
876
878 }
879}
unsigned int uint
Definition VkReduce.h:5
void deleteNode(QtNode &n)
void showHelper(QtNode &n)
void enableRendering(QtNode &n, bool checked)
void createQtNode(std::shared_ptr< dyno::Node > node)
void enablePhysics(QtNode &n, bool checked)
void autoSyncAllNodes(bool autoSync)
void enableAutoSync(QtNode &n, bool checked)
void updateNodeGraphView()
Update the view only for the active scene graph, the data model will not be changed.
void resetNode(QtNode &n)
void showThisNodeOnly(QtNode &n)
void moveNode(QtNode &n, const QPointF &newLocation)
void addNodeByString(std::string NodeName)
void createNodeGraphView()
create a QT-based view for the active scene graph.
void addNode(QtNode &n)
void autoSyncAllDescendants(QtNode &n, bool autoSync)
void showContextMenu(QtNode &n, const QPointF &pos)
void activateThisNodeOnly(QtNode &n)
void fieldUpdated(dyno::FBase *field, int status)
QtNodeFlowScene(std::shared_ptr< QtDataModelRegistry > registry, QObject *parent=Q_NULLPTR)
The model dictates the number of inputs and outputs for the Node.
std::shared_ptr< Node > getNode()
Automatic layout for directed acyclic graph Refer to "Sugiyama Algorithm" by Nikola S....
std::set< ObjectId > & getOtherVertices()
std::vector< ObjectId > & layer(size_t l)
Graph class represents a directed graph.
void removeID(ObjectId v=-1, ObjectId w=-1)
void addEdge(ObjectId v, ObjectId w)
FBase * promoteOuput()
Display a state field as an ouput field.
Definition FBase.cpp:57
FBase * demoteOuput()
Hide a state field from outputs.
Definition FBase.cpp:81
Node * getParentNode()
Definition Module.cpp:246
void setAutoSync(bool con)
Whether the node can be automatically synchronized when its ancestor is updated.
Definition Node.cpp:54
std::vector< FBase * > & getOutputFields()
Definition OBase.h:179
void setBlockCoord(float x, float y)
Definition OBase.h:161
static std::map< std::string, ClassInfo * > * getClassMap()
Definition Object.cpp:42
static Object * createObject(std::string name)
Definition Object.cpp:33
ObjectId objectId()
Definition Object.h:129
static SceneGraphFactory * instance()
std::shared_ptr< SceneGraph > active()
QString FormatBlockCaptionName(std::string name)
Definition Format.cpp:64
uint32_t ObjectId
Definition Object.h:110
NodePortType
Definition NodePort.h:27
@ Multiple
Definition NodePort.h:29
@ Single
Definition NodePort.h:28