]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_Main.h
Salome HOME
043a915f59dc48d03ae876e5e305025c67bde654
[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     bool exportDataflow(QString theFile);
65     void openSubGraph(SUPERV_CNode theNode, bool correct = false);
66
67     bool putDataStudy(SUPERV_Port port, const char* inout);
68     void setData(SUPERVGUI_PortIn* p);
69
70     SUPERVGUI_Graph* getGraph();
71     SUPERVGUI_Array* getArray();
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     bool isKilled() { return myIsKilled; }
108
109     SUPERV::GraphState getNodeExecState();
110     void setNodeExecState(SUPERV::GraphState theNodeExecState);
111
112     QPtrList< char * > getEventNodes();
113     void setEventNodes(QPtrList< char * > theEventNodes);
114     bool removeFirstEN() { return myEventNodes.removeFirst(); }
115     void removeEventNodes() { myEventNodes.clear(); }
116
117     QPtrList< SUPERV::GraphState > getStates();
118     void setStates(QPtrList< SUPERV::GraphState > theStates);
119     bool removeFirstS() { return myStates.removeFirst(); }
120     void removeStates() { myStates.clear(); }
121
122     int getNodesNumber();
123     SUPERVGUI_Thread* getMyThread();
124
125     void startTimer();
126     void executionFinished();
127
128     bool eventFilter( QObject* o, QEvent* e);
129
130   signals:
131     void KillMyThread(bool theValue);
132
133   public slots:
134     void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
135     void sync();
136     void syncAsync();
137     bool addStudy();
138     void insertFile();
139     void addNode();
140     void changeInformation();
141     void copy();
142     void showTable();
143     void showFullGraph();
144     void showContolFlow();
145     void showCanvas();
146     void filterNotification();
147     void changeDSGraphParameters();
148     void onSubGraphClosed(QAD_StudyFrame* );
149     void onSubGraphActivated(QAD_StudyFrame* );
150  
151   private slots:
152     void chooseData(QListViewItem* item);
153     void checkExecution();
154
155   private:
156     void init(QAD_Desktop* parent);
157     void syncNotification();
158     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
159     void closeEvent(QCloseEvent*);
160
161     SUPERV_Graph            dataflow;
162
163     QMap<QString, QAD_StudyFrame*> mySubGraphs;
164     QMap<QString, QString>  mySubGraphMap;
165     QAD_StudyFrame*         myLastGraph;
166
167     QAD_Study*              study;
168     QAD_ObjectBrowser*      objectBrowser;
169     QAD_Message*            message;
170     SUPERVGUI_Graph*        graph;
171     
172     GraphViewType   myCurrentView;
173     SUPERVGUI_Array*   array;
174     SUPERVGUI_Canvas*       myCanvas;
175     SUPERVGUI_CanvasView*   myCanvasView;
176
177     bool               choosing;
178     SUPERVGUI_PortIn*  portIn;
179
180     QString            myHashCode;
181     
182     bool               myIsFromStudy;
183     int                myCopyNum;
184
185     SALOME_NamingService* myNService;
186     QDateTime             myRunTime; // mpv 23.12.2002: we need time of running of dataflow
187                                      // for right Study document modification
188     /* notification data */                            
189     NOTIFICATION_Consumer* notification;
190     bool                   myFiltered;
191     bool                   myLogged;
192     QString                myLogFileName;
193     FILE*                  myLogFile;
194     bool                   myWarning;
195     bool                   myStep;
196     bool                   myTrace;
197     bool                   myVerbose;
198     bool                   myIsKilled;
199     bool                   myIsLocked;
200
201     SUPERVGUI_Thread*      myThread; 
202
203     QPtrList< char * >                myEventNodes ;
204     QPtrList< SUPERV::GraphState >    myStates ;
205     QTimer*                myTimer;
206 };
207
208 class SUPERVGUI_Thread : public QObject, public QThread {
209   Q_OBJECT;
210  public:
211   SUPERVGUI_Thread();
212   ~SUPERVGUI_Thread();
213
214   void startThread(const char* m);
215   void stopThread(const char* m);
216   void setMain(SUPERVGUI_Main* theMain);
217
218  public slots:
219    void KillThread(bool theValue); 
220   
221  protected:
222   void run();
223
224  private:
225   bool                myIsActive;
226   SUPERVGUI_Main*     myMain;
227   QMutex              myMutex;
228
229 };
230
231 //**************************************************************
232 class SUPERVGUI_DSGraphParameters: public QDialog {
233   Q_OBJECT
234
235   public:
236     SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly);
237     virtual ~SUPERVGUI_DSGraphParameters();
238
239   private slots:
240     void accept();
241
242   private:
243     
244     void setData();
245     
246     QAD_SpinBoxDbl*      myDeltaTime;
247     QLineEdit*           myTimeOut;
248     QComboBox*           myDataStreamTrace;
249
250     SUPERV_Graph    myGraph;
251 };
252
253 #endif