From: mpv Date: Mon, 8 Jun 2020 11:51:08 +0000 (+0300) Subject: Initial implementation of support of dump and save to hdf in case SHAPER module was... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fc5edc559b49e769e49b072a306a335e901e2af8;p=modules%2Fshaper.git Initial implementation of support of dump and save to hdf in case SHAPER module was not activated, but script is loaded. --- diff --git a/src/InitializationPlugin/InitializationPlugin_EvalListener.cpp b/src/InitializationPlugin/InitializationPlugin_EvalListener.cpp index a8265d441..e90246349 100644 --- a/src/InitializationPlugin/InitializationPlugin_EvalListener.cpp +++ b/src/InitializationPlugin/InitializationPlugin_EvalListener.cpp @@ -219,3 +219,8 @@ void InitializationPlugin_EvalListener::processEvaluationEvent( aCalculatedValue[1]); } } + +void InitializationPlugin_EvalListener::initDataModel() +{ + myInterp->runString("salome_iapp.load_module(\"Shaper\")"); +} diff --git a/src/InitializationPlugin/InitializationPlugin_EvalListener.h b/src/InitializationPlugin/InitializationPlugin_EvalListener.h index ca381b2e4..5b6f3d7be 100644 --- a/src/InitializationPlugin/InitializationPlugin_EvalListener.h +++ b/src/InitializationPlugin/InitializationPlugin_EvalListener.h @@ -45,6 +45,9 @@ class InitializationPlugin_EvalListener : public Events_Listener INITIALIZATIONPLUGIN_EXPORT virtual void processEvent(const std::shared_ptr& 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 theParameter, diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp index 872a60372..6ddcc0af7 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp @@ -63,6 +63,8 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrmoduleDocument()) return; + myEvalListener->initDataModel(); + std::list aFeatures; // the viewer update should be blocked in order to avoid the features blinking before they are diff --git a/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp b/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp index e64fc3788..0e07f9696 100644 --- a/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp +++ b/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp @@ -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()); +} diff --git a/src/InitializationPlugin/InitializationPlugin_PyInterp.h b/src/InitializationPlugin/InitializationPlugin_PyInterp.h index 094d4fbc9..b34a8df82 100644 --- a/src/InitializationPlugin/InitializationPlugin_PyInterp.h +++ b/src/InitializationPlugin/InitializationPlugin_PyInterp.h @@ -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(); diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index efdddb88e..066750018 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -224,6 +224,8 @@ void SHAPERGUI::initialize(CAM_Application* theApp) } } } + SHAPERGUI_DataModel* aDataModel = dynamic_cast(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(dataModel()); - aDataModel->initRootObject(); - if (isDone) { setMenuShown(true); setToolShown(true);