Version: 6.3.1

src/LightApp/LightApp_Application.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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_DataObject;
00049 class SUIT_DataBrowser;
00050 class SUIT_Study;
00051 class SUIT_Accel;
00052 class CAM_Module;
00053 
00054 class QString;
00055 class QWidget;
00056 class QStringList;
00057 class QDockWidget;
00058 class QTimer;
00059 
00060 #ifdef WIN32
00061 #pragma warning( disable:4251 )
00062 #endif
00063 
00068 class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application, public SUIT_DataSearcher
00069 {
00070   Q_OBJECT
00071 
00072 public:
00073   typedef enum { WT_ObjectBrowser,
00074 #ifndef DISABLE_PYCONSOLE
00075                  WT_PyConsole,
00076 #endif
00077                  WT_LogWindow,
00078                  WT_User }
00079   WindowTypes;
00080 
00081   enum { MenuWindowId = 6 };
00082 
00083   enum { RenameId = CAM_Application::UserID,
00084          CloseId, CloseAllId, GroupAllId,
00085          PreferencesId, MRUId, ModulesListId,
00086          NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
00087          NewQxSceneViewId = NewQxGraphViewId, StyleId,
00088          UserID };
00089 
00090 protected:
00091   enum { NewStudyId = 1, OpenStudyId };
00092 
00093   enum BrowsePolicy { BP_Never = 0, BP_ApplyAndClose, BP_Always };
00094 
00095 public:
00096   LightApp_Application();
00097   virtual ~LightApp_Application();
00098 
00099   virtual QString                     applicationName() const;
00100   virtual QString                     applicationVersion() const;
00101 
00102   virtual CAM_Module*                 loadModule( const QString&, const bool = true );
00103   virtual bool                        activateModule( const QString& );
00104 
00105   LightApp_SelectionMgr*              selectionMgr() const;
00106 
00107   LogWindow*                          logWindow();
00108   SUIT_DataBrowser*                   objectBrowser();
00109 #ifndef DISABLE_PYCONSOLE
00110   PyConsole_Console*                  pythonConsole();
00111 #endif
00112 
00113   virtual void                        updateObjectBrowser( const bool = true );
00114 
00115   LightApp_Preferences*               preferences() const;
00116 
00117   virtual QString                     getFileFilter() const;
00118 
00119   virtual QString                     getFileName( bool open, const QString& initial, const QString& filters,
00120                                                    const QString& caption, QWidget* parent );
00121   virtual QString                     getDirectory( const QString& initial, const QString& caption, QWidget* parent );
00122   virtual QStringList                 getOpenFileNames( const QString& initial, const QString& filters,
00123                                                         const QString& caption, QWidget* parent );
00124 
00125   void                                updateActions();
00126 
00127   SUIT_ViewManager*                   getViewManager( const QString&, const bool );
00128   virtual void                        addViewManager( SUIT_ViewManager* );
00129   virtual void                        removeViewManager( SUIT_ViewManager* );
00130   virtual SUIT_ViewManager*           createViewManager( const QString& vmType );
00131   virtual SUIT_ViewManager*           createViewManager( const QString& vmType, QWidget* w );
00132 
00133   QWidget*                            getWindow( const int, const int = -1 );
00134   QWidget*                            dockWindow( const int ) const;
00135   void                                removeDockWindow( const int );
00136   void                                insertDockWindow( const int, QWidget* );
00137   void                                placeDockWindow( const int, Qt::DockWidgetArea );
00138 
00139   virtual void                        start();
00140 
00141   virtual void                        contextMenuPopup( const QString&, QMenu*, QString& );
00142 
00143   virtual void                        createEmptyStudy();
00144 
00145   SUIT_Accel*                         accel() const;
00146 
00147   void                                setDefaultStudyName( const QString& theName );
00148 
00149   static int                          studyId();
00150 
00151   virtual bool                        event( QEvent* );
00152 
00153   virtual bool                        checkDataObject( LightApp_DataObject* theObj );
00154 
00155   virtual void                        updateDesktopTitle();
00156 
00158   QStringList                          viewManagersTypes() const;
00159 
00161   virtual void                        clearKnownViewManagers();
00162 
00163   virtual QString                     browseObjects( const QStringList& theEntryList,
00164                                                      const bool theIsApplyAndClose = true,
00165                                                      const bool theIsOptimizedBrowsing = false );
00166 
00167   virtual SUIT_DataObject*            findObject( const QString& ) const;
00168 
00169   virtual bool                        renameAllowed( const QString& ) const;
00170   virtual bool                        renameObject( const QString&, const QString& );
00171 
00172 signals:
00173   void                                studyOpened();
00174   void                                studySaved();
00175   void                                studyClosed();
00176   void                                preferenceChanged( const QString&, const QString&, const QString& );
00177 
00178 public slots:
00179   virtual void                        onHelpContentsModule();
00180   virtual void                        onHelpContextModule( const QString&, const QString&, const QString& = QString() );
00181   virtual void                        onNewDoc();
00182   virtual void                        onOpenDoc();
00183   virtual void                        onHelpAbout();
00184   virtual bool                        onOpenDoc( const QString& );
00185   virtual void                        onCopy();
00186   virtual void                        onPaste();
00187   virtual void                        onSelectionChanged();
00188 
00189 protected:
00190   virtual void                        createActions();
00191   virtual void                        createActionForViewer( const int id,
00192                                                              const int parentId,
00193                                                              const QString& suffix,
00194                                                              const int accel );
00195   virtual SUIT_Study*                 createNewStudy();
00196   virtual QWidget*                    createWindow( const int );
00197   virtual void                        defaultWindows( QMap<int, int>& ) const;
00198   void                                defaultViewManagers( QStringList& ) const;
00199 
00200   virtual void                        setActiveStudy( SUIT_Study* );
00201   virtual void                        updateCommandsStatus();
00202 
00203   virtual void                        beforeCloseDoc( SUIT_Study* );
00204   virtual void                        afterCloseDoc();
00205   virtual void                        moduleAdded( CAM_Module* );
00206   virtual bool                        activateModule( CAM_Module* = 0 );
00207 
00208   LightApp_Preferences*               preferences( const bool ) const;
00209   virtual void                        createPreferences( LightApp_Preferences* );
00210   virtual void                        preferencesChanged( const QString&, const QString& );
00211 
00212   virtual void                        loadPreferences();
00213   virtual void                        savePreferences();
00214 
00215   virtual QMap<int, QString>          activateModuleActions() const;
00216   virtual void                        moduleActionSelected( const int );
00217 
00218 protected slots:
00219   virtual void                        onDesktopActivated();
00220 
00221   void                                onNewWindow();
00222   void                                onModuleActivation( const QString& );
00223   void                                onCloseView( SUIT_ViewManager* );
00224 
00225   void                                onStudyCreated( SUIT_Study* );
00226   void                                onStudyOpened( SUIT_Study* );
00227   void                                onStudySaved( SUIT_Study* );
00228   void                                onStudyClosed( SUIT_Study* );
00229 
00230   void                                onWCDestroyed( QObject* );
00231 
00232   void                                onMRUActivated( const QString& );
00233 
00234   void                                onStylePreferences();
00235 
00236 private slots:
00237   void                                onSelection();
00238   void                                onRefresh();
00239   void                                onPreferences();
00240   void                                onPreferenceChanged( QString&, QString&, QString& );
00241   void                                onRenameWindow();
00242   void                                onCloseWindow();
00243   void                                onCloseAllWindow();
00244   void                                onGroupAllWindow();
00245 
00246 protected:
00247   void                                updateWindows();
00248   void                                updateViewManagers();
00249   void                                updateModuleActions();
00250   void                                removeModuleAction( const QString& );
00251 
00252   void                                loadDockWindowsState();
00253   void                                saveDockWindowsState();
00254 
00255   virtual void                        studyOpened( SUIT_Study* );
00256   virtual void                        studyCreated( SUIT_Study* );
00257   virtual void                        studySaved( SUIT_Study* );
00258 
00259   void                                updatePreference( const QString&, const QString&, const QString& );
00260 
00261   QString                             defaultModule() const;
00262   void                                currentWindows( QMap<int, int>& ) const;
00263   void                                currentViewManagers( QStringList& ) const;
00264   void                                moduleIconNames( QMap<QString, QString>& ) const;
00265 
00266   bool                                isLibExists( const QString& ) const;
00267 
00268   QDockWidget*                        windowDock( QWidget* ) const;
00269   QByteArray                          dockWindowsState( const QMap<QString, bool>&, const QMap<QString, bool>& ) const;
00270   void                                dockWindowsState( const QByteArray&, QMap<QString, bool>&, QMap<QString, bool>& ) const;
00271 
00272   virtual int                         openChoice( const QString& );
00273   virtual bool                        openAction( const int, const QString& );
00274 
00275   void                                showPreferences( const QString& = QString() );
00276 
00277 private:
00278   void                                emptyPreferences( const QString& );
00279 
00280 protected:
00281   typedef QPointer<QWidget>         WinPtr;
00282   typedef QMap<int, WinPtr>         WinMap;
00283   typedef QMap<QString, QByteArray> WinVis;
00284   typedef QMap<QString, QByteArray> WinGeom;
00285 
00286   enum { OpenReload = CAM_Application::OpenExist + 1 };
00287 
00288 protected:
00289   LightApp_Preferences*               myPrefs;
00290   LightApp_SelectionMgr*              mySelMgr;
00291 
00292   WinMap                              myWin;
00293   WinVis                              myWinVis;
00294   WinGeom                             myWinGeom;
00295 
00296   SUIT_Accel*                         myAccel;
00297   QTimer*                             myAutoSaveTimer;
00298 
00299   static LightApp_Preferences*        _prefs_;
00300 
00301   static int                          lastStudyId;
00302   QStringList                         myUserWmTypes;
00303 };
00304 
00305 #ifdef WIN32
00306 #pragma warning( default:4251 )
00307 #endif
00308 
00309 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS