]> Creatis software - cpPlugins.git/blobdiff - appli/cpPipelineEditor/QNEConnection.cxx
More on graph editor
[cpPlugins.git] / appli / cpPipelineEditor / QNEConnection.cxx
index eb0f3bb36691cfd2c6f3598282d6b149f723438d..c79bb7ed27e02d6b7c5d1af662d3a7671665ab71 100644 (file)
@@ -47,13 +47,12 @@ QNEConnection( QGraphicsItem* parent, QGraphicsScene* scene )
 PipelineEditor::QNEConnection::\r
 ~QNEConnection( )\r
 {\r
-  QNEOutputPort* op = dynamic_cast< QNEOutputPort* >( this->m_Port1 );\r
-  if( op != NULL )\r
-    op->connections( ).remove( op->connections( ).indexOf( this ) );\r
+  if( this->m_Port1 != NULL )\r
+    this->m_Port1->connections( ).\r
+      remove( this->m_Port1->connections( ).indexOf( this ) );\r
 \r
-  QNEInputPort* ip = dynamic_cast< QNEInputPort* >( this->m_Port2 );\r
-  if( ip != NULL )\r
-    ip->setConnection( NULL );\r
+  if( this->m_Port2 != NULL )\r
+    this->m_Port2->setConnection( NULL );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -72,28 +71,26 @@ setPos2( const QPointF& p )
 \r
 // -------------------------------------------------------------------------\r
 void PipelineEditor::QNEConnection::\r
-setPort1( QNEPort* p )\r
+setPort1( QNEOutputPort* p )\r
 {\r
-  QNEOutputPort* op = dynamic_cast< QNEOutputPort* >( p );\r
-  if( op != NULL )\r
+  if( p != NULL )\r
   {\r
-    op->connections( ).append( this );\r
-    this->m_Port1 = op;\r
+    p->connections( ).append( this );\r
+    this->m_Port1 = p;\r
 \r
   } // fi\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
 void PipelineEditor::QNEConnection::\r
-setPort2( QNEPort* p )\r
+setPort2( QNEInputPort* p )\r
 {\r
-  QNEInputPort* ip = dynamic_cast< QNEInputPort* >( p );\r
-  if( ip != NULL )\r
+  if( p != NULL )\r
   {\r
-    if( ip->connection( ) == NULL )\r
+    if( p->connection( ) == NULL )\r
     {\r
-      ip->setConnection( this );\r
-      this->m_Port2 = ip;\r
+      p->setConnection( this );\r
+      this->m_Port2 = p;\r
 \r
     } // fi\r
 \r
@@ -104,8 +101,14 @@ setPort2( QNEPort* p )
 void PipelineEditor::QNEConnection::\r
 updatePosFromPorts( )\r
 {\r
-  this->m_Pos1 = this->m_Port1->scenePos( );\r
-  this->m_Pos2 = this->m_Port2->scenePos( );\r
+  if( this->m_Port1 != NULL )\r
+    this->m_Pos1 =\r
+      this->m_Port1->scenePos( ) +\r
+      QPointF( this->m_Port1->radius( ), this->m_Port1->radius( ) );\r
+  if( this->m_Port2 != NULL )\r
+    this->m_Pos2 =\r
+      this->m_Port2->scenePos( ) +\r
+      QPointF( this->m_Port2->radius( ), this->m_Port2->radius( ) );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -125,14 +128,14 @@ updatePath( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEPort* PipelineEditor::QNEConnection::\r
+PipelineEditor::QNEOutputPort* PipelineEditor::QNEConnection::\r
 port1( ) const\r
 {\r
   return( this->m_Port1 );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEPort* PipelineEditor::QNEConnection::\r
+PipelineEditor::QNEInputPort* PipelineEditor::QNEConnection::\r
 port2( ) const\r
 {\r
   return( this->m_Port2 );\r