]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_Main.h
Salome HOME
1. PAL6170, "Bugs and Improvements" p.2.21: calling of dataflow->Editing() added...
[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 "SUPERVGraph_ViewFrame.h"
32 #include "QAD_Desktop.h"
33 #include "SUPERVGUI_Canvas.h"
34 #include "SUPERVGUI_CanvasView.h"
35 #include "SUPERVGUI_ArrayView.h"
36
37 #include <qobject.h>
38 #include <qapplication.h>
39 #include <qthread.h>
40
41 class QAD_Study;
42 class QAD_ObjectBrowser;
43 class QAD_Message;
44 class QAD_SpinBoxDbl;
45 class QLineEdit;
46 class QComboBox;
47 class NOTIFICATION_Consumer;
48 class SUPERVGUI_Thread;
49
50 class SUPERVGUI_Main: public SUPERVGraph_View {
51   Q_OBJECT
52
53   // asv : 18.11.04 : making Thread class a friend in order to allow it to modify
54   // a private field myGUIEventLoopFinished
55   friend class SUPERVGUI_Thread;
56
57   public:
58     SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, SUPERV_Graph);
59     virtual ~SUPERVGUI_Main();
60
61     void run();
62     void startExecute();
63     void kill();
64     void suspendResume();
65     //void stopRestart();
66     void openSubGraph(SUPERV_CNode theNode, bool correct = false);
67
68     bool putDataStudy(SUPERV_Port port, const char* inout);
69
70     SUPERVGUI_CanvasArray*  getCanvasArray();
71     SUPERVGUI_ArrayView* getArrayView();
72     SUPERVGUI_Canvas* getCanvas();
73     SUPERVGUI_CanvasView* getCanvasView();
74     SUPERV_Graph getDataflow();
75     QAD_Message* getMessage();
76     QAD_Study* getStudy();
77     bool isArrayShown();
78     void showPopup(QPopupMenu* p, QMouseEvent* e);
79
80     void ActivatePanning();
81     void ResetView();
82
83     void setHashCode(QString theCode) 
84       { myHashCode = theCode; };
85
86     QString getHashCode() 
87       { return myHashCode; };
88
89     
90     bool isEditable() 
91       { if (SUPERV_isNull(dataflow)) return false;
92       return !dataflow->IsReadOnly(); };
93
94     bool isFromStudy() { return myIsFromStudy; }
95     void setAsFromStudy(bool theToStudy);
96     void checkIsInStudy();
97     
98     void addComputeNode(SUPERV_CNode theNode);
99     void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update);
100     void addGOTONode(SUPERV_CNode theNode);
101     void addMacroNode(SUPERV_CNode theNode);
102
103     void setPaletteBackgroundColor(const QColor& color);
104
105     void lockedGraph(bool theLock) { myIsLocked = theLock; }
106     bool isLocked() { return myIsLocked; }
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     bool IsGUIEventLoopFinished() const { return myGUIEventLoopFinished; }
130
131     void Editing(); // any Editing operation is to be performed ->
132                     // activate Editors data model in Engine
133
134   signals:
135     void KillMyThread(bool theValue);
136
137   public slots:
138     void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
139     void sync();
140     void syncAsync();
141     bool addStudy();
142     void insertFile();
143     void addNode();
144     void changeInformation();
145     void copy();
146
147     void showCanvasTable();
148     void showContolFlow();
149     void showCanvas();
150
151     void filterNotification();
152     void changeDSGraphParameters();
153     void onSubGraphClosed(QAD_StudyFrame* );
154     void onSubGraphActivated(QAD_StudyFrame* );
155  
156   private slots:
157     void chooseData(QListViewItem* item);
158     void checkExecution();
159
160   private:
161     void init(QAD_Desktop* parent);
162     void syncNotification();
163     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
164     void closeEvent(QCloseEvent*);
165
166     SUPERV_Graph            dataflow;
167
168     QMap<QString, QAD_StudyFrame*> mySubGraphs;
169     QMap<QString, QString>  mySubGraphMap;
170     QAD_StudyFrame*         myLastGraph;
171
172     QAD_Study*              study;
173     QAD_ObjectBrowser*      objectBrowser;
174     QAD_Message*            message;
175     
176     GraphViewType   myCurrentView;
177     SUPERVGUI_CanvasArray*  myArray;
178     SUPERVGUI_ArrayView*    myArrayView;
179     SUPERVGUI_Canvas*       myCanvas;
180     SUPERVGUI_CanvasView*   myCanvasView;
181
182     bool               choosing;
183
184     QString            myHashCode;
185     
186     bool               myIsFromStudy;
187     int                myCopyNum;
188
189     SALOME_NamingService* myNService;
190     QDateTime             myRunTime; // mpv 23.12.2002: we need time of running of dataflow
191                                      // for right Study document modification
192     /* notification data */                            
193     NOTIFICATION_Consumer* notification;
194     bool                   myFiltered;
195     bool                   myLogged;
196     QString                myLogFileName;
197     FILE*                  myLogFile;
198     bool                   myWarning;
199     bool                   myStep;
200     bool                   myTrace;
201     bool                   myVerbose;
202     bool                   myIsLocked;
203
204     SUPERVGUI_Thread*      myThread; 
205
206     QPtrList< char * >                myEventNodes ;
207     QPtrList< SUPERV::GraphState >    myStates ;
208     QTimer*                myTimer;
209     
210     // asv : 18.11.04 : fix for bug 6170 : this field is FALSE when SUPERVGUI_Thread
211     // is inside event loop during graph execution.  dataflow->IsDone() returns true
212     // BEFORE all events are handled (a few of them are still being processed in GUI thread), 
213     // and for bug 6170 it is neccessary to know exactly when GUI events processing stops..
214     bool                   myGUIEventLoopFinished;
215 };
216
217 class SUPERVGUI_Thread : public QObject, public QThread {
218   Q_OBJECT;
219  public:
220   SUPERVGUI_Thread();
221   ~SUPERVGUI_Thread();
222
223   void startThread(const char* m);
224   void stopThread(const char* m);
225   void setMain(SUPERVGUI_Main* theMain);
226
227  public slots:
228    void KillThread(bool theValue); 
229   
230  protected:
231   void run();
232
233  private:
234   bool                myIsActive;
235   SUPERVGUI_Main*     myMain;
236   QMutex              myMutex;
237
238 };
239
240 /**
241  * A dialog for setting Graph execution parameters
242  */
243 class SUPERVGUI_DSGraphParameters: public QDialog {
244   Q_OBJECT
245
246   public:
247     SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly);
248     virtual ~SUPERVGUI_DSGraphParameters();
249
250   private slots:
251     void accept();
252
253   private:
254
255     void setData();
256
257     QAD_SpinBoxDbl*      myDeltaTime;
258     QLineEdit*           myTimeOut;
259     QComboBox*           myDataStreamTrace;
260
261     SUPERV_Graph    myGraph;
262 };
263
264 #endif