Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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                        addViewManager( SUIT_ViewManager* );
112   virtual void                        removeViewManager( SUIT_ViewManager* );
113   QWidget*                            getWindow( const int, const int = -1 );
114   QWidget*                            window( const int, const int = -1 ) const;
115   void                                addWindow( QWidget*, const int, const int = -1 );
116   void                                removeWindow( const int, const int = -1 );
117
118   bool                                isWindowVisible( const int ) const;
119   void                                setWindowShown( const int, const bool );
120
121   virtual void                        start();
122
123   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
124
125   virtual void                        createEmptyStudy();
126
127   SUIT_Accel*                         accel() const;
128
129   void                                setDefaultStudyName( const QString& theName );
130
131   static int                          studyId();
132
133   virtual bool                        event( QEvent* );
134
135 signals:
136   void                                studyOpened();
137   void                                studySaved();
138   void                                studyClosed();
139
140 public slots:
141   virtual void                        onHelpContentsModule();
142   virtual void                        onHelpContextModule( const QString&, const QString& );
143   virtual void                        onNewDoc();
144   virtual void                        onOpenDoc();
145   virtual void                        onHelpAbout();
146   virtual bool                        onOpenDoc( const QString& );
147   virtual bool                        onLoadDoc( const QString& );
148
149 protected:
150   virtual void                        createActions();
151   virtual void                        createActionForViewer( const int id,
152                                                              const int parentId,
153                                                              const QString& suffix,
154                                                              const int accel );
155   virtual SUIT_Study*                 createNewStudy();
156   virtual QWidget*                    createWindow( const int );
157   virtual void                        defaultWindows( QMap<int, int>& ) const;
158   void                                defaultViewManagers( QStringList& ) const;
159
160   virtual void                        setActiveStudy( SUIT_Study* );
161   virtual void                        updateCommandsStatus();
162   virtual void                        onSelectionChanged();
163
164   virtual void                        beforeCloseDoc( SUIT_Study* );
165   virtual void                        afterCloseDoc();
166   virtual void                        moduleAdded( CAM_Module* );
167   virtual bool                        activateModule( CAM_Module* = 0 );
168
169   LightApp_Preferences*               preferences( const bool ) const;
170   virtual void                        createPreferences( LightApp_Preferences* );
171   virtual void                        preferencesChanged( const QString&, const QString& );
172   virtual void                        savePreferences();
173   virtual void                        updateDesktopTitle();
174
175 protected slots:
176   virtual void                        onDesktopActivated();
177
178   void                                onNewWindow();
179   void                                onModuleActivation( QAction* );
180   void                                onCloseView( SUIT_ViewManager* );
181
182   void                                onStudyCreated( SUIT_Study* );
183   void                                onStudyOpened( SUIT_Study* );
184   void                                onStudySaved( SUIT_Study* );
185   void                                onStudyClosed( SUIT_Study* );
186
187   void                                onWCDestroyed( QObject* );
188
189 private slots:
190   void                                onSelection();
191   void                                onRefresh();
192   void                                onPreferences();
193   void                                onMRUActivated( QString );
194   void                                onPreferenceChanged( QString&, QString&, QString& );
195   void                                onRenameWindow();
196   void                                onVisibilityChanged( bool );
197
198 protected:
199   void                                updateWindows();
200   void                                updateViewManagers();
201   void                                updateModuleActions();
202
203   void                                loadWindowsGeometry();
204   void                                saveWindowsGeometry();
205
206   void                                updatePreference( const QString&, const QString&, const QString& );
207
208   QString                             defaultModule() const;
209   void                                currentWindows( QMap<int, int>& ) const;
210   void                                currentViewManagers( QStringList& ) const;
211   virtual SUIT_ViewManager*           createViewManager( const QString& vmType );
212   void                                moduleIconNames( QMap<QString, QString>& ) const;
213
214   void                                activateWindows();
215   bool                                isLibExists( const QString& ) const;
216
217 protected:
218   typedef QMap<QString, QAction*>              ActionMap;
219   typedef QMap<int, LightApp_WidgetContainer*> WindowMap;
220   typedef QMap<int, bool>                      WindowVisibilityMap;
221
222 protected:
223   LightApp_Preferences*               myPrefs;
224   LightApp_SelectionMgr*              mySelMgr;
225   ActionMap                           myActions;
226   WindowMap                           myWindows;
227   WindowVisibilityMap                 myWindowsVisible;
228
229   SUIT_Accel*                         myAccel;
230
231   static LightApp_Preferences*        _prefs_;
232
233   static int                          lastStudyId;
234 };
235
236 #ifdef WIN32
237 #pragma warning( default:4251 )
238 #endif
239
240 #endif