]> Creatis software - cpPlugins.git/blob - appli/cpPipelineEditor/QNEPort.h
383167b9bfcc39d977b4024b612afa43fafaafda
[cpPlugins.git] / appli / cpPipelineEditor / QNEPort.h
1 /* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
2    All rights reserved.\r
3 \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
14 \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
25 */\r
26 \r
27 #ifndef __PIPELINEEDITOR__QNEPORT__H__\r
28 #define __PIPELINEEDITOR__QNEPORT__H__\r
29 \r
30 #include <QGraphicsPathItem>\r
31 \r
32 namespace PipelineEditor\r
33 {\r
34   class QNEBlock;\r
35   class QNEConnection;\r
36 \r
37   /**\r
38    */\r
39   class QNEPort\r
40     : public QGraphicsPathItem\r
41   {\r
42   public:\r
43     typedef QNEPort Self;\r
44     typedef QGraphicsPathItem Superclass;\r
45 \r
46     enum { Type = QGraphicsItem::UserType + 1 };\r
47 \r
48   public:\r
49     QNEPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
50     virtual ~QNEPort( );\r
51 \r
52     void setBlock( QNEBlock* b );\r
53     inline QNEBlock* block( ) const\r
54       { return( this->m_Block ); }\r
55 \r
56     virtual void setName( const QString& n );\r
57     inline const QString& name( ) const\r
58       { return( this->m_Name ); }\r
59 \r
60     void setPtr( quint64 p );\r
61     inline quint64 ptr( )\r
62       { return( this->m_Ptr ); }\r
63 \r
64     inline int radius( ) const\r
65       { return( this->m_Radius ); }\r
66 \r
67     virtual bool isConnected( QNEPort* other ) = 0;\r
68     inline int type( ) const\r
69       { return( this->Type ); }\r
70 \r
71   protected:\r
72     QNEBlock* m_Block;\r
73 \r
74     QString            m_Name;\r
75     QGraphicsTextItem* m_Label;\r
76     int                m_Radius;\r
77     int                m_Margin;\r
78     quint64            m_Ptr;\r
79   };\r
80 \r
81   /**\r
82    */\r
83   class QNENamePort\r
84     : public QNEPort\r
85   {\r
86   public:\r
87     typedef QNENamePort Self;\r
88     typedef QNEPort     Superclass;\r
89 \r
90     enum { Type = Superclass::Type + 1 };\r
91 \r
92   public:\r
93     QNENamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
94     virtual ~QNENamePort( );\r
95 \r
96     virtual void setName( const QString& n );\r
97 \r
98     virtual bool isConnected( QNEPort* other );\r
99     inline int type( ) const\r
100       { return( this->Type ); }\r
101   };\r
102 \r
103   /**\r
104    */\r
105   class QNETypePort\r
106     : public QNEPort\r
107   {\r
108   public:\r
109     typedef QNETypePort Self;\r
110     typedef QNEPort     Superclass;\r
111 \r
112     enum { Type = Superclass::Type + 2 };\r
113 \r
114   public:\r
115     QNETypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
116     virtual ~QNETypePort( );\r
117 \r
118     virtual void setName( const QString& n );\r
119 \r
120     virtual bool isConnected( QNEPort* other );\r
121     inline int type( ) const\r
122       { return( this->Type ); }\r
123   };\r
124 \r
125   /**\r
126    */\r
127   class QNEInputPort\r
128     : public QNEPort\r
129   {\r
130   public:\r
131     typedef QNEInputPort Self;\r
132     typedef QNEPort      Superclass;\r
133 \r
134     enum { Type = Superclass::Type + 3 };\r
135 \r
136   public:\r
137     QNEInputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
138     virtual ~QNEInputPort( );\r
139 \r
140     virtual void setName( const QString& n );\r
141 \r
142     virtual bool isConnected( QNEPort* other );\r
143     inline int type( ) const\r
144       { return( this->Type ); }\r
145 \r
146     void setConnection( QNEConnection* c );\r
147     inline QNEConnection* connection( )\r
148       { return( this->m_Connection ); }\r
149     inline const QNEConnection* connection( ) const\r
150       { return( this->m_Connection ); }\r
151     inline bool hasConnection( ) const\r
152       { return( this->m_Connection != NULL ); }\r
153 \r
154   protected:\r
155     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
156 \r
157   protected:\r
158     QNEConnection* m_Connection;\r
159   };\r
160 \r
161   /**\r
162    */\r
163   class QNEOutputPort\r
164     : public QNEPort\r
165   {\r
166   public:\r
167     typedef QNEOutputPort Self;\r
168     typedef QNEPort       Superclass;\r
169 \r
170     enum { Type = Superclass::Type + 4 };\r
171 \r
172   public:\r
173     QNEOutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
174     virtual ~QNEOutputPort( );\r
175 \r
176     virtual void setName( const QString& n );\r
177 \r
178     virtual bool isConnected( QNEPort* other );\r
179     inline int type( ) const\r
180       { return( this->Type ); }\r
181 \r
182     inline QVector< QNEConnection* >& connections( )\r
183       { return( this->m_Connections ); }\r
184     inline const QVector< QNEConnection* >& connections( ) const\r
185       { return( this->m_Connections ); }\r
186 \r
187   protected:\r
188     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
189 \r
190   protected:\r
191     QVector< QNEConnection* > m_Connections;\r
192   };\r
193 \r
194 } // ecapseman\r
195 \r
196 #endif // __PIPELINEEDITOR__QNEPORT__H__\r
197 \r
198 // eof - $RCSfile$\r