Version: 6.3.1

src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File   : SALOME_PYQT_Module.h
00021 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00022 //
00023 #ifndef SALOME_PYQT_MODULELIGHT_H
00024 #define SALOME_PYQT_MODULELIGHT_H
00025 
00026 #include "PyInterp_Interp.h" // // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
00027 #include "SALOME_PYQT_GUILight.h"
00028 #include "LightApp_Module.h"
00029 #include "SALOME_PYQT_DataObjectLight.h"
00030 #include <CAM_Module.h>
00031 
00032 #include <map>
00033 #include <QStringList>
00034 #include <QList>
00035 #include <QMap>
00036 #include <QIcon>
00037 
00038 class SALOME_PYQT_RootObjectLight;
00039 class SALOME_PYQT_PyInterp;
00040 class SUIT_ViewWindow;
00041 class QAction;
00042 class QtxActionGroup;
00043 class QMenu;
00044 
00045 
00046 class SALOME_PYQT_LIGHT_EXPORT SALOME_PYQT_ModuleLight: virtual public LightApp_Module
00047 {
00048   Q_OBJECT;
00049 
00050 private:
00051   class XmlHandler;
00052 
00054   typedef QMap<int, PyInterp_Interp*> InterpMap;
00055   static SALOME_PYQT_ModuleLight* myInitModule; 
00056 
00057   XmlHandler*                myXmlHandler; 
00058   QMap<int, int>             myWindowsMap; 
00059   QStringList                myViewMgrList;
00060   bool                       myLastActivateStatus; 
00061 
00062 protected:
00063   PyObject*                  myModule;     
00064   PyInterp_Interp*           myInterp;     
00065   static InterpMap           myInterpMap;  
00066 
00067 public:
00068   SALOME_PYQT_ModuleLight();
00069   ~SALOME_PYQT_ModuleLight();
00070 
00071 public:
00072   static SALOME_PYQT_ModuleLight* getInitModule();
00073 
00074   void                       initialize( CAM_Application* );
00075   void                       windows( QMap<int, int>& ) const;
00076   void                       viewManagers( QStringList& ) const;
00077   void                       contextMenuPopup( const QString&, QMenu*, QString& );
00078   void                       createPreferences();
00079   void                       studyActivated();
00080   void                       preferencesChanged( const QString&, const QString& );
00081 
00082   static int                 defaultMenuGroup();
00083 
00084   int                        createTool( const QString& );
00085   int                        createTool( const int, const int, const int = -1 );
00086   int                        createTool( const int, const QString&, const int = -1 );
00087   int                        createTool( QAction*, const int, 
00088                                          const int = -1, const int = -1 );
00089   int                        createTool( QAction*, const QString&, 
00090                                          const int = -1, const int = -1 );
00091 
00092   int                        createMenu( const QString&, const int, 
00093                                          const int = -1, const int = -1, const int = -1 );
00094   int                        createMenu( const QString&, const QString&, 
00095                                          const int = -1, const int = -1, const int = -1 );
00096   int                        createMenu( const int, const int, 
00097                                          const int = -1, const int = -1 );
00098   int                        createMenu( const int, const QString&, 
00099                                          const int = -1, const int = -1 );
00100   int                        createMenu( QAction*, const int, 
00101                                          const int = -1, const int = -1, const int = -1 );
00102   int                        createMenu( QAction*, const QString&, 
00103                                          const int = -1, const int = -1, const int = -1 );
00104 
00105   QAction*                   separator();
00106 
00107   QAction*                   action( const int ) const;
00108   int                        actionId( const QAction* ) const;
00109   QAction*                   createAction( const int, const QString&, const QString&, 
00110                                            const QString&, const QString&, const int, 
00111                                            const bool = false, QObject* = 0 );
00112   QtxActionGroup*            createActionGroup( const int, const bool );
00113 
00114 
00115   QIcon                      loadIcon( const QString& fileName );
00116 
00117   int                        addGlobalPreference( const QString& );
00118   int                        addPreference( const QString& );
00119   int                        addPreference( const QString&, const int, const int = LightApp_Preferences::Auto,
00120                                             const QString& = QString(),
00121                                             const QString& = QString() );
00122   QVariant                   preferenceProperty( const int, const QString& ) const;
00123   void                       setPreferenceProperty( const int, const QString&, 
00124                                                     const QVariant& );
00125 
00126   void                   save(QStringList& theListOfFiles);
00127 
00128   bool                   open(QStringList theListOfFiles);
00129 
00130   /*create new SALOME_PYQT_DataObjectLight and return its entry*/
00131   QString                   createObject(const QString& parent);
00132   QString                   createObject(const QString& name, 
00133                                          const QString& iconname,
00134                                          const QString& tooltip,
00135                                          const QString& parent);
00136   /*Sets Name, Icon and Tool Tip for object*/
00137   void                      setName(const QString& obj,const QString& iconname);
00138   void                      setIcon(const QString& obj,const QString& name);
00139   void                      setToolTip(const QString& obj, const QString& name);
00140 
00141   /*Gets Name and Tool Tip for object*/
00142   QString                   getName(const QString& obj);
00143   QString                   getToolTip(const QString& obj);
00144                              /*remove object*/
00145   void                      removeObject(const QString& obj);
00146                             /*remove child*/
00147   void                      removeChild(const QString& obj);
00148                             /*return list of child objets*/
00149   QStringList               getChildren(const QString& obj, const bool rec);
00150 
00151 
00152 public slots:
00153   virtual bool               activateModule( SUIT_Study* );
00154   virtual bool               deactivateModule( SUIT_Study* );
00155   void                       preferenceChanged( const QString&, 
00156                                                 const QString&, 
00157                                                 const QString& );
00158   void                       onGUIEvent();
00159 
00160   void                       onActiveViewChanged( SUIT_ViewWindow* );
00161   void                       onViewTryClose( SUIT_ViewWindow* );
00162   void                       onViewClosed( SUIT_ViewWindow* );
00163   void                       onViewCloned( SUIT_ViewWindow* );
00164 
00165 protected:
00166   /* create data model */
00167   virtual CAM_DataModel*     createDataModel();
00168   virtual bool               activateModuleInternal( SUIT_Study* );
00169 
00170 private:
00171   void                       init( CAM_Application* );
00172   void                       activate( SUIT_Study* );
00173   void                       deactivate( SUIT_Study* );
00174   bool                       lastActivationStatus() const;
00175   void                       customize( SUIT_Study* );
00176   void                       studyChanged( SUIT_Study* );
00177   void                       contextMenu( const QString&, QMenu* );
00178   void                       guiEvent( const int );
00179   void                       initPreferences();
00180   void                       prefChanged( const QString&, const QString& );
00181 
00182   virtual void               initInterp  ( int );
00183   void                       importModule();
00184   void                       setWorkSpace();
00185   
00186   void                       activeViewChanged( const SUIT_ViewWindow* );
00187   void                       viewTryClose( const SUIT_ViewWindow* );
00188   void                       viewClosed( const SUIT_ViewWindow* );
00189   void                       viewCloned( const SUIT_ViewWindow* );
00190   void                       connectView( const SUIT_ViewWindow* );
00191 
00192   void                       saveEvent(QStringList& theListOfFiles);
00193   void                       openEvent(QStringList theListOfFiles, bool& opened);
00194 
00195   SALOME_PYQT_DataObjectLight* findObject(const QString& entry);
00196 
00197   friend class XmlHandler;
00198 };
00199 
00200 #endif // SALOME_PYQT_MODULELIGHT_H
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