Salome HOME
Merge branch 'master' of newgeom:newgeom.git into BR_PYTHON_PLUGIN
[modules/shaper.git] / src / Model / Model_Session.cpp
index e63c97cabb2a1cb06744d8f8d8b5307a0be294c7..a42eb204696b7283251aae226a13b145bf6cc8e0 100644 (file)
@@ -21,6 +21,9 @@
 #include <TDF_RelocationTable.hxx>
 #include <TDF_ClosureTool.hxx>
 
+// TEST
+#include <Python.h>
+
 using namespace std;
 
 static Model_Session* myImpl = new Model_Session();
@@ -91,22 +94,30 @@ void Model_Session::redo()
 
 FeaturePtr Model_Session::createFeature(string theFeatureID)
 {
-  if (this != myImpl)
+  if (this != myImpl) {
     return myImpl->createFeature(theFeatureID);
+  }
 
   LoadPluginsInfo();
   if (myPlugins.find(theFeatureID) != myPlugins.end()) {
     std::pair<std::string, std::string>& aPlugin = myPlugins[theFeatureID]; // plugin and doc kind
     if (!aPlugin.second.empty() && aPlugin.second != activeDocument()->kind()) {
       Events_Error::send(
-          string("Feature '") + theFeatureID + "' can not be created in document '"
+          string("Feature '") + theFeatureID + "' can be created only in document '"
               + aPlugin.second + "' by the XML definition");
       return FeaturePtr();
     }
     myCurrentPluginName = aPlugin.first;
     if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) {
       // load plugin library if not yet done
-      Config_ModuleReader::loadLibrary(myCurrentPluginName);
+      //TODO: Get info from Config about python libraries
+      if (myCurrentPluginName.compare(string("PythonFeaturesPlugin")) == 0) {
+        Py_Initialize();
+        PyObject* module = PyImport_ImportModule(myCurrentPluginName.c_str());
+        assert(module != NULL);
+      } else {
+        Config_ModuleReader::loadLibrary(myCurrentPluginName);
+      }
     }
     if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) {
       FeaturePtr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID);
@@ -191,7 +202,7 @@ boost::shared_ptr<ModelAPI_Document> Model_Session::copy(
   aRT->SetRelocation(aSourceRoot, aTargetRoot);
   TDF_CopyTool::Copy(aDS, aRT);
 
-  aNew->synchronizeFeatures();
+  aNew->synchronizeFeatures(false, true);
   return aNew;
 }