1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: LightApp_Application.h
23 // Created: 6/20/2005 18:39:25 PM
26 #ifndef LIGHTAPP_APPLICATION_H
27 #define LIGHTAPP_APPLICATION_H
31 #endif // _MSC_VER > 1000
34 #include <CAM_Application.h>
39 #ifndef DISABLE_PYCONSOLE
40 class PyConsole_Console;
42 class LightApp_WidgetContainer;
43 class LightApp_Preferences;
44 class LightApp_SelectionMgr;
45 class LightApp_DataObject;
46 class SUIT_DataBrowser;
57 #pragma warning( disable:4251 )
61 Description : Application containing only LightApp module
64 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
69 typedef enum { WT_ObjectBrowser,
70 #ifndef DISABLE_PYCONSOLE
77 enum { MenuWindowId = 6 };
79 enum { RenameId = CAM_Application::UserID,
80 CloseId, CloseAllId, GroupAllId,
81 PreferencesId, MRUId, ModulesListId,
82 NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
83 NewQxSceneViewId, StyleId,
87 enum { NewStudyId = 1, OpenStudyId };
90 LightApp_Application();
91 virtual ~LightApp_Application();
93 virtual QString applicationName() const;
94 virtual QString applicationVersion() const;
96 virtual CAM_Module* loadModule( const QString&, const bool = true );
97 virtual bool activateModule( const QString& );
99 LightApp_SelectionMgr* selectionMgr() const;
101 LogWindow* logWindow();
102 SUIT_DataBrowser* objectBrowser();
103 #ifndef DISABLE_PYCONSOLE
104 PyConsole_Console* pythonConsole();
107 virtual void updateObjectBrowser( const bool = true );
109 LightApp_Preferences* preferences() const;
111 virtual QString getFileFilter() const;
113 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
114 const QString& caption, QWidget* parent );
115 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
116 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
117 const QString& caption, QWidget* parent );
119 void updateActions();
121 SUIT_ViewManager* getViewManager( const QString&, const bool );
122 virtual void addViewManager( SUIT_ViewManager* );
123 virtual void removeViewManager( SUIT_ViewManager* );
124 virtual SUIT_ViewManager* createViewManager( const QString& vmType );
126 QWidget* getWindow( const int, const int = -1 );
127 QWidget* dockWindow( const int ) const;
128 void removeDockWindow( const int );
129 void insertDockWindow( const int, QWidget* );
130 void placeDockWindow( const int, Qt::DockWidgetArea );
132 virtual void start();
134 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
136 virtual void createEmptyStudy();
138 SUIT_Accel* accel() const;
140 void setDefaultStudyName( const QString& theName );
142 static int studyId();
144 virtual bool event( QEvent* );
146 virtual bool checkDataObject( LightApp_DataObject* theObj );
148 virtual void updateDesktopTitle();
154 void preferenceChanged( const QString&, const QString&, const QString& );
157 virtual void onHelpContentsModule();
158 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
159 virtual void onNewDoc();
160 virtual void onOpenDoc();
161 virtual void onHelpAbout();
162 virtual bool onOpenDoc( const QString& );
165 virtual void createActions();
166 virtual void createActionForViewer( const int id,
168 const QString& suffix,
170 virtual SUIT_Study* createNewStudy();
171 virtual QWidget* createWindow( const int );
172 virtual void defaultWindows( QMap<int, int>& ) const;
173 void defaultViewManagers( QStringList& ) const;
175 virtual void setActiveStudy( SUIT_Study* );
176 virtual void updateCommandsStatus();
177 virtual void onSelectionChanged();
179 virtual void beforeCloseDoc( SUIT_Study* );
180 virtual void afterCloseDoc();
181 virtual void moduleAdded( CAM_Module* );
182 virtual bool activateModule( CAM_Module* = 0 );
184 LightApp_Preferences* preferences( const bool ) const;
185 virtual void createPreferences( LightApp_Preferences* );
186 virtual void preferencesChanged( const QString&, const QString& );
188 virtual void loadPreferences();
189 virtual void savePreferences();
191 virtual QMap<int, QString> activateModuleActions() const;
192 virtual void moduleActionSelected( const int );
195 virtual void onDesktopActivated();
198 void onModuleActivation( const QString& );
199 void onCloseView( SUIT_ViewManager* );
201 void onStudyCreated( SUIT_Study* );
202 void onStudyOpened( SUIT_Study* );
203 void onStudySaved( SUIT_Study* );
204 void onStudyClosed( SUIT_Study* );
206 void onWCDestroyed( QObject* );
208 void onMRUActivated( const QString& );
210 void onStylePreferences();
215 void onPreferences();
216 void onPreferenceChanged( QString&, QString&, QString& );
217 void onRenameWindow();
218 void onCloseWindow();
219 void onCloseAllWindow();
220 void onGroupAllWindow();
223 void updateWindows();
224 void updateViewManagers();
225 void updateModuleActions();
227 void loadDockWindowsState();
228 void saveDockWindowsState();
230 virtual void studyOpened( SUIT_Study* );
231 virtual void studyCreated( SUIT_Study* );
233 void updatePreference( const QString&, const QString&, const QString& );
235 QString defaultModule() const;
236 void currentWindows( QMap<int, int>& ) const;
237 void currentViewManagers( QStringList& ) const;
238 void moduleIconNames( QMap<QString, QString>& ) const;
240 bool isLibExists( const QString& ) const;
242 QDockWidget* windowDock( QWidget* ) const;
243 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
244 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
246 virtual int openChoice( const QString& );
247 virtual bool openAction( const int, const QString& );
249 void showPreferences( const QString& = QString() );
252 void emptyPreferences( const QString& );
255 typedef QPointer<QWidget> WinPtr;
256 typedef QMap<int, WinPtr> WinMap;
257 typedef QMap<QString, QByteArray> WinVis;
258 typedef QMap<QString, QByteArray> WinGeom;
260 enum { OpenReload = CAM_Application::OpenExist + 1 };
263 LightApp_Preferences* myPrefs;
264 LightApp_SelectionMgr* mySelMgr;
272 static LightApp_Preferences* _prefs_;
274 static int lastStudyId;
278 #pragma warning( default:4251 )