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, NewPVViewId, 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 );
135 virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
137 QWidget* getWindow( const int, const int = -1 );
138 QWidget* dockWindow( const int ) const;
139 void removeDockWindow( const int );
140 void insertDockWindow( const int, QWidget* );
141 void placeDockWindow( const int, Qt::DockWidgetArea );
143 virtual void start();
145 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
147 virtual void createEmptyStudy();
149 virtual void setDesktop( SUIT_Desktop* );
151 SUIT_Accel* accel() const;
153 void setDefaultStudyName( const QString& theName );
155 static int studyId();
157 virtual bool event( QEvent* );
159 virtual bool checkDataObject( LightApp_DataObject* theObj );
161 virtual void updateDesktopTitle();
163 //! Returns list of view manager types which are supported by this application
164 QStringList viewManagersTypes() const;
166 //! Removes ViewManagers only of known type
167 virtual void clearKnownViewManagers();
169 virtual QString browseObjects( const QStringList& theEntryList,
170 const bool theIsApplyAndClose = true,
171 const bool theIsOptimizedBrowsing = false );
173 virtual SUIT_DataObject* findObject( const QString& ) const;
175 virtual bool renameAllowed( const QString& ) const;
176 virtual bool renameObject( const QString&, const QString& );
178 void emitOperationFinished( const QString&, const QString&, const QStringList& );
180 void updateVisibilityState( DataObjectList& theList,
181 SUIT_ViewModel* theViewModel );
183 virtual bool checkExistingDoc();
189 void preferenceChanged( const QString&, const QString&, const QString& );
190 void operationFinished( const QString&, const QString&, const QStringList& );
193 virtual void onHelpContentsModule();
194 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
195 virtual void onNewDoc();
196 virtual void onOpenDoc();
198 virtual void onHelpAbout();
199 virtual bool onOpenDoc( const QString& );
200 virtual void onCopy();
201 virtual void onPaste();
202 virtual void onSelectionChanged();
205 virtual void createActions();
206 virtual void createActionForViewer( const int id,
208 const QString& suffix,
210 virtual SUIT_Study* createNewStudy();
211 virtual QWidget* createWindow( const int );
212 virtual void defaultWindows( QMap<int, int>& ) const;
213 void defaultViewManagers( QStringList& ) const;
215 virtual void setActiveStudy( SUIT_Study* );
216 virtual void updateCommandsStatus();
218 virtual void beforeCloseDoc( SUIT_Study* );
219 virtual void afterCloseDoc();
220 virtual void moduleAdded( CAM_Module* );
221 virtual bool activateModule( CAM_Module* = 0 );
223 LightApp_Preferences* preferences( const bool ) const;
224 virtual void createPreferences( LightApp_Preferences* );
225 virtual void preferencesChanged( const QString&, const QString& );
227 virtual void loadPreferences();
228 virtual void savePreferences();
230 virtual QMap<int, QString> activateModuleActions() const;
231 virtual void moduleActionSelected( const int );
234 virtual void onDesktopActivated();
235 virtual void onViewManagerRemoved( SUIT_ViewManager* );
236 virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
239 void onModuleActivation( const QString& );
240 void onCloseView( SUIT_ViewManager* );
242 virtual void onStudyCreated( SUIT_Study* );
243 virtual void onStudyOpened( SUIT_Study* );
244 virtual void onStudySaved( SUIT_Study* );
245 virtual void onStudyClosed( SUIT_Study* );
247 void onWCDestroyed( QObject* );
249 void onMRUActivated( const QString& );
251 void onStylePreferences();
254 virtual void onDesktopMessage( const QString& );
259 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
260 void onPreferences();
261 void onPreferenceChanged( QString&, QString&, QString& );
262 void onRenameWindow();
263 void onCloseWindow();
264 void onCloseAllWindow();
265 void onGroupAllWindow();
268 void updateWindows();
269 void updateViewManagers();
270 void updateModuleActions();
271 void removeModuleAction( const QString& );
273 void loadDockWindowsState();
274 void saveDockWindowsState();
276 virtual void studyOpened( SUIT_Study* );
277 virtual void studyCreated( SUIT_Study* );
278 virtual void studySaved( SUIT_Study* );
280 void updatePreference( const QString&, const QString&, const QString& );
282 QString defaultModule() const;
283 virtual void currentWindows( QMap<int, int>& ) const;
284 void currentViewManagers( QStringList& ) const;
285 void moduleIconNames( QMap<QString, QString>& ) const;
287 bool isLibExists( const QString& ) const;
289 QDockWidget* windowDock( QWidget* ) const;
290 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
291 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
293 virtual int openChoice( const QString& );
294 virtual bool openAction( const int, const QString& );
296 void showPreferences( const QString& = QString() );
299 void emptyPreferences( const QString& );
300 QList<QToolBar*> findToolBars( const QStringList& names = QStringList() );
302 QByteArray processState(QByteArray& input,
303 const bool processWin,
304 const bool processTb,
305 const bool isRestoring,
306 QByteArray defaultState = QByteArray());
309 typedef QPointer<QWidget> WinPtr;
310 typedef QMap<int, WinPtr> WinMap;
311 typedef QMap<QString, QByteArray> WinVis;
312 typedef QMap<QString, QByteArray> WinGeom;
314 enum { OpenReload = CAM_Application::OpenExist + 1 };
317 LightApp_Preferences* myPrefs;
318 LightApp_SelectionMgr* mySelMgr;
320 LightApp_FullScreenHelper* myScreenHelper;
326 QTimer* myAutoSaveTimer;
328 static LightApp_Preferences* _prefs_;
330 static int lastStudyId;
331 QStringList myUserWmTypes;
335 #pragma warning( default:4251 )