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