Salome HOME
Fix for problem: broken reference objects after delete originals.
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.h
1 // File:      SalomeApp_Application.h
2 // Created:   10/22/2004 3:37:25 PM
3 // Author:    Sergey LITONIN
4 // Copyright (C) CEA 2004
5
6 #ifndef SALOMEAPP_APPLICATION_H
7 #define SALOMEAPP_APPLICATION_H
8
9 #if _MSC_VER > 1000
10 #pragma once
11 #endif // _MSC_VER > 1000
12
13 #include "SalomeApp.h"
14 #include <CAM_Application.h>
15
16 #include <CORBA.h>
17
18 #include <SALOMEconfig.h>
19 //#include CORBA_CLIENT_HEADER(SALOMEDS)
20 #include <SALOME_NamingService.hxx>
21
22 #include "SALOMEDSClient.hxx"
23
24 class QAction;
25 class QComboBox;
26 class QDockWindow;
27
28 class LogWindow;
29 class OB_Browser;
30 class PythonConsole;
31 class SalomeApp_Module;
32 class SalomeApp_Preferences;
33 class SalomeApp_SelectionMgr;
34 class SalomeApp_WidgetContainer;
35 class SUIT_Accel;
36
37 class SALOME_LifeCycleCORBA;
38
39 #ifdef WIN32
40 #pragma warning( disable:4251 )
41 #endif
42
43 /*!
44   Description : Application containing SalomeApp module
45 */
46
47 class SALOMEAPP_EXPORT SalomeApp_Application : public CAM_Application
48 {
49   Q_OBJECT
50
51 public:
52   typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
53
54   enum { ModulesListId = STD_Application::UserID, NewGLViewId,
55          NewPlot2dId, NewOCCViewId, NewVTKViewId, DumpStudyId,
56          LoadScriptId, PropertiesId, PreferencesId, MRUId, 
57          CatalogGenId, RegDisplayId, UserID };
58
59 public:
60   SalomeApp_Application();
61   virtual ~SalomeApp_Application();
62   
63   virtual QString                     applicationName() const;
64   virtual QString                     applicationVersion() const;
65
66   virtual CAM_Module*                 loadModule( const QString& );
67   virtual bool                        activateModule( const QString& );
68   
69   virtual bool                        useStudy( const QString& );
70
71   SalomeApp_SelectionMgr*             selectionMgr() const;
72
73   LogWindow*                          logWindow();
74   OB_Browser*                         objectBrowser();
75   PythonConsole*                      pythonConsole();   
76
77   virtual void                        updateObjectBrowser( const bool = true );
78
79   SalomeApp_Preferences*              preferences() const;
80
81   virtual QString                     getFileFilter() const;
82   virtual QString                     getFileName( bool open, const QString& initial, const QString& filters, 
83                                                    const QString& caption, QWidget* parent );
84   virtual QString                     getDirectory( const QString& initial, const QString& caption, QWidget* parent );
85   virtual QStringList                 getOpenFileNames( const QString& initial, const QString& filters, 
86                                                         const QString& caption, QWidget* parent );
87
88   SUIT_ViewManager*                   getViewManager( const QString&, const bool );
89
90   void                                updateActions();
91
92   QWidget*                            getWindow( const int, const int = -1 );
93
94   QWidget*                            window( const int, const int = -1 ) const;
95   void                                addWindow( QWidget*, const int, const int = -1 );
96   void                                removeWindow( const int, const int = -1 );
97
98   bool                                isWindowVisible( const int ) const;
99   void                                setWindowShown( const int, const bool );
100
101   virtual void                        start();
102
103   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
104
105   virtual void                        createEmptyStudy();
106
107   SUIT_Accel*                         accel() const;
108
109   static CORBA::ORB_var               orb();
110   static SALOMEDSClient_StudyManager* studyMgr();
111   static SALOME_NamingService*        namingService();
112   static SALOME_LifeCycleCORBA*       lcc();
113   static QString                      defaultEngineIOR();
114
115 signals:
116   void                                studyOpened();
117   void                                studySaved();
118   void                                studyClosed();
119
120 public slots:
121   virtual void                        onNewDoc();
122   virtual void                        onOpenDoc();
123   virtual void                        onHelpAbout();
124   virtual bool                        onOpenDoc( const QString& );
125   virtual void                        onLoadDoc();
126   virtual bool                        onLoadDoc( const QString& );
127   virtual void                        onCopy();
128   virtual void                        onPaste();  
129   
130 private slots:
131   void                                onSelection();
132   void                                onRefresh();
133   void                                onDeleteReferences();
134
135 protected:
136   virtual void                        createActions();
137   virtual SUIT_Study*                 createNewStudy();
138   virtual QWidget*                    createWindow( const int );
139   virtual void                        defaultWindows( QMap<int, int>& ) const;
140   virtual void                        defaultViewManagers( QStringList& ) const;
141
142   virtual void                        setActiveStudy( SUIT_Study* );
143
144   virtual void                        updateCommandsStatus();
145
146   virtual void                        onSelectionChanged();
147
148   virtual void                        beforeCloseDoc( SUIT_Study* );
149   virtual void                        afterCloseDoc();
150
151   virtual void                        moduleAdded( CAM_Module* );
152   virtual bool                        activateModule( CAM_Module* = 0 );
153
154   SalomeApp_Preferences*              preferences( const bool ) const;
155
156   virtual void                        createPreferences( SalomeApp_Preferences* );
157   virtual void                        preferencesChanged( const QString&, const QString& );
158   virtual void                        updateDesktopTitle();
159
160 protected slots:
161   virtual void                        onDesktopActivated();
162
163 private slots:
164   void                                onNewWindow();
165   void                                onModuleActivation( QAction* );
166   void                                onCloseView( SUIT_ViewManager* );
167
168   void                                onStudyCreated( SUIT_Study* );
169   void                                onStudyOpened( SUIT_Study* );
170   void                                onStudySaved( SUIT_Study* );
171   void                                onStudyClosed( SUIT_Study* );
172   
173   void                                onProperties();
174   void                                onDumpStudy();
175   void                                onLoadScript(); 
176
177   void                                onPreferences();
178   void                                onMRUActivated( QString );
179
180   void                                onCatalogGen();
181   void                                onRegDisplay();
182
183   void                                onPreferenceChanged( QString&, QString&, QString& );
184   void                                onOpenWith();
185
186 private:
187   void                                updateWindows();
188   void                                updateViewManagers();
189   void                                updateModuleActions();
190
191   void                                loadWindowsGeometry();
192   void                                saveWindowsGeometry();
193
194   void                                updatePreference( const QString&, const QString&, const QString& );
195
196   QString                             defaultModule() const;
197   void                                currentWindows( QMap<int, int>& ) const;
198   void                                currentViewManagers( QStringList& ) const;
199   SUIT_ViewManager*                   createViewManager( const QString& vmType );
200   void                                moduleIconNames( QMap<QString, QString>& ) const;
201
202   void                                activateWindows();
203
204 private:
205   typedef QMap<QString, QAction*>               ActionMap;
206   typedef QMap<int, SalomeApp_WidgetContainer*> WindowMap;
207
208 private:
209   SalomeApp_Preferences*              myPrefs;
210   SalomeApp_SelectionMgr*             mySelMgr;
211   ActionMap                           myActions;
212   WindowMap                           myWindows;
213
214   SUIT_Accel*                         myAccel;
215
216   static SalomeApp_Preferences*       _prefs_;
217 };
218
219 #ifdef WIN32
220 #pragma warning( default:4251 )
221 #endif
222
223 #endif