#ifndef __cpBaseQtApplication__Pipeline__Port__h__ #define __cpBaseQtApplication__Pipeline__Port__h__ #include #include namespace cpBaseQtApplication { namespace Pipeline { class Block; class Connection; /** */ class cpBaseQtApplication_EXPORT Port : public QObject, public QGraphicsPathItem { Q_OBJECT; public: typedef Port Self; typedef QGraphicsPathItem Superclass; enum { Type = QGraphicsItem::UserType + 1 }; public: Port( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~Port( ); void setBlock( Block* b ); inline Block* 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( Port* other ) = 0; inline int type( ) const { return( this->Type ); } virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ); protected: virtual void _updateLabels( ) { } protected: Block* m_Block; int m_Radius; int m_Margin; bool m_IsExtended; QGraphicsTextItem* m_Label; QGraphicsTextItem* m_ExtendedLabel; }; /** */ class cpBaseQtApplication_EXPORT NamePort : public Port { Q_OBJECT; public: typedef NamePort Self; typedef Port Superclass; enum { Type = Superclass::Type + 1 }; public: NamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~NamePort( ); virtual bool isConnected( Port* other ); inline int type( ) const { return( this->Type ); } protected: virtual void _updateLabels( ); }; /** */ class cpBaseQtApplication_EXPORT InfoPort : public Port { Q_OBJECT; public: typedef InfoPort Self; typedef Port Superclass; enum { Type = Superclass::Type + 2 }; public: InfoPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~InfoPort( ); virtual bool isConnected( Port* other ); inline int type( ) const { return( this->Type ); } protected: virtual void _updateLabels( ); }; /** */ class cpBaseQtApplication_EXPORT InputPort : public Port { Q_OBJECT; public: typedef InputPort Self; typedef Port Superclass; enum { Type = Superclass::Type + 3 }; public: InputPort( QGraphicsItem* parent, bool multiple, QGraphicsScene* scene = NULL ); virtual ~InputPort( ); virtual void setExtend( bool extend ); virtual bool isConnected( Port* other ); inline int type( ) const { return( this->Type ); } void setConnection( Connection* c ); void removeConnection( Connection* c ); inline unsigned int numberOfConnections( ) const { return( this->m_Connection.size( ) ); } inline Connection* connection( unsigned int i ) { return( this->m_Connection[ i ] ); } inline const Connection* connection( unsigned int i ) const { return( this->m_Connection[ i ] ); } inline bool hasConnection( ) const { return( this->m_Connection.size( ) > 0 ); } inline bool isMultiple( ) const { return( this->m_IsMultiple ); } protected: QVariant itemChange( GraphicsItemChange change, const QVariant& value ); virtual void _updateLabels( ); protected: std::vector< Connection* > m_Connection; bool m_IsMultiple; }; /** */ class cpBaseQtApplication_EXPORT OutputPort : public Port { Q_OBJECT; public: typedef OutputPort Self; typedef Port Superclass; enum { Type = Superclass::Type + 4 }; public: OutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~OutputPort( ); void removeConnection( Connection* c ); virtual void setExtend( bool extend ); virtual bool isConnected( Port* other ); inline int type( ) const { return( this->Type ); } inline std::vector< Connection* >& connections( ) { return( this->m_Connections ); } inline const std::vector< Connection* >& connections( ) const { return( this->m_Connections ); } signals: void viewData( const std::string& name, bool show ); protected: QVariant itemChange( GraphicsItemChange change, const QVariant& value ); virtual void _updateLabels( ); virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt ); protected: std::vector< Connection* > m_Connections; }; } // ecapseman } // ecapseman #endif // __cpBaseQtApplication__Pipeline__Port__h__ // eof - $RCSfile$