Salome HOME
Update copyright information
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasNode.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SUPERV SUPERVGUI : GUI for Supervisor component
23 //  File   : SUPERVGUI_CanvasNode.h
24 //  Author : Natalia KOPNOVA
25 //  Module : SUPERV
26 //
27 #ifndef SUPERVGUI_CanvasNode_H
28 #define SUPERVGUI_CanvasNode_H
29
30 #include "SUPERVGUI_Def.h"
31 #include "SUPERVGUI_BrowseNodeDlg.h"
32 #include <qstringlist.h>
33
34 class SUPERVGUI_Main;
35 class SUPERVGUI_CanvasNodePrs;
36 class SUIT_ResourceMgr;
37
38 class SUPERVGUI_CanvasNode : public QObject {
39   friend class SUPERVGUI_ManagePortsDlg;
40   friend class SUPERVGUI_Clipboard;
41
42   Q_OBJECT
43
44   public:
45     virtual ~SUPERVGUI_CanvasNode();
46
47     // done to ignore port update when node is removed
48     bool isDestroyed() const { return myDestroyed; }
49     void setDestroyed();
50
51     virtual void merge();
52     virtual void sync();
53     virtual void syncOnEvent(SUPERV::GraphState theStateFromEvent);
54
55     virtual void show();
56     virtual void move(int x, int y);
57
58     virtual void hideAll();
59     virtual void showAll();
60     virtual bool setNodeName(QString aName);
61
62     SUPERV_CNode             getEngine() const { return myNode; }
63     SUPERVGUI_Main*          getMain()   const { return myMain; }
64     SUPERVGUI_CanvasNodePrs* getPrs();
65
66     bool isWarning();
67     bool isStep();
68     bool isTrace();
69     bool isVerbose();
70
71     SUPERV::KindOfNode getNodeType() const { return myNode->Kind(); }
72
73     SUPERV_CNode  getComputingNode() const { return myNode; }
74     SUPERV_FNode  getFactoryNode()   const { return SUPERV::FNode::_narrow(myNode); }
75     SUPERV_INode  getInlineNode()    const { return SUPERV::INode::_narrow(myNode); }
76     SUPERV_GNode  getGotoNode()      const { return SUPERV::GNode::_narrow(myNode); }
77     SUPERV_LNode  getLoopNode()      const { return SUPERV::LNode::_narrow(myNode); }
78     SUPERV_ELNode getEndLoopNode()   const { return SUPERV::ELNode::_narrow(myNode);}
79     SUPERV_SNode  getSwitchNode()    const { return SUPERV::SNode::_narrow(myNode); }
80     SUPERV_ESNode getEndSwitchNode() const { return SUPERV::ESNode::_narrow(myNode);}
81     SUPERV_Graph  getMacroNode()     const { return SUPERV::Graph::_narrow(myNode); }
82
83     SUPERV_Port createInPort();
84     SUPERV_Port createOutPort();
85     QStringList getPortsNamesIN(SUPERV_INode theNode, bool theInputPorts);
86
87     virtual QPopupMenu* getPopupMenu(QWidget* theParent);
88
89     QString getLabelText() const { return myLabelText; }
90
91     virtual QString getToolTipText() const;
92
93   signals:
94     void objectCreatedDeleted(); // mkr : PAL8237
95
96   public slots:
97     void suspendResume();
98     void kill();
99     //void stopRestart();
100
101     //asv: 13.12.04: ??? --> void configure();
102     //asv: 13.12.04: ??? --> void showPython();
103
104     virtual void rename();
105     virtual void remove();
106     void copy();
107     void changeInformation();
108     void browse();
109
110     void switchLabel();
111     void switchPorts();
112
113     void setWarning(bool b);
114     void setStep(bool b);
115     void setTrace(bool b);
116     void setVerbose(bool b);
117
118     // mkr : IPAL9815 : commented the following code
119     /*virtual void addInputPort();
120       virtual void addOutputPort();*/
121     virtual void editFunction();
122     virtual void pastePort();
123     void managePorts();
124     void exportToLib();
125   
126   protected:
127     SUPERVGUI_CanvasNode (SUIT_ResourceMgr*, QObject*, SUPERVGUI_Main*,
128                           SUPERV_CNode theNode, bool theIsCell=false);
129
130     // redefined by most of CanvasNode successors
131     virtual SUPERVGUI_CanvasNodePrs* createPrs() const;
132     SUIT_ResourceMgr* resMgr() const { return myMgr; }
133     
134     void createPort(SUPERV::Port_ptr thePort);
135     void createStreamPort(SUPERV::StreamPort_ptr thePort);
136     
137     virtual bool eventFilter(QObject* o, QEvent* e);
138     SUPERVGUI_BrowseNodeDlg* myBrowseDlg;
139
140     bool isIgnore;
141
142   protected slots:
143     virtual void onDestroyed(QObject*);
144
145   private:
146     SUPERV_CNode     myNode;
147     SUPERVGUI_Main*  myMain;
148
149     QString          myLabelText;
150     SUPERVGUI_CanvasNodePrs* myPrs;
151     SUIT_ResourceMgr* myMgr;
152
153     bool myDestroyed;
154
155     bool        warning;
156     bool        step;
157     bool        trace;
158     bool        verbose;
159 };
160
161 #endif