1 /* Copyright (c) 2012, STANISLAW ADASZEWSKI
\r
4 Redistribution and use in source and binary forms, with or without
\r
5 modification, are permitted provided that the following conditions are met:
\r
6 * Redistributions of source code must retain the above copyright
\r
7 notice, this list of conditions and the following disclaimer.
\r
8 * Redistributions in binary form must reproduce the above copyright
\r
9 notice, this list of conditions and the following disclaimer in the
\r
10 documentation and/or other materials provided with the distribution.
\r
11 * Neither the name of STANISLAW ADASZEWSKI nor the
\r
12 names of its contributors may be used to endorse or promote products
\r
13 derived from this software without specific prior written permission.
\r
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
\r
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
18 DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY
\r
19 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\r
20 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
21 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
\r
22 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
23 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 #ifndef __PIPELINEEDITOR__QNEPORT__H__
\r
28 #define __PIPELINEEDITOR__QNEPORT__H__
\r
30 #include <QGraphicsPathItem>
\r
32 namespace PipelineEditor
\r
35 class QNEConnection;
\r
40 : public QGraphicsPathItem
\r
43 typedef QNEPort Self;
\r
44 typedef QGraphicsPathItem Superclass;
\r
46 enum { Type = QGraphicsItem::UserType + 1 };
\r
49 QNEPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
50 virtual ~QNEPort( );
\r
52 void setBlock( QNEBlock* b );
\r
53 inline QNEBlock* block( ) const
\r
54 { return( this->m_Block ); }
\r
56 virtual void setName( const QString& n );
\r
57 virtual void setExtendedName( const QString& n );
\r
58 inline QString name( ) const
\r
59 { return( this->m_Label->toPlainText( ) ); }
\r
60 inline QString extendedName( ) const
\r
61 { return( this->m_ExtendedLabel->toPlainText( ) ); }
\r
63 inline int radius( ) const
\r
64 { return( this->m_Radius ); }
\r
66 inline bool isExtended( ) const
\r
67 { return( this->m_IsExtended ); }
\r
68 virtual void setExtend( bool extend );
\r
70 virtual bool isConnected( QNEPort* other ) = 0;
\r
71 inline int type( ) const
\r
72 { return( this->Type ); }
\r
76 const QStyleOptionGraphicsItem* option,
\r
81 virtual void _updateLabels( ) { }
\r
90 QGraphicsTextItem* m_Label;
\r
91 QGraphicsTextItem* m_ExtendedLabel;
\r
100 typedef QNENamePort Self;
\r
101 typedef QNEPort Superclass;
\r
103 enum { Type = Superclass::Type + 1 };
\r
106 QNENamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
107 virtual ~QNENamePort( );
\r
109 virtual bool isConnected( QNEPort* other );
\r
110 inline int type( ) const
\r
111 { return( this->Type ); }
\r
114 virtual void _updateLabels( );
\r
123 typedef QNETypePort Self;
\r
124 typedef QNEPort Superclass;
\r
126 enum { Type = Superclass::Type + 2 };
\r
129 QNETypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
130 virtual ~QNETypePort( );
\r
132 virtual bool isConnected( QNEPort* other );
\r
133 inline int type( ) const
\r
134 { return( this->Type ); }
\r
137 virtual void _updateLabels( );
\r
146 typedef QNEInputPort Self;
\r
147 typedef QNEPort Superclass;
\r
149 enum { Type = Superclass::Type + 3 };
\r
152 QNEInputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
153 virtual ~QNEInputPort( );
\r
155 virtual void setExtend( bool extend );
\r
157 virtual bool isConnected( QNEPort* other );
\r
158 inline int type( ) const
\r
159 { return( this->Type ); }
\r
161 void setConnection( QNEConnection* c );
\r
162 inline QNEConnection* connection( )
\r
163 { return( this->m_Connection ); }
\r
164 inline const QNEConnection* connection( ) const
\r
165 { return( this->m_Connection ); }
\r
166 inline bool hasConnection( ) const
\r
167 { return( this->m_Connection != NULL ); }
\r
170 QVariant itemChange( GraphicsItemChange change, const QVariant& value );
\r
171 virtual void _updateLabels( );
\r
174 QNEConnection* m_Connection;
\r
179 class QNEOutputPort
\r
183 typedef QNEOutputPort Self;
\r
184 typedef QNEPort Superclass;
\r
186 enum { Type = Superclass::Type + 4 };
\r
189 QNEOutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );
\r
190 virtual ~QNEOutputPort( );
\r
192 virtual void setExtend( bool extend );
\r
194 virtual bool isConnected( QNEPort* other );
\r
195 inline int type( ) const
\r
196 { return( this->Type ); }
\r
198 inline QVector< QNEConnection* >& connections( )
\r
199 { return( this->m_Connections ); }
\r
200 inline const QVector< QNEConnection* >& connections( ) const
\r
201 { return( this->m_Connections ); }
\r
204 QVariant itemChange( GraphicsItemChange change, const QVariant& value );
\r
205 virtual void _updateLabels( );
\r
208 QVector< QNEConnection* > m_Connections;
\r
213 #endif // __PIPELINEEDITOR__QNEPORT__H__
\r