1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File: LightApp_Application.h
20 // Created: 6/20/2005 18:39:25 PM
22 // Copyright (C) CEA 2005
24 #ifndef LIGHTAPP_APPLICATION_H
25 #define LIGHTAPP_APPLICATION_H
29 #endif // _MSC_VER > 1000
32 #include <CAM_Application.h>
36 #ifndef DISABLE_PYCONSOLE
39 class STD_Application;
40 class LightApp_WidgetContainer;
41 class LightApp_Preferences;
42 class LightApp_SelectionMgr;
53 #pragma warning( disable:4251 )
57 Description : Application containing only LightApp module
60 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
65 typedef enum { WT_ObjectBrowser,
66 #ifndef DISABLE_PYCONSOLE
73 enum { MenuWindowId = 6 };
75 enum { RenameId = CAM_Application::UserID,
77 #ifndef DISABLE_GLVIEWER
81 #ifndef DISABLE_PLOT2DVIEWER
85 #ifndef DISABLE_OCCVIEWER
89 #ifndef DISABLE_VTKVIEWER
93 PreferencesId, MRUId, UserID };
95 LightApp_Application();
96 virtual ~LightApp_Application();
98 virtual QString applicationName() const;
99 virtual QString applicationVersion() const;
101 virtual CAM_Module* loadModule( const QString& );
102 virtual bool activateModule( const QString& );
104 virtual bool useStudy( const QString& );
106 LightApp_SelectionMgr* selectionMgr() const;
108 LogWindow* logWindow();
109 OB_Browser* objectBrowser();
110 #ifndef DISABLE_PYCONSOLE
111 PythonConsole* pythonConsole();
114 virtual void updateObjectBrowser( const bool = true );
116 LightApp_Preferences* preferences() const;
118 virtual QString getFileFilter() const;
120 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
121 const QString& caption, QWidget* parent );
122 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
123 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
124 const QString& caption, QWidget* parent );
126 void updateActions();
128 SUIT_ViewManager* getViewManager( const QString&, const bool );
129 virtual void addViewManager( SUIT_ViewManager* );
130 virtual void removeViewManager( SUIT_ViewManager* );
131 QWidget* getWindow( const int, const int = -1 );
132 QWidget* window( const int, const int = -1 ) const;
133 void addWindow( QWidget*, const int, const int = -1 );
134 void removeWindow( const int, const int = -1 );
136 bool isWindowVisible( const int ) const;
137 void setWindowShown( const int, const bool );
139 virtual void start();
141 virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
143 virtual void createEmptyStudy();
145 SUIT_Accel* accel() const;
147 void setDefaultStudyName( const QString& theName );
149 static int studyId();
151 virtual bool event( QEvent* );
159 virtual void onHelpContentsModule();
160 virtual void onHelpContextModule( const QString&, const QString& );
161 virtual void onNewDoc();
162 virtual void onOpenDoc();
163 virtual void onHelpAbout();
164 virtual bool onOpenDoc( const QString& );
165 virtual bool onLoadDoc( const QString& );
168 virtual void createActions();
169 virtual void createActionForViewer( const int id,
171 const QString& suffix,
173 virtual SUIT_Study* createNewStudy();
174 virtual QWidget* createWindow( const int );
175 virtual void defaultWindows( QMap<int, int>& ) const;
176 void defaultViewManagers( QStringList& ) const;
178 virtual void setActiveStudy( SUIT_Study* );
179 virtual void updateCommandsStatus();
180 virtual void onSelectionChanged();
182 virtual void beforeCloseDoc( SUIT_Study* );
183 virtual void afterCloseDoc();
184 virtual void moduleAdded( CAM_Module* );
185 virtual bool activateModule( CAM_Module* = 0 );
187 LightApp_Preferences* preferences( const bool ) const;
188 virtual void createPreferences( LightApp_Preferences* );
189 virtual void preferencesChanged( const QString&, const QString& );
190 virtual void savePreferences();
191 virtual void updateDesktopTitle();
194 virtual void onDesktopActivated();
197 void onModuleActivation( QAction* );
198 void onCloseView( SUIT_ViewManager* );
200 void onStudyCreated( SUIT_Study* );
201 void onStudyOpened( SUIT_Study* );
202 void onStudySaved( SUIT_Study* );
203 void onStudyClosed( SUIT_Study* );
205 void onWCDestroyed( QObject* );
210 void onPreferences();
211 void onMRUActivated( QString );
212 void onPreferenceChanged( QString&, QString&, QString& );
213 void onRenameWindow();
214 void onVisibilityChanged( bool );
217 void updateWindows();
218 void updateViewManagers();
219 void updateModuleActions();
221 void loadWindowsGeometry();
222 void saveWindowsGeometry();
224 void updatePreference( const QString&, const QString&, const QString& );
226 QString defaultModule() const;
227 void currentWindows( QMap<int, int>& ) const;
228 void currentViewManagers( QStringList& ) const;
229 virtual SUIT_ViewManager* createViewManager( const QString& vmType );
230 void moduleIconNames( QMap<QString, QString>& ) const;
232 void activateWindows();
233 bool isLibExists( const QString& ) const;
236 typedef QMap<QString, QAction*> ActionMap;
237 typedef QMap<int, LightApp_WidgetContainer*> WindowMap;
238 typedef QMap<int, bool> WindowVisibilityMap;
241 LightApp_Preferences* myPrefs;
242 LightApp_SelectionMgr* mySelMgr;
245 WindowVisibilityMap myWindowsVisible;
249 static LightApp_Preferences* _prefs_;
251 static int lastStudyId;
255 #pragma warning( default:4251 )