]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Application.h
Salome HOME
Add method updateObjectBrowser() for the SalomeApp_Application
[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, LoadScriptId,
56          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   SalomeApp_SelectionMgr*             selectionMgr() const;
69
70   LogWindow*                          logWindow();
71   OB_Browser*                         objectBrowser();
72   PythonConsole*                      pythonConsole();   
73
74   virtual void                        updateObjectBrowser( const bool = true );
75
76   SalomeApp_Preferences*              preferences() const;
77
78   virtual QString                     getFileFilter() const;
79   virtual QString                     getFileName( bool open, const QString& initial, const QString& filters, 
80                                                    const QString& caption, QWidget* parent );
81   QString                             getDirectory( const QString& initial, const QString& caption, QWidget* parent );
82
83   SUIT_ViewManager*                   getViewManager( const QString&, const bool );
84
85   void                                updateActions();
86
87   QWidget*                            getWindow( const int, const int = -1 );
88
89   QWidget*                            window( const int, const int = -1 ) const;
90   void                                addWindow( QWidget*, const int, const int = -1 );
91   void                                removeWindow( const int, const int = -1 );
92
93   bool                                isWindowVisible( const int ) const;
94   void                                setWindowShown( const int, const bool );
95
96   virtual void                        start();
97
98   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
99
100   static CORBA::ORB_var               orb();
101   static SALOMEDSClient_StudyManager* studyMgr();
102   static SALOME_NamingService*        namingService();
103   static SALOME_LifeCycleCORBA*       lcc();
104   static QString                      defaultEngineIOR();
105
106 signals:
107   void                                studyOpened();
108   void                                studySaved();
109   void                                studyClosed();
110
111 public slots:
112   virtual void                        onNewDoc();
113   virtual void                        onOpenDoc();
114   virtual void                        onHelpAbout();
115   virtual bool                        onOpenDoc( const QString& );
116
117 private slots:
118   void                                onSelection();
119   void                                onRefresh();
120
121 protected:
122   virtual void                        createActions();
123   virtual SUIT_Study*                 createNewStudy();
124   virtual QWidget*                    createWindow( const int );
125   virtual void                        defaultWindows( QMap<int, int>& ) const;
126   virtual void                        defaultViewManagers( QStringList& ) const;
127
128   virtual void                        setActiveStudy( SUIT_Study* );
129
130   virtual void                        updateCommandsStatus();
131
132   virtual void                        onSelectionChanged();
133
134   virtual void                        beforeCloseDoc( SUIT_Study* );
135   virtual void                        afterCloseDoc();
136
137   virtual void                        moduleAdded( CAM_Module* );
138
139   SalomeApp_Preferences*              preferences( const bool ) const;
140
141   virtual void                        createPreferences( SalomeApp_Preferences* );
142   virtual void                        preferencesChanged( const QString&, const QString& );
143
144 private slots:
145   void                                onNewWindow();
146   void                                onModuleActivation( QAction* );
147   void                                onCloseView( SUIT_ViewManager* );
148
149   void                                onStudyCreated( SUIT_Study* );
150   void                                onStudyOpened( SUIT_Study* );
151   void                                onStudySaved( SUIT_Study* );
152   void                                onStudyClosed( SUIT_Study* );
153   
154   void                                onProperties();
155   void                                onLoadScript(); 
156
157   void                                onPreferences();
158   void                                onMRUActivated( QString );
159
160   void                                onPreferenceChanged( QString&, QString&, QString& );
161
162 private:
163   void                                updateWindows();
164   void                                updateViewManagers();
165   void                                updateModuleActions();
166
167   void                                loadWindowsGeometry();
168   void                                saveWindowsGeometry();
169
170   void                                updatePreference( const QString&, const QString&, const QString& );
171
172   QString                             defaultModule() const;
173   void                                currentWindows( QMap<int, int>& ) const;
174   void                                currentViewManagers( QStringList& ) const;
175   SUIT_ViewManager*                   createViewManager( const QString& vmType );
176   void                                moduleIconNames( QMap<QString, QString>& ) const;
177
178   void                                activateWindows();
179
180 private:
181   typedef QMap<QString, QAction*>               ActionMap;
182   typedef QMap<int, SalomeApp_WidgetContainer*> WindowMap;
183
184 private:
185   SalomeApp_Preferences*              myPrefs;
186   SalomeApp_SelectionMgr*             mySelMgr;
187   ActionMap                           myActions;
188   WindowMap                           myWindows;
189
190   static SalomeApp_Preferences*       _prefs_;
191 };
192
193 #ifdef WIN32
194 #pragma warning( default:4251 )
195 #endif
196
197 #endif