Salome HOME
08692040f8072f66d921cc84aba2bdc8f257d265
[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
102     SUPERV::GraphState getNodeExecState();
103     void setNodeExecState(SUPERV::GraphState theNodeExecState);
104
105     QPtrList< char * > getEventNodes();
106     void setEventNodes(QPtrList< char * > theEventNodes);
107     bool removeFirstEN() { return myEventNodes.removeFirst(); }
108     void removeEventNodes() { myEventNodes.clear(); }
109
110     QPtrList< SUPERV::GraphState > getStates();
111     void setStates(QPtrList< SUPERV::GraphState > theStates);
112     bool removeFirstS() { return myStates.removeFirst(); }
113     void removeStates() { myStates.clear(); }
114
115     int getNodesNumber();
116     SUPERVGUI_Thread* getMyThread();
117
118     void startTimer();
119     void executionFinished();
120
121   public slots:
122     void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
123     void sync();
124     void syncAsync();
125     bool addStudy();
126     void insertFile();
127     void addNode();
128     void changeInformation();
129     void copy();
130     void showTable();
131     void showFullGraph();
132     void showContolFlow();
133     void filterNotification();
134  
135   private slots:
136     void chooseData(QListViewItem* item);
137     void checkExecution();
138
139   private:
140     void init(QAD_Desktop* parent);
141     void syncNotification();
142     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
143
144     SUPERV_Graph            dataflow;
145     QAD_Study*              study;
146     QAD_ObjectBrowser*      objectBrowser;
147     QAD_Message*            message;
148     SUPERVGUI_Graph*        graph;
149     
150     GraphViewType   myCurrentView;
151     SUPERVGUI_Array*   array;
152
153     bool               choosing;
154     SUPERVGUI_PortIn*  portIn;
155
156     QString            myHashCode;
157     
158     bool               myIsFromStudy;
159     int                myCopyNum;
160
161     SALOME_NamingService* myNService;
162     QDateTime             myRunTime; // mpv 23.12.2002: we need time of running of dataflow
163                                      // for right Study document modification
164     /* notification data */                            
165     NOTIFICATION_Consumer* notification;
166     bool                   myFiltered;
167     bool                   myLogged;
168     QString                myLogFileName;
169     FILE*                  myLogFile;
170     bool                   myWarning;
171     bool                   myStep;
172     bool                   myTrace;
173     bool                   myVerbose;
174     bool                   myIsKilled;
175     bool                   myIsLocked;
176
177     SUPERVGUI_Thread*      myThread; 
178
179     QPtrList< char * >                myEventNodes ;
180     QPtrList< SUPERV::GraphState >    myStates ;
181     QTimer*                myTimer;
182 };
183
184 class SUPERVGUI_Thread : public QObject, public QThread {
185   Q_OBJECT;
186  public:
187   SUPERVGUI_Thread();
188   ~SUPERVGUI_Thread();
189
190   void startThread(const char* m);
191   void stopThread(const char* m);
192   void setMain(SUPERVGUI_Main* theMain);
193
194  protected:
195   void run();
196
197  private:
198   bool                myIsActive;
199   SUPERVGUI_Main*     myMain;
200
201 };
202
203 #endif