1 // Copyright (C) 2007-2022 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>
41 #include <QStringList>
45 #ifndef DISABLE_PYCONSOLE
46 class PyConsole_Console;
47 class PyConsole_Interp;
49 class LightApp_WidgetContainer;
50 class LightApp_Preferences;
51 class LightApp_SelectionMgr;
52 class LightApp_FullScreenHelper;
53 class LightApp_DataObject;
54 class SUIT_DataBrowser;
67 #pragma warning( disable:4251 )
71 Description : Application containing only LightApp module
74 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
79 typedef enum { WT_ObjectBrowser,
81 #ifndef DISABLE_PYCONSOLE
88 enum { MenuWindowId = 6 };
90 enum { RenameId = CAM_Application::UserID,
91 CloseId, CloseAllId, GroupAllId,
92 PreferencesId, MRUId, ModulesListId,
93 NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId,
94 NewQxSceneViewId, NewGraphicsViewId, NewPVViewId, NewPyViewerId, StyleId, FullScreenId,
95 WebSiteId, ForumId, VideosId, TutorialsId,
99 enum { NewStudyId = 1, OpenStudyId };
101 enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
104 LightApp_Application();
105 virtual ~LightApp_Application();
107 virtual QString applicationName() const;
108 virtual QString applicationVersion() const;
110 virtual CAM_Module* loadModule( const QString&, const bool = true );
111 virtual bool activateModule( const QString& );
113 LightApp_SelectionMgr* selectionMgr() const;
115 LogWindow* logWindow();
116 SUIT_DataBrowser* objectBrowser();
117 QtxInfoPanel* infoPanel();
118 #ifndef DISABLE_PYCONSOLE
119 PyConsole_Console* pythonConsole(const bool force = false);
122 virtual void updateObjectBrowser( const bool = true );
124 LightApp_Preferences* preferences() const;
126 virtual QString getFileFilter( bool ) const;
128 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
129 const QString& caption, QWidget* parent );
130 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
131 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
132 const QString& caption, QWidget* parent );
134 void updateActions();
136 SUIT_ViewManager* getViewManager( const QString&, const bool );
137 virtual void addViewManager( SUIT_ViewManager* );
138 virtual void removeViewManager( SUIT_ViewManager* );
139 virtual SUIT_ViewManager* createViewManager( const QString& vmType, bool detached = false );
140 virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
141 virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
143 QWidget* getWindow( const int );
144 QWidget* dockWindow( const int ) const;
145 void removeDockWindow( const int );
146 void insertDockWindow( const int, QWidget* );
147 void placeDockWindow( const int, Qt::DockWidgetArea );
149 virtual void start();
150 virtual void closeApplication();
152 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
154 virtual void createEmptyStudy();
156 virtual void setDesktop( SUIT_Desktop* );
158 SUIT_Accel* accel() const;
160 void setDefaultStudyName( const QString& theName );
162 virtual bool event( QEvent* );
164 virtual bool checkDataObject( LightApp_DataObject* theObj );
166 virtual void updateDesktopTitle();
168 //! Returns list of view manager types which are supported by this application
169 QStringList viewManagersTypes() const;
171 //! Removes ViewManagers only of known type
172 virtual void clearKnownViewManagers();
174 virtual QString browseObjects( const QStringList& theEntryList,
175 const bool theIsApplyAndClose = true,
176 const bool theIsOptimizedBrowsing = false );
178 virtual SUIT_DataObject* findObject( const QString& ) const;
180 virtual bool renameAllowed( const QString& ) const;
181 virtual bool renameObject( const QString&, const QString& );
183 void emitOperationFinished( const QString&, const QString&, const QStringList& );
185 void updateVisibilityState( DataObjectList& theList,
186 SUIT_ViewModel* theViewModel );
188 void updatePresentations( const QString& theComponent,
189 const QStringList& theViewManagerTypes );
191 virtual bool checkExistingDoc( bool = true );
193 #ifndef DISABLE_PYCONSOLE
194 PyConsole_Interp* getPyInterp();
198 void moduleActivated( const QString& );
202 void preferenceChanged( const QString&, const QString&, const QString& );
203 void preferenceResetToDefaults();
204 void operationFinished( const QString&, const QString&, const QStringList& );
207 virtual void onHelpContentsModule();
208 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
209 virtual void onNewDoc();
210 virtual void onOpenDoc();
212 virtual void onHelpAbout();
213 virtual bool onOpenDoc( const QString& );
214 virtual void onCopy();
215 virtual void onPaste();
216 virtual void onSelectionChanged();
217 virtual void onDockWindowVisibilityChanged( bool );
220 void showHelp( const QString& );
221 virtual void createActions();
222 virtual void customize();
223 virtual void createActionForViewer( const int id,
225 const QString& suffix,
227 virtual SUIT_Study* createNewStudy();
228 virtual QWidget* createWindow( const int );
229 virtual void defaultWindows( QMap<int, int>& ) const;
230 void defaultViewManagers( QStringList& ) const;
232 virtual void setActiveStudy( SUIT_Study* );
233 virtual void updateCommandsStatus();
235 virtual bool canOpenDoc( const QString& );
237 virtual void beforeCloseDoc( SUIT_Study* );
238 virtual void afterCloseDoc();
239 virtual void moduleAdded( CAM_Module* );
240 virtual void moduleDeactivated( CAM_Module* );
241 virtual bool activateModule( CAM_Module* = 0 );
243 LightApp_Preferences* preferences( const bool ) const;
244 virtual void createPreferences( LightApp_Preferences* );
245 virtual void preferencesChanged( const QString&, const QString& );
247 virtual void loadPreferences();
248 virtual void savePreferences();
250 virtual QMap<int, QString> activateModuleActions() const;
251 virtual void moduleActionSelected( const int );
253 #ifndef DISABLE_PYCONSOLE
254 virtual PyConsole_Interp* createPyInterp();
257 virtual void addCatalogue( const QString&, const QString& ) {}
260 virtual void onDesktopActivated();
261 virtual void onViewManagerRemoved( SUIT_ViewManager* );
262 virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
265 virtual void onModuleActivation( const QString& );
266 void onModuleAdding();
267 void onModuleRemoving( const QString& );
268 void onCloseView( SUIT_ViewManager* );
270 virtual void onStudyCreated( SUIT_Study* );
271 virtual void onStudyOpened( SUIT_Study* );
272 virtual void onStudySaved( SUIT_Study* );
273 virtual void onStudyClosed( SUIT_Study* );
275 void onWCDestroyed( QObject* );
277 void onMRUActivated( const QString& );
279 void onStylePreferences();
282 virtual void onDesktopMessage( const QString& );
284 virtual void onInfoPanelShown();
289 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
290 void onPreferences();
291 void onPreferenceChanged( QString&, QString&, QString& );
292 void onRenameWindow();
293 void onCloseWindow();
294 void onCloseAllWindow();
295 void onGroupAllWindow();
300 void updateWindows();
301 void updateViewManagers();
302 void updateModuleActions();
304 bool checkModule( const QString& );
306 void loadDockWindowsState();
307 void saveDockWindowsState();
309 virtual void studyOpened( SUIT_Study* );
310 virtual void studyCreated( SUIT_Study* );
311 virtual void studySaved( SUIT_Study* );
313 void updatePreference( const QString&, const QString&, const QString& );
315 QString defaultModule() const;
316 virtual void currentWindows( QMap<int, int>& ) const;
317 void currentViewManagers( QStringList& ) const;
318 QPixmap moduleIcon( const QString&, const int = -1 ) const;
320 QDockWidget* windowDock( QWidget* ) const;
321 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
322 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
324 virtual int openChoice( const QString& );
325 virtual bool openAction( const int, const QString& );
327 void showPreferences( const QString& = QString() );
328 void showPreferences( const QStringList& );
331 bool addUserModule( const QString&, const QString&, bool = false );
332 void emptyPreferences( const QString& );
333 QList<QToolBar*> findToolBars( const QStringList& names = QStringList() );
334 void createHelpItems( const QString& );
335 void removeHelpItems( const QString& );
337 QByteArray processState(QByteArray& input,
338 const bool processWin,
339 const bool processTb,
340 const bool isRestoring,
341 QByteArray defaultState = QByteArray());
344 typedef QPointer<QWidget> WinPtr;
345 typedef QMap<int, WinPtr> WinMap;
346 typedef QMap<QString, QByteArray> WinVis;
347 typedef QMap<QString, QByteArray> WinGeom;
348 typedef QList<int> IdList;
349 typedef QMap<QString, IdList> IdMap;
351 enum { OpenReload = CAM_Application::OpenExist + 1 };
354 LightApp_Preferences* myPrefs;
355 LightApp_SelectionMgr* mySelMgr;
357 LightApp_FullScreenHelper* myScreenHelper;
364 QTimer* myAutoSaveTimer;
366 static LightApp_Preferences* _prefs_;
368 QStringList myUserWmTypes;
370 friend void LightAppCleanUpAppResources();
374 #pragma warning( default:4251 )