Salome HOME
Removed exportDataflow() function. It was called from SUPERVGUI class only, so the...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Main.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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SUPERVGUI_Main.h
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 #ifndef SUPERVGUI_Main_H
29 #define SUPERVGUI_Main_H
30
31 //#include "SUPERVGUI.h"
32 #include "SUPERVGraph_ViewFrame.h"
33 #include "SUPERVGUI_Array.h"
34 #include "SUPERVGUI_Graph.h"
35 #include "QAD_Desktop.h"
36 #include "SUPERVGUI_Port.h"
37 #include "SUPERVGUI_Canvas.h"
38 #include "SUPERVGUI_CanvasView.h"
39
40 #include <qobject.h>
41 #include <qapplication.h>
42 #include <qthread.h>
43
44 class QAD_Study;
45 class QAD_ObjectBrowser;
46 class QAD_Message;
47 class NOTIFICATION_Consumer;
48 class SUPERVGUI_Thread;
49
50 class SUPERVGUI_Main: public SUPERVGraph_View {
51   Q_OBJECT
52
53   public:
54     //SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool fromIOR);
55     //SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool isModify, const char* filename);
56     SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, SUPERV_Graph);
57     virtual ~SUPERVGUI_Main();
58
59     void run();
60     void startExecute();
61     void kill();
62     void suspendResume();
63     void stopRestart();
64     void openSubGraph(SUPERV_CNode theNode, bool correct = false);
65
66     bool putDataStudy(SUPERV_Port port, const char* inout);
67     void setData(SUPERVGUI_PortIn* p);
68
69     SUPERVGUI_Graph* getGraph();
70     SUPERVGUI_Array* getArray();
71     SUPERVGUI_Canvas* getCanvas();
72     SUPERVGUI_CanvasView* getCanvasView();
73     SUPERV_Graph getDataflow();
74     QAD_Message* getMessage();
75     QAD_Study* getStudy();
76     bool isArrayShown();
77     void showPopup(QPopupMenu* p, QMouseEvent* e);
78
79     void ActivatePanning();
80     void ResetView();
81
82     void setHashCode(QString theCode) 
83       { myHashCode = theCode; };
84
85     QString getHashCode() 
86       { return myHashCode; };
87
88     
89     bool isEditable() 
90       { if (SUPERV_isNull(dataflow)) return false;
91       return !dataflow->IsReadOnly(); };
92
93     bool isFromStudy() { return myIsFromStudy; }
94     void setAsFromStudy(bool theToStudy);
95     void checkIsInStudy();
96     
97     void addComputeNode(SUPERV_CNode theNode);
98     void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update);
99     void addGOTONode(SUPERV_CNode theNode);
100     void addMacroNode(SUPERV_CNode theNode);
101
102     void setPaletteBackgroundColor(const QColor& color);
103
104     void lockedGraph(bool theLock) { myIsLocked = theLock; }
105     bool isLocked() { return myIsLocked; }
106     bool isKilled() { return myIsKilled; }
107
108     SUPERV::GraphState getNodeExecState();
109     void setNodeExecState(SUPERV::GraphState theNodeExecState);
110
111     QPtrList< char * > getEventNodes();
112     void setEventNodes(QPtrList< char * > theEventNodes);
113     bool removeFirstEN() { return myEventNodes.removeFirst(); }
114     void removeEventNodes() { myEventNodes.clear(); }
115
116     QPtrList< SUPERV::GraphState > getStates();
117     void setStates(QPtrList< SUPERV::GraphState > theStates);
118     bool removeFirstS() { return myStates.removeFirst(); }
119     void removeStates() { myStates.clear(); }
120
121     int getNodesNumber();
122     SUPERVGUI_Thread* getMyThread();
123
124     void startTimer();
125     void executionFinished();
126
127     bool eventFilter( QObject* o, QEvent* e);
128
129   signals:
130     void KillMyThread(bool theValue);
131
132   public slots:
133     void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
134     void sync();
135     void syncAsync();
136     bool addStudy();
137     void insertFile();
138     void addNode();
139     void changeInformation();
140     void copy();
141     void showTable();
142     void showFullGraph();
143     void showContolFlow();
144     void showCanvas();
145     void filterNotification();
146     void changeDSGraphParameters();
147     void onSubGraphClosed(QAD_StudyFrame* );
148     void onSubGraphActivated(QAD_StudyFrame* );
149  
150   private slots:
151     void chooseData(QListViewItem* item);
152     void checkExecution();
153
154   private:
155     void init(QAD_Desktop* parent);
156     void syncNotification();
157     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
158     void closeEvent(QCloseEvent*);
159
160     SUPERV_Graph            dataflow;
161
162     QMap<QString, QAD_StudyFrame*> mySubGraphs;
163     QMap<QString, QString>  mySubGraphMap;
164     QAD_StudyFrame*         myLastGraph;
165
166     QAD_Study*              study;
167     QAD_ObjectBrowser*      objectBrowser;
168     QAD_Message*            message;
169     SUPERVGUI_Graph*        graph;
170     
171     GraphViewType   myCurrentView;
172     SUPERVGUI_Array*   array;
173     SUPERVGUI_Canvas*       myCanvas;
174     SUPERVGUI_CanvasView*   myCanvasView;
175
176     bool               choosing;
177     SUPERVGUI_PortIn*  portIn;
178
179     QString            myHashCode;
180     
181     bool               myIsFromStudy;
182     int                myCopyNum;
183
184     SALOME_NamingService* myNService;
185     QDateTime             myRunTime; // mpv 23.12.2002: we need time of running of dataflow
186                                      // for right Study document modification
187     /* notification data */                            
188     NOTIFICATION_Consumer* notification;
189     bool                   myFiltered;
190     bool                   myLogged;
191     QString                myLogFileName;
192     FILE*                  myLogFile;
193     bool                   myWarning;
194     bool                   myStep;
195     bool                   myTrace;
196     bool                   myVerbose;
197     bool                   myIsKilled;
198     bool                   myIsLocked;
199
200     SUPERVGUI_Thread*      myThread; 
201
202     QPtrList< char * >                myEventNodes ;
203     QPtrList< SUPERV::GraphState >    myStates ;
204     QTimer*                myTimer;
205 };
206
207 class SUPERVGUI_Thread : public QObject, public QThread {
208   Q_OBJECT;
209  public:
210   SUPERVGUI_Thread();
211   ~SUPERVGUI_Thread();
212
213   void startThread(const char* m);
214   void stopThread(const char* m);
215   void setMain(SUPERVGUI_Main* theMain);
216
217  public slots:
218    void KillThread(bool theValue); 
219   
220  protected:
221   void run();
222
223  private:
224   bool                myIsActive;
225   SUPERVGUI_Main*     myMain;
226   QMutex              myMutex;
227
228 };
229
230 //**************************************************************
231 class SUPERVGUI_DSGraphParameters: public QDialog {
232   Q_OBJECT
233
234   public:
235     SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly);
236     virtual ~SUPERVGUI_DSGraphParameters();
237
238   private slots:
239     void accept();
240
241   private:
242     
243     void setData();
244     
245     QAD_SpinBoxDbl*      myDeltaTime;
246     QLineEdit*           myTimeOut;
247     QComboBox*           myDataStreamTrace;
248
249     SUPERV_Graph    myGraph;
250 };
251
252 #endif