X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FcpPipelineEditor%2FQNEConnection.cxx;h=c79bb7ed27e02d6b7c5d1af662d3a7671665ab71;hb=c06908465eb6da50572779f423d1e2c9e03b68dd;hp=eb0f3bb36691cfd2c6f3598282d6b149f723438d;hpb=f4aeff15ebb41183d4b89f41b29ec26043848722;p=cpPlugins.git diff --git a/appli/cpPipelineEditor/QNEConnection.cxx b/appli/cpPipelineEditor/QNEConnection.cxx index eb0f3bb..c79bb7e 100644 --- a/appli/cpPipelineEditor/QNEConnection.cxx +++ b/appli/cpPipelineEditor/QNEConnection.cxx @@ -47,13 +47,12 @@ QNEConnection( QGraphicsItem* parent, QGraphicsScene* scene ) PipelineEditor::QNEConnection:: ~QNEConnection( ) { - QNEOutputPort* op = dynamic_cast< QNEOutputPort* >( this->m_Port1 ); - if( op != NULL ) - op->connections( ).remove( op->connections( ).indexOf( this ) ); + if( this->m_Port1 != NULL ) + this->m_Port1->connections( ). + remove( this->m_Port1->connections( ).indexOf( this ) ); - QNEInputPort* ip = dynamic_cast< QNEInputPort* >( this->m_Port2 ); - if( ip != NULL ) - ip->setConnection( NULL ); + if( this->m_Port2 != NULL ) + this->m_Port2->setConnection( NULL ); } // ------------------------------------------------------------------------- @@ -72,28 +71,26 @@ setPos2( const QPointF& p ) // ------------------------------------------------------------------------- void PipelineEditor::QNEConnection:: -setPort1( QNEPort* p ) +setPort1( QNEOutputPort* p ) { - QNEOutputPort* op = dynamic_cast< QNEOutputPort* >( p ); - if( op != NULL ) + if( p != NULL ) { - op->connections( ).append( this ); - this->m_Port1 = op; + p->connections( ).append( this ); + this->m_Port1 = p; } // fi } // ------------------------------------------------------------------------- void PipelineEditor::QNEConnection:: -setPort2( QNEPort* p ) +setPort2( QNEInputPort* p ) { - QNEInputPort* ip = dynamic_cast< QNEInputPort* >( p ); - if( ip != NULL ) + if( p != NULL ) { - if( ip->connection( ) == NULL ) + if( p->connection( ) == NULL ) { - ip->setConnection( this ); - this->m_Port2 = ip; + p->setConnection( this ); + this->m_Port2 = p; } // fi @@ -104,8 +101,14 @@ setPort2( QNEPort* p ) void PipelineEditor::QNEConnection:: updatePosFromPorts( ) { - this->m_Pos1 = this->m_Port1->scenePos( ); - this->m_Pos2 = this->m_Port2->scenePos( ); + if( this->m_Port1 != NULL ) + this->m_Pos1 = + this->m_Port1->scenePos( ) + + QPointF( this->m_Port1->radius( ), this->m_Port1->radius( ) ); + if( this->m_Port2 != NULL ) + this->m_Pos2 = + this->m_Port2->scenePos( ) + + QPointF( this->m_Port2->radius( ), this->m_Port2->radius( ) ); } // ------------------------------------------------------------------------- @@ -125,14 +128,14 @@ updatePath( ) } // ------------------------------------------------------------------------- -PipelineEditor::QNEPort* PipelineEditor::QNEConnection:: +PipelineEditor::QNEOutputPort* PipelineEditor::QNEConnection:: port1( ) const { return( this->m_Port1 ); } // ------------------------------------------------------------------------- -PipelineEditor::QNEPort* PipelineEditor::QNEConnection:: +PipelineEditor::QNEInputPort* PipelineEditor::QNEConnection:: port2( ) const { return( this->m_Port2 );