#include <GeomData_Point2D.h>
#include <GeomData_Dir.h>
#include <TDataStd_Name.hxx>
+#include "Model_Events.h"
+#include <Events_Loop.h>
using namespace std;
void Model_Data::setName(string theName)
{
TDataStd_Name::Set(myLab, theName.c_str());
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
+ Model_FeatureUpdatedMessage aMsg(myFeature, anEvent);
+ Events_Loop::loop()->send(aMsg, false);
}
void Model_Data::addAttribute(string theID, string theAttrType)
}
}
// after all updates, sends a message that groups of features were created or updated
+ boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
+ setCheckTransactions(false);
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_DELETED));
+ boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
+ setCheckTransactions(true);
}
#include "Model_Object.h"
#include <TCollection_AsciiString.hxx>
+#include "Model_Events.h"
+#include <Events_Loop.h>
boost::shared_ptr<ModelAPI_Feature> Model_Object::featureRef()
{
void Model_Object::setName(std::string theName)
{
- myName->Set(theName.c_str());
+ if (myName->Get() != theName.c_str()) {
+ myName->Set(theName.c_str());
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
+ Model_FeatureUpdatedMessage aMsg(boost::shared_ptr<ModelAPI_Object>(this), anEvent);
+ Events_Loop::loop()->send(aMsg, false);
+ }
}
Model_Object::Model_Object(boost::shared_ptr<ModelAPI_Feature> theRef,
Model_PluginManager::Model_PluginManager()
{
myPluginsInfoLoaded = false;
+ myCheckTransactions = true;
ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager>(this));
// register the configuration reading listener
Events_Loop* aLoop = Events_Loop::loop();
// plugins information was started to load, so, it will be loaded
myPluginsInfoLoaded = true;
} else { // create/update/delete
- if (!rootDocument()->isOperation())
+ if (myCheckTransactions && !rootDocument()->isOperation())
Events_Error::send("Modification of data structure outside of the transaction");
}
}
std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
boost::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
+ bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction
public:
/// Returns the root document of the application (that may contains sub-documents)
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> rootDocument();
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> copy(
boost::shared_ptr<ModelAPI_Document> theSource, std::string theID);
+ void setCheckTransactions(const bool theCheck) {myCheckTransactions = theCheck;}
+
/// Is called only once, on startup of the application
Model_PluginManager();