1 // Copyright (C) 2007-2013 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.
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 <CAM_Application.h>
39 #include <QStringList>
42 #ifndef DISABLE_PYCONSOLE
43 class PyConsole_Console;
45 class LightApp_WidgetContainer;
46 class LightApp_Preferences;
47 class LightApp_SelectionMgr;
48 class LightApp_FullScreenHelper;
49 class LightApp_DataObject;
50 class SUIT_DataBrowser;
62 #pragma warning( disable:4251 )
66 Description : Application containing only LightApp module
69 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
74 typedef enum { WT_ObjectBrowser,
75 #ifndef DISABLE_PYCONSOLE
82 enum { MenuWindowId = 6 };
84 enum { RenameId = CAM_Application::UserID,
85 CloseId, CloseAllId, GroupAllId,
86 PreferencesId, MRUId, ModulesListId,
87 NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId,
88 NewQxSceneViewId, NewGraphicsViewId, StyleId, FullScreenId,
92 enum { NewStudyId = 1, OpenStudyId };
94 enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
97 LightApp_Application();
98 virtual ~LightApp_Application();
100 virtual QString applicationName() const;
101 virtual QString applicationVersion() const;
103 virtual CAM_Module* loadModule( const QString&, const bool = true );
104 virtual bool activateModule( const QString& );
106 LightApp_SelectionMgr* selectionMgr() const;
108 LogWindow* logWindow();
109 SUIT_DataBrowser* objectBrowser();
110 #ifndef DISABLE_PYCONSOLE
111 PyConsole_Console* pythonConsole(const bool force = false);
114 virtual void updateObjectBrowser( const bool = true );
116 LightApp_Preferences* preferences() const;
118 virtual QString getFileFilter() const;
120 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
121 const QString& caption, QWidget* parent );
122 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
123 virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
124 const QString& caption, QWidget* parent );
126 void updateActions();
128 SUIT_ViewManager* getViewManager( const QString&, const bool );
129 virtual void addViewManager( SUIT_ViewManager* );
130 virtual void removeViewManager( SUIT_ViewManager* );
131 virtual SUIT_ViewManager* createViewManager( const QString& vmType );
132 virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
134 QWidget* getWindow( const int, const int = -1 );
135 QWidget* dockWindow( const int ) const;
136 void removeDockWindow( const int );
137 void insertDockWindow( const int, QWidget* );
138 void placeDockWindow( const int, Qt::DockWidgetArea );
140 virtual void start();
142 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
144 virtual void createEmptyStudy();
146 virtual void setDesktop( SUIT_Desktop* );
148 SUIT_Accel* accel() const;
150 void setDefaultStudyName( const QString& theName );
152 static int studyId();
154 virtual bool event( QEvent* );
156 virtual bool checkDataObject( LightApp_DataObject* theObj );
158 virtual void updateDesktopTitle();
160 //! Returns list of view manager types which are supported by this application
161 QStringList viewManagersTypes() const;
163 //! Removes ViewManagers only of known type
164 virtual void clearKnownViewManagers();
166 virtual QString browseObjects( const QStringList& theEntryList,
167 const bool theIsApplyAndClose = true,
168 const bool theIsOptimizedBrowsing = false );
170 virtual SUIT_DataObject* findObject( const QString& ) const;
172 virtual bool renameAllowed( const QString& ) const;
173 virtual bool renameObject( const QString&, const QString& );
175 void emitOperationFinished( const QString&, const QString&, const QStringList& );
181 void preferenceChanged( const QString&, const QString&, const QString& );
182 void operationFinished( const QString&, const QString&, const QStringList& );
185 virtual void onHelpContentsModule();
186 virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
187 virtual void onNewDoc();
188 virtual void onOpenDoc();
189 virtual void onHelpAbout();
190 virtual bool onOpenDoc( const QString& );
191 virtual void onCopy();
192 virtual void onPaste();
193 virtual void onSelectionChanged();
194 virtual void onCloseDoc( bool ask = true);
197 virtual void createActions();
198 virtual void createActionForViewer( const int id,
200 const QString& suffix,
202 virtual SUIT_Study* createNewStudy();
203 virtual QWidget* createWindow( const int );
204 virtual void defaultWindows( QMap<int, int>& ) const;
205 void defaultViewManagers( QStringList& ) const;
207 virtual void setActiveStudy( SUIT_Study* );
208 virtual void updateCommandsStatus();
210 virtual void beforeCloseDoc( SUIT_Study* );
211 virtual void afterCloseDoc();
212 virtual void moduleAdded( CAM_Module* );
213 virtual bool activateModule( CAM_Module* = 0 );
215 LightApp_Preferences* preferences( const bool ) const;
216 virtual void createPreferences( LightApp_Preferences* );
217 virtual void preferencesChanged( const QString&, const QString& );
219 virtual void loadPreferences();
220 virtual void savePreferences();
222 virtual QMap<int, QString> activateModuleActions() const;
223 virtual void moduleActionSelected( const int );
226 virtual void onDesktopActivated();
229 void onModuleActivation( const QString& );
230 void onCloseView( SUIT_ViewManager* );
232 void onStudyCreated( SUIT_Study* );
233 void onStudyOpened( SUIT_Study* );
234 void onStudySaved( SUIT_Study* );
235 void onStudyClosed( SUIT_Study* );
237 void onWCDestroyed( QObject* );
239 void onMRUActivated( const QString& );
241 void onStylePreferences();
244 virtual void onDesktopMessage( const QString& );
249 void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
250 void onPreferences();
251 void onPreferenceChanged( QString&, QString&, QString& );
252 void onRenameWindow();
253 void onCloseWindow();
254 void onCloseAllWindow();
255 void onGroupAllWindow();
258 void updateWindows();
259 void updateViewManagers();
260 void updateModuleActions();
261 void removeModuleAction( const QString& );
263 void loadDockWindowsState();
264 void saveDockWindowsState();
266 virtual void studyOpened( SUIT_Study* );
267 virtual void studyCreated( SUIT_Study* );
268 virtual void studySaved( SUIT_Study* );
270 void updatePreference( const QString&, const QString&, const QString& );
272 QString defaultModule() const;
273 virtual void currentWindows( QMap<int, int>& ) const;
274 void currentViewManagers( QStringList& ) const;
275 void moduleIconNames( QMap<QString, QString>& ) const;
277 bool isLibExists( const QString& ) const;
279 QDockWidget* windowDock( QWidget* ) const;
280 QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
281 void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
283 virtual int openChoice( const QString& );
284 virtual bool openAction( const int, const QString& );
286 void showPreferences( const QString& = QString() );
289 void emptyPreferences( const QString& );
290 QList<QToolBar*> findToolBars();
292 QByteArray processState(QByteArray& input, const bool processWin,const bool processTb, QByteArray defaultState = QByteArray());
295 typedef QPointer<QWidget> WinPtr;
296 typedef QMap<int, WinPtr> WinMap;
297 typedef QMap<QString, QByteArray> WinVis;
298 typedef QMap<QString, QByteArray> WinGeom;
300 enum { OpenReload = CAM_Application::OpenExist + 1 };
303 LightApp_Preferences* myPrefs;
304 LightApp_SelectionMgr* mySelMgr;
306 LightApp_FullScreenHelper* myScreenHelper;
312 QTimer* myAutoSaveTimer;
314 static LightApp_Preferences* _prefs_;
316 static int lastStudyId;
317 QStringList myUserWmTypes;
321 #pragma warning( default:4251 )