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