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