Salome HOME
Has functionality from SalomeApp without dependency from CORBA
[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 class PythonConsole;
19 class STD_Application;
20 class LightApp_WidgetContainer;
21 class LightApp_Preferences;
22 class LightApp_SelectionMgr;
23 class SUIT_Study;
24 class SUIT_Accel;
25 class CAM_Module;
26
27 class QString;
28 class QWidget;
29 class QStringList;
30 class QPixmap;
31
32 #ifdef WIN32
33 #pragma warning( disable:4251 )
34 #endif
35
36 /*!
37   Description : Application containing only LightApp module
38 */
39
40 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
41 {
42   Q_OBJECT
43
44 public:
45   typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
46
47   enum { NewGLViewId = STD_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId,
48          PreferencesId, MRUId, UserID };
49 public:
50   LightApp_Application();
51   virtual ~LightApp_Application();
52
53   virtual QString                     applicationName() const;
54   virtual QString                     applicationVersion() const;
55
56   virtual CAM_Module*                 loadModule( const QString& );
57   virtual bool                        activateModule( const QString& );
58
59   virtual bool                        useStudy( const QString& );
60
61   LightApp_SelectionMgr*              selectionMgr() const;
62   
63   LogWindow*                          logWindow();
64   OB_Browser*                         objectBrowser();
65   PythonConsole*                      pythonConsole(); 
66
67   virtual void                        updateObjectBrowser( const bool = true );
68
69   LightApp_Preferences*               preferences() const;
70
71   virtual QString                     getFileFilter() const;
72
73   virtual QString                     getFileName( bool open, const QString& initial, const QString& filters, 
74                                                    const QString& caption, QWidget* parent );
75   virtual QString                     getDirectory( const QString& initial, const QString& caption, QWidget* parent );
76   virtual QStringList                 getOpenFileNames( const QString& initial, const QString& filters, 
77                                                         const QString& caption, QWidget* parent );
78
79   void                                updateActions();
80
81   SUIT_ViewManager*                   getViewManager( const QString&, const bool );
82   QWidget*                            getWindow( const int, const int = -1 );
83   QWidget*                            window( const int, const int = -1 ) const;
84   void                                addWindow( QWidget*, const int, const int = -1 );
85   void                                removeWindow( const int, const int = -1 );
86
87   bool                                isWindowVisible( const int ) const;
88   void                                setWindowShown( const int, const bool );
89
90   virtual void                        start();
91
92   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
93
94   virtual void                        createEmptyStudy();
95
96   SUIT_Accel*                         accel() const;
97
98 signals:
99   void                                studyOpened();
100   void                                studySaved();
101   void                                studyClosed();
102
103 public slots:
104   virtual void                        onHelpContentsModule();
105   virtual void                        onNewDoc();
106   virtual void                        onOpenDoc();
107   virtual void                        onHelpAbout();
108   virtual bool                        onOpenDoc( const QString& );
109   virtual bool                        onLoadDoc( const QString& );
110
111 protected:
112   virtual void                        createActions();
113   virtual SUIT_Study*                 createNewStudy();
114   virtual QWidget*                    createWindow( const int );
115   virtual void                        defaultWindows( QMap<int, int>& ) const;
116   void                                defaultViewManagers( QStringList& ) const;
117
118   virtual void                        setActiveStudy( SUIT_Study* );
119   virtual void                        updateCommandsStatus();
120   virtual void                        onSelectionChanged();
121
122   virtual void                        beforeCloseDoc( SUIT_Study* );
123   virtual void                        afterCloseDoc();
124   virtual void                        moduleAdded( CAM_Module* );
125   virtual bool                        activateModule( CAM_Module* = 0 );
126
127   LightApp_Preferences*               preferences( const bool ) const;
128   virtual void                        createPreferences( LightApp_Preferences* );
129   virtual void                        preferencesChanged( const QString&, const QString& );
130   virtual void                        updateDesktopTitle();
131
132 protected slots:
133   virtual void                        onDesktopActivated();
134
135   void                                onNewWindow();
136   void                                onModuleActivation( QAction* );
137   void                                onCloseView( SUIT_ViewManager* );
138
139   void                                onStudyCreated( SUIT_Study* );
140   void                                onStudyOpened( SUIT_Study* );
141   void                                onStudySaved( SUIT_Study* );
142   void                                onStudyClosed( SUIT_Study* );
143
144 private slots:
145   void                                onSelection();
146   void                                onRefresh();
147   void                                onPreferences();
148   void                                onMRUActivated( QString );
149   void                                onPreferenceChanged( QString&, QString&, QString& );
150
151 protected:
152   void                                updateWindows();
153   void                                updateViewManagers();
154   void                                updateModuleActions();
155
156   void                                loadWindowsGeometry();
157   void                                saveWindowsGeometry();
158
159   void                                updatePreference( const QString&, const QString&, const QString& );
160
161   QString                             defaultModule() const;
162   void                                currentWindows( QMap<int, int>& ) const;
163   void                                currentViewManagers( QStringList& ) const;
164   virtual SUIT_ViewManager*           createViewManager( const QString& vmType );
165   void                                moduleIconNames( QMap<QString, QString>& ) const;
166
167   void                                activateWindows();
168
169 protected:
170   typedef QMap<QString, QAction*>              ActionMap;
171   typedef QMap<int, LightApp_WidgetContainer*> WindowMap;
172
173 protected:
174   LightApp_Preferences*               myPrefs;
175   LightApp_SelectionMgr*              mySelMgr;
176   ActionMap                           myActions;
177   WindowMap                           myWindows;
178
179   SUIT_Accel*                         myAccel;
180
181   static LightApp_Preferences*        _prefs_;
182 };
183
184 #ifdef WIN32
185 #pragma warning( default:4251 )
186 #endif
187
188 #endif