Salome HOME
Merging with JR_ASV_2_1_0_deb_with_KERNEL_Head branch, which contains many bug fixes...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI.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.h
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 #ifndef SUPERVGUI_H
29 #define SUPERVGUI_H
30
31 // Acces a l`ihm de SALOME
32 // -----------------------
33
34 #include "QAD_Desktop.h"
35
36
37 #include "SUPERVGUI_Def.h"
38 #include "SUPERVGUI_Service.h"
39 #include "SUPERVGUI_Main.h"
40 //#include "SUPERVGUI_Information.h"
41
42 #include "SALOMEGUI.h"
43
44 // Definition de la classe principale du module de supervision
45 // -----------------------------------------------------------
46
47 class SUPERVGUI: public SALOMEGUI {
48   Q_OBJECT
49
50   public:
51     SUPERVGUI( const QString&, QObject* = 0 );
52     virtual ~SUPERVGUI();
53
54     QAD_Desktop*       getDesktop();
55     SUPERV_Engine      getEngine();
56     QAD_Study*         getActiveStudy() 
57       { return study; };
58
59     SUPERVGUI_Service* getBrowser();
60     QCursor            getCursor();
61     //bool information(SUPERV_CNode node, bool isReadOnly);
62     void putInfo(const char* mess);
63
64     void importDataflow();
65     void exportDataflow();
66     void newDataflow();
67     void modifyDataflow();
68     void reloadDataflow();
69     void runDataflow();
70     void stepByStep();
71     void killDataflow();
72     void suspendResumeDataflow();
73     void showComponents();
74
75     void init(QAD_Desktop* parent);
76     SUPERVGUI_Main* getMain();
77
78     bool OnGUIEvent(int theCommandID, QAD_Desktop* parent);
79     bool SetSettings(QAD_Desktop* parent);
80     void DefinePopup(QString & theContext,
81                      QString & theParent, 
82                      QString & theObject ) ;
83     bool CustomPopup(QAD_Desktop* parent,
84                      QPopupMenu* popup,
85                      const QString & theContext,
86                      const QString & theParent,
87                      const QString & theObject);
88     bool ActiveStudyChanged( QAD_Desktop* parent );
89     void SupportedViewType (int* buffer, int bufferSize);
90
91     bool isContains(QAD_Study* theStudy, const QString theKey);
92
93     void registerGraph(QString theName, SUPERVGUI_Main* theGraph);
94     void unregisterGraph(SUPERVGUI_Main* theGraph);
95     QAD_StudyFrame* createGraph();
96
97     /** Returns:
98         theIsOwner = true if Selected object belongs to Suipervision.
99         theIsDataflow = true if Selected object is Dataflow
100     */
101     void whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow);
102
103     /* asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, 
104        a backup copy of an existing file must be created (in case Export fails..)
105        This method creates a backup file and returns its name or QString::null if it fails
106        Function is static because it is called from 
107        SUPERVGUI::exportDataflow() and SUPERVGUI_CanvasMacroNode::exportDataflow()    
108     */
109     static QString createBackupFile( const QString& theOriginalFileName );
110
111   signals:
112     void KillMainThread(bool theValue);
113
114   private slots:
115     void setMain(QWidget* w);
116     void displayDataflow();
117     void renameDataflow();
118     void deleteObject();
119     void onGraphClosed(QAD_ViewFrame* );
120
121   private:
122     void loadEngine(SALOME_NamingService* namingService);
123
124     static int             factory;
125     QAD_Desktop*           desktop;
126     QAD_Study*             study;
127     SUPERV_Engine          engine;
128     SUPERVGUI_Service*     browser;
129     //SUPERVGUI_Information* info;
130     QCursor                cursor;
131
132     SUPERVGUI_Main*        main;  // active main    
133     QPtrList<SUPERVGUI_Main> myGraphList;
134 };
135
136
137 // Acces a l'instance unique de la classe du module de l'interface graphique de la supervision
138 // -------------------------------------------------------------------------------------------
139 extern SUPERVGUI Supervision;
140
141 #endif