1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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 <SUIT_DataObject.h>
37 #include <CAM_Application.h>
40 #include <QStringList>
43 #ifndef DISABLE_PYCONSOLE
44 class PyConsole_Console;
46 class LightApp_WidgetContainer;
47 class LightApp_Preferences;
48 class LightApp_SelectionMgr;
49 class LightApp_FullScreenHelper;
50 class LightApp_DataObject;
51 class SUIT_DataBrowser;
64 #pragma warning( disable:4251 )
68 Description : Application containing only LightApp module
71 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
76 typedef enum { WT_ObjectBrowser,
77 #ifndef DISABLE_PYCONSOLE
84 enum { MenuWindowId = 6 };
86 enum { RenameId = CAM_Application::UserID,
87 CloseId, CloseAllId, GroupAllId,
88 PreferencesId, MRUId, ModulesListId,
89 NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId,
90 NewQxSceneViewId, NewGraphicsViewId, StyleId, FullScreenId,
94 enum { NewStudyId = 1, OpenStudyId };
96 enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
99 LightApp_Application();
100 virtual ~LightApp_Application();
102 virtual QString applicationName() const;
103 virtual QString applicationVersion() const;
105 virtual CAM_Module* loadModule( const QString&, const bool = true );
106 virtual bool activateModule( const QString& );
108 LightApp_SelectionMgr* selectionMgr() const;
110 LogWindow* logWindow();
111 SUIT_DataBrowser* objectBrowser();
112 #ifndef DISABLE_PYCONSOLE
113 PyConsole_Console* pythonConsole(const bool force = false);
116 virtual void updateObjectBrowser( const bool = true );
118 LightApp_Preferences* preferences() const;
120 virtual QString getFileFilter() const;
122 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
123 const QString& caption, QWidget* parent );
124 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
125 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
126 const QString& caption, QWidget* parent );
128 void updateActions();
130 SUIT_ViewManager* getViewManager( const QString&, const bool );
131 virtual void addViewManager( SUIT_ViewManager* );
132 virtual void removeViewManager( SUIT_ViewManager* );
133 virtual SUIT_ViewManager* createViewManager( const QString& vmType );
134 virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
136 QWidget* getWindow( const int, const int = -1 );
137 QWidget* dockWindow( const int ) const;
138 void removeDockWindow( const int );
139 void insertDockWindow( const int, QWidget* );
140 void placeDockWindow( const int, Qt::DockWidgetArea );
142 virtual void start();
144 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
146 virtual void createEmptyStudy();
148 virtual void setDesktop( SUIT_Desktop* );
150 SUIT_Accel* accel() const;
152 void setDefaultStudyName( const QString& theName );
154 static int studyId();
156 virtual bool event( QEvent* );
158 virtual bool checkDataObject( LightApp_DataObject* theObj );
160 virtual void updateDesktopTitle();
162 //! Returns list of view manager types which are supported by this application
163 QStringList viewManagersTypes() const;
165 //! Removes ViewManagers only of known type
166 virtual void clearKnownViewManagers();
168 virtual QString browseObjects( const QStringList& theEntryList,
169 const bool theIsApplyAndClose = true,
170 const bool theIsOptimizedBrowsing = false );
172 virtual SUIT_DataObject* findObject( const QString& ) const;
174 virtual bool renameAllowed( const QString& ) const;
175 virtual bool renameObject( const QString&, const QString& );
177 void emitOperationFinished( const QString&, const QString&, const QStringList& );
179 void updateVisibilityState( DataObjectList& theList,
180 SUIT_ViewModel* theViewModel );
182 virtual bool checkExistingDoc();
188 void preferenceChanged( const QString&, const QString&, const QString& );
189 void operationFinished( const QString&, const QString&, const QStringList& );
192 virtual void onHelpContentsModule();
193 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
194 virtual void onNewDoc();
195 virtual void onOpenDoc();
197 virtual void onHelpAbout();
198 virtual bool onOpenDoc( const QString& );
199 virtual void onCopy();
200 virtual void onPaste();
201 virtual void onSelectionChanged();
204 virtual void createActions();
205 virtual void createActionForViewer( const int id,
207 const QString& suffix,
209 virtual SUIT_Study* createNewStudy();
210 virtual QWidget* createWindow( const int );
211 virtual void defaultWindows( QMap<int, int>& ) const;
212 void defaultViewManagers( QStringList& ) const;
214 virtual void setActiveStudy( SUIT_Study* );
215 virtual void updateCommandsStatus();
217 virtual void beforeCloseDoc( SUIT_Study* );
218 virtual void afterCloseDoc();
219 virtual void moduleAdded( CAM_Module* );
220 virtual bool activateModule( CAM_Module* = 0 );
222 LightApp_Preferences* preferences( const bool ) const;
223 virtual void createPreferences( LightApp_Preferences* );
224 virtual void preferencesChanged( const QString&, const QString& );
226 virtual void loadPreferences();
227 virtual void savePreferences();
229 virtual QMap<int, QString> activateModuleActions() const;
230 virtual void moduleActionSelected( const int );
233 virtual void onDesktopActivated();
234 virtual void onViewManagerRemoved( SUIT_ViewManager* );
235 virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
238 void onModuleActivation( const QString& );
239 void onCloseView( SUIT_ViewManager* );
241 virtual void onStudyCreated( SUIT_Study* );
242 virtual void onStudyOpened( SUIT_Study* );
243 virtual void onStudySaved( SUIT_Study* );
244 virtual void onStudyClosed( SUIT_Study* );
246 void onWCDestroyed( QObject* );
248 void onMRUActivated( const QString& );
250 void onStylePreferences();
253 virtual void onDesktopMessage( const QString& );
258 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
259 void onPreferences();
260 void onPreferenceChanged( QString&, QString&, QString& );
261 void onRenameWindow();
262 void onCloseWindow();
263 void onCloseAllWindow();
264 void onGroupAllWindow();
267 void updateWindows();
268 void updateViewManagers();
269 void updateModuleActions();
270 void removeModuleAction( const QString& );
272 void loadDockWindowsState();
273 void saveDockWindowsState();
275 virtual void studyOpened( SUIT_Study* );
276 virtual void studyCreated( SUIT_Study* );
277 virtual void studySaved( SUIT_Study* );
279 void updatePreference( const QString&, const QString&, const QString& );
281 QString defaultModule() const;
282 virtual void currentWindows( QMap<int, int>& ) const;
283 void currentViewManagers( QStringList& ) const;
284 void moduleIconNames( QMap<QString, QString>& ) const;
286 bool isLibExists( const QString& ) const;
288 QDockWidget* windowDock( QWidget* ) const;
289 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
290 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
292 virtual int openChoice( const QString& );
293 virtual bool openAction( const int, const QString& );
295 void showPreferences( const QString& = QString() );
298 void emptyPreferences( const QString& );
299 QList<QToolBar*> findToolBars();
301 QByteArray processState(QByteArray& input,
302 const bool processWin,
303 const bool processTb,
304 const bool isRestoring,
305 QByteArray defaultState = QByteArray());
308 typedef QPointer<QWidget> WinPtr;
309 typedef QMap<int, WinPtr> WinMap;
310 typedef QMap<QString, QByteArray> WinVis;
311 typedef QMap<QString, QByteArray> WinGeom;
313 enum { OpenReload = CAM_Application::OpenExist + 1 };
316 LightApp_Preferences* myPrefs;
317 LightApp_SelectionMgr* mySelMgr;
319 LightApp_FullScreenHelper* myScreenHelper;
325 QTimer* myAutoSaveTimer;
327 static LightApp_Preferences* _prefs_;
329 static int lastStudyId;
330 QStringList myUserWmTypes;
334 #pragma warning( default:4251 )