Salome HOME
c435188a4b185f3bc92f5b2c0cc97296884e744c
[modules/gui.git] / src / LightApp / LightApp_Application.h
1 // File:      LightApp_Application.h
2 // Created:   6/20/2005 18:39:25 PM
3 // Author:    OCC team
4 // Copyright (C) CEA 2005
5
6 #ifndef LIGHTAPP_APPLICATION_H
7 #define LIGHTAPP_APPLICATION_H
8
9 #if _MSC_VER > 1000
10 #pragma once
11 #endif // _MSC_VER > 1000
12
13 #include "LightApp.h"
14 #include <CAM_Application.h>
15
16 class LogWindow;
17 class OB_Browser;
18 #ifndef DISABLE_PYCONSOLE
19   class PythonConsole;
20 #endif
21 class STD_Application;
22 class LightApp_WidgetContainer;
23 class LightApp_Preferences;
24 class LightApp_SelectionMgr;
25 class SUIT_Study;
26 class SUIT_Accel;
27 class CAM_Module;
28
29 class QString;
30 class QWidget;
31 class QStringList;
32 class QPixmap;
33
34 #ifdef WIN32
35 #pragma warning( disable:4251 )
36 #endif
37
38 /*!
39   Description : Application containing only LightApp module
40 */
41
42 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
43 {
44   Q_OBJECT
45
46 public:
47   typedef enum { WT_ObjectBrowser, 
48 #ifndef DISABLE_PYCONSOLE
49                  WT_PyConsole,
50 #endif
51                  WT_LogWindow,
52                  WT_User }
53   WindowTypes;
54
55   enum { MenuWindowId = 6 };
56
57   enum { RenameId = CAM_Application::UserID,
58
59 #ifndef DISABLE_GLVIEWER
60          NewGLViewId ,
61 #endif
62
63 #ifndef DISABLE_PLOT2DVIEWER
64          NewPlot2dId,
65 #endif
66
67 #ifndef DISABLE_OCCVIEWER
68          NewOCCViewId,
69 #endif
70
71 #ifndef DISABLE_VTKVIEWER
72          NewVTKViewId,
73 #endif
74
75          PreferencesId, MRUId, UserID };
76 public:
77   LightApp_Application();
78   virtual ~LightApp_Application();
79
80   virtual QString                     applicationName() const;
81   virtual QString                     applicationVersion() const;
82
83   virtual CAM_Module*                 loadModule( const QString& );
84   virtual bool                        activateModule( const QString& );
85
86   virtual bool                        useStudy( const QString& );
87
88   LightApp_SelectionMgr*              selectionMgr() const;
89   
90   LogWindow*                          logWindow();
91   OB_Browser*                         objectBrowser();
92 #ifndef DISABLE_PYCONSOLE
93   PythonConsole*                      pythonConsole(); 
94 #endif
95
96   virtual void                        updateObjectBrowser( const bool = true );
97
98   LightApp_Preferences*               preferences() const;
99
100   virtual QString                     getFileFilter() const;
101
102   virtual QString                     getFileName( bool open, const QString& initial, const QString& filters, 
103                                                    const QString& caption, QWidget* parent );
104   virtual QString                     getDirectory( const QString& initial, const QString& caption, QWidget* parent );
105   virtual QStringList                 getOpenFileNames( const QString& initial, const QString& filters, 
106                                                         const QString& caption, QWidget* parent );
107
108   void                                updateActions();
109
110   SUIT_ViewManager*                   getViewManager( const QString&, const bool );
111   virtual void                        removeViewManager( SUIT_ViewManager* );
112   QWidget*                            getWindow( const int, const int = -1 );
113   QWidget*                            window( const int, const int = -1 ) const;
114   void                                addWindow( QWidget*, const int, const int = -1 );
115   void                                removeWindow( const int, const int = -1 );
116
117   bool                                isWindowVisible( const int ) const;
118   void                                setWindowShown( const int, const bool );
119
120   virtual void                        start();
121
122   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
123
124   virtual void                        createEmptyStudy();
125
126   SUIT_Accel*                         accel() const;
127
128   void                                setDefaultStudyName( const QString& theName );
129
130   static int                          studyId();
131
132 signals:
133   void                                studyOpened();
134   void                                studySaved();
135   void                                studyClosed();
136
137 public slots:
138   virtual void                        onHelpContentsModule();
139   virtual void                        onNewDoc();
140   virtual void                        onOpenDoc();
141   virtual void                        onHelpAbout();
142   virtual bool                        onOpenDoc( const QString& );
143   virtual bool                        onLoadDoc( const QString& );
144
145 protected:
146   virtual void                        createActions();
147   virtual void                        createActionForViewer( const int id,
148                                                              const int parentId,
149                                                              const QString& suffix,
150                                                              const int accel );
151   virtual SUIT_Study*                 createNewStudy();
152   virtual QWidget*                    createWindow( const int );
153   virtual void                        defaultWindows( QMap<int, int>& ) const;
154   void                                defaultViewManagers( QStringList& ) const;
155
156   virtual void                        setActiveStudy( SUIT_Study* );
157   virtual void                        updateCommandsStatus();
158   virtual void                        onSelectionChanged();
159
160   virtual void                        beforeCloseDoc( SUIT_Study* );
161   virtual void                        afterCloseDoc();
162   virtual void                        moduleAdded( CAM_Module* );
163   virtual bool                        activateModule( CAM_Module* = 0 );
164
165   LightApp_Preferences*               preferences( const bool ) const;
166   virtual void                        createPreferences( LightApp_Preferences* );
167   virtual void                        preferencesChanged( const QString&, const QString& );
168   virtual void                        savePreferences();
169   virtual void                        updateDesktopTitle();
170
171 protected slots:
172   virtual void                        onDesktopActivated();
173
174   void                                onNewWindow();
175   void                                onModuleActivation( QAction* );
176   void                                onCloseView( SUIT_ViewManager* );
177
178   void                                onStudyCreated( SUIT_Study* );
179   void                                onStudyOpened( SUIT_Study* );
180   void                                onStudySaved( SUIT_Study* );
181   void                                onStudyClosed( SUIT_Study* );
182
183   void                                onWCDestroyed( QObject* );
184
185 private slots:
186   void                                onSelection();
187   void                                onRefresh();
188   void                                onPreferences();
189   void                                onMRUActivated( QString );
190   void                                onPreferenceChanged( QString&, QString&, QString& );
191   void                                onRenameWindow();
192
193 protected:
194   void                                updateWindows();
195   void                                updateViewManagers();
196   void                                updateModuleActions();
197
198   void                                loadWindowsGeometry();
199   void                                saveWindowsGeometry();
200
201   void                                updatePreference( const QString&, const QString&, const QString& );
202
203   QString                             defaultModule() const;
204   void                                currentWindows( QMap<int, int>& ) const;
205   void                                currentViewManagers( QStringList& ) const;
206   virtual SUIT_ViewManager*           createViewManager( const QString& vmType );
207   void                                moduleIconNames( QMap<QString, QString>& ) const;
208
209   void                                activateWindows();
210   bool                                isLibExists( const QString& ) const;
211
212 protected:
213   typedef QMap<QString, QAction*>              ActionMap;
214   typedef QMap<int, LightApp_WidgetContainer*> WindowMap;
215
216 protected:
217   LightApp_Preferences*               myPrefs;
218   LightApp_SelectionMgr*              mySelMgr;
219   ActionMap                           myActions;
220   WindowMap                           myWindows;
221
222   SUIT_Accel*                         myAccel;
223
224   static LightApp_Preferences*        _prefs_;
225
226   static int                          lastStudyId;
227 };
228
229 #ifdef WIN32
230 #pragma warning( default:4251 )
231 #endif
232
233 #endif