]> Creatis software - cpPlugins.git/blob - appli/cpPipelineEditor/QNEBlock.h
dfe51991deb45c99bc576038c46b6a26853c4029
[cpPlugins.git] / appli / cpPipelineEditor / QNEBlock.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__QNEBLOCK__H__\r
28 #define __PIPELINEEDITOR__QNEBLOCK__H__\r
29 \r
30 #include <QGraphicsPathItem>\r
31 #include <cpPlugins/Interface/ProcessObject.h>\r
32 \r
33 namespace PipelineEditor\r
34 {\r
35   class QNEPort;\r
36   class QNENamePort;\r
37   class QNETypePort;\r
38   class QNEInputPort;\r
39   class QNEOutputPort;\r
40 \r
41   class QNEBlock\r
42     : public QGraphicsPathItem\r
43   {\r
44   public:\r
45     typedef QNEBlock          Self;\r
46     typedef QGraphicsPathItem Superclass;\r
47     typedef cpPlugins::Interface::ProcessObject TFilter;\r
48   \r
49   public:\r
50     enum { Type = QGraphicsItem::UserType + 6 };\r
51 \r
52     QNEBlock(\r
53       TFilter* filter,\r
54       QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL\r
55       );\r
56     virtual ~QNEBlock( );\r
57 \r
58     void setNamePort( const QString& txt );\r
59     void setTypePort( const QString& txt );\r
60     void addInputPort( const QString& txt );\r
61     void addOutputPort( const QString& txt );\r
62     QVector< QNEPort* > ports( );\r
63 \r
64     inline QNENamePort* namePort( )\r
65       { return( this->m_NamePort ); }\r
66     inline QNETypePort* typePort( )\r
67       { return( this->m_TypePort ); }\r
68     inline QVector< QNEInputPort* >& inputPorts( )\r
69       { return( this->m_InputPorts ); }\r
70     inline QVector< QNEOutputPort* >& outputPorts( )\r
71       { return( this->m_OutputPorts ); }\r
72 \r
73     inline const QNENamePort* namePort( ) const\r
74       { return( this->m_NamePort ); }\r
75     inline const QNETypePort* typePort( ) const\r
76       { return( this->m_TypePort ); }\r
77     inline const QVector< QNEInputPort* >& inputPorts( ) const\r
78       { return( this->m_InputPorts ); }\r
79     inline const QVector< QNEOutputPort* >& outputPorts( ) const\r
80       { return( this->m_OutputPorts ); }\r
81 \r
82     QNEBlock* clone( );\r
83     inline int type( ) const\r
84       { return( this->Type ); }\r
85 \r
86     void paint(\r
87       QPainter* painter,\r
88       const QStyleOptionGraphicsItem* option,\r
89       QWidget* widget\r
90       );\r
91     \r
92   protected:\r
93     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
94     void _configPort( QNEPort* port );\r
95 \r
96   private:\r
97     int m_HorzMargin;\r
98     int m_VertMargin;\r
99     int m_Width;\r
100     int m_Height;\r
101 \r
102     QNENamePort* m_NamePort;\r
103     QNETypePort* m_TypePort;\r
104     QVector< QNEInputPort* >  m_InputPorts;\r
105     QVector< QNEOutputPort* > m_OutputPorts;\r
106 \r
107     TFilter::Pointer m_Filter;\r
108   };\r
109 \r
110 } // ecapseman\r
111 \r
112 #endif // __PIPELINEEDITOR__QNEBLOCK__H__\r
113 \r
114 // eof - $RCSfile$\r