Salome HOME
Join modifications from branch BR_3_1_0deb
[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     // mkr : IPAL10825
122     QColor getIVFBackgroundColor() { return myIVFBackgroundColor; }
123     void   setIVFBackgroundColor( QColor theColor ) { if ( myInitialViewFrame ) myIVFBackgroundColor = theColor; }
124
125   signals:
126     void KillMainThread(bool theValue);
127
128   private slots:
129     void setMain(SUIT_ViewWindow* w);
130     void displayDataflow();
131     void renameDataflow();
132     void deleteObject();
133     void onGraphClosed( SUIT_ViewWindow* );
134     void OnGUIEvent();
135
136   public slots:
137     virtual bool           activateModule( SUIT_Study* );
138     virtual bool           deactivateModule( SUIT_Study* );
139       
140   protected:
141     virtual CAM_DataModel* createDataModel();
142     virtual LightApp_Selection* createSelection() const;
143
144   private:
145     void loadEngine(SALOME_NamingService* namingService);
146
147     // enumeration used in newDataflow() method
148     enum NEW_DF_MODE { Import, Modify, New }; 
149     // method called from importDataflow(), modifyDataflow(), newDataflow() with
150     // different modes.  The behavior of the function is very similar in all 3 cases, 
151     // but some differences still exist.  These differences are implemented using NEW_DF_MODE param.
152     bool createDataflow( const NEW_DF_MODE f, bool theInitialDF = false );  
153
154     void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""), 
155                              const int key = 0, const bool toggle = false );
156
157     void fillInterfaceNameMap();
158
159     static int             factory;
160     SUIT_Study*            study;
161     SUPERV_Engine          engine;
162     SUPERVGUI_Service*     browser;
163     //SUPERVGUI_Information* info;
164     QCursor                cursor;
165
166     SUPERVGUI_Main*        main;  // active main    
167     QPtrList<SUPERVGUI_Main> myGraphList;
168     QMap<QString, QString> myInterfaceNameMap;
169
170     bool                   myFirstActivation;
171     bool                   myAllGraphsClosed;
172     SUPERVGraph_ViewFrame* myInitialViewFrame;
173     QColor                 myIVFBackgroundColor; // mkr : IPAL10825
174 };
175
176 #endif