Salome HOME
Fix for bug IPAL9214 : 3.0.0(/dn06/../current1506): dataflow object has no "Rename...
[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   signals:
114     void KillMainThread(bool theValue);
115
116   private slots:
117     void setMain(SUIT_ViewWindow* w);
118     void displayDataflow();
119     void renameDataflow();
120     void deleteObject();
121     void onGraphClosed( SUIT_ViewWindow* );
122     void OnGUIEvent();
123
124   public slots:
125     virtual bool           activateModule( SUIT_Study* );
126     virtual bool           deactivateModule( SUIT_Study* );
127       
128   protected:
129     virtual CAM_DataModel* createDataModel();
130     virtual SalomeApp_Selection* createSelection() const;
131
132   private:
133     void loadEngine(SALOME_NamingService* namingService);
134
135     // enumeration used in newDataflow() method
136     enum NEW_DF_MODE { Import, Modify, New }; 
137     // method called from importDataflow(), modifyDataflow(), newDataflow() with
138     // different modes.  The behavior of the function is very similar in all 3 cases, 
139     // but some differences still exist.  These differences are implemented using NEW_DF_MODE param.
140     bool createDataflow( const NEW_DF_MODE f );  
141
142     void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""), 
143                              const int key = 0, const bool toggle = false );
144
145     void fillInterfaceNameMap();
146
147     static int             factory;
148     SUIT_Study*            study;
149     SUPERV_Engine          engine;
150     SUPERVGUI_Service*     browser;
151     //SUPERVGUI_Information* info;
152     QCursor                cursor;
153
154     SUPERVGUI_Main*        main;  // active main    
155     QPtrList<SUPERVGUI_Main> myGraphList;
156     QMap<QString, QString> myInterfaceNameMap;
157 };
158
159 #endif