]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Application.h
Salome HOME
Remove obsolete code
[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   static CORBA::ORB_var               orb();
105   static SALOMEDSClient_StudyManager* studyMgr();
106   static SALOME_NamingService*        namingService();
107   static SALOME_LifeCycleCORBA*       lcc();
108   static QString                      defaultEngineIOR();
109
110 signals:
111   void                                studyOpened();
112   void                                studySaved();
113   void                                studyClosed();
114
115 public slots:
116   virtual void                        onNewDoc();
117   virtual void                        onOpenDoc();
118   virtual void                        onHelpAbout();
119   virtual bool                        onOpenDoc( const QString& );
120   virtual bool                        onLoadDoc( const QString& );
121   virtual void                        onCopy();
122   virtual void                        onPaste();  
123
124 private slots:
125   void                                onSelection();
126   void                                onRefresh();
127
128 protected:
129   virtual void                        createActions();
130   virtual SUIT_Study*                 createNewStudy();
131   virtual QWidget*                    createWindow( const int );
132   virtual void                        defaultWindows( QMap<int, int>& ) const;
133   virtual void                        defaultViewManagers( QStringList& ) const;
134
135   virtual void                        setActiveStudy( SUIT_Study* );
136
137   virtual void                        updateCommandsStatus();
138
139   virtual void                        onSelectionChanged();
140
141   virtual void                        beforeCloseDoc( SUIT_Study* );
142   virtual void                        afterCloseDoc();
143
144   virtual void                        moduleAdded( CAM_Module* );
145
146   SalomeApp_Preferences*              preferences( const bool ) const;
147
148   virtual void                        createPreferences( SalomeApp_Preferences* );
149   virtual void                        preferencesChanged( const QString&, const QString& );
150
151 private slots:
152   void                                onNewWindow();
153   void                                onModuleActivation( QAction* );
154   void                                onCloseView( SUIT_ViewManager* );
155
156   void                                onStudyCreated( SUIT_Study* );
157   void                                onStudyOpened( SUIT_Study* );
158   void                                onStudySaved( SUIT_Study* );
159   void                                onStudyClosed( SUIT_Study* );
160   
161   void                                onProperties();
162   void                                onDumpStudy();
163   void                                onLoadScript(); 
164
165   void                                onPreferences();
166   void                                onMRUActivated( QString );
167
168   void                                onPreferenceChanged( QString&, QString&, QString& );
169   void                                onOpenWith();
170
171 private:
172   void                                updateWindows();
173   void                                updateViewManagers();
174   void                                updateModuleActions();
175
176   void                                loadWindowsGeometry();
177   void                                saveWindowsGeometry();
178
179   void                                updatePreference( const QString&, const QString&, const QString& );
180
181   QString                             defaultModule() const;
182   void                                currentWindows( QMap<int, int>& ) const;
183   void                                currentViewManagers( QStringList& ) const;
184   SUIT_ViewManager*                   createViewManager( const QString& vmType );
185   void                                moduleIconNames( QMap<QString, QString>& ) const;
186
187   void                                activateWindows();
188
189 private:
190   typedef QMap<QString, QAction*>               ActionMap;
191   typedef QMap<int, SalomeApp_WidgetContainer*> WindowMap;
192
193 private:
194   SalomeApp_Preferences*              myPrefs;
195   SalomeApp_SelectionMgr*             mySelMgr;
196   ActionMap                           myActions;
197   WindowMap                           myWindows;
198
199   static SalomeApp_Preferences*       _prefs_;
200 };
201
202 #ifdef WIN32
203 #pragma warning( default:4251 )
204 #endif
205
206 #endif