1 #ifndef __CPPIPELINEEDITOR__PORT__H__
\r
2 #define __CPPIPELINEEDITOR__PORT__H__
\r
4 #include <cpPipelineEditor/cpPipelineEditor_Export.h>
\r
5 #include <QGraphicsPathItem>
\r
7 namespace cpPipelineEditor
\r
14 class cpPipelineEditor_EXPORT Port
\r
15 : public QGraphicsPathItem
\r
19 typedef QGraphicsPathItem Superclass;
\r
21 enum { Type = QGraphicsItem::UserType + 1 };
\r
24 Port( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
27 void setBlock( Block* b );
\r
28 inline Block* block( ) const
\r
29 { return( this->m_Block ); }
\r
31 virtual void setName( const QString& n );
\r
32 virtual void setExtendedName( const QString& n );
\r
33 inline QString name( ) const
\r
34 { return( this->m_Label->toPlainText( ) ); }
\r
35 inline QString extendedName( ) const
\r
36 { return( this->m_ExtendedLabel->toPlainText( ) ); }
\r
38 inline int radius( ) const
\r
39 { return( this->m_Radius ); }
\r
41 inline bool isExtended( ) const
\r
42 { return( this->m_IsExtended ); }
\r
43 virtual void setExtend( bool extend );
\r
45 virtual bool isConnected( Port* other ) = 0;
\r
46 inline int type( ) const
\r
47 { return( this->Type ); }
\r
51 const QStyleOptionGraphicsItem* option,
\r
56 virtual void _updateLabels( ) { }
\r
65 QGraphicsTextItem* m_Label;
\r
66 QGraphicsTextItem* m_ExtendedLabel;
\r
75 typedef NamePort Self;
\r
76 typedef Port Superclass;
\r
78 enum { Type = Superclass::Type + 1 };
\r
81 NamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
82 virtual ~NamePort( );
\r
84 virtual bool isConnected( Port* other );
\r
85 inline int type( ) const
\r
86 { return( this->Type ); }
\r
89 virtual void _updateLabels( );
\r
98 typedef InputPort Self;
\r
99 typedef Port Superclass;
\r
101 enum { Type = Superclass::Type + 3 };
\r
104 InputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
105 virtual ~InputPort( );
\r
107 virtual void setExtend( bool extend );
\r
109 virtual bool isConnected( Port* other );
\r
110 inline int type( ) const
\r
111 { return( this->Type ); }
\r
113 void setConnection( Connection* c );
\r
114 inline Connection* connection( )
\r
115 { return( this->m_Connection ); }
\r
116 inline const Connection* connection( ) const
\r
117 { return( this->m_Connection ); }
\r
118 inline bool hasConnection( ) const
\r
119 { return( this->m_Connection != NULL ); }
\r
122 QVariant itemChange( GraphicsItemChange change, const QVariant& value );
\r
123 virtual void _updateLabels( );
\r
126 Connection* m_Connection;
\r
135 typedef OutputPort Self;
\r
136 typedef Port Superclass;
\r
138 enum { Type = Superclass::Type + 4 };
\r
141 OutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
142 virtual ~OutputPort( );
\r
144 virtual void setExtend( bool extend );
\r
146 virtual bool isConnected( Port* other );
\r
147 inline int type( ) const
\r
148 { return( this->Type ); }
\r
150 inline QVector< Connection* >& connections( )
\r
151 { return( this->m_Connections ); }
\r
152 inline const QVector< Connection* >& connections( ) const
\r
153 { return( this->m_Connections ); }
\r
156 QVariant itemChange( GraphicsItemChange change, const QVariant& value );
\r
157 virtual void _updateLabels( );
\r
159 virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt );
\r
162 QVector< Connection* > m_Connections;
\r
167 #endif // __CPPIPELINEEDITOR__PORT__H__
\r