X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FcpPipelineEditor%2FQNEPort.h;h=e10af5ef87c1d0fcc69ac06bd01a69d8d028fe5b;hb=c06908465eb6da50572779f423d1e2c9e03b68dd;hp=1f445d003c0aa1587eba25044172284451741246;hpb=9c75dcecf566cc567583caf4687ce523a2af586d;p=cpPlugins.git diff --git a/appli/cpPipelineEditor/QNEPort.h b/appli/cpPipelineEditor/QNEPort.h index 1f445d0..e10af5e 100644 --- a/appli/cpPipelineEditor/QNEPort.h +++ b/appli/cpPipelineEditor/QNEPort.h @@ -44,45 +44,168 @@ namespace PipelineEditor typedef QGraphicsPathItem Superclass; enum { Type = QGraphicsItem::UserType + 1 }; - enum { NamePort = 1, TypePort = 2 }; public: - QNEPort( QGraphicsItem* parent = 0, QGraphicsScene* scene = NULL ); + QNEPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~QNEPort( ); - void setNEBlock( QNEBlock* b ); - void setName( const QString& n ); - void setIsOutput( bool o ); - int radius( ); - bool isOutput( ); - QVector< QNEConnection* >& connections( ); - void setPortFlags( int f ); - - QNEBlock* block( ) const; - quint64 ptr( ); - void setPtr( quint64 p ); - bool isConnected( QNEPort* other ); - - inline const QString& portName( ) const - { return( this->m_Name ); } - inline int portFlags( ) const - { return( this->m_PortFlags ); } - int type( ) const + void setBlock( QNEBlock* b ); + inline QNEBlock* block( ) const + { return( this->m_Block ); } + + virtual void setName( const QString& n ); + virtual void setExtendedName( const QString& n ); + inline QString name( ) const + { return( this->m_Label->toPlainText( ) ); } + inline QString extendedName( ) const + { return( this->m_ExtendedLabel->toPlainText( ) ); } + + inline int radius( ) const + { return( this->m_Radius ); } + + inline bool isExtended( ) const + { return( this->m_IsExtended ); } + virtual void setExtend( bool extend ); + + virtual bool isConnected( QNEPort* other ) = 0; + inline int type( ) const { return( this->Type ); } + virtual void paint( + QPainter* painter, + const QStyleOptionGraphicsItem* option, + QWidget* widget + ); + protected: - QVariant itemChange( GraphicsItemChange change, const QVariant& value ); + virtual void _updateLabels( ) { } - private: + protected: QNEBlock* m_Block; - QString m_Name; - bool m_IsOutput; + + int m_Radius; + int m_Margin; + bool m_IsExtended; + QGraphicsTextItem* m_Label; - int m_Radius; - int m_Margin; + QGraphicsTextItem* m_ExtendedLabel; + }; + + /** + */ + class QNENamePort + : public QNEPort + { + public: + typedef QNENamePort Self; + typedef QNEPort Superclass; + + enum { Type = Superclass::Type + 1 }; + + public: + QNENamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); + virtual ~QNENamePort( ); + + virtual bool isConnected( QNEPort* other ); + inline int type( ) const + { return( this->Type ); } + + protected: + virtual void _updateLabels( ); + }; + + /** + */ + class QNETypePort + : public QNEPort + { + public: + typedef QNETypePort Self; + typedef QNEPort Superclass; + + enum { Type = Superclass::Type + 2 }; + + public: + QNETypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); + virtual ~QNETypePort( ); + + virtual bool isConnected( QNEPort* other ); + inline int type( ) const + { return( this->Type ); } + + protected: + virtual void _updateLabels( ); + }; + + /** + */ + class QNEInputPort + : public QNEPort + { + public: + typedef QNEInputPort Self; + typedef QNEPort Superclass; + + enum { Type = Superclass::Type + 3 }; + + public: + QNEInputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); + virtual ~QNEInputPort( ); + + virtual void setExtend( bool extend ); + + virtual bool isConnected( QNEPort* other ); + inline int type( ) const + { return( this->Type ); } + + void setConnection( QNEConnection* c ); + inline QNEConnection* connection( ) + { return( this->m_Connection ); } + inline const QNEConnection* connection( ) const + { return( this->m_Connection ); } + inline bool hasConnection( ) const + { return( this->m_Connection != NULL ); } + + protected: + QVariant itemChange( GraphicsItemChange change, const QVariant& value ); + virtual void _updateLabels( ); + + protected: + QNEConnection* m_Connection; + }; + + /** + */ + class QNEOutputPort + : public QNEPort + { + public: + typedef QNEOutputPort Self; + typedef QNEPort Superclass; + + enum { Type = Superclass::Type + 4 }; + + public: + QNEOutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); + virtual ~QNEOutputPort( ); + + virtual void setExtend( bool extend ); + + virtual bool isConnected( QNEPort* other ); + inline int type( ) const + { return( this->Type ); } + + inline QVector< QNEConnection* >& connections( ) + { return( this->m_Connections ); } + inline const QVector< QNEConnection* >& connections( ) const + { return( this->m_Connections ); } + + protected: + QVariant itemChange( GraphicsItemChange change, const QVariant& value ); + virtual void _updateLabels( ); + + protected: QVector< QNEConnection* > m_Connections; - int m_PortFlags; - quint64 m_Ptr; }; } // ecapseman