]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Initial implementation of support of dump and save to hdf in case SHAPER module was...
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 8 Jun 2020 11:51:08 +0000 (14:51 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 8 Jun 2020 11:51:08 +0000 (14:51 +0300)
src/InitializationPlugin/InitializationPlugin_EvalListener.cpp
src/InitializationPlugin/InitializationPlugin_EvalListener.h
src/InitializationPlugin/InitializationPlugin_Plugin.cpp
src/InitializationPlugin/InitializationPlugin_PyInterp.cpp
src/InitializationPlugin/InitializationPlugin_PyInterp.h
src/SHAPERGUI/SHAPERGUI.cpp

index a8265d4414505b94c12678d0c01b7a6435c81c5c..e9024634939e4ea59a9bf846ded1bc1b158d9aa6 100644 (file)
@@ -219,3 +219,8 @@ void InitializationPlugin_EvalListener::processEvaluationEvent(
                                     aCalculatedValue[1]);
   }
 }
+
+void InitializationPlugin_EvalListener::initDataModel()
+{
+  myInterp->runString("salome_iapp.load_module(\"Shaper\")");
+}
index ca381b2e45c66e1d514b06dc201424cad6854836..5b6f3d7be7cf7a5b59378166204790a5ebcbaf69 100644 (file)
@@ -45,6 +45,9 @@ class InitializationPlugin_EvalListener : public Events_Listener
   INITIALIZATIONPLUGIN_EXPORT
     virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
+  // performs the python call to initialize high level data model on internal data model creation
+  void initDataModel();
+
  protected:
   /// Evaluates theExpression and returns its value.
    double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
index 872a603722251cc71ebd111f74cfa334fb052b45..6ddcc0af70d18a9cb32e276f7aaa7c40123174fe 100644 (file)
@@ -63,6 +63,8 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptr<Events_Mess
     if (aDoc != ModelAPI_Session::get()->moduleDocument())
       return;
 
+    myEvalListener->initDataModel();
+
     std::list<FeaturePtr> aFeatures;
 
     // the viewer update should be blocked in order to avoid the features blinking before they are
index e64fc378841c9c4e1aa34033a005c33ca5c29320..0e07f96967e4d972b16ac40f379422cc40ea219e 100644 (file)
@@ -255,3 +255,9 @@ void InitializationPlugin_PyInterp::closeContext()
   Py_XDECREF(_local_context);
   PyInterp_Interp::closeContext();
 }
+
+bool InitializationPlugin_PyInterp::runString(std::string theString)
+{
+  PyLockWrapper lck; // Acquire GIL until the end of the method
+  return PyRun_SimpleString(theString.c_str());
+}
index 094d4fbc9771f899b39bd88f6262f384aa8a9a9b..b34a8df82ba0b213c71c2b2f81f49722eb3579ee 100644 (file)
@@ -50,6 +50,9 @@ class INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_PyInterp : public PyInter
   /// Evaluates theExpression and returns its value.
   double evaluate(const std::string& theExpression, std::string& theError);
 
+  /// Runs the string command in the python interpreter. Returns true if no error is in result.
+  bool runString(std::string theString);
+
  protected:
   /// Returns error message.
   std::string errorMessage();
index efdddb88e124d6bd2f8003829b06c16361a34a9a..06675001862dfc60535c0e95413d4ecfc4b80adb 100644 (file)
@@ -224,6 +224,8 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
       }
     }
   }
+  SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
+  aDataModel->initRootObject();
 }
 
 //******************************************************
@@ -268,9 +270,6 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
   bool isDone = LightApp_Module::activateModule(theStudy);
   loadToolbarsConfig();
 
-  SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
-  aDataModel->initRootObject();
-
   if (isDone) {
     setMenuShown(true);
     setToolShown(true);