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