*/\r
\r
#include "QNEConnection.h"\r
-\r
#include "QNEPort.h"\r
\r
#include <QBrush>\r
this->setPen( QPen( Qt::black, 2 ) );\r
this->setBrush( Qt::NoBrush );\r
this->setZValue( -1 );\r
- this->m_Port1 = 0;\r
- this->m_Port2 = 0;\r
+ this->m_Port1 = NULL;\r
+ this->m_Port2 = NULL;\r
}\r
\r
// -------------------------------------------------------------------------\r
PipelineEditor::QNEConnection::\r
~QNEConnection( )\r
{\r
- if ( this->m_Port1 )\r
- this->m_Port1->connections( ).remove(\r
- this->m_Port1->connections( ).indexOf( this )\r
- );\r
- if ( this->m_Port2 )\r
- this->m_Port2->connections( ).remove(\r
- this->m_Port2->connections( ).indexOf( this )\r
- );\r
+ if( this->m_Port1 != NULL )\r
+ this->m_Port1->connections( ).\r
+ remove( this->m_Port1->connections( ).indexOf( this ) );\r
+\r
+ if( this->m_Port2 != NULL )\r
+ this->m_Port2->setConnection( NULL );\r
}\r
\r
// -------------------------------------------------------------------------\r
\r
// -------------------------------------------------------------------------\r
void PipelineEditor::QNEConnection::\r
-setPort1( QNEPort* p )\r
+setPort1( QNEOutputPort* p )\r
{\r
- this->m_Port1 = p;\r
- this->m_Port1->connections( ).append( this );\r
+ if( p != NULL )\r
+ {\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
- this->m_Port2 = p;\r
- this->m_Port2->connections( ).append( this );\r
+ if( p != NULL )\r
+ {\r
+ if( p->connection( ) == NULL )\r
+ {\r
+ p->setConnection( this );\r
+ this->m_Port2 = p;\r
+\r
+ } // fi\r
+\r
+ } // fi\r
}\r
\r
// -------------------------------------------------------------------------\r
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
updatePath( )\r
{\r
QPainterPath p;\r
-\r
p.moveTo( this->m_Pos1 );\r
\r
qreal dx = this->m_Pos2.x( ) - this->m_Pos1.x( );\r
qreal dy = this->m_Pos2.y( ) - this->m_Pos1.y( );\r
-\r
- QPointF ctr1( this->m_Pos1.x( ) + dx * 0.25, this->m_Pos1.y( ) + dy * 0.1 );\r
- QPointF ctr2( this->m_Pos1.x( ) + dx * 0.75, this->m_Pos1.y( ) + dy * 0.9 );\r
-\r
- p.cubicTo( ctr1, ctr2, this->m_Pos2 );\r
+ QPointF c1( this->m_Pos1.x( ) + dx * 0.25, this->m_Pos1.y( ) + dy * 0.1 );\r
+ QPointF c2( this->m_Pos1.x( ) + dx * 0.75, this->m_Pos1.y( ) + dy * 0.9 );\r
+ p.cubicTo( c1, c2, this->m_Pos2 );\r
\r
this->setPath( p );\r
}\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
}\r
\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
-save( QDataStream& ds )\r
-{\r
- ds << ( quint64 ) this->m_Port1;\r
- ds << ( quint64 ) this->m_Port2;\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
-load( QDataStream& ds, const QMap< quint64, QNEPort* >& portMap )\r
-{\r
- quint64 ptr1;\r
- quint64 ptr2;\r
- ds >> ptr1;\r
- ds >> ptr2;\r
-\r
- this->setPort1( portMap[ ptr1 ] );\r
- this->setPort2( portMap[ ptr2 ] );\r
- this->updatePosFromPorts( );\r
- this->updatePath( );\r
-}\r
-\r
// eof - $RCSfile$\r