2#include <Wt/WEnvironment.h>
3#include <Wt/WApplication.h>
4#include <Wt/WMessageBox.h>
9 setPreferredMethod(Wt::RenderMethod::HtmlCanvas);
21 mLastMousePos = Wt::WPointF(event.widget().x, event.widget().y);
47 if (existConnection !=
nullptr)
50 for (
auto it =
mScene->begin(); it !=
mScene->end(); it++)
53 auto node =
nodeMap[m->objectId()];
54 auto outPortIndex = existConnection->getPortIndex(
PortType::Out);
55 auto exportPortsData = outNode->flowNodeData().getPointsData();
57 for (
auto point : exportPortsData)
59 if (point.portIndex == outPortIndex)
61 exportPointData = point;
70 if (it->exportNode ==
mOutNode && it->inportNode == m && it->inPoint.portIndex ==
outPoint.portIndex && it->outPoint.portIndex == exportPointData.
portIndex)
105 Wt::WPointF delta = Wt::WPointF(event.dragDelta().x, event.dragDelta().y);
112 Wt::WPointF delta = Wt::WPointF(event.dragDelta().x, event.dragDelta().y);
119 for (
auto it =
mScene->begin(); it !=
mScene->end(); it++)
122 auto node =
nodeMap[m->objectId()];
123 auto nodeData = node->flowNodeData();
124 auto mousePoint = Wt::WPointF(event.widget().x, event.widget().y);
143 Wt::WPointF mouseWentUpPosition = Wt::WPointF(event.widget().x, event.widget().y);
147 auto nodeData = node->flowNodeData();
151 Wt::WPointF mousePoint = Wt::WPointF(event.widget().x, event.widget().y);
163 auto nodeWidget =
dynamic_cast<WtNodeWidget*
>(node->nodeDataModel());
164 auto m = nodeWidget->
getNode();
180 auto nodeWidget =
dynamic_cast<WtNodeWidget*
>(node->nodeDataModel());
181 auto m = nodeWidget->
getNode();
202 for (
auto it =
mScene->begin(); it !=
mScene->end(); it++)
205 auto node =
nodeMap[m->objectId()];
206 auto nodeData = node->flowNodeData();
209 auto connectionInNode = node;
255 Wt::WPainter painter(paintDevice);
284 for (
auto it =
mScene->begin(); it !=
mScene->end(); it++)
287 auto node =
nodeMap[m->objectId()];
288 auto nodeData = node->flowNodeData();
304 Wt::WPointF topLeft = Wt::WPointF(relativeHotkey.topLeft().x() + origin.x(), relativeHotkey.topLeft().y() + origin.y());
305 Wt::WPointF bottomRight = Wt::WPointF(relativeHotkey.bottomRight().x() + origin.x(), relativeHotkey.bottomRight().y() + origin.y());
307 Wt::WRectF absRect = Wt::WRectF(topLeft, bottomRight);
311 return absRect.contains(trueMouse);
319 Wt::WPointF topLeft = Wt::WPointF(relativeHotkey.topLeft().x() + origin.x(), relativeHotkey.topLeft().y() + origin.y());
320 Wt::WPointF bottomRight = Wt::WPointF(relativeHotkey.bottomRight().x() + origin.x(), relativeHotkey.bottomRight().y() + origin.y());
322 Wt::WRectF absRect = Wt::WRectF(topLeft, bottomRight);
326 return absRect.contains(trueMouse);
333 Wt::WPointF topLeft = Wt::WPointF(portData.
diamond_out[3].x() + origin.x(), portData.
diamond_out[2].y() + origin.y());
334 Wt::WPointF bottomRight = Wt::WPointF(portData.
diamond_out[1].x() + origin.x(), portData.
diamond_out[0].y() + origin.y());
335 Wt::WRectF diamondBoundingRect = Wt::WRectF(topLeft, bottomRight);
336 return Wt::WPointF((topLeft.x() + bottomRight.x()) / 2, (topLeft.y() + bottomRight.y()) / 2);
340 Wt::WPointF topLeft = Wt::WPointF(portData.
diamond[3].x() + origin.x(), portData.
diamond[2].y() + origin.y());
341 Wt::WPointF bottomRight = Wt::WPointF(portData.
diamond[1].x() + origin.x(), portData.
diamond[0].y() + origin.y());
342 Wt::WRectF diamondBoundingRect = Wt::WRectF(topLeft, bottomRight);
343 return Wt::WPointF((topLeft.x() + bottomRight.x()) / 2, (topLeft.y() + bottomRight.y()) / 2);
347 auto rectTopLeft = portData.
pointRect.topLeft();
348 auto rectBottomRight = portData.
pointRect.bottomRight();
349 Wt::WPointF topLeft = Wt::WPointF(rectTopLeft.x() + origin.x(), rectTopLeft.y() + origin.y());
350 Wt::WPointF bottomRight = Wt::WPointF(rectBottomRight.x() + origin.x(), rectBottomRight.y() + origin.y());
351 Wt::WRectF diamondBoundingRect = Wt::WRectF(topLeft, bottomRight);
352 return Wt::WPointF((topLeft.x() + bottomRight.x()) / 2, (topLeft.y() + bottomRight.y()) / 2);
362 auto node = nodeData->getNode();
366 if (c.exportNode == node || c.inportNode == node)
368 Wt::WMessageBox::show(
"Error",
369 "<p>Please disconnect before deleting the node </p>",
370 Wt::StandardButton::Ok);
391 auto node = nodeData->getNode();
392 node->setBlockCoord(newLocation.x(), newLocation.y());
401 auto node = nodeData->getNode();
402 node->setVisible(checked);
410 auto node = nodeData->getNode();
411 node->setActive(checked);
417 auto inportIndex =
inPoint.portIndex;
420 exportNode->disconnect(inportNode->getImportNodes()[inportIndex]);
424 auto outFieldNum = 0;
426 for (
auto point : outPoints)
430 outFieldNum = point.portIndex;
435 auto field = exportNode->getOutputFields()[
outPoint.portIndex - outFieldNum];
445 for (
auto point : points)
456 auto inField = inportNode->getInputFields()[
inPoint.portIndex - fieldNum];
458 field->disconnect(inField);
Wt::WRectF getHotKey1BoundingRect()
Wt::WRectF getHotKey0BoundingRect()
std::vector< connectionPointData > getPointsData()
Wt::WPointF getNodeOrigin() const
WtNodeDataModel * nodeDataModel() const
WtFlowNodeData & flowNodeData()
Wt::WPointF diamond_out[4]
std::shared_ptr< Node > inportNode
std::shared_ptr< Node > exportNode
connectionPointData inPoint
connectionPointData outPoint