1 // Copyright (C) 2007-2023 CEA, EDF, 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 LightApp_ModuleAction;
55 class SUIT_DataBrowser;
68 #pragma warning( disable:4251 )
72 Description : Application containing only LightApp module
75 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
80 typedef enum { WT_ObjectBrowser,
82 #ifndef DISABLE_PYCONSOLE
89 enum { MenuWindowId = 6 };
91 enum { RenameId = CAM_Application::UserID,
92 CloseId, CloseAllId, GroupAllId,
93 PreferencesId, MRUId, ModulesListId,
94 NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId,
95 NewQxSceneViewId, NewGraphicsViewId, NewPVViewId, NewPyViewerId, NewPV3DViewId, StyleId, FullScreenId,
96 WebSiteId, ForumId, VideosId, TutorialsId,
100 enum { NewStudyId = 1, OpenStudyId };
102 enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
105 LightApp_Application();
106 virtual ~LightApp_Application();
108 virtual QString applicationName() const;
109 virtual QString applicationVersion() const;
111 virtual CAM_Module* loadModule( const QString&, const bool = true );
112 virtual bool activateModule( const QString& );
114 LightApp_SelectionMgr* selectionMgr() const;
116 LogWindow* logWindow();
117 SUIT_DataBrowser* objectBrowser();
118 QtxInfoPanel* infoPanel();
119 #ifndef DISABLE_PYCONSOLE
120 PyConsole_Console* pythonConsole(const bool force = false);
123 virtual void updateObjectBrowser( const bool = true );
125 LightApp_Preferences* preferences() const;
127 virtual QString getFileFilter( bool ) const;
129 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
130 const QString& caption, QWidget* parent );
131 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
132 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
133 const QString& caption, QWidget* parent );
135 void updateActions();
137 SUIT_ViewManager* getViewManager( const QString&, const bool );
138 virtual void addViewManager( SUIT_ViewManager* );
139 virtual void removeViewManager( SUIT_ViewManager* );
140 virtual SUIT_ViewManager* createViewManager( const QString& vmType, bool detached = false );
141 virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
142 virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
144 QWidget* getWindow( const int );
145 QWidget* dockWindow( const int ) const;
146 void removeDockWindow( const int );
147 void insertDockWindow( const int, QWidget* );
148 void placeDockWindow( const int, Qt::DockWidgetArea );
150 virtual void start();
151 virtual void closeApplication();
153 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
155 virtual void createEmptyStudy();
157 virtual void setDesktop( SUIT_Desktop* );
159 SUIT_Accel* accel() const;
161 void setDefaultStudyName( const QString& theName );
163 virtual bool event( QEvent* );
165 virtual bool checkDataObject( LightApp_DataObject* theObj );
167 virtual void updateDesktopTitle();
169 //! Returns list of view manager types which are supported by this application
170 QStringList viewManagersTypes() const;
172 //! Removes ViewManagers only of known type
173 virtual void clearKnownViewManagers();
175 virtual QString browseObjects( const QStringList& theEntryList,
176 const bool theIsApplyAndClose = true,
177 const bool theIsOptimizedBrowsing = false );
179 virtual SUIT_DataObject* findObject( const QString& ) const;
181 virtual bool renameAllowed( const QString& ) const;
182 virtual bool renameObject( const QString&, const QString& );
184 void emitOperationFinished( const QString&, const QString&, const QStringList& );
186 void updateVisibilityState( DataObjectList& theList,
187 SUIT_ViewModel* theViewModel );
189 void updatePresentations( const QString& theComponent,
190 const QStringList& theViewManagerTypes );
192 virtual bool checkExistingDoc( bool = true );
194 #ifndef DISABLE_PYCONSOLE
195 PyConsole_Interp* getPyInterp();
199 void moduleActivated( const QString& );
203 void preferenceChanged( const QString&, const QString&, const QString& );
204 void preferenceResetToDefaults();
205 void operationFinished( const QString&, const QString&, const QStringList& );
208 virtual void onHelpContentsModule();
209 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
210 virtual void onNewDoc();
211 virtual void onOpenDoc();
213 virtual void onHelpAbout();
214 virtual bool onOpenDoc( const QString& );
215 virtual void onCopy();
216 virtual void onPaste();
217 virtual void onSelectionChanged();
218 virtual void onDockWindowVisibilityChanged( bool );
221 void showHelp( const QString& );
222 virtual void createActions();
223 virtual void addExtensionsActions(LightApp_ModuleAction* moduleAction);
224 virtual void customize();
225 virtual void createActionForViewer( const int id,
227 const QString& suffix,
229 virtual SUIT_Study* createNewStudy();
230 virtual QWidget* createWindow( const int );
231 virtual void defaultWindows( QMap<int, int>& ) const;
232 void defaultViewManagers( QStringList& ) const;
234 virtual void setActiveStudy( SUIT_Study* );
235 virtual void updateCommandsStatus();
237 virtual bool canOpenDoc( const QString& );
239 virtual void beforeCloseDoc( SUIT_Study* );
240 virtual void afterCloseDoc();
241 virtual void moduleAdded( CAM_Module* );
242 virtual void moduleDeactivated( CAM_Module* );
243 virtual bool activateModule( CAM_Module* = 0 );
245 LightApp_Preferences* preferences( const bool ) const;
246 virtual void createPreferences( LightApp_Preferences* );
247 virtual void preferencesChanged( const QString&, const QString& );
249 virtual void loadPreferences();
250 virtual void savePreferences();
252 virtual QMap<int, QString> activateModuleActions() const;
253 virtual void moduleActionSelected( const int );
255 #ifndef DISABLE_PYCONSOLE
256 virtual PyConsole_Interp* createPyInterp();
259 virtual void addCatalogue( const QString&, const QString& ) {}
262 virtual void onDesktopActivated();
263 virtual void onViewManagerRemoved( SUIT_ViewManager* );
264 virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
267 virtual void onModuleActivation( const QString& );
269 void onExtRemoving( const QString& );
270 void onShowExtInfo();
271 void onCloseView( SUIT_ViewManager* );
273 virtual void onStudyCreated( SUIT_Study* );
274 virtual void onStudyOpened( SUIT_Study* );
275 virtual void onStudySaved( SUIT_Study* );
276 virtual void onStudyClosed( SUIT_Study* );
278 void onWCDestroyed( QObject* );
280 void onMRUActivated( const QString& );
282 void onStylePreferences();
285 virtual void onDesktopMessage( const QString& );
287 virtual void onInfoPanelShown();
292 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
293 void onPreferences();
294 void onPreferenceChanged( QString&, QString&, QString& );
295 void onRenameWindow();
296 void onCloseWindow();
297 void onCloseAllWindow();
298 void onGroupAllWindow();
303 void updateWindows();
304 void updateViewManagers();
305 void updateModuleActions();
307 bool checkModule( const QString& );
309 void loadDockWindowsState();
310 void saveDockWindowsState();
312 virtual void studyOpened( SUIT_Study* );
313 virtual void studyCreated( SUIT_Study* );
314 virtual void studySaved( SUIT_Study* );
316 void updatePreference( const QString&, const QString&, const QString& );
318 QString defaultModule() const;
319 virtual void currentWindows( QMap<int, int>& ) const;
320 void currentViewManagers( QStringList& ) const;
321 QPixmap moduleIcon( const QString&, const int = -1 ) const;
323 QDockWidget* windowDock( QWidget* ) const;
324 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
325 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
327 virtual int openChoice( const QString& );
328 virtual bool openAction( const int, const QString& );
330 void showPreferences( const QString& = QString() );
331 void showPreferences( const QStringList& );
334 bool addUserModule( const QString&, const QString&, bool = false );
335 void removeUserModule(const QString& moduleInnerName, LightApp_ModuleAction* moduleAction);
336 void emptyPreferences( const QString& );
337 QList<QToolBar*> findToolBars( const QStringList& names = QStringList() );
338 void createHelpItems( const QString& );
339 void removeHelpItems( const QString& );
340 void updateSalomeApprc();
342 QByteArray processState(QByteArray& input,
343 const bool processWin,
344 const bool processTb,
345 const bool isRestoring,
346 QByteArray defaultState = QByteArray());
349 typedef QPointer<QWidget> WinPtr;
350 typedef QMap<int, WinPtr> WinMap;
351 typedef QMap<QString, QByteArray> WinVis;
352 typedef QMap<QString, QByteArray> WinGeom;
353 typedef QList<int> IdList;
354 typedef QMap<QString, IdList> IdMap;
356 enum { OpenReload = CAM_Application::OpenExist + 1 };
359 LightApp_Preferences* myPrefs;
360 LightApp_SelectionMgr* mySelMgr;
362 LightApp_FullScreenHelper* myScreenHelper;
369 QTimer* myAutoSaveTimer;
371 static LightApp_Preferences* _prefs_;
373 QStringList myUserWmTypes;
375 friend void LightAppCleanUpAppResources();
379 #pragma warning( default:4251 )