]> Creatis software - cpPlugins.git/blob - appli/cpPipelineEditor/QNodesEditor.h
e2dc37c7f7fc6718234a15ee455c3350a45ed955
[cpPlugins.git] / appli / cpPipelineEditor / QNodesEditor.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__QNODESEDITOR__H__\r
28 #define __PIPELINEEDITOR__QNODESEDITOR__H__\r
29 \r
30 #include <QObject>\r
31 #include <QPointF>\r
32 #include <cpExtensions/DataStructures/Graph.h>\r
33 #include <cpPlugins/Interface/Workspace.h>\r
34 \r
35 class QGraphicsScene;\r
36 class QGraphicsSceneMouseEvent;\r
37 class QGraphicsItem;\r
38 \r
39 namespace PipelineEditor\r
40 {\r
41   class QNEConnection;\r
42   class QNEBlock;\r
43 \r
44   /**\r
45    */\r
46   class QNodesEditor\r
47     : public QObject\r
48   {\r
49     Q_OBJECT;\r
50 \r
51   public:\r
52     typedef QNodesEditor Self;\r
53     typedef QObject      Superclass;\r
54 \r
55     typedef cpPlugins::Interface::Workspace TWorkspace;\r
56     typedef TWorkspace::TFilter             TFilter;\r
57     typedef\r
58       cpExtensions::DataStructures::\r
59       Graph< QNEBlock*, QNEConnection*, std::string > TGraph;\r
60 \r
61   public:\r
62     explicit QNodesEditor( QObject* parent = 0 );\r
63     virtual ~QNodesEditor( );\r
64 \r
65     TWorkspace* workspace( );\r
66     const TWorkspace* workspace( ) const;\r
67     void setWorkspace( TWorkspace* ws );\r
68 \r
69     std::string createFilter(\r
70       const std::string& filter,\r
71       const QPointF& pnt = QPointF( )\r
72       );\r
73 \r
74     void install( QGraphicsScene* s );\r
75     bool eventFilter( QObject* o, QEvent* e );\r
76 \r
77   private:\r
78     QGraphicsItem* itemAt( const QPointF& pos );\r
79 \r
80     inline void _CreateBlock( TFilter* f, const QPointF& pnt );\r
81     inline void _DoubleClick( QGraphicsSceneMouseEvent* evt, QGraphicsItem* item );\r
82 \r
83   private:\r
84     QGraphicsScene* m_Scene;\r
85     QNEConnection* m_Conn;\r
86 \r
87     TWorkspace* m_Workspace;\r
88     TGraph::Pointer m_Graph;\r
89   };\r
90 \r
91 } // ecapseman\r
92 \r
93 #endif // __PIPELINEEDITOR__QNODESEDITOR__H__\r
94 \r
95 // eof - $RCSfile$\r