Back to index

salome-gui  6.5.0
SalomePyQt.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   : SalomePyQt.h
00024 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00025 //
00026 #ifndef SALOME_PYQT_H
00027 #define SALOME_PYQT_H
00028 
00029 #include <Python.h>
00030 
00031 #include <QObject>
00032 #include <QString>
00033 #include <QColor>
00034 
00035 #include <LightApp_Application.h>
00036 #include <LightApp_Preferences.h>
00037 
00038 class LightApp_SelectionMgr;
00039 class LightApp_Application;
00040 class QMenuBar;
00041 class QMenu;
00042 class QWidget;
00043 class QAction;
00044 class QTreeView;
00045 class QtxActionGroup;
00046 
00047 class SALOME_Selection : public QObject
00048 {
00049   Q_OBJECT
00050 
00051 public:
00052   ~SALOME_Selection();
00053   static SALOME_Selection* GetSelection( LightApp_Application* );
00054 
00055   void Clear();
00056   void ClearIObjects();
00057   void ClearFilters();
00058 
00059 signals:
00060   void currentSelectionChanged();
00061 
00062 private slots:
00063   void onSelMgrDestroyed();
00064 
00065 private:
00066   LightApp_SelectionMgr* mySelMgr;
00067   SALOME_Selection( QObject* );
00068 };
00069 
00070 enum MenuName {
00071   File        = 1,
00072   View        = 2,
00073   Edit        = 3,
00074   Preferences = 4,
00075   Tools       = 5,
00076   Window      = 6,
00077   Help        = 7  
00078 };
00079 
00080 enum {
00081   WT_ObjectBrowser = LightApp_Application::WT_ObjectBrowser,
00082   WT_PyConsole     = LightApp_Application::WT_PyConsole,
00083   WT_LogWindow     = LightApp_Application::WT_LogWindow,
00084   WT_User          = LightApp_Application::WT_User
00085 };
00086 
00087 enum { 
00088   PT_Auto     = LightApp_Preferences::Auto,
00089   PT_Space    = LightApp_Preferences::Space,
00090   PT_Bool     = LightApp_Preferences::Bool, 
00091   PT_Color    = LightApp_Preferences::Color,
00092   PT_String   = LightApp_Preferences::String, 
00093   PT_Selector = LightApp_Preferences::Selector, 
00094   PT_DblSpin  = LightApp_Preferences::DblSpin, 
00095   PT_IntSpin  = LightApp_Preferences::IntSpin, 
00096   PT_Double   = LightApp_Preferences::Double, 
00097   PT_Integer  = LightApp_Preferences::Integer, 
00098   PT_GroupBox = LightApp_Preferences::GroupBox, 
00099   PT_Tab      = LightApp_Preferences::Tab, 
00100   PT_Frame    = LightApp_Preferences::Frame, 
00101   PT_Font     = LightApp_Preferences::Font, 
00102   PT_DirList  = LightApp_Preferences::DirList, 
00103   PT_File     = LightApp_Preferences::File, 
00104 };
00105 
00107 enum Orientation {
00108   Horizontal = 0, 
00109   Vertical   = 1  
00110 };
00111 
00113 enum Action {
00114   MoveWidget   = 0, 
00115   LeaveWidget  = 1, 
00116   SplitAt      = 2  
00117 };
00118 
00119 class SalomePyQt
00120 {
00121 public:
00122   static QWidget*          getDesktop();
00123   static QWidget*          getMainFrame();
00124   static QMenuBar*         getMainMenuBar();
00125   static QMenu*            getPopupMenu( const MenuName );
00126   static QMenu*            getPopupMenu( const QString& );
00127   static QTreeView*        getObjectBrowser();
00128   static SALOME_Selection* getSelection();
00129   static int               getStudyId();
00130   static void              putInfo( const QString&, const int = 0 );
00131   static const QString     getActiveComponent();
00132   static PyObject*         getActivePythonModule();
00133   static bool              activateModule( const QString& );
00134   static void              updateObjBrowser( const int = 0, bool = true );
00135 
00136   static bool              isModified();
00137   static void              setModified( bool );
00138 
00139   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool );
00140   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& );
00141   static QString           getExistingDirectory( QWidget*, const QString&, const QString& );
00142 
00143   static QString           createObject(const QString& parent = QString(""));
00144   static QString           createObject(const QString& name,
00145                                         const QString& iconname,
00146                                         const QString& tooltip,
00147                                         const QString& parent = QString(""));
00148 
00149   static void              removeObject( const QString& obj);
00150   static void              removeChild( const QString& obj = QString(""));
00151   static QStringList       getChildren(const QString& obj = QString(""), const bool rec = false);
00152   static void              setName(const QString& obj,const QString& name);
00153   static void              setIcon(const QString& obj,const QString& iconname);
00154   static void              setToolTip(const QString& obj,const QString& tooltip);
00155   static QString           getName(const QString& obj);
00156   static QString           getToolTip(const QString& obj);
00157 
00158   static void              setColor(const QString& obj,const QColor& color);
00159   static QColor            getColor(const QString& obj);
00160 
00161   static void              setReference( const QString& obj, 
00162                                     const QString& refEntry ); 
00163   static QString           getReference( const QString& obj );
00164 
00165   static QIcon             loadIcon( const QString&, const QString& );
00166 
00167   static void              helpContext( const QString&, const QString& );
00168 
00169   static bool              dumpView( const QString& );
00170 
00171   static int               defaultMenuGroup();
00172 
00173   static int               createTool( const QString& );
00174   static int               createTool( const int,  const int,      const int = -1 );
00175   static int               createTool( const int,  const QString&, const int = -1 );
00176   static int               createTool( QAction*, const int,      const int = -1, const int = -1 );
00177   static int               createTool( QAction*, const QString&, const int = -1, const int = -1 );
00178 
00179   static int               createMenu( const QString&, const int = -1,
00180                                        const int = -1, const int = -1, const int = -1 );
00181   static int               createMenu( const QString&, const QString& = QString(), 
00182                                        const int = -1, const int = -1, const int = -1 );
00183   static int               createMenu( const int,      const int = -1,
00184                                        const int = -1, const int = -1 );
00185   static int               createMenu( const int,      const QString& = QString(), 
00186                                        const int = -1, const int = -1 );
00187   static int               createMenu( QAction*,     const int,      const int = -1, 
00188                                        const int = -1, const int = -1 );
00189   static int               createMenu( QAction*,     const QString&, const int = -1, 
00190                                        const int = -1, const int = -1 );
00191 
00192   static QAction*          createSeparator();
00193 
00194   static QAction*          createAction( const int, const QString&,
00195                                          const QString& = QString(), const QString& = QString(), 
00196                                          const QString& = QString(), const int = 0, const bool = false );
00197   
00198   static QtxActionGroup*   createActionGroup( const int, const bool = true );
00199 
00200   static QAction*          action( const int );
00201   static int               actionId( const QAction* );
00202 
00203   static void              addSetting    ( const QString&, const QString&, const double );
00204   static void              addSetting    ( const QString&, const QString&, const int );
00205   static void              addSetting    ( const QString&, const QString&, const bool, const int );
00206   static void              addSetting    ( const QString&, const QString&, const QString& );
00207   static void              addSetting    ( const QString&, const QString&, const QColor& );
00208   static int               integerSetting( const QString&, const QString&, const int = 0 );
00209   static double            doubleSetting ( const QString&, const QString&, const double = 0 );
00210   static bool              boolSetting   ( const QString&, const QString&, const bool = 0 );
00211   static QString           stringSetting ( const QString&, const QString&, const QString& = QString("") );
00212   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() );
00213   static void              removeSetting ( const QString&, const QString& );
00214   static bool              hasSetting    ( const QString&, const QString& );
00215   // obsolete
00216   static void              addStringSetting( const QString&, const QString&, bool = true );
00217   static void              addIntSetting   ( const QString&, const int,      bool = true );
00218   static void              addBoolSetting  ( const QString&, const bool,     bool = true );
00219   static void              addDoubleSetting( const QString&, const double,   bool = true );
00220   static void              removeSettings  ( const QString& );
00221   static QString           getSetting      ( const QString& );
00222 
00223   static int               addGlobalPreference( const QString& );
00224   static int               addPreference( const QString& );
00225   static int               addPreference( const QString&,
00226                                           const int, const int = PT_Auto,
00227                                           const QString& = QString(),
00228                                           const QString& = QString() );
00229   static QVariant          preferenceProperty( const int, const QString& );
00230   static void              setPreferenceProperty( const int, 
00231                                                   const QString&,
00232                                                   const QVariant& );
00233   static void              addPreferenceProperty( const int,
00234                                                   const QString&,
00235                                                   const int,
00236                                                   const QVariant& );
00237 
00238   static void              message( const QString&, bool = true );
00239   static void              clearMessages();
00240   
00241   static QList<int>        getViews();
00242   static int               getActiveView();
00243   static QString           getViewType( const int );
00244   static bool              setViewTitle( const int, const QString& );
00245   static QString           getViewTitle( const int );
00246   static QList<int>        findViews( const QString& );
00247   static bool              activateView( const int );
00248   static int               createView( const QString& );
00249   static int               createView( const QString&, QWidget* );
00250   static bool              closeView( const int );
00251   static int               cloneView( const int );
00252   static bool              isViewVisible( const int );
00253   static void              setViewClosable( const int, const bool );
00254   static bool              isViewClosable( const int );
00255 
00256   static bool              groupAllViews();
00257   static bool              splitView( const int, const Orientation, const Action );
00258   static bool              moveView( const int, const int, const bool );
00259   static QList<int>        neighbourViews( const int );
00260 };
00261 
00262 #endif // SALOME_PYQT_H