]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Add function to initialize root data object for "light" Python module.
authorvsr <vsr@opencascade.com>
Wed, 30 Nov 2016 09:49:25 +0000 (12:49 +0300)
committervsr <vsr@opencascade.com>
Wed, 30 Nov 2016 09:49:25 +0000 (12:49 +0300)
src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip

index e0041979837ed7e0cfe19a260a9854e5550f463d..67c57f31d7a844f315f5ae778d81cc46e1633762 100644 (file)
@@ -3319,6 +3319,36 @@ QList<int> SalomePyQt::neighbourViews( const int id )
 }
 
 
+/*!
+  \fn void SalomePyQt::createRoot();
+  \brief Initialize root data object.
+
+  Does nothing if root is already initialized.
+*/
+
+void SalomePyQt::createRoot()
+{
+  class TEvent: public SALOME_Event
+  {
+  public:
+    TEvent() {}
+    virtual void Execute() 
+    {
+      SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+      if ( module ) {
+        SALOME_PYQT_DataModelLight* dm =
+          dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
+        if ( dm )
+          dm->getRoot();
+      }
+      else {
+        if ( verbose() ) printf( "SalomePyQt.createRoot() function is not supported for the current module.\n" );
+      }
+    }
+  };
+  ProcessVoidEvent( new TEvent() );
+}
+
 /*!
   \fn QString SalomePyQt::createObject( const QString& parent );
   \brief Create empty data object
index 26dcda505e370bca6d54ab2117e980f046da00a3..4194fa3b664df1ecc4d4ea2af42fd33714085c1f 100644 (file)
@@ -183,6 +183,7 @@ public:
   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& );
   static QString           getExistingDirectory( QWidget*, const QString&, const QString& );
 
+  static void              createRoot();
   static QString           createObject( const QString& parent = QString() );
   static QString           createObject( const QString&, const QString&, const QString&, const QString& = QString() );
 
index 90f840faa61c24895e62b4858640721a6eb70291..c481c24449ac6e70327aeb184ebd44065c7c279f 100644 (file)
@@ -285,6 +285,7 @@ public:
   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ;
   static QString           getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ;
                         
+  static void              createRoot() /ReleaseGIL/ ;
   static QString           createObject( const QString& = QString("") )  /ReleaseGIL/ ;
   static QString           createObject( const QString&,
                                         const QString&,