#include <TDF_RelocationTable.hxx>
#include <TDF_ClosureTool.hxx>
+// TEST
+#include <Python.h>
+
using namespace std;
static Model_Session* myImpl = new Model_Session();
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);
aRT->SetRelocation(aSourceRoot, aTargetRoot);
TDF_CopyTool::Copy(aDS, aRT);
- aNew->synchronizeFeatures();
+ aNew->synchronizeFeatures(false, true);
return aNew;
}
Events_Loop* aLoop = Events_Loop::loop();
static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent");
aLoop->registerListener(this, kFeatureEvent);
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED), 0, true);
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED), 0, true);
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED), 0, true);
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VALIDATOR_LOADED));
}