]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Application.h
Salome HOME
New Help for KERNEL & GUI.
[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 void                        onHelpContentsModule();
125   virtual bool                        onOpenDoc( const QString& );
126   virtual void                        onLoadDoc();
127   virtual bool                        onLoadDoc( const QString& );
128   virtual void                        onCopy();
129   virtual void                        onPaste();  
130   
131 private slots:
132   void                                onSelection();
133   void                                onRefresh();
134   void                                onDeleteReferences();
135
136 protected:
137   virtual void                        createActions();
138   virtual SUIT_Study*                 createNewStudy();
139   virtual QWidget*                    createWindow( const int );
140   virtual void                        defaultWindows( QMap<int, int>& ) const;
141   virtual void                        defaultViewManagers( QStringList& ) const;
142
143   virtual void                        setActiveStudy( SUIT_Study* );
144
145   virtual void                        updateCommandsStatus();
146
147   virtual void                        onSelectionChanged();
148
149   virtual void                        beforeCloseDoc( SUIT_Study* );
150   virtual void                        afterCloseDoc();
151
152   virtual void                        moduleAdded( CAM_Module* );
153   virtual bool                        activateModule( CAM_Module* = 0 );
154
155   SalomeApp_Preferences*              preferences( const bool ) const;
156
157   virtual void                        createPreferences( SalomeApp_Preferences* );
158   virtual void                        preferencesChanged( const QString&, const QString& );
159   virtual void                        updateDesktopTitle();
160
161 protected slots:
162   virtual void                        onDesktopActivated();
163
164 private slots:
165   void                                onNewWindow();
166   void                                onModuleActivation( QAction* );
167   void                                onCloseView( SUIT_ViewManager* );
168
169   void                                onStudyCreated( SUIT_Study* );
170   void                                onStudyOpened( SUIT_Study* );
171   void                                onStudySaved( SUIT_Study* );
172   void                                onStudyClosed( SUIT_Study* );
173   
174   void                                onProperties();
175   void                                onDumpStudy();
176   void                                onLoadScript(); 
177
178   void                                onPreferences();
179   void                                onMRUActivated( QString );
180
181   void                                onCatalogGen();
182   void                                onRegDisplay();
183
184   void                                onPreferenceChanged( QString&, QString&, QString& );
185   void                                onOpenWith();
186
187 private:
188   void                                updateWindows();
189   void                                updateViewManagers();
190   void                                updateModuleActions();
191
192   void                                loadWindowsGeometry();
193   void                                saveWindowsGeometry();
194
195   void                                updatePreference( const QString&, const QString&, const QString& );
196
197   QString                             defaultModule() const;
198   void                                currentWindows( QMap<int, int>& ) const;
199   void                                currentViewManagers( QStringList& ) const;
200   SUIT_ViewManager*                   createViewManager( const QString& vmType );
201   void                                moduleIconNames( QMap<QString, QString>& ) const;
202
203   void                                activateWindows();
204
205 private:
206   typedef QMap<QString, QAction*>               ActionMap;
207   typedef QMap<int, SalomeApp_WidgetContainer*> WindowMap;
208
209 private:
210   SalomeApp_Preferences*              myPrefs;
211   SalomeApp_SelectionMgr*             mySelMgr;
212   ActionMap                           myActions;
213   WindowMap                           myWindows;
214
215   SUIT_Accel*                         myAccel;
216
217   static SalomeApp_Preferences*       _prefs_;
218 };
219
220 #ifdef WIN32
221 #pragma warning( default:4251 )
222 #endif
223
224 #endif