Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[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
38 #include <qobject.h>
39 #include <qapplication.h>
40 #include <qthread.h>
41
42 class QAD_Study;
43 class QAD_ObjectBrowser;
44 class QAD_Message;
45 class NOTIFICATION_Consumer;
46 class SUPERVGUI_Thread;
47
48 class SUPERVGUI_Main: public SUPERVGraph_View {
49   Q_OBJECT
50
51   public:
52     SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool fromIOR);
53     SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool isModify, const char* filename);
54     SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, SUPERV_Graph);
55     virtual ~SUPERVGUI_Main();
56
57     void run();
58     void startExecute();
59     void kill();
60     void suspendResume();
61     void stopRestart();
62     bool exportDataflow(QString theFile);
63
64     bool putDataStudy(SUPERV_Port port, const char* inout);
65     void setData(SUPERVGUI_PortIn* p);
66
67     SUPERVGUI_Graph* getGraph();
68     SUPERVGUI_Array* getArray();
69     SUPERV_Graph getDataflow();
70     QAD_Message* getMessage();
71     QAD_Study* getStudy();
72     bool isArrayShown();
73     void showPopup(QPopupMenu* p, QMouseEvent* e);
74
75     void ActivatePanning();
76     void ResetView();
77
78     void setHashCode(QString theCode) 
79       { myHashCode = theCode; };
80
81     QString getHashCode() 
82       { return myHashCode; };
83
84     
85     bool isEditable() 
86       { if (SUPERV_isNull(dataflow)) return false;
87       return !dataflow->IsReadOnly(); };
88
89     bool isFromStudy() { return myIsFromStudy; }
90     void setAsFromStudy(bool theToStudy);
91     void checkIsInStudy();
92     
93     void addComputeNode(SUPERV_CNode theNode);
94     void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update);
95     void addGOTONode(SUPERV_CNode theNode);
96
97     void setPaletteBackgroundColor(const QColor& color);
98
99     void lockedGraph(bool theLock) { myIsLocked = theLock; }
100     bool isLocked() { return myIsLocked; }
101     bool isKilled() { return myIsKilled; }
102
103     SUPERV::GraphState getNodeExecState();
104     void setNodeExecState(SUPERV::GraphState theNodeExecState);
105
106     QPtrList< char * > getEventNodes();
107     void setEventNodes(QPtrList< char * > theEventNodes);
108     bool removeFirstEN() { return myEventNodes.removeFirst(); }
109     void removeEventNodes() { myEventNodes.clear(); }
110
111     QPtrList< SUPERV::GraphState > getStates();
112     void setStates(QPtrList< SUPERV::GraphState > theStates);
113     bool removeFirstS() { return myStates.removeFirst(); }
114     void removeStates() { myStates.clear(); }
115
116     int getNodesNumber();
117     SUPERVGUI_Thread* getMyThread();
118
119     void startTimer();
120     void executionFinished();
121
122   signals:
123     void KillMyThread(bool theValue);
124
125   public slots:
126     void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
127     void sync();
128     void syncAsync();
129     bool addStudy();
130     void insertFile();
131     void addNode();
132     void changeInformation();
133     void copy();
134     void showTable();
135     void showFullGraph();
136     void showContolFlow();
137     void filterNotification();
138     void changeDSGraphParameters();
139  
140   private slots:
141     void chooseData(QListViewItem* item);
142     void checkExecution();
143
144   private:
145     void init(QAD_Desktop* parent);
146     void syncNotification();
147     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
148
149     SUPERV_Graph            dataflow;
150     QAD_Study*              study;
151     QAD_ObjectBrowser*      objectBrowser;
152     QAD_Message*            message;
153     SUPERVGUI_Graph*        graph;
154     
155     GraphViewType   myCurrentView;
156     SUPERVGUI_Array*   array;
157
158     bool               choosing;
159     SUPERVGUI_PortIn*  portIn;
160
161     QString            myHashCode;
162     
163     bool               myIsFromStudy;
164     int                myCopyNum;
165
166     SALOME_NamingService* myNService;
167     QDateTime             myRunTime; // mpv 23.12.2002: we need time of running of dataflow
168                                      // for right Study document modification
169     /* notification data */                            
170     NOTIFICATION_Consumer* notification;
171     bool                   myFiltered;
172     bool                   myLogged;
173     QString                myLogFileName;
174     FILE*                  myLogFile;
175     bool                   myWarning;
176     bool                   myStep;
177     bool                   myTrace;
178     bool                   myVerbose;
179     bool                   myIsKilled;
180     bool                   myIsLocked;
181
182     SUPERVGUI_Thread*      myThread; 
183
184     QPtrList< char * >                myEventNodes ;
185     QPtrList< SUPERV::GraphState >    myStates ;
186     QTimer*                myTimer;
187 };
188
189 class SUPERVGUI_Thread : public QObject, public QThread {
190   Q_OBJECT;
191  public:
192   SUPERVGUI_Thread();
193   ~SUPERVGUI_Thread();
194
195   void startThread(const char* m);
196   void stopThread(const char* m);
197   void setMain(SUPERVGUI_Main* theMain);
198
199  public slots:
200    void KillThread(bool theValue); 
201   
202  protected:
203   void run();
204
205  private:
206   bool                myIsActive;
207   SUPERVGUI_Main*     myMain;
208   QMutex              myMutex;
209
210 };
211
212 #endif