1 // Copyright (C) 2007-2012 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
23 // File: LightApp_Application.h
24 // Created: 6/20/2005 18:39:25 PM
27 #ifndef LIGHTAPP_APPLICATION_H
28 #define LIGHTAPP_APPLICATION_H
32 #endif // _MSC_VER > 1000
35 #include <SUIT_TreeModel.h>
36 #include <CAM_Application.h>
39 #include <QStringList>
42 #ifndef DISABLE_PYCONSOLE
43 class PyConsole_Console;
45 class LightApp_WidgetContainer;
46 class LightApp_Preferences;
47 class LightApp_SelectionMgr;
48 class LightApp_FullScreenHelper;
49 class LightApp_DataObject;
50 class SUIT_DataBrowser;
62 #pragma warning( disable:4251 )
66 Description : Application containing only LightApp module
69 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
74 typedef enum { WT_ObjectBrowser,
75 #ifndef DISABLE_PYCONSOLE
82 enum { MenuWindowId = 6 };
84 enum { RenameId = CAM_Application::UserID,
85 CloseId, CloseAllId, GroupAllId,
86 PreferencesId, MRUId, ModulesListId,
87 NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
88 NewQxSceneViewId = NewQxGraphViewId, StyleId, FullScreenId,
92 enum { NewStudyId = 1, OpenStudyId };
94 enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
97 LightApp_Application();
98 virtual ~LightApp_Application();
100 virtual QString applicationName() const;
101 virtual QString applicationVersion() const;
103 virtual CAM_Module* loadModule( const QString&, const bool = true );
104 virtual bool activateModule( const QString& );
106 LightApp_SelectionMgr* selectionMgr() const;
108 LogWindow* logWindow();
109 SUIT_DataBrowser* objectBrowser();
110 #ifndef DISABLE_PYCONSOLE
111 PyConsole_Console* pythonConsole(const bool force = false);
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 virtual SUIT_ViewManager* createViewManager( const QString& vmType );
132 virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
134 QWidget* getWindow( const int, const int = -1 );
135 QWidget* dockWindow( const int ) const;
136 void removeDockWindow( const int );
137 void insertDockWindow( const int, QWidget* );
138 void placeDockWindow( const int, Qt::DockWidgetArea );
140 virtual void start();
142 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
144 virtual void createEmptyStudy();
146 virtual void setDesktop( SUIT_Desktop* );
148 SUIT_Accel* accel() const;
150 void setDefaultStudyName( const QString& theName );
152 static int studyId();
154 virtual bool event( QEvent* );
156 virtual bool checkDataObject( LightApp_DataObject* theObj );
158 virtual void updateDesktopTitle();
160 //! Returns list of view manager types which are supported by this application
161 QStringList viewManagersTypes() const;
163 //! Removes ViewManagers only of known type
164 virtual void clearKnownViewManagers();
166 virtual QString browseObjects( const QStringList& theEntryList,
167 const bool theIsApplyAndClose = true,
168 const bool theIsOptimizedBrowsing = false );
170 virtual SUIT_DataObject* findObject( const QString& ) const;
172 virtual bool renameAllowed( const QString& ) const;
173 virtual bool renameObject( const QString&, const QString& );
179 void preferenceChanged( const QString&, const QString&, const QString& );
182 virtual void onHelpContentsModule();
183 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
184 virtual void onNewDoc();
185 virtual void onOpenDoc();
186 virtual void onHelpAbout();
187 virtual bool onOpenDoc( const QString& );
188 virtual void onCopy();
189 virtual void onPaste();
190 virtual void onSelectionChanged();
193 virtual void createActions();
194 virtual void createActionForViewer( const int id,
196 const QString& suffix,
198 virtual SUIT_Study* createNewStudy();
199 virtual QWidget* createWindow( const int );
200 virtual void defaultWindows( QMap<int, int>& ) const;
201 void defaultViewManagers( QStringList& ) const;
203 virtual void setActiveStudy( SUIT_Study* );
204 virtual void updateCommandsStatus();
206 virtual void beforeCloseDoc( SUIT_Study* );
207 virtual void afterCloseDoc();
208 virtual void moduleAdded( CAM_Module* );
209 virtual bool activateModule( CAM_Module* = 0 );
211 LightApp_Preferences* preferences( const bool ) const;
212 virtual void createPreferences( LightApp_Preferences* );
213 virtual void preferencesChanged( const QString&, const QString& );
215 virtual void loadPreferences();
216 virtual void savePreferences();
218 virtual QMap<int, QString> activateModuleActions() const;
219 virtual void moduleActionSelected( const int );
222 virtual void onDesktopActivated();
225 void onModuleActivation( const QString& );
226 void onCloseView( SUIT_ViewManager* );
228 void onStudyCreated( SUIT_Study* );
229 void onStudyOpened( SUIT_Study* );
230 void onStudySaved( SUIT_Study* );
231 void onStudyClosed( SUIT_Study* );
233 void onWCDestroyed( QObject* );
235 void onMRUActivated( const QString& );
237 void onStylePreferences();
240 virtual void onDesktopMessage( const QString& );
245 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
246 void onPreferences();
247 void onPreferenceChanged( QString&, QString&, QString& );
248 void onRenameWindow();
249 void onCloseWindow();
250 void onCloseAllWindow();
251 void onGroupAllWindow();
254 void updateWindows();
255 void updateViewManagers();
256 void updateModuleActions();
257 void removeModuleAction( const QString& );
259 void loadDockWindowsState();
260 void saveDockWindowsState();
262 virtual void studyOpened( SUIT_Study* );
263 virtual void studyCreated( SUIT_Study* );
264 virtual void studySaved( SUIT_Study* );
266 void updatePreference( const QString&, const QString&, const QString& );
268 QString defaultModule() const;
269 virtual void currentWindows( QMap<int, int>& ) const;
270 void currentViewManagers( QStringList& ) const;
271 void moduleIconNames( QMap<QString, QString>& ) const;
273 bool isLibExists( const QString& ) const;
275 QDockWidget* windowDock( QWidget* ) const;
276 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
277 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
279 virtual int openChoice( const QString& );
280 virtual bool openAction( const int, const QString& );
282 void showPreferences( const QString& = QString() );
285 void emptyPreferences( const QString& );
288 typedef QPointer<QWidget> WinPtr;
289 typedef QMap<int, WinPtr> WinMap;
290 typedef QMap<QString, QByteArray> WinVis;
291 typedef QMap<QString, QByteArray> WinGeom;
293 enum { OpenReload = CAM_Application::OpenExist + 1 };
296 LightApp_Preferences* myPrefs;
297 LightApp_SelectionMgr* mySelMgr;
299 LightApp_FullScreenHelper* myScreenHelper;
306 QTimer* myAutoSaveTimer;
308 static LightApp_Preferences* _prefs_;
310 static int lastStudyId;
311 QStringList myUserWmTypes;
315 #pragma warning( default:4251 )