Back to index

salome-gui  6.5.0
LightApp_Application.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      LightApp_Application.h
00024 // Created:   6/20/2005 18:39:25 PM
00025 // Author:    OCC team
00026 
00027 #ifndef LIGHTAPP_APPLICATION_H
00028 #define LIGHTAPP_APPLICATION_H
00029 
00030 #if _MSC_VER > 1000
00031 #pragma once
00032 #endif // _MSC_VER > 1000
00033 
00034 #include "LightApp.h"
00035 #include <SUIT_TreeModel.h>
00036 #include <CAM_Application.h>
00037 
00038 #include <QPointer>
00039 #include <QStringList>
00040 
00041 class LogWindow;
00042 #ifndef DISABLE_PYCONSOLE
00043 class PyConsole_Console;
00044 #endif
00045 class LightApp_WidgetContainer;
00046 class LightApp_Preferences;
00047 class LightApp_SelectionMgr;
00048 class LightApp_FullScreenHelper;
00049 class LightApp_DataObject;
00050 class SUIT_DataBrowser;
00051 class SUIT_Study;
00052 class SUIT_Accel;
00053 class CAM_Module;
00054 
00055 class QString;
00056 class QWidget;
00057 class QStringList;
00058 class QDockWidget;
00059 class QTimer;
00060 
00061 #ifdef WIN32
00062 #pragma warning( disable:4251 )
00063 #endif
00064 
00069 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
00070 {
00071   Q_OBJECT
00072 
00073 public:
00074   typedef enum { WT_ObjectBrowser,
00075 #ifndef DISABLE_PYCONSOLE
00076                  WT_PyConsole,
00077 #endif
00078                  WT_LogWindow,
00079                  WT_User }
00080   WindowTypes;
00081 
00082   enum { MenuWindowId = 6 };
00083 
00084   enum { RenameId = CAM_Application::UserID,
00085          CloseId, CloseAllId, GroupAllId,
00086          PreferencesId, MRUId, ModulesListId,
00087          NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
00088          NewQxSceneViewId = NewQxGraphViewId, StyleId, FullScreenId,
00089          UserID };
00090 
00091 protected:
00092   enum { NewStudyId = 1, OpenStudyId };
00093 
00094   enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
00095 
00096 public:
00097   LightApp_Application();
00098   virtual ~LightApp_Application();
00099 
00100   virtual QString                     applicationName() const;
00101   virtual QString                     applicationVersion() const;
00102 
00103   virtual CAM_Module*                 loadModule( const QString&, const bool = true );
00104   virtual bool                        activateModule( const QString& );
00105 
00106   LightApp_SelectionMgr*              selectionMgr() const;
00107 
00108   LogWindow*                          logWindow();
00109   SUIT_DataBrowser*                   objectBrowser();
00110 #ifndef DISABLE_PYCONSOLE
00111   PyConsole_Console*                  pythonConsole();
00112 #endif
00113 
00114   virtual void                        updateObjectBrowser( const bool = true );
00115 
00116   LightApp_Preferences*               preferences() const;
00117 
00118   virtual QString                     getFileFilter() const;
00119 
00120   virtual QString                     getFileName( bool open, const QString& initial, const QString& filters,
00121                                                    const QString& caption, QWidget* parent );
00122   virtual QString                     getDirectory( const QString& initial, const QString& caption, QWidget* parent );
00123   virtual QStringList                 getOpenFileNames( const QString& initial, const QString& filters,
00124                                                         const QString& caption, QWidget* parent );
00125 
00126   void                                updateActions();
00127 
00128   SUIT_ViewManager*                   getViewManager( const QString&, const bool );
00129   virtual void                        addViewManager( SUIT_ViewManager* );
00130   virtual void                        removeViewManager( SUIT_ViewManager* );
00131   virtual SUIT_ViewManager*           createViewManager( const QString& vmType );
00132   virtual SUIT_ViewManager*           createViewManager( const QString& vmType, QWidget* w );
00133 
00134   QWidget*                            getWindow( const int, const int = -1 );
00135   QWidget*                            dockWindow( const int ) const;
00136   void                                removeDockWindow( const int );
00137   void                                insertDockWindow( const int, QWidget* );
00138   void                                placeDockWindow( const int, Qt::DockWidgetArea );
00139 
00140   virtual void                        start();
00141 
00142   virtual void                        contextMenuPopup( const QString&, QMenu*, QString& );
00143 
00144   virtual void                        createEmptyStudy();
00145 
00146   virtual void                        setDesktop( SUIT_Desktop* );
00147 
00148   SUIT_Accel*                         accel() const;
00149 
00150   void                                setDefaultStudyName( const QString& theName );
00151 
00152   static int                          studyId();
00153 
00154   virtual bool                        event( QEvent* );
00155 
00156   virtual bool                        checkDataObject( LightApp_DataObject* theObj );
00157 
00158   virtual void                        updateDesktopTitle();
00159 
00161   QStringList                          viewManagersTypes() const;
00162 
00164   virtual void                        clearKnownViewManagers();
00165 
00166   virtual QString                     browseObjects( const QStringList& theEntryList,
00167                                                      const bool theIsApplyAndClose = true,
00168                                                      const bool theIsOptimizedBrowsing = false );
00169 
00170   virtual SUIT_DataObject*            findObject( const QString& ) const;
00171 
00172   virtual bool                        renameAllowed( const QString& ) const;
00173   virtual bool                        renameObject( const QString&, const QString& );
00174 
00175 signals:
00176   void                                studyOpened();
00177   void                                studySaved();
00178   void                                studyClosed();
00179   void                                preferenceChanged( const QString&, const QString&, const QString& );
00180 
00181 public slots:
00182   virtual void                        onHelpContentsModule();
00183   virtual void                        onHelpContextModule( const QString&, const QString&, const QString& = QString() );
00184   virtual void                        onNewDoc();
00185   virtual void                        onOpenDoc();
00186   virtual void                        onHelpAbout();
00187   virtual bool                        onOpenDoc( const QString& );
00188   virtual void                        onCopy();
00189   virtual void                        onPaste();
00190   virtual void                        onSelectionChanged();
00191 
00192 protected:
00193   virtual void                        createActions();
00194   virtual void                        createActionForViewer( const int id,
00195                                                              const int parentId,
00196                                                              const QString& suffix,
00197                                                              const int accel );
00198   virtual SUIT_Study*                 createNewStudy();
00199   virtual QWidget*                    createWindow( const int );
00200   virtual void                        defaultWindows( QMap<int, int>& ) const;
00201   void                                defaultViewManagers( QStringList& ) const;
00202 
00203   virtual void                        setActiveStudy( SUIT_Study* );
00204   virtual void                        updateCommandsStatus();
00205 
00206   virtual void                        beforeCloseDoc( SUIT_Study* );
00207   virtual void                        afterCloseDoc();
00208   virtual void                        moduleAdded( CAM_Module* );
00209   virtual bool                        activateModule( CAM_Module* = 0 );
00210 
00211   LightApp_Preferences*               preferences( const bool ) const;
00212   virtual void                        createPreferences( LightApp_Preferences* );
00213   virtual void                        preferencesChanged( const QString&, const QString& );
00214 
00215   virtual void                        loadPreferences();
00216   virtual void                        savePreferences();
00217 
00218   virtual QMap<int, QString>          activateModuleActions() const;
00219   virtual void                        moduleActionSelected( const int );
00220 
00221 protected slots:
00222   virtual void                        onDesktopActivated();
00223 
00224   void                                onNewWindow();
00225   void                                onModuleActivation( const QString& );
00226   void                                onCloseView( SUIT_ViewManager* );
00227 
00228   void                                onStudyCreated( SUIT_Study* );
00229   void                                onStudyOpened( SUIT_Study* );
00230   void                                onStudySaved( SUIT_Study* );
00231   void                                onStudyClosed( SUIT_Study* );
00232 
00233   void                                onWCDestroyed( QObject* );
00234 
00235   void                                onMRUActivated( const QString& );
00236 
00237   void                                onStylePreferences();
00238   void                                onFullScreen();
00239 
00240   virtual void                        onDesktopMessage( const QString& );
00241 
00242 private slots:
00243   void                                onSelection();
00244   void                                onRefresh();
00245   void                                onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction );
00246   void                                onPreferences();
00247   void                                onPreferenceChanged( QString&, QString&, QString& );
00248   void                                onRenameWindow();
00249   void                                onCloseWindow();
00250   void                                onCloseAllWindow();
00251   void                                onGroupAllWindow();
00252 
00253 protected:
00254   void                                updateWindows();
00255   void                                updateViewManagers();
00256   void                                updateModuleActions();
00257   void                                removeModuleAction( const QString& );
00258 
00259   void                                loadDockWindowsState();
00260   void                                saveDockWindowsState();
00261 
00262   virtual void                        studyOpened( SUIT_Study* );
00263   virtual void                        studyCreated( SUIT_Study* );
00264   virtual void                        studySaved( SUIT_Study* );
00265 
00266   void                                updatePreference( const QString&, const QString&, const QString& );
00267 
00268   QString                             defaultModule() const;
00269   void                                currentWindows( QMap<int, int>& ) const;
00270   void                                currentViewManagers( QStringList& ) const;
00271   void                                moduleIconNames( QMap<QString, QString>& ) const;
00272 
00273   bool                                isLibExists( const QString& ) const;
00274 
00275   QDockWidget*                        windowDock( QWidget* ) const;
00276   QByteArray                          dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
00277   void                                dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
00278 
00279   virtual int                         openChoice( const QString& );
00280   virtual bool                        openAction( const int, const QString& );
00281 
00282   void                                showPreferences( const QString& = QString() );
00283 
00284 private:
00285   void                                emptyPreferences( const QString& );
00286 
00287 protected:
00288   typedef QPointer<QWidget>         WinPtr;
00289   typedef QMap<int, WinPtr>         WinMap;
00290   typedef QMap<QString, QByteArray> WinVis;
00291   typedef QMap<QString, QByteArray> WinGeom;
00292 
00293   enum { OpenReload = CAM_Application::OpenExist + 1 };
00294 
00295 protected:
00296   LightApp_Preferences*               myPrefs;
00297   LightApp_SelectionMgr*              mySelMgr;
00298 
00299   LightApp_FullScreenHelper*          myScreenHelper;
00300 
00301   WinMap                              myWin;
00302   WinVis                              myWinVis;
00303   WinGeom                             myWinGeom;
00304 
00305   SUIT_Accel*                         myAccel;
00306   QTimer*                             myAutoSaveTimer;
00307 
00308   static LightApp_Preferences*        _prefs_;
00309 
00310   static int                          lastStudyId;
00311   QStringList                         myUserWmTypes;
00312 };
00313 
00314 #ifdef WIN32
00315 #pragma warning( default:4251 )
00316 #endif
00317 
00318 #endif