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