+#ifndef __CPPIPELINEEDITOR__PORT__H__\r
+#define __CPPIPELINEEDITOR__PORT__H__\r
+\r
+#include <cpPipelineEditor/cpPipelineEditor_Export.h>\r
+#include <QGraphicsPathItem>\r
+\r
+namespace cpPipelineEditor\r
+{\r
+ class Block;\r
+ class Connection;\r
+\r
+ /**\r
+ */\r
+ class cpPipelineEditor_EXPORT Port\r
+ : public QGraphicsPathItem\r
+ {\r
+ public:\r
+ typedef Port Self;\r
+ typedef QGraphicsPathItem Superclass;\r
+\r
+ enum { Type = QGraphicsItem::UserType + 1 };\r
+\r
+ public:\r
+ Port( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+ virtual ~Port( );\r
+\r
+ void setBlock( Block* b );\r
+ inline Block* block( ) const\r
+ { return( this->m_Block ); }\r
+\r
+ virtual void setName( const QString& n );\r
+ virtual void setExtendedName( const QString& n );\r
+ inline QString name( ) const\r
+ { return( this->m_Label->toPlainText( ) ); }\r
+ inline QString extendedName( ) const\r
+ { return( this->m_ExtendedLabel->toPlainText( ) ); }\r
+\r
+ inline int radius( ) const\r
+ { return( this->m_Radius ); }\r
+\r
+ inline bool isExtended( ) const\r
+ { return( this->m_IsExtended ); }\r
+ virtual void setExtend( bool extend );\r
+\r
+ virtual bool isConnected( Port* other ) = 0;\r
+ inline int type( ) const\r
+ { return( this->Type ); }\r
+\r
+ virtual void paint(\r
+ QPainter* painter,\r
+ const QStyleOptionGraphicsItem* option,\r
+ QWidget* widget\r
+ );\r
+\r
+ protected:\r
+ virtual void _updateLabels( ) { }\r
+\r
+ protected:\r
+ Block* m_Block;\r
+\r
+ int m_Radius;\r
+ int m_Margin;\r
+ bool m_IsExtended;\r
+\r
+ QGraphicsTextItem* m_Label;\r
+ QGraphicsTextItem* m_ExtendedLabel;\r
+ };\r
+\r
+ /**\r
+ */\r
+ class NamePort\r
+ : public Port\r
+ {\r
+ public:\r
+ typedef NamePort Self;\r
+ typedef Port Superclass;\r
+\r
+ enum { Type = Superclass::Type + 1 };\r
+\r
+ public:\r
+ NamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+ virtual ~NamePort( );\r
+\r
+ virtual bool isConnected( Port* other );\r
+ inline int type( ) const\r
+ { return( this->Type ); }\r
+\r
+ protected:\r
+ virtual void _updateLabels( );\r
+ };\r
+\r
+ /**\r
+ */\r
+ class InputPort\r
+ : public Port\r
+ {\r
+ public:\r
+ typedef InputPort Self;\r
+ typedef Port Superclass;\r
+\r
+ enum { Type = Superclass::Type + 3 };\r
+\r
+ public:\r
+ InputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+ virtual ~InputPort( );\r
+\r
+ virtual void setExtend( bool extend );\r
+\r
+ virtual bool isConnected( Port* other );\r
+ inline int type( ) const\r
+ { return( this->Type ); }\r
+\r
+ void setConnection( Connection* c );\r
+ inline Connection* connection( )\r
+ { return( this->m_Connection ); }\r
+ inline const Connection* connection( ) const\r
+ { return( this->m_Connection ); }\r
+ inline bool hasConnection( ) const\r
+ { return( this->m_Connection != NULL ); }\r
+\r
+ protected:\r
+ QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
+ virtual void _updateLabels( );\r
+\r
+ protected:\r
+ Connection* m_Connection;\r
+ };\r
+\r
+ /**\r
+ */\r
+ class OutputPort\r
+ : public Port\r
+ {\r
+ public:\r
+ typedef OutputPort Self;\r
+ typedef Port Superclass;\r
+\r
+ enum { Type = Superclass::Type + 4 };\r
+\r
+ public:\r
+ OutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+ virtual ~OutputPort( );\r
+\r
+ virtual void setExtend( bool extend );\r
+\r
+ virtual bool isConnected( Port* other );\r
+ inline int type( ) const\r
+ { return( this->Type ); }\r
+\r
+ inline QVector< Connection* >& connections( )\r
+ { return( this->m_Connections ); }\r
+ inline const QVector< Connection* >& connections( ) const\r
+ { return( this->m_Connections ); }\r
+\r
+ protected:\r
+ QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
+ virtual void _updateLabels( );\r
+\r
+ virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt );\r
+\r
+ protected:\r
+ QVector< Connection* > m_Connections;\r
+ };\r
+\r
+} // ecapseman\r
+\r
+#endif // __CPPIPELINEEDITOR__PORT__H__\r
+\r
+// eof - $RCSfile$\r