Salome HOME
6124d3dbbe9783a194e3b0885c8981ff5ba3e449
[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     SUPERVGUI_CanvasNode( SUIT_ResourceMgr*, QObject*, SUPERVGUI_Main*, SUPERV_CNode theNode, bool theIsCell=false);
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     // redefined by most of CanvasNode successors
128     virtual SUPERVGUI_CanvasNodePrs* createPrs() const;
129     SUIT_ResourceMgr* resMgr() const { return myMgr; }
130     
131     void createPort(SUPERV::Port_ptr thePort);
132     void createStreamPort(SUPERV::StreamPort_ptr thePort);
133     
134     virtual bool eventFilter(QObject* o, QEvent* e);
135     SUPERVGUI_BrowseNodeDlg* myBrowseDlg;
136
137     bool isIgnore;
138
139   protected slots:
140     virtual void onDestroyed(QObject*);
141
142   private:
143     SUPERV_CNode     myNode;
144     SUPERVGUI_Main*  myMain;
145
146     QString          myLabelText;
147     SUPERVGUI_CanvasNodePrs* myPrs;
148     SUIT_ResourceMgr* myMgr;
149
150     bool myDestroyed;
151
152     bool        warning;
153     bool        step;
154     bool        trace;
155     bool        verbose;
156 };
157
158 #endif