]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Application.h
Salome HOME
debug IPAL9411: redefine virtual methods createEmptyStudy and activateModule
[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   Class       : SalomeApp_Application
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, 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                                onPreferenceChanged( QString&, QString&, QString& );
177   void                                onOpenWith();
178
179 private:
180   void                                updateWindows();
181   void                                updateViewManagers();
182   void                                updateModuleActions();
183
184   void                                loadWindowsGeometry();
185   void                                saveWindowsGeometry();
186
187   void                                updatePreference( const QString&, const QString&, const QString& );
188
189   QString                             defaultModule() const;
190   void                                currentWindows( QMap<int, int>& ) const;
191   void                                currentViewManagers( QStringList& ) const;
192   SUIT_ViewManager*                   createViewManager( const QString& vmType );
193   void                                moduleIconNames( QMap<QString, QString>& ) const;
194
195   void                                activateWindows();
196
197 private:
198   typedef QMap<QString, QAction*>               ActionMap;
199   typedef QMap<int, SalomeApp_WidgetContainer*> WindowMap;
200
201 private:
202   SalomeApp_Preferences*              myPrefs;
203   SalomeApp_SelectionMgr*             mySelMgr;
204   ActionMap                           myActions;
205   WindowMap                           myWindows;
206
207   static SalomeApp_Preferences*       _prefs_;
208 };
209
210 #ifdef WIN32
211 #pragma warning( default:4251 )
212 #endif
213
214 #endif