Change connections to have multiple destination points
MODIFY
src/graphics/connection.h
src/graphics/connection.h
@@ -39,11 +39,12 @@ class Connection : public QObject, public QGraphicsItem {
Q_OBJECT
public:
Connection(Shape* source, QPointF* sourcePoint, Shape* dest, QPointF* destPoint);
+ Connection(Shape* source, QPointF* sourcePoint, QList<QPair<Shape*, QPointF*>> dests);
void setValueDrawPos(ValueDrawPos pos) { m_valuePos = pos, update(); }
void setValue(uint32_t value);
QPair<QPointF, QPointF> getPoints() const;
- QPair<Shape*, Shape*> getShapes() const { return QPair<Shape*, Shape*>(m_source, m_dest); }
+ QPair<Shape*, Shape*> getShapes() const { return QPair<Shape*, Shape*>(m_source, m_dests[0].first); }
Shape* getSource() { return m_source; }
static int connectionType() { return QGraphicsItem::UserType + 1; }
@@ -84,9 +85,8 @@ private:
int m_arrowSize = 10;
Shape* m_source;
- Shape* m_dest;
QPointF* m_sourcePointPtr;
- QPointF* m_destPointPtr;
+ QList<QPair<Shape*,QPointF*>> m_dests;
Label m_label;
};

MODIFY
src/graphics/pipelinewidget.cpp
src/graphics/pipelinewidget.cpp
@@ -290,7 +290,8 @@ void PipelineWidget::moveToIO(Graphics::Shape* source, Graphics::Shape* dest, QP
Graphics::Connection* PipelineWidget::createConnection(Graphics::Shape* source, int index1, Graphics::Shape* dest,
int index2) {
- // for testing
+ // Connects a source and destination shape using IO index numbers
+
static uint32_t value = 1;
value <<= 1;
//
@@ -305,9 +306,35 @@ Graphics::Connection* PipelineWidget::createConnection(Graphics::Shape* source,
connection->addLabelToScene();
return connection;
}
+Graphics::Connection* PipelineWidget::createConnection(Graphics::Shape* source, int index1,
+ QList<QPair<Graphics::Shape*, int>> dests) {
+ // Connects multiple input points to one output point
+
+ // Generate list of output shapes and points
+ QList<QPair<Graphics::Shape*,QPointF*>> shapePointList;
+ for (const auto& dest : dests) {
+ shapePointList << QPair<Graphics::Shape*, QPointF*>(dest.first, dest.first->getOutputPoint(dest.second));
+ }
+
+ // Create connection
+ Graphics::Connection* connection =
+ new Graphics::Connection(source, source->getOutputPoint(index1), shapePointList);
+ connect(this, &PipelineWidget::displayAllValuesSig, connection, &Graphics::Connection::showValue);
+ source->addConnection(connection);
+ m_connections.append(connection);
+ scene()->addItem(connection);
+ connection->addLabelToScene();
+
+ // Add connection to destination shapes
+ for(const auto& dest: dests){
+ dest.first->addConnection(connection);
+ }
+ return connection;
+}
Graphics::Connection* PipelineWidget::createConnection(Graphics::Shape* source, Graphics::Shape* dest,
QPointF* sourcePoint, QPointF* destPoint) {
+ // Connects source and destinations using point pointers
Graphics::Connection* connection = new Graphics::Connection(source, sourcePoint, dest, destPoint);
m_connections.append(connection);
source->addConnection(connection);

MODIFY
src/graphics/pipelinewidget.h
src/graphics/pipelinewidget.h
#include <QGraphicsItem>
#include <QGraphicsView>
+#include <QPair>
namespace Graphics {
class Connection;
@@ -28,6 +29,7 @@ private:
Graphics::Connection* createConnection(Graphics::Shape* source, int index1, Graphics::Shape* dest, int index2);
Graphics::Connection* createConnection(Graphics::Shape* source, Graphics::Shape* dest, QPointF* sourcePoint,
QPointF* destPoint);
+ Graphics::Connection* createConnection(Graphics::Shape* source, int index1, QList<QPair<Graphics::Shape*,int>> dests);
void moveToIO(Graphics::Shape* source, Graphics::Shape* dest, QPointF* sourcePoint, QPointF* destPointm,
int connectionLength = minConnectionLen);

Change connections to have multiple destination points