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>
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 void updatePresentations( const QString& theComponent,
188 const QStringList& theViewManagerTypes );
190 virtual bool checkExistingDoc( bool = true );
192 #ifndef DISABLE_PYCONSOLE
193 PyConsole_Interp* getPyInterp();
200 void preferenceChanged( const QString&, const QString&, const QString& );
201 void preferenceResetToDefaults();
202 void operationFinished( const QString&, const QString&, const QStringList& );
205 virtual void onHelpContentsModule();
206 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
207 virtual void onNewDoc();
208 virtual void onOpenDoc();
210 virtual void onHelpAbout();
211 virtual bool onOpenDoc( const QString& );
212 virtual void onCopy();
213 virtual void onPaste();
214 virtual void onSelectionChanged();
215 virtual void onDockWindowVisibilityChanged( bool );
218 void showHelp( const QString& );
219 virtual void createActions();
220 virtual void createActionForViewer( const int id,
222 const QString& suffix,
224 virtual SUIT_Study* createNewStudy();
225 virtual QWidget* createWindow( const int );
226 virtual void defaultWindows( QMap<int, int>& ) const;
227 void defaultViewManagers( QStringList& ) const;
229 virtual void setActiveStudy( SUIT_Study* );
230 virtual void updateCommandsStatus();
232 virtual bool canOpenDoc( const QString& );
234 virtual void beforeCloseDoc( SUIT_Study* );
235 virtual void afterCloseDoc();
236 virtual void moduleAdded( CAM_Module* );
237 virtual void moduleDeactivated( CAM_Module* );
238 virtual bool activateModule( CAM_Module* = 0 );
240 LightApp_Preferences* preferences( const bool ) const;
241 virtual void createPreferences( LightApp_Preferences* );
242 virtual void preferencesChanged( const QString&, const QString& );
244 virtual void loadPreferences();
245 virtual void savePreferences();
247 virtual QMap<int, QString> activateModuleActions() const;
248 virtual void moduleActionSelected( const int );
250 #ifndef DISABLE_PYCONSOLE
251 virtual PyConsole_Interp* createPyInterp();
255 virtual void onDesktopActivated();
256 virtual void onViewManagerRemoved( SUIT_ViewManager* );
257 virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
260 virtual void onModuleActivation( const QString& );
261 void onCloseView( SUIT_ViewManager* );
263 virtual void onStudyCreated( SUIT_Study* );
264 virtual void onStudyOpened( SUIT_Study* );
265 virtual void onStudySaved( SUIT_Study* );
266 virtual void onStudyClosed( SUIT_Study* );
268 void onWCDestroyed( QObject* );
270 void onMRUActivated( const QString& );
272 void onStylePreferences();
275 virtual void onDesktopMessage( const QString& );
277 virtual void onInfoPanelShown();
282 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
283 void onPreferences();
284 void onPreferenceChanged( QString&, QString&, QString& );
285 void onRenameWindow();
286 void onCloseWindow();
287 void onCloseAllWindow();
288 void onGroupAllWindow();
293 void updateWindows();
294 void updateViewManagers();
295 void updateModuleActions();
296 void removeModuleAction( const QString& );
298 bool checkModule( const QString& );
300 void loadDockWindowsState();
301 void saveDockWindowsState();
303 virtual void studyOpened( SUIT_Study* );
304 virtual void studyCreated( SUIT_Study* );
305 virtual void studySaved( SUIT_Study* );
307 void updatePreference( const QString&, const QString&, const QString& );
309 QString defaultModule() const;
310 virtual void currentWindows( QMap<int, int>& ) const;
311 void currentViewManagers( QStringList& ) const;
312 void moduleIconNames( QMap<QString, QString>& ) const;
314 QDockWidget* windowDock( QWidget* ) const;
315 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
316 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
318 virtual int openChoice( const QString& );
319 virtual bool openAction( const int, const QString& );
321 void showPreferences( const QString& = QString() );
322 void showPreferences( const QStringList& );
325 void emptyPreferences( const QString& );
326 QList<QToolBar*> findToolBars( const QStringList& names = QStringList() );
328 QByteArray processState(QByteArray& input,
329 const bool processWin,
330 const bool processTb,
331 const bool isRestoring,
332 QByteArray defaultState = QByteArray());
335 typedef QPointer<QWidget> WinPtr;
336 typedef QMap<int, WinPtr> WinMap;
337 typedef QMap<QString, QByteArray> WinVis;
338 typedef QMap<QString, QByteArray> WinGeom;
340 enum { OpenReload = CAM_Application::OpenExist + 1 };
343 LightApp_Preferences* myPrefs;
344 LightApp_SelectionMgr* mySelMgr;
346 LightApp_FullScreenHelper* myScreenHelper;
352 QTimer* myAutoSaveTimer;
354 static LightApp_Preferences* _prefs_;
356 QStringList myUserWmTypes;
358 friend void LightAppCleanUpAppResources();
362 #pragma warning( default:4251 )