diff --git a/agui2/graphics/graphicsbox.cpp b/agui2/graphics/graphicsbox.cpp index b84986f0d060dda9f614a5f5fe94414d554b3f54..711e3a765c1c582ce93cc5b81a6e3482779de4f6 100644 --- a/agui2/graphics/graphicsbox.cpp +++ b/agui2/graphics/graphicsbox.cpp @@ -49,11 +49,31 @@ void GraphicsBox::addOutput(GraphicsConnection *connection) m_OutConnection = connection; } +void GraphicsBox::addInput(GraphicsConnection *connection) +{ + m_InConnections.append( connection ); +} + void GraphicsBox::removeOutput() { m_OutConnection = NULL; } +void GraphicsBox::removeInput(GraphicsConnection *connection) +{ + m_InConnections.removeOne( connection ); +} + +void GraphicsBox::disconnectInputEvent( WrapperBox* origin, GraphicsConnection *connection) +{ + m_wrapper->removeInput( origin, connection ); +} + +void GraphicsBox::disconnectOutputEvent() +{ + m_wrapper->removeOutput(); +} + QPointF GraphicsBox::getConnectionOrigin() { return QPointF(m_boundRect.right(), m_boundRect.center().y()); @@ -64,11 +84,6 @@ QPointF GraphicsBox::getConnectionTarget() return QPointF(m_boundRect.left(), m_boundRect.center().y()); } -WrapperBox *GraphicsBox::wrapper() -{ - return m_wrapper; -} - void GraphicsBox::setWrapper(WrapperBox *wrapper) { m_wrapper = wrapper; diff --git a/agui2/graphics/graphicsbox.h b/agui2/graphics/graphicsbox.h index c6e758ac0b1a7f16df617c6099bfc50915f18563..859e4e96dc8d22f037002d1f94952d0d8b9ecd65 100644 --- a/agui2/graphics/graphicsbox.h +++ b/agui2/graphics/graphicsbox.h @@ -23,19 +23,21 @@ public: virtual ~GraphicsBox(){} void paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget); void addOutput( GraphicsConnection* connection ); - void addInput( GraphicsConnection* connection ) {} + void addInput( GraphicsConnection* connection ); void removeOutput(); void removeInput( GraphicsConnection* connection ); + void disconnectInputEvent(WrapperBox *origin, GraphicsConnection* connection ); + void disconnectOutputEvent(); QRectF boundingRect() const; QPointF getConnectionOrigin(); QPointF getConnectionTarget(); - WrapperBox* wrapper(); void setWrapper( WrapperBox* wrapper ); protected: QFont m_font; QString m_text; QRectF m_boundRect; GraphicsConnection* m_OutConnection; + QList<GraphicsConnection*> m_InConnections; WrapperBox* m_wrapper; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) = 0; diff --git a/agui2/modelbox.cpp b/agui2/modelbox.cpp index d830f8a62a67231b710aba10db195118e3aa4bee..ceed5758d86fbb10ebc142373590c19f9e7a11b7 100644 --- a/agui2/modelbox.cpp +++ b/agui2/modelbox.cpp @@ -24,6 +24,16 @@ bool ModelBox::addOutput(ModelBox *target) return true; } +void ModelBox::removeInput(ModelBox *origin) +{ + m_InConnections.removeOne( origin ); +} + +void ModelBox::removeOutput() +{ + m_OutConnection = NULL; +} + bool ModelBox::isInputAvailable() { return ( m_InConnections.count() < m_maxInConnections ); diff --git a/agui2/modelbox.h b/agui2/modelbox.h index 7afcfefa7e8f998d3f143b1b841c6c4a3ca1e40a..ccbad54793c4f8c60a33684ed0a3a029b5521ea7 100644 --- a/agui2/modelbox.h +++ b/agui2/modelbox.h @@ -15,6 +15,8 @@ public: ModelBox(int maxInConnections, int maxOutConnections ); bool addInput( ModelBox * origin ); bool addOutput( ModelBox * target ); + void removeInput( ModelBox * origin ); + void removeOutput(); bool isInputAvailable(); bool isOutputAvailable(); int availableInputs(); diff --git a/agui2/wrapperbox.cpp b/agui2/wrapperbox.cpp index 5c0a7faca901cdbbffff8d789b1c13f40893865f..adc13e10b53530923a7be0aad0ee94541ac90100 100644 --- a/agui2/wrapperbox.cpp +++ b/agui2/wrapperbox.cpp @@ -29,6 +29,18 @@ bool WrapperBox::addOutput(WrapperBox *target, GraphicsConnection *connection) return true; } +bool WrapperBox::removeInput(WrapperBox *origin, GraphicsConnection *connection) +{ + m_model->removeInput( origin->getModel() ); + m_graphics->removeInput( connection ); +} + +bool WrapperBox::removeOutput() +{ + m_model->removeOutput(); + m_graphics->removeOutput(); +} + ModelBox *WrapperBox::getModel() { return m_model; diff --git a/agui2/wrapperbox.h b/agui2/wrapperbox.h index 477fa47b1b47a29f675b31d258caf50974ce0715..a65f30b1fbc3414f3bd7b4650e5a4dc1042a9f55 100644 --- a/agui2/wrapperbox.h +++ b/agui2/wrapperbox.h @@ -16,8 +16,8 @@ public: ~WrapperBox(); bool addInput( WrapperBox * origin, GraphicsConnection * connection ); bool addOutput( WrapperBox * target, GraphicsConnection * connection ); - bool removeInput( WrapperBox * origin, GraphicsConnection * connection ) {} - bool removeOutput() {} + bool removeInput( WrapperBox * origin, GraphicsConnection * connection ); + bool removeOutput(); ModelBox *getModel(); GraphicsBox *getGraphics(); private: