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