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