Salome HOME
Color for background and title are taken from resource manager
[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 #include "SALOMEDSClient.hxx"
40
41 class SUIT_Study;
42
43 // Definition de la classe principale du module de supervision
44 // -----------------------------------------------------------
45
46 class SUPERVGUI: public SalomeApp_Module {
47   Q_OBJECT
48
49   public:
50     SUPERVGUI();
51     virtual ~SUPERVGUI();
52
53     static SUPERVGUI*  Supervision();
54
55     virtual void       initialize( CAM_Application* );
56     virtual QString    engineIOR() const;
57     SUPERV_Engine      getEngine();
58     SUIT_Study*        getActiveStudy() { return study; }
59
60     SUPERVGUI_Service* getBrowser();
61     QCursor            getCursor();
62     //bool information(SUPERV_CNode node, bool isReadOnly);
63     void putInfo(const char* mess);
64
65     void importDataflow();
66     void exportDataflow();
67     void newDataflow();
68     void modifyDataflow();
69     void reloadDataflow();
70     void runDataflow();
71     void stepByStep();
72     void killDataflow();
73     void suspendResumeDataflow();
74     void showComponents();
75
76     SUPERVGUI_Main* getMain();
77
78     bool OnGUIEvent(int theCommandID);
79     //bool SetSettings();
80     //void DefinePopup(QString & theContext,
81     //                 QString & theParent, 
82     //                 QString & theObject ) ;
83     //bool CustomPopup(QPopupMenu* popup,
84     //                 const QString & theContext,
85     //                 const QString & theParent,
86     //                 const QString & theObject);
87     bool ActiveStudyChanged();
88     //void SupportedViewType (int* buffer, int bufferSize);
89
90     bool isContains(SUIT_Study* theStudy, const QString theKey);
91
92     void registerGraph(QString theName, SUPERVGUI_Main* theGraph);
93     void unregisterGraph(SUPERVGUI_Main* theGraph);
94     SUIT_ViewWindow* createGraph();
95
96     /** Returns:
97         theIsOwner = true if Selected object belongs to Suipervision.
98         theIsDataflow = true if Selected object is Dataflow
99     */
100     void whatIsSelected(const _PTR(SObject)& theObj, bool& theIsOwner, bool& theIsDataflow);
101
102     /* asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, 
103        a backup copy of an existing file must be created (in case Export fails..)
104        This method creates a backup file and returns its name or QString::null if it fails
105        Function is static because it is called from 
106        SUPERVGUI::exportDataflow() and SUPERVGUI_CanvasMacroNode::exportDataflow()    
107     */
108     static QString createBackupFile( const QString& theOriginalFileName );
109
110     virtual void windows( QMap<int, int>& ) const;
111
112     QMap<QString, QString> getInterfaceNameMap() const;
113
114     /*!
115      * \brief The method nullify myInitalViewFrame variable
116      * to avoid using this view frame once more, it is using
117      * after add any node into first new dataflow in study.
118      */
119     void nullifyInitialVF() { if ( myInitialViewFrame ) myInitialViewFrame = 0; }
120
121   signals:
122     void KillMainThread(bool theValue);
123
124   private slots:
125     void setMain(SUIT_ViewWindow* w);
126     void displayDataflow();
127     void renameDataflow();
128     void deleteObject();
129     void onGraphClosed( SUIT_ViewWindow* );
130     void OnGUIEvent();
131
132   public slots:
133     virtual bool           activateModule( SUIT_Study* );
134     virtual bool           deactivateModule( SUIT_Study* );
135       
136   protected:
137     virtual CAM_DataModel* createDataModel();
138     virtual LightApp_Selection* createSelection() const;
139
140   private:
141     void loadEngine(SALOME_NamingService* namingService);
142
143     // enumeration used in newDataflow() method
144     enum NEW_DF_MODE { Import, Modify, New }; 
145     // method called from importDataflow(), modifyDataflow(), newDataflow() with
146     // different modes.  The behavior of the function is very similar in all 3 cases, 
147     // but some differences still exist.  These differences are implemented using NEW_DF_MODE param.
148     bool createDataflow( const NEW_DF_MODE f, bool theInitialDF = false );  
149
150     void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""), 
151                              const int key = 0, const bool toggle = false );
152
153     void fillInterfaceNameMap();
154
155     static int             factory;
156     SUIT_Study*            study;
157     SUPERV_Engine          engine;
158     SUPERVGUI_Service*     browser;
159     //SUPERVGUI_Information* info;
160     QCursor                cursor;
161
162     SUPERVGUI_Main*        main;  // active main    
163     QPtrList<SUPERVGUI_Main> myGraphList;
164     QMap<QString, QString> myInterfaceNameMap;
165
166     bool                   myFirstActivation;
167     bool                   myAllGraphsClosed;
168     SUPERVGraph_ViewFrame* myInitialViewFrame;
169 };
170
171 #endif