Salome HOME
d5239a90f03a2c13556e2403d5c60af2016b20e9
[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 _PTR(SObject)& 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     QMap<QString, QString> getInterfaceNameMap() const;
112
113     /*!
114      * \brief The method nullify myInitalViewFrame variable
115      * to avoid using this view frame once more, it is using
116      * after add any node into first new dataflow in study.
117      */
118     void nullifyInitialVF() { if ( myInitialViewFrame ) myInitialViewFrame = 0; }
119
120   signals:
121     void KillMainThread(bool theValue);
122
123   private slots:
124     void setMain(SUIT_ViewWindow* w);
125     void displayDataflow();
126     void renameDataflow();
127     void deleteObject();
128     void onGraphClosed( SUIT_ViewWindow* );
129     void OnGUIEvent();
130
131   public slots:
132     virtual bool           activateModule( SUIT_Study* );
133     virtual bool           deactivateModule( SUIT_Study* );
134       
135   protected:
136     virtual CAM_DataModel* createDataModel();
137     virtual SalomeApp_Selection* createSelection() const;
138
139   private:
140     void loadEngine(SALOME_NamingService* namingService);
141
142     // enumeration used in newDataflow() method
143     enum NEW_DF_MODE { Import, Modify, New }; 
144     // method called from importDataflow(), modifyDataflow(), newDataflow() with
145     // different modes.  The behavior of the function is very similar in all 3 cases, 
146     // but some differences still exist.  These differences are implemented using NEW_DF_MODE param.
147     bool createDataflow( const NEW_DF_MODE f, bool theInitialDF = false );  
148
149     void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""), 
150                              const int key = 0, const bool toggle = false );
151
152     void fillInterfaceNameMap();
153
154     static int             factory;
155     SUIT_Study*            study;
156     SUPERV_Engine          engine;
157     SUPERVGUI_Service*     browser;
158     //SUPERVGUI_Information* info;
159     QCursor                cursor;
160
161     SUPERVGUI_Main*        main;  // active main    
162     QPtrList<SUPERVGUI_Main> myGraphList;
163     QMap<QString, QString> myInterfaceNameMap;
164
165     bool                   myFirstActivation;
166     bool                   myAllGraphsClosed;
167     SUPERVGraph_ViewFrame* myInitialViewFrame;
168 };
169
170 #endif