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;
43 class LightApp_DataObject;
54 #pragma warning( disable:4251 )
58 Description : Application containing only LightApp module
61 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
66 typedef enum { WT_ObjectBrowser,
67 #ifndef DISABLE_PYCONSOLE
74 enum { MenuWindowId = 6 };
76 enum { RenameId = CAM_Application::UserID,
78 #ifndef DISABLE_GLVIEWER
82 #ifndef DISABLE_PLOT2DVIEWER
86 #ifndef DISABLE_OCCVIEWER
90 #ifndef DISABLE_VTKVIEWER
94 #ifndef DISABLE_QXGRAPHVIEWER
98 PreferencesId, MRUId, UserID };
101 enum { NewStudyId = 1, OpenStudyId };
104 LightApp_Application();
105 virtual ~LightApp_Application();
107 virtual QString applicationName() const;
108 virtual QString applicationVersion() const;
110 virtual CAM_Module* loadModule( const QString& );
111 virtual bool activateModule( const QString& );
113 virtual bool useStudy( const QString& );
115 LightApp_SelectionMgr* selectionMgr() const;
117 LogWindow* logWindow();
118 OB_Browser* objectBrowser();
119 #ifndef DISABLE_PYCONSOLE
120 PythonConsole* pythonConsole();
123 virtual void updateObjectBrowser( const bool = true );
125 LightApp_Preferences* preferences() const;
127 virtual QString getFileFilter() const;
129 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
130 const QString& caption, QWidget* parent );
131 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
132 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
133 const QString& caption, QWidget* parent );
135 void updateActions();
137 SUIT_ViewManager* getViewManager( const QString&, const bool );
138 virtual void addViewManager( SUIT_ViewManager* );
139 virtual void removeViewManager( SUIT_ViewManager* );
140 virtual SUIT_ViewManager* createViewManager( const QString& vmType );
142 QWidget* getWindow( const int, const int = -1 );
143 QWidget* window( const int, const int = -1 ) const;
144 void addWindow( QWidget*, const int, const int = -1 );
145 void removeWindow( const int, const int = -1 );
147 bool isWindowVisible( const int ) const;
148 void setWindowShown( const int, const bool );
150 virtual void start();
152 virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
154 virtual void createEmptyStudy();
156 SUIT_Accel* accel() const;
158 void setDefaultStudyName( const QString& theName );
160 static int studyId();
162 virtual bool event( QEvent* );
164 virtual bool checkDataObject( LightApp_DataObject* theObj );
170 void preferenceChanged( const QString&, const QString&, const QString& );
173 virtual void onHelpContentsModule();
174 virtual void onHelpContextModule( const QString&, const QString& );
175 virtual void onNewDoc();
176 virtual void onOpenDoc();
177 virtual void onHelpAbout();
178 virtual bool onOpenDoc( const QString& );
179 virtual bool onLoadDoc( const QString& );
182 virtual void createActions();
183 virtual void createActionForViewer( const int id,
185 const QString& suffix,
187 virtual SUIT_Study* createNewStudy();
188 virtual QWidget* createWindow( const int );
189 virtual void defaultWindows( QMap<int, int>& ) const;
190 void defaultViewManagers( QStringList& ) const;
192 virtual void setActiveStudy( SUIT_Study* );
193 virtual void updateCommandsStatus();
194 virtual void onSelectionChanged();
196 virtual void beforeCloseDoc( SUIT_Study* );
197 virtual void afterCloseDoc();
198 virtual void moduleAdded( CAM_Module* );
199 virtual bool activateModule( CAM_Module* = 0 );
201 LightApp_Preferences* preferences( const bool ) const;
202 virtual void createPreferences( LightApp_Preferences* );
203 virtual void preferencesChanged( const QString&, const QString& );
204 virtual void savePreferences();
205 virtual void updateDesktopTitle();
207 virtual QMap<int, QString> activateModuleActions() const;
208 virtual void moduleActionSelected( const int );
211 virtual void onDesktopActivated();
214 void onModuleActivation( QAction* );
215 void onCloseView( SUIT_ViewManager* );
217 void onStudyCreated( SUIT_Study* );
218 void onStudyOpened( SUIT_Study* );
219 void onStudySaved( SUIT_Study* );
220 void onStudyClosed( SUIT_Study* );
222 void onWCDestroyed( QObject* );
228 void onPreferences();
229 void onMRUActivated( QString );
230 void onPreferenceChanged( QString&, QString&, QString& );
231 void onRenameWindow();
232 void onVisibilityChanged( bool );
235 void updateWindows();
236 void updateViewManagers();
237 void updateModuleActions();
239 void loadWindowsGeometry();
240 void saveWindowsGeometry();
242 void updatePreference( const QString&, const QString&, const QString& );
244 QString defaultModule() const;
245 void currentWindows( QMap<int, int>& ) const;
246 void currentViewManagers( QStringList& ) const;
247 void moduleIconNames( QMap<QString, QString>& ) const;
249 void activateWindows();
250 bool isLibExists( const QString& ) const;
253 typedef QMap<QString, QAction*> ActionMap;
254 typedef QMap<int, LightApp_WidgetContainer*> WindowMap;
255 typedef QMap<int, bool> WindowVisibilityMap;
258 LightApp_Preferences* myPrefs;
259 LightApp_SelectionMgr* mySelMgr;
262 WindowVisibilityMap myWindowsVisible;
266 static LightApp_Preferences* _prefs_;
268 static int lastStudyId;
272 #pragma warning( default:4251 )