Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LightApp_Application.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File: LightApp_Application.h
24 // Created: 6/20/2005 18:39:25 PM
25 // Author: OCC team
26 
27 #ifndef LIGHTAPP_APPLICATION_H
28 #define LIGHTAPP_APPLICATION_H
29 
30 #if _MSC_VER > 1000
31 #pragma once
32 #endif // _MSC_VER > 1000
33 
34 #include "LightApp.h"
35 #include <SUIT_TreeModel.h>
36 #include <SUIT_DataObject.h>
37 #include <CAM_Application.h>
38 
39 #include <QPointer>
40 #include <QStringList>
41 
42 class LogWindow;
43 #ifndef DISABLE_PYCONSOLE
44 class PyConsole_Console;
45 class PyConsole_Interp;
46 #endif
47 class LightApp_WidgetContainer;
52 class SUIT_DataBrowser;
53 class SUIT_Study;
54 class SUIT_Accel;
55 class SUIT_ViewModel;
56 class CAM_Module;
57 
58 class QString;
59 class QWidget;
60 class QStringList;
61 class QDockWidget;
62 class QTimer;
63 
64 #ifdef WIN32
65 #pragma warning( disable:4251 )
66 #endif
67 
73 {
74  Q_OBJECT
75 
76 public:
77  typedef enum { WT_ObjectBrowser,
78 #ifndef DISABLE_PYCONSOLE
80 #endif
83  WindowTypes;
84 
85  enum { MenuWindowId = 6 };
86 
87  enum { RenameId = CAM_Application::UserID,
88  CloseId, CloseAllId, GroupAllId,
89  PreferencesId, MRUId, ModulesListId,
90  NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId,
91  NewQxSceneViewId, NewGraphicsViewId, NewPVViewId, NewPyViewerId, StyleId, FullScreenId,
92  UserID };
93 
94 protected:
95  enum { NewStudyId = 1, OpenStudyId };
96 
97  enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
98 
99 public:
101  virtual ~LightApp_Application();
102 
103  virtual QString applicationName() const;
104  virtual QString applicationVersion() const;
105 
106  virtual CAM_Module* loadModule( const QString&, const bool = true );
107  virtual bool activateModule( const QString& );
108 
109  LightApp_SelectionMgr* selectionMgr() const;
110 
111  LogWindow* logWindow();
112  SUIT_DataBrowser* objectBrowser();
113 #ifndef DISABLE_PYCONSOLE
114  PyConsole_Console* pythonConsole(const bool force = false);
115 #endif
116 
117  virtual void updateObjectBrowser( const bool = true );
118 
119  LightApp_Preferences* preferences() const;
120 
121  virtual QString getFileFilter( bool ) const;
122 
123  virtual QString getFileName( bool open, const QString& initial, const QString& filters,
124  const QString& caption, QWidget* parent );
125  virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
126  virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
127  const QString& caption, QWidget* parent );
128 
129  void updateActions();
130 
131  SUIT_ViewManager* getViewManager( const QString&, const bool );
132  virtual void addViewManager( SUIT_ViewManager* );
133  virtual void removeViewManager( SUIT_ViewManager* );
134  virtual SUIT_ViewManager* createViewManager( const QString& vmType, bool detached = false );
135  virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
136  virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
137 
138  QWidget* getWindow( const int, const int = -1 );
139  QWidget* dockWindow( const int ) const;
140  void removeDockWindow( const int );
141  void insertDockWindow( const int, QWidget* );
142  void placeDockWindow( const int, Qt::DockWidgetArea );
143 
144  virtual void start();
145  virtual void closeApplication();
146 
147  virtual void contextMenuPopup( const QString&, QMenu*, QString& );
148 
149  virtual void createEmptyStudy();
150 
151  virtual void setDesktop( SUIT_Desktop* );
152 
153  SUIT_Accel* accel() const;
154 
155  void setDefaultStudyName( const QString& theName );
156 
157  static int studyId();
158 
159  virtual bool event( QEvent* );
160 
161  virtual bool checkDataObject( LightApp_DataObject* theObj );
162 
163  virtual void updateDesktopTitle();
164 
166  QStringList viewManagersTypes() const;
167 
169  virtual void clearKnownViewManagers();
170 
171  virtual QString browseObjects( const QStringList& theEntryList,
172  const bool theIsApplyAndClose = true,
173  const bool theIsOptimizedBrowsing = false );
174 
175  virtual SUIT_DataObject* findObject( const QString& ) const;
176 
177  virtual bool renameAllowed( const QString& ) const;
178  virtual bool renameObject( const QString&, const QString& );
179 
180  void emitOperationFinished( const QString&, const QString&, const QStringList& );
181 
182  void updateVisibilityState( DataObjectList& theList,
183  SUIT_ViewModel* theViewModel );
184 
185  virtual bool checkExistingDoc();
186 
187 #ifndef DISABLE_PYCONSOLE
188  PyConsole_Interp* getPyInterp();
189 #endif
190 
191 signals:
192  void studyOpened();
193  void studySaved();
194  void studyClosed();
195  void preferenceChanged( const QString&, const QString&, const QString& );
196  void preferenceResetToDefaults();
197  void operationFinished( const QString&, const QString&, const QStringList& );
198 
199 public slots:
200  virtual void onHelpContentsModule();
201  virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
202  virtual void onNewDoc();
203  virtual void onOpenDoc();
204 
205  virtual void onHelpAbout();
206  virtual bool onOpenDoc( const QString& );
207  virtual void onCopy();
208  virtual void onPaste();
209  virtual void onSelectionChanged();
210  virtual void onDockWindowVisibilityChanged( bool );
211 
212 protected:
213  virtual void createActions();
214  virtual void createActionForViewer( const int id,
215  const int parentId,
216  const QString& suffix,
217  const int accel );
218  virtual SUIT_Study* createNewStudy();
219  virtual QWidget* createWindow( const int );
220  virtual void defaultWindows( QMap<int, int>& ) const;
221  void defaultViewManagers( QStringList& ) const;
222 
223  virtual void setActiveStudy( SUIT_Study* );
224  virtual void updateCommandsStatus();
225 
226  virtual void beforeCloseDoc( SUIT_Study* );
227  virtual void afterCloseDoc();
228  virtual void moduleAdded( CAM_Module* );
229  virtual bool activateModule( CAM_Module* = 0 );
230 
231  LightApp_Preferences* preferences( const bool ) const;
232  virtual void createPreferences( LightApp_Preferences* );
233  virtual void preferencesChanged( const QString&, const QString& );
234 
235  virtual void loadPreferences();
236  virtual void savePreferences();
237 
238  virtual QMap<int, QString> activateModuleActions() const;
239  virtual void moduleActionSelected( const int );
240 
241 #ifndef DISABLE_PYCONSOLE
242  virtual PyConsole_Interp* createPyInterp();
243 #endif
244 
245 protected slots:
246  virtual void onDesktopActivated();
247  virtual void onViewManagerRemoved( SUIT_ViewManager* );
248  virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
249 
250  void onNewWindow();
251  void onModuleActivation( const QString& );
252  void onCloseView( SUIT_ViewManager* );
253 
254  virtual void onStudyCreated( SUIT_Study* );
255  virtual void onStudyOpened( SUIT_Study* );
256  virtual void onStudySaved( SUIT_Study* );
257  virtual void onStudyClosed( SUIT_Study* );
258 
259  void onWCDestroyed( QObject* );
260 
261  void onMRUActivated( const QString& );
262 
263  void onStylePreferences();
264  void onFullScreen();
265 
266  virtual void onDesktopMessage( const QString& );
267 
268 private slots:
269  void onSelection();
270  void onRefresh();
271  void onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
272  void onPreferences();
273  void onPreferenceChanged( QString&, QString&, QString& );
274  void onRenameWindow();
275  void onCloseWindow();
276  void onCloseAllWindow();
277  void onGroupAllWindow();
278  void onRenamed();
279  //void onMoved();
280 
281 protected:
282  void updateWindows();
283  void updateViewManagers();
284  void updateModuleActions();
285  void removeModuleAction( const QString& );
286 
287  void loadDockWindowsState();
288  void saveDockWindowsState();
289 
290  virtual void studyOpened( SUIT_Study* );
291  virtual void studyCreated( SUIT_Study* );
292  virtual void studySaved( SUIT_Study* );
293 
294  void updatePreference( const QString&, const QString&, const QString& );
295 
296  QString defaultModule() const;
297  virtual void currentWindows( QMap<int, int>& ) const;
298  void currentViewManagers( QStringList& ) const;
299  void moduleIconNames( QMap<QString, QString>& ) const;
300 
301  bool isLibExists( const QString& ) const;
302 
303  QDockWidget* windowDock( QWidget* ) const;
304  QByteArray dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
305  void dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
306 
307  virtual int openChoice( const QString& );
308  virtual bool openAction( const int, const QString& );
309 
310  void showPreferences( const QString& = QString() );
311 
312 private:
313  void emptyPreferences( const QString& );
314  QList<QToolBar*> findToolBars( const QStringList& names = QStringList() );
315 
316  QByteArray processState(QByteArray& input,
317  const bool processWin,
318  const bool processTb,
319  const bool isRestoring,
320  QByteArray defaultState = QByteArray());
321 
322 protected:
323  typedef QPointer<QWidget> WinPtr;
324  typedef QMap<int, WinPtr> WinMap;
325  typedef QMap<QString, QByteArray> WinVis;
326  typedef QMap<QString, QByteArray> WinGeom;
327 
328  enum { OpenReload = CAM_Application::OpenExist + 1 };
329 
330 protected:
333 
335 
338 
341 
343 
344  static int lastStudyId;
345  QStringList myUserWmTypes;
346 };
347 
348 #ifdef WIN32
349 #pragma warning( default:4251 )
350 #endif
351 
352 #endif