Salome HOME
Fix for improvement IPAL9815 : Remove "Add Port" functionality as duplicate of "Edit...
[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
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(QObject* theParent, SUPERVGUI_Main* theMain, 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   public slots:
75     void suspendResume();
76     void kill();
77     //void stopRestart();
78
79     //asv: 13.12.04: ??? --> void configure();
80     //asv: 13.12.04: ??? --> void showPython();
81
82     virtual void rename();
83     virtual void remove();
84     void copy();
85     void changeInformation();
86     void browse();
87
88     void switchLabel();
89     void switchPorts();
90
91     void setWarning(bool b);
92     void setStep(bool b);
93     void setTrace(bool b);
94     void setVerbose(bool b);
95
96     // mkr : IPAL9815 : commented the following code
97     /*virtual void addInputPort();
98       virtual void addOutputPort();*/
99     virtual void editFunction();
100     virtual void pastePort();
101     void managePorts();
102     void exportToLib();
103
104   protected:
105     // redefined by most of CanvasNode successors
106     virtual SUPERVGUI_CanvasNodePrs* createPrs() const;
107     
108     void createPort(SUPERV::Port_ptr thePort);
109     void createStreamPort(SUPERV::StreamPort_ptr thePort);
110     
111     virtual bool eventFilter(QObject* o, QEvent* e);
112     SUPERVGUI_BrowseNodeDlg* myBrowseDlg;
113
114     bool isIgnore;
115
116   protected slots:
117     virtual void onDestroyed(QObject*);
118
119   private:
120     SUPERV_CNode     myNode;
121     SUPERVGUI_Main*  myMain;
122
123     QString          myLabelText;
124     SUPERVGUI_CanvasNodePrs* myPrs;
125
126     bool myDestroyed;
127
128     bool        warning;
129     bool        step;
130     bool        trace;
131     bool        verbose;
132 };
133
134 #endif