]> Creatis software - cpPlugins.git/blob - appli/cpPipelineEditor/QNEPort.h
More on graph editor
[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   public:\r
47     enum { Type = QGraphicsItem::UserType + 1 };\r
48     enum { NamePort = 1, TypePort = 2 };\r
49 \r
50     QNEPort( QGraphicsItem* parent = 0, QGraphicsScene* scene = NULL );\r
51     virtual ~QNEPort( );\r
52 \r
53     void setNEBlock( QNEBlock* b );\r
54     void setName( const QString& n );\r
55     void setIsOutput( bool o );\r
56     int radius( );\r
57     bool isOutput( );\r
58     QVector< QNEConnection* >& connections( );\r
59     void setPortFlags( int f );\r
60 \r
61     inline const QString& portName( ) const\r
62       { return( this->m_Name ); }\r
63     inline int portFlags( ) const\r
64       { return( this->m_PortFlags ); }\r
65     int type( ) const\r
66       { return( this->Type ); }\r
67 \r
68     QNEBlock* block( ) const;\r
69     quint64 ptr( );\r
70     void setPtr( quint64 p );\r
71     bool isConnected( QNEPort* other );\r
72 \r
73   protected:\r
74     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
75 \r
76   private:\r
77     QNEBlock* m_Block;\r
78     QString m_Name;\r
79     bool m_IsOutput;\r
80     QGraphicsTextItem* m_Label;\r
81     int m_Radius;\r
82     int m_Margin;\r
83     QVector< QNEConnection* > m_Connections;\r
84     int m_PortFlags;\r
85     quint64 m_Ptr;\r
86   };\r
87 \r
88 } // ecapseman\r
89 \r
90 #endif // __PIPELINEEDITOR__QNEPORT__H__\r
91 \r
92 // eof - $RCSfile$\r