]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_Main.h
Salome HOME
Merge with OCC_development_01
[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   // 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*, bool fromIOR);
59     //SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool isModify, const char* filename);
60     SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, SUPERV_Graph);
61     virtual ~SUPERVGUI_Main();
62
63     void run();
64     void startExecute();
65     void kill();
66     void suspendResume();
67     void stopRestart();
68     bool exportDataflow(QString theFile);
69     void openSubGraph(SUPERV_CNode theNode, bool correct = false);
70
71     bool putDataStudy(SUPERV_Port port, const char* inout);
72     void setData(SUPERVGUI_PortIn* p);
73
74     SUPERVGUI_Graph* getGraph();
75     SUPERVGUI_Array* getArray();
76     SUPERVGUI_Canvas* getCanvas();
77     SUPERVGUI_CanvasView* getCanvasView();
78     SUPERV_Graph getDataflow();
79     QAD_Message* getMessage();
80     QAD_Study* getStudy();
81     bool isArrayShown();
82     void showPopup(QPopupMenu* p, QMouseEvent* e);
83
84     void ActivatePanning();
85     void ResetView();
86
87     void setHashCode(QString theCode) 
88       { myHashCode = theCode; };
89
90     QString getHashCode() 
91       { return myHashCode; };
92
93     
94     bool isEditable() 
95       { if (SUPERV_isNull(dataflow)) return false;
96       return !dataflow->IsReadOnly(); };
97
98     bool isFromStudy() { return myIsFromStudy; }
99     void setAsFromStudy(bool theToStudy);
100     void checkIsInStudy();
101     
102     void addComputeNode(SUPERV_CNode theNode);
103     void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update);
104     void addGOTONode(SUPERV_CNode theNode);
105     void addMacroNode(SUPERV_CNode theNode);
106
107     void setPaletteBackgroundColor(const QColor& color);
108
109     void lockedGraph(bool theLock) { myIsLocked = theLock; }
110     bool isLocked() { return myIsLocked; }
111     bool isKilled() { return myIsKilled; }
112
113     SUPERV::GraphState getNodeExecState();
114     void setNodeExecState(SUPERV::GraphState theNodeExecState);
115
116     QPtrList< char * > getEventNodes();
117     void setEventNodes(QPtrList< char * > theEventNodes);
118     bool removeFirstEN() { return myEventNodes.removeFirst(); }
119     void removeEventNodes() { myEventNodes.clear(); }
120
121     QPtrList< SUPERV::GraphState > getStates();
122     void setStates(QPtrList< SUPERV::GraphState > theStates);
123     bool removeFirstS() { return myStates.removeFirst(); }
124     void removeStates() { myStates.clear(); }
125
126     int getNodesNumber();
127     SUPERVGUI_Thread* getMyThread();
128
129     void startTimer();
130     void executionFinished();
131
132     bool eventFilter( QObject* o, QEvent* e);
133
134     bool IsGUIEventLoopFinished() const { return myGUIEventLoopFinished; }
135
136   signals:
137     void KillMyThread(bool theValue);
138
139   public slots:
140     void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
141     void sync();
142     void syncAsync();
143     bool addStudy();
144     void insertFile();
145     void addNode();
146     void changeInformation();
147     void copy();
148     void showTable();
149     void showFullGraph();
150     void showContolFlow();
151     void showCanvas();
152     void filterNotification();
153     void changeDSGraphParameters();
154     void onSubGraphClosed(QAD_StudyFrame* );
155     void onSubGraphActivated(QAD_StudyFrame* );
156  
157   private slots:
158     void chooseData(QListViewItem* item);
159     void checkExecution();
160
161   private:
162     void init(QAD_Desktop* parent);
163     void syncNotification();
164     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
165     void closeEvent(QCloseEvent*);
166
167     SUPERV_Graph            dataflow;
168
169     QMap<QString, QAD_StudyFrame*> mySubGraphs;
170     QMap<QString, QString>  mySubGraphMap;
171     QAD_StudyFrame*         myLastGraph;
172
173     QAD_Study*              study;
174     QAD_ObjectBrowser*      objectBrowser;
175     QAD_Message*            message;
176     SUPERVGUI_Graph*        graph;
177     
178     GraphViewType   myCurrentView;
179     SUPERVGUI_Array*   array;
180     SUPERVGUI_Canvas*       myCanvas;
181     SUPERVGUI_CanvasView*   myCanvasView;
182
183     bool               choosing;
184     SUPERVGUI_PortIn*  portIn;
185
186     QString            myHashCode;
187     
188     bool               myIsFromStudy;
189     int                myCopyNum;
190
191     SALOME_NamingService* myNService;
192     QDateTime             myRunTime; // mpv 23.12.2002: we need time of running of dataflow
193                                      // for right Study document modification
194     /* notification data */                            
195     NOTIFICATION_Consumer* notification;
196     bool                   myFiltered;
197     bool                   myLogged;
198     QString                myLogFileName;
199     FILE*                  myLogFile;
200     bool                   myWarning;
201     bool                   myStep;
202     bool                   myTrace;
203     bool                   myVerbose;
204     bool                   myIsKilled;
205     bool                   myIsLocked;
206
207     SUPERVGUI_Thread*      myThread; 
208
209     QPtrList< char * >                myEventNodes ;
210     QPtrList< SUPERV::GraphState >    myStates ;
211     QTimer*                myTimer;
212     
213     // asv : 18.11.04 : fix for bug 6170 : this field is FALSE when SUPERVGUI_Thread
214     // is inside event loop during graph execution.  dataflow->IsDone() returns true
215     // BEFORE all events are handled (a few of them are still being processed in GUI thread), 
216     // and for bug 6170 it is neccessary to know exactly when GUI events processing stops..
217     bool                   myGUIEventLoopFinished;
218 };
219
220 class SUPERVGUI_Thread : public QObject, public QThread {
221   Q_OBJECT;
222  public:
223   SUPERVGUI_Thread();
224   ~SUPERVGUI_Thread();
225
226   void startThread(const char* m);
227   void stopThread(const char* m);
228   void setMain(SUPERVGUI_Main* theMain);
229
230  public slots:
231    void KillThread(bool theValue); 
232   
233  protected:
234   void run();
235
236  private:
237   bool                myIsActive;
238   SUPERVGUI_Main*     myMain;
239   QMutex              myMutex;
240
241 };
242
243 //**************************************************************
244 class SUPERVGUI_DSGraphParameters: public QDialog {
245   Q_OBJECT
246
247   public:
248     SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly);
249     virtual ~SUPERVGUI_DSGraphParameters();
250
251   private slots:
252     void accept();
253
254   private:
255     
256     void setData();
257     
258     QAD_SpinBoxDbl*      myDeltaTime;
259     QLineEdit*           myTimeOut;
260     QComboBox*           myDataStreamTrace;
261
262     SUPERV_Graph    myGraph;
263 };
264
265 #endif