X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpBaseQtApplication%2FPort.cxx;h=e61bd284ef999d1857b50e7e798929cc056a834c;hb=db0a767418f78b371c1e4fb0db00e6b75df74ff3;hp=bdd9aea75819aad334ad54894dda32e894a2add4;hpb=49d2d7db538d60008b9a5701ea8f26bb19997a82;p=cpPlugins.git diff --git a/lib/cpBaseQtApplication/Port.cxx b/lib/cpBaseQtApplication/Port.cxx index bdd9aea..e61bd28 100644 --- a/lib/cpBaseQtApplication/Port.cxx +++ b/lib/cpBaseQtApplication/Port.cxx @@ -126,9 +126,9 @@ isConnected( Port* other ) // ------------------------------------------------------------------------- cpBaseQtApplication::InputPort:: -InputPort( QGraphicsItem* parent, QGraphicsScene* scene ) +InputPort( QGraphicsItem* parent, bool multiple, QGraphicsScene* scene ) : Superclass( parent, scene ), - m_Connection( NULL ) + m_IsMultiple( multiple ) { } @@ -136,8 +136,7 @@ InputPort( QGraphicsItem* parent, QGraphicsScene* scene ) cpBaseQtApplication::InputPort:: ~InputPort( ) { - if( this->m_Connection != NULL ) - delete this->m_Connection; + this->m_Connection.clear( ); } // ------------------------------------------------------------------------- @@ -156,7 +155,7 @@ _updateLabels( ) void cpBaseQtApplication::InputPort:: setExtend( bool extend ) { - if( this->m_Connection == NULL ) + if( this->m_Connection.size( ) == 0 ) { this->m_IsExtended = extend; this->m_ExtendedLabel->setVisible( extend ); @@ -169,20 +168,19 @@ setExtend( bool extend ) bool cpBaseQtApplication::InputPort:: isConnected( Port* other ) { - if( this->m_Connection != NULL ) - return( - this->m_Connection->port1( ) == other && - this->m_Connection->port2( ) == this - ); - else - return( false ); + bool conn = false; + auto i = this->m_Connection.begin( ); + for( ; i != this->m_Connection.end( ); ++i ) + conn |= ( ( *i )->port1( ) == other && ( *i )->port2( ) == this ); + return( conn ); } // ------------------------------------------------------------------------- void cpBaseQtApplication::InputPort:: setConnection( Connection* c ) { - this->m_Connection = c; + if( this->m_IsMultiple || this->m_Connection.size( ) == 0 ) + this->m_Connection.push_back( c ); } // ------------------------------------------------------------------------- @@ -191,10 +189,14 @@ itemChange( GraphicsItemChange change, const QVariant& value ) { if( change == ItemScenePositionHasChanged ) { - if( this->m_Connection != NULL ) + for( + auto i = this->m_Connection.begin( ); + i != this->m_Connection.end( ); + ++i + ) { - this->m_Connection->updatePosFromPorts( ); - this->m_Connection->updatePath( ); + ( *i )->updatePosFromPorts( ); + ( *i )->updatePath( ); } // fi