1 // Copyright (C) 2007-2020 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>
44 #ifndef DISABLE_PYCONSOLE
45 class PyConsole_Console;
46 class PyConsole_Interp;
48 class LightApp_WidgetContainer;
49 class LightApp_Preferences;
50 class LightApp_SelectionMgr;
51 class LightApp_FullScreenHelper;
52 class LightApp_DataObject;
53 class SUIT_DataBrowser;
66 #pragma warning( disable:4251 )
70 Description : Application containing only LightApp module
73 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
78 typedef enum { WT_ObjectBrowser,
80 #ifndef DISABLE_PYCONSOLE
87 enum { MenuWindowId = 6 };
89 enum { RenameId = CAM_Application::UserID,
90 CloseId, CloseAllId, GroupAllId,
91 PreferencesId, MRUId, ModulesListId,
92 NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId,
93 NewQxSceneViewId, NewGraphicsViewId, NewPVViewId, NewPyViewerId, StyleId, FullScreenId,
94 WebSiteId, ForumId, VideosId, TutorialsId,
98 enum { NewStudyId = 1, OpenStudyId };
100 enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
103 LightApp_Application();
104 virtual ~LightApp_Application();
106 virtual QString applicationName() const;
107 virtual QString applicationVersion() const;
109 virtual CAM_Module* loadModule( const QString&, const bool = true );
110 virtual bool activateModule( const QString& );
112 LightApp_SelectionMgr* selectionMgr() const;
114 LogWindow* logWindow();
115 SUIT_DataBrowser* objectBrowser();
116 QtxInfoPanel* infoPanel();
117 #ifndef DISABLE_PYCONSOLE
118 PyConsole_Console* pythonConsole(const bool force = false);
121 virtual void updateObjectBrowser( const bool = true );
123 LightApp_Preferences* preferences() const;
125 virtual QString getFileFilter( bool ) const;
127 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
128 const QString& caption, QWidget* parent );
129 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
130 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
131 const QString& caption, QWidget* parent );
133 void updateActions();
135 SUIT_ViewManager* getViewManager( const QString&, const bool );
136 virtual void addViewManager( SUIT_ViewManager* );
137 virtual void removeViewManager( SUIT_ViewManager* );
138 virtual SUIT_ViewManager* createViewManager( const QString& vmType, bool detached = false );
139 virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
140 virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
142 QWidget* getWindow( const int );
143 QWidget* dockWindow( const int ) const;
144 void removeDockWindow( const int );
145 void insertDockWindow( const int, QWidget* );
146 void placeDockWindow( const int, Qt::DockWidgetArea );
148 virtual void start();
149 virtual void closeApplication();
151 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
153 virtual void createEmptyStudy();
155 virtual void setDesktop( SUIT_Desktop* );
157 SUIT_Accel* accel() const;
159 void setDefaultStudyName( const QString& theName );
161 virtual bool event( QEvent* );
163 virtual bool checkDataObject( LightApp_DataObject* theObj );
165 virtual void updateDesktopTitle();
167 //! Returns list of view manager types which are supported by this application
168 QStringList viewManagersTypes() const;
170 //! Removes ViewManagers only of known type
171 virtual void clearKnownViewManagers();
173 virtual QString browseObjects( const QStringList& theEntryList,
174 const bool theIsApplyAndClose = true,
175 const bool theIsOptimizedBrowsing = false );
177 virtual SUIT_DataObject* findObject( const QString& ) const;
179 virtual bool renameAllowed( const QString& ) const;
180 virtual bool renameObject( const QString&, const QString& );
182 void emitOperationFinished( const QString&, const QString&, const QStringList& );
184 void updateVisibilityState( DataObjectList& theList,
185 SUIT_ViewModel* theViewModel );
187 virtual bool checkExistingDoc( bool = true );
189 #ifndef DISABLE_PYCONSOLE
190 PyConsole_Interp* getPyInterp();
197 void preferenceChanged( const QString&, const QString&, const QString& );
198 void preferenceResetToDefaults();
199 void operationFinished( const QString&, const QString&, const QStringList& );
202 virtual void onHelpContentsModule();
203 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
204 virtual void onNewDoc();
205 virtual void onOpenDoc();
207 virtual void onHelpAbout();
208 virtual bool onOpenDoc( const QString& );
209 virtual void onCopy();
210 virtual void onPaste();
211 virtual void onSelectionChanged();
212 virtual void onDockWindowVisibilityChanged( bool );
215 void showHelp( const QString& );
216 virtual void createActions();
217 virtual void createActionForViewer( const int id,
219 const QString& suffix,
221 virtual SUIT_Study* createNewStudy();
222 virtual QWidget* createWindow( const int );
223 virtual void defaultWindows( QMap<int, int>& ) const;
224 void defaultViewManagers( QStringList& ) const;
226 virtual void setActiveStudy( SUIT_Study* );
227 virtual void updateCommandsStatus();
229 virtual bool canOpenDoc( const QString& );
231 virtual void beforeCloseDoc( SUIT_Study* );
232 virtual void afterCloseDoc();
233 virtual void moduleAdded( CAM_Module* );
234 virtual bool activateModule( CAM_Module* = 0 );
236 LightApp_Preferences* preferences( const bool ) const;
237 virtual void createPreferences( LightApp_Preferences* );
238 virtual void preferencesChanged( const QString&, const QString& );
240 virtual void loadPreferences();
241 virtual void savePreferences();
243 virtual QMap<int, QString> activateModuleActions() const;
244 virtual void moduleActionSelected( const int );
246 #ifndef DISABLE_PYCONSOLE
247 virtual PyConsole_Interp* createPyInterp();
251 virtual void onDesktopActivated();
252 virtual void onViewManagerRemoved( SUIT_ViewManager* );
253 virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
256 virtual void onModuleActivation( const QString& );
257 void onCloseView( SUIT_ViewManager* );
259 virtual void onStudyCreated( SUIT_Study* );
260 virtual void onStudyOpened( SUIT_Study* );
261 virtual void onStudySaved( SUIT_Study* );
262 virtual void onStudyClosed( SUIT_Study* );
264 void onWCDestroyed( QObject* );
266 void onMRUActivated( const QString& );
268 void onStylePreferences();
271 virtual void onDesktopMessage( const QString& );
273 virtual void onInfoPanelShown();
278 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
279 void onPreferences();
280 void onPreferenceChanged( QString&, QString&, QString& );
281 void onRenameWindow();
282 void onCloseWindow();
283 void onCloseAllWindow();
284 void onGroupAllWindow();
289 void updateWindows();
290 void updateViewManagers();
291 void updateModuleActions();
292 void removeModuleAction( const QString& );
294 bool checkModule( const QString& );
296 void loadDockWindowsState();
297 void saveDockWindowsState();
299 virtual void studyOpened( SUIT_Study* );
300 virtual void studyCreated( SUIT_Study* );
301 virtual void studySaved( SUIT_Study* );
303 void updatePreference( const QString&, const QString&, const QString& );
305 QString defaultModule() const;
306 virtual void currentWindows( QMap<int, int>& ) const;
307 void currentViewManagers( QStringList& ) const;
308 void moduleIconNames( QMap<QString, QString>& ) const;
310 QDockWidget* windowDock( QWidget* ) const;
311 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
312 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
314 virtual int openChoice( const QString& );
315 virtual bool openAction( const int, const QString& );
317 void showPreferences( const QString& = QString() );
318 void showPreferences( const QStringList& );
321 void emptyPreferences( const QString& );
322 QList<QToolBar*> findToolBars( const QStringList& names = QStringList() );
324 QByteArray processState(QByteArray& input,
325 const bool processWin,
326 const bool processTb,
327 const bool isRestoring,
328 QByteArray defaultState = QByteArray());
331 typedef QPointer<QWidget> WinPtr;
332 typedef QMap<int, WinPtr> WinMap;
333 typedef QMap<QString, QByteArray> WinVis;
334 typedef QMap<QString, QByteArray> WinGeom;
336 enum { OpenReload = CAM_Application::OpenExist + 1 };
339 LightApp_Preferences* myPrefs;
340 LightApp_SelectionMgr* mySelMgr;
342 LightApp_FullScreenHelper* myScreenHelper;
348 QTimer* myAutoSaveTimer;
350 static LightApp_Preferences* _prefs_;
352 QStringList myUserWmTypes;
354 friend void LightAppCleanUpAppResources();
358 #pragma warning( default:4251 )