Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasNode.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  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 //  File   : SUPERVGUI_CanvasNode.h
23 //  Author : Natalia KOPNOVA
24 //  Module : SUPERV
25
26 #ifndef SUPERVGUI_CanvasNode_H
27 #define SUPERVGUI_CanvasNode_H
28
29 #include "SUPERVGUI_Def.h"
30 #include "SUPERVGUI_BrowseNodeDlg.h"
31 #include <qstringlist.h>
32
33 class SUPERVGUI_Main;
34 class SUPERVGUI_CanvasNodePrs;
35 class SUIT_ResourceMgr;
36
37 class SUPERVGUI_CanvasNode : public QObject {
38   friend class SUPERVGUI_ManagePortsDlg;
39   friend class SUPERVGUI_Clipboard;
40
41   Q_OBJECT
42
43   public:
44     virtual ~SUPERVGUI_CanvasNode();
45
46     // done to ignore port update when node is removed
47     bool isDestroyed() const { return myDestroyed; }
48     void setDestroyed();
49
50     virtual void merge();
51     virtual void sync();
52     virtual void syncOnEvent(SUPERV::GraphState theStateFromEvent);
53
54     virtual void show();
55     virtual void move(int x, int y);
56
57     virtual void hideAll();
58     virtual void showAll();
59     virtual bool setNodeName(QString aName);
60
61     SUPERV_CNode             getEngine() const { return myNode; }
62     SUPERVGUI_Main*          getMain()   const { return myMain; }
63     SUPERVGUI_CanvasNodePrs* getPrs();
64
65     bool isWarning();
66     bool isStep();
67     bool isTrace();
68     bool isVerbose();
69
70     SUPERV::KindOfNode getNodeType() const { return myNode->Kind(); }
71
72     SUPERV_CNode  getComputingNode() const { return myNode; }
73     SUPERV_FNode  getFactoryNode()   const { return SUPERV::FNode::_narrow(myNode); }
74     SUPERV_INode  getInlineNode()    const { return SUPERV::INode::_narrow(myNode); }
75     SUPERV_GNode  getGotoNode()      const { return SUPERV::GNode::_narrow(myNode); }
76     SUPERV_LNode  getLoopNode()      const { return SUPERV::LNode::_narrow(myNode); }
77     SUPERV_ELNode getEndLoopNode()   const { return SUPERV::ELNode::_narrow(myNode);}
78     SUPERV_SNode  getSwitchNode()    const { return SUPERV::SNode::_narrow(myNode); }
79     SUPERV_ESNode getEndSwitchNode() const { return SUPERV::ESNode::_narrow(myNode);}
80     SUPERV_Graph  getMacroNode()     const { return SUPERV::Graph::_narrow(myNode); }
81
82     SUPERV_Port createInPort();
83     SUPERV_Port createOutPort();
84     QStringList getPortsNamesIN(SUPERV_INode theNode, bool theInputPorts);
85
86     virtual QPopupMenu* getPopupMenu(QWidget* theParent);
87
88     QString getLabelText() const { return myLabelText; }
89
90     virtual QString getToolTipText() const;
91
92   signals:
93     void objectCreatedDeleted(); // mkr : PAL8237
94
95   public slots:
96     void suspendResume();
97     void kill();
98     //void stopRestart();
99
100     //asv: 13.12.04: ??? --> void configure();
101     //asv: 13.12.04: ??? --> void showPython();
102
103     virtual void rename();
104     virtual void remove();
105     void copy();
106     void changeInformation();
107     void browse();
108
109     void switchLabel();
110     void switchPorts();
111
112     void setWarning(bool b);
113     void setStep(bool b);
114     void setTrace(bool b);
115     void setVerbose(bool b);
116
117     // mkr : IPAL9815 : commented the following code
118     /*virtual void addInputPort();
119       virtual void addOutputPort();*/
120     virtual void editFunction();
121     virtual void pastePort();
122     void managePorts();
123     void exportToLib();
124   
125   protected:
126     SUPERVGUI_CanvasNode (SUIT_ResourceMgr*, QObject*, SUPERVGUI_Main*,
127                           SUPERV_CNode theNode, bool theIsCell=false);
128
129     // redefined by most of CanvasNode successors
130     virtual SUPERVGUI_CanvasNodePrs* createPrs() const;
131     SUIT_ResourceMgr* resMgr() const { return myMgr; }
132     
133     void createPort(SUPERV::Port_ptr thePort);
134     void createStreamPort(SUPERV::StreamPort_ptr thePort);
135     
136     virtual bool eventFilter(QObject* o, QEvent* e);
137     SUPERVGUI_BrowseNodeDlg* myBrowseDlg;
138
139     bool isIgnore;
140
141   protected slots:
142     virtual void onDestroyed(QObject*);
143
144   private:
145     SUPERV_CNode     myNode;
146     SUPERVGUI_Main*  myMain;
147
148     QString          myLabelText;
149     SUPERVGUI_CanvasNodePrs* myPrs;
150     SUIT_ResourceMgr* myMgr;
151
152     bool myDestroyed;
153
154     bool        warning;
155     bool        step;
156     bool        trace;
157     bool        verbose;
158 };
159
160 #endif