Salome HOME
Bug fix: don't set "Loading" state for MacroNodes in InitialState() function (called...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Main.h
index 300b1c23414a8d8df0f74f202bc78b78a2dc88b7..d319f2adfa80d82f7287b93e4bcbf2f030e432ee 100644 (file)
 #ifndef SUPERVGUI_Main_H
 #define SUPERVGUI_Main_H
 
-//#include "SUPERVGUI.h"
 #include "SUPERVGraph_ViewFrame.h"
-#include "SUPERVGUI_Array.h"
-#include "SUPERVGUI_Graph.h"
 #include "QAD_Desktop.h"
-#include "SUPERVGUI_Port.h"
+#include "SUPERVGUI_Canvas.h"
+#include "SUPERVGUI_CanvasView.h"
+#include "SUPERVGUI_ArrayView.h"
+
+#include <qobject.h>
+#include <qapplication.h>
+#include <qthread.h>
 
 class QAD_Study;
 class QAD_ObjectBrowser;
 class QAD_Message;
+class QAD_SpinBoxDbl;
+class QLineEdit;
+class QComboBox;
 class NOTIFICATION_Consumer;
-
+class SUPERVGUI_Thread;
 
 class SUPERVGUI_Main: public SUPERVGraph_View {
   Q_OBJECT
 
+  // asv : 18.11.04 : making Thread class a friend in order to allow it to modify
+  // a private field myGUIEventLoopFinished
+  friend class SUPERVGUI_Thread;
+
   public:
-    SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool fromIOR);
-    SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool isModify, const char* filename);
     SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, SUPERV_Graph);
     virtual ~SUPERVGUI_Main();
 
@@ -55,13 +63,14 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     void kill();
     void suspendResume();
     void stopRestart();
-    bool exportDataflow(QString theFile);
+    void openSubGraph(SUPERV_CNode theNode, bool correct = false);
 
     bool putDataStudy(SUPERV_Port port, const char* inout);
-    void setData(SUPERVGUI_PortIn* p);
 
-    SUPERVGUI_Graph* getGraph();
-    SUPERVGUI_Array* getArray();
+    SUPERVGUI_CanvasArray*  getCanvasArray();
+    SUPERVGUI_ArrayView* getArrayView();
+    SUPERVGUI_Canvas* getCanvas();
+    SUPERVGUI_CanvasView* getCanvasView();
     SUPERV_Graph getDataflow();
     QAD_Message* getMessage();
     QAD_Study* getStudy();
@@ -89,14 +98,45 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     void addComputeNode(SUPERV_CNode theNode);
     void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update);
     void addGOTONode(SUPERV_CNode theNode);
+    void addMacroNode(SUPERV_CNode theNode);
 
     void setPaletteBackgroundColor(const QColor& color);
 
     void lockedGraph(bool theLock) { myIsLocked = theLock; }
     bool isLocked() { return myIsLocked; }
+    bool isKilled() { return myIsKilled; }
+
+    SUPERV::GraphState getNodeExecState();
+    void setNodeExecState(SUPERV::GraphState theNodeExecState);
+
+    QPtrList< char * > getEventNodes();
+    void setEventNodes(QPtrList< char * > theEventNodes);
+    bool removeFirstEN() { return myEventNodes.removeFirst(); }
+    void removeEventNodes() { myEventNodes.clear(); }
+
+    QPtrList< SUPERV::GraphState > getStates();
+    void setStates(QPtrList< SUPERV::GraphState > theStates);
+    bool removeFirstS() { return myStates.removeFirst(); }
+    void removeStates() { myStates.clear(); }
+
+    int getNodesNumber();
+    SUPERVGUI_Thread* getMyThread();
+
+    void startTimer();
+    void executionFinished();
+
+    bool eventFilter( QObject* o, QEvent* e);
+
+    bool IsGUIEventLoopFinished() const { return myGUIEventLoopFinished; }
+
+    void Editing(); // any Editing operation is to be performed ->
+                   // activate Editors data model in Engine
+
+  signals:
+    void KillMyThread(bool theValue);
 
   public slots:
-    void execute();
+    void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
     void sync();
     void syncAsync();
     bool addStudy();
@@ -104,33 +144,43 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     void addNode();
     void changeInformation();
     void copy();
-    void showTable();
-    void showFullGraph();
+
+    void showCanvasTable();
     void showContolFlow();
+    void showCanvas();
+
     void filterNotification();
+    void changeDSGraphParameters();
+    void onSubGraphClosed(QAD_StudyFrame* );
+    void onSubGraphActivated(QAD_StudyFrame* );
  
   private slots:
     void chooseData(QListViewItem* item);
+    void checkExecution();
 
   private:
     void init(QAD_Desktop* parent);
-    void StartTimer(const char* m);
-    void StopTimer(const char* m);
     void syncNotification();
     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
+    void closeEvent(QCloseEvent*);
 
     SUPERV_Graph            dataflow;
+
+    QMap<QString, QAD_StudyFrame*> mySubGraphs;
+    QMap<QString, QString>  mySubGraphMap;
+    QAD_StudyFrame*         myLastGraph;
+
     QAD_Study*              study;
     QAD_ObjectBrowser*      objectBrowser;
     QAD_Message*            message;
-    SUPERVGUI_Graph*        graph;
-    QTimer*                 timer;
-
+    
     GraphViewType   myCurrentView;
-    SUPERVGUI_Array*   array;
+    SUPERVGUI_CanvasArray*  myArray;
+    SUPERVGUI_ArrayView*    myArrayView;
+    SUPERVGUI_Canvas*       myCanvas;
+    SUPERVGUI_CanvasView*   myCanvasView;
 
     bool               choosing;
-    SUPERVGUI_PortIn*  portIn;
 
     QString            myHashCode;
     
@@ -152,6 +202,65 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     bool                   myVerbose;
     bool                   myIsKilled;
     bool                   myIsLocked;
+
+    SUPERVGUI_Thread*      myThread; 
+
+    QPtrList< char * >                myEventNodes ;
+    QPtrList< SUPERV::GraphState >    myStates ;
+    QTimer*                myTimer;
+    
+    // asv : 18.11.04 : fix for bug 6170 : this field is FALSE when SUPERVGUI_Thread
+    // is inside event loop during graph execution.  dataflow->IsDone() returns true
+    // BEFORE all events are handled (a few of them are still being processed in GUI thread), 
+    // and for bug 6170 it is neccessary to know exactly when GUI events processing stops..
+    bool                   myGUIEventLoopFinished;
+};
+
+class SUPERVGUI_Thread : public QObject, public QThread {
+  Q_OBJECT;
+ public:
+  SUPERVGUI_Thread();
+  ~SUPERVGUI_Thread();
+
+  void startThread(const char* m);
+  void stopThread(const char* m);
+  void setMain(SUPERVGUI_Main* theMain);
+
+ public slots:
+   void KillThread(bool theValue); 
+  
+ protected:
+  void run();
+
+ private:
+  bool                myIsActive;
+  SUPERVGUI_Main*     myMain;
+  QMutex              myMutex;
+
+};
+
+/**
+ * A dialog for setting Graph execution parameters
+ */
+class SUPERVGUI_DSGraphParameters: public QDialog {
+  Q_OBJECT
+
+  public:
+    SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly);
+    virtual ~SUPERVGUI_DSGraphParameters();
+
+  private slots:
+    void accept();
+
+  private:
+
+    void setData();
+
+    QAD_SpinBoxDbl*      myDeltaTime;
+    QLineEdit*           myTimeOut;
+    QComboBox*           myDataStreamTrace;
+
+    SUPERV_Graph    myGraph;
 };
 
 #endif