Salome HOME
d35d4ac1b1af337533619679416c9106362e83bf
[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 "SUPERVGUI_Def.h"
35 #include "SUPERVGUI_Service.h"
36 #include "SUPERVGUI_Main.h"
37
38 #include "SalomeApp_Module.h"
39
40 class SUIT_Study;
41
42 // Definition de la classe principale du module de supervision
43 // -----------------------------------------------------------
44
45 class SUPERVGUI: public SalomeApp_Module {
46   Q_OBJECT
47
48   public:
49     SUPERVGUI();
50     virtual ~SUPERVGUI();
51
52     static SUPERVGUI*  Supervision();
53
54     virtual void       initialize( CAM_Application* );
55     virtual QString    engineIOR() const;
56     SUPERV_Engine      getEngine();
57     SUIT_Study*        getActiveStudy() { 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     SUPERVGUI_Main* getMain();
76
77     bool OnGUIEvent(int theCommandID);
78     //bool SetSettings();
79     //void DefinePopup(QString & theContext,
80     //                 QString & theParent, 
81     //                 QString & theObject ) ;
82     //bool CustomPopup(QPopupMenu* popup,
83     //                 const QString & theContext,
84     //                 const QString & theParent,
85     //                 const QString & theObject);
86     bool ActiveStudyChanged();
87     //void SupportedViewType (int* buffer, int bufferSize);
88
89     bool isContains(SUIT_Study* theStudy, const QString theKey);
90
91     void registerGraph(QString theName, SUPERVGUI_Main* theGraph);
92     void unregisterGraph(SUPERVGUI_Main* theGraph);
93     SUIT_ViewWindow* createGraph();
94
95     /** Returns:
96         theIsOwner = true if Selected object belongs to Suipervision.
97         theIsDataflow = true if Selected object is Dataflow
98     */
99     void whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow);
100
101     /* asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, 
102        a backup copy of an existing file must be created (in case Export fails..)
103        This method creates a backup file and returns its name or QString::null if it fails
104        Function is static because it is called from 
105        SUPERVGUI::exportDataflow() and SUPERVGUI_CanvasMacroNode::exportDataflow()    
106     */
107     static QString createBackupFile( const QString& theOriginalFileName );
108
109     virtual void windows( QMap<int, int>& ) const;
110
111   signals:
112     void KillMainThread(bool theValue);
113
114   private slots:
115     void setMain(SUIT_ViewWindow* w);
116     void displayDataflow();
117     void renameDataflow();
118     void deleteObject();
119     void onGraphClosed( SUIT_ViewWindow* );
120     void OnGUIEvent();
121
122   public slots:
123     virtual void           activateModule( SUIT_Study* );
124     virtual void           deactivateModule( SUIT_Study* );
125       
126   protected:
127     virtual CAM_DataModel* createDataModel();
128
129   private:
130     void loadEngine(SALOME_NamingService* namingService);
131
132     // enumeration used in newDataflow() method
133     enum NEW_DF_MODE { Import, Modify, New }; 
134     // method called from importDataflow(), modifyDataflow(), newDataflow() with
135     // different modes.  The behavior of the function is very similar in all 3 cases, 
136     // but some differences still exist.  These differences are implemented using NEW_DF_MODE param.
137     bool createDataflow( const NEW_DF_MODE f );  
138
139     void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""), 
140                              const int key = 0, const bool toggle = false );
141
142     static int             factory;
143     SUIT_Study*            study;
144     SUPERV_Engine          engine;
145     SUPERVGUI_Service*     browser;
146     //SUPERVGUI_Information* info;
147     QCursor                cursor;
148
149     SUPERVGUI_Main*        main;  // active main    
150     QPtrList<SUPERVGUI_Main> myGraphList;
151 };
152
153 #endif