#include <Config_AttributeMessage.h>
#include <Config_ValidatorMessage.h>
#include <Config_ModuleReader.h>
+#include <Config_ValidatorReader.h>
#include <ModelAPI_ResultPart.h>
#include <TDF_CopyTool.hxx>
bool Model_Session::load(const char* theFileName)
{
- return ROOT_DOC->load(theFileName);
+ bool aRes = ROOT_DOC->load(theFileName);
+ return aRes;
}
bool Model_Session::save(const char* theFileName, std::list<std::string>& theResults)
Model_Application::getApplication()->deleteAllDocuments();
}
-void Model_Session::startOperation()
+void Model_Session::startOperation(const std::string& theId)
{
ROOT_DOC->startOperation();
+ ROOT_DOC->operationId(theId);
static std::shared_ptr<Events_Message> aStartedMsg
(new Events_Message(Events_Loop::eventByName("StartOperation")));
Events_Loop::loop()->send(aStartedMsg);
void Model_Session::finishOperation()
{
+ setCheckTransactions(false);
ROOT_DOC->finishOperation();
+ setCheckTransactions(true);
}
void Model_Session::abortOperation()
{
+ setCheckTransactions(false);
ROOT_DOC->abortOperation();
+ setCheckTransactions(true);
// here the update mechanism may work after abort, so, supress the warnings about
// modifications outside of the transactions
bool aWasCheck = myCheckTransactions;
void Model_Session::undo()
{
+ setCheckTransactions(false);
ROOT_DOC->undo();
+ setCheckTransactions(true);
}
bool Model_Session::canRedo()
void Model_Session::redo()
{
+ setCheckTransactions(false);
ROOT_DOC->redo();
+ setCheckTransactions(true);
}
-FeaturePtr Model_Session::createFeature(string theFeatureID)
+//! Returns stack of performed operations
+std::list<std::string> Model_Session::undoList()
+{
+ return ROOT_DOC->undoList();
+}
+//! Returns stack of rolled back operations
+std::list<std::string> Model_Session::redoList()
+{
+ return ROOT_DOC->redoList();
+}
+
+FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* theDocOwner)
{
if (this != myImpl) {
- return myImpl->createFeature(theFeatureID);
+ return myImpl->createFeature(theFeatureID, theDocOwner);
}
// load all information about plugins, features and attributes
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()) {
+ if (!aPlugin.second.empty() && aPlugin.second != theDocOwner->kind()) {
Events_Error::send(
string("Feature '") + theFeatureID + "' can be created only in document '"
+ aPlugin.second + "' by the XML definition");
std::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
{
- return std::shared_ptr<ModelAPI_Document>(
+ bool aFirstCall = !Model_Application::getApplication()->hasDocument("root");
+ if (aFirstCall) {
+ // creation of the root document is always outside of the transaction, so, avoid checking it
+ setCheckTransactions(false);
+ }
+ std::shared_ptr<ModelAPI_Document> aDoc = std::shared_ptr<ModelAPI_Document>(
Model_Application::getApplication()->getDocument("root"));
+ if (aFirstCall) {
+ // creation of the root document is always outside of the transaction, so, avoid checking it
+ setCheckTransactions(true);
+ }
+ return aDoc;
}
std::shared_ptr<ModelAPI_Document> Model_Session::document(std::string theDocID)
{
if (myCurrentDoc != theDoc) {
myCurrentDoc = theDoc;
- if (theSendSignal) {
+ if (theDoc.get() && theSendSignal) {
+ // syncronize the document: it may be just opened or opened but removed before
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(theDoc);
+ if (aDoc.get()) {
+ bool aWasChecked = myCheckTransactions;
+ setCheckTransactions(false);
+ aDoc->synchronizeFeatures(false, true, true);
+ if (aWasChecked)
+ setCheckTransactions(true);
+ }
static std::shared_ptr<Events_Message> aMsg(
new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)));
Events_Loop::loop()->send(aMsg);
aRT->SetRelocation(aSourceRoot, aTargetRoot);
TDF_CopyTool::Copy(aDS, aRT);
- aNew->synchronizeFeatures(false, true);
+ aNew->synchronizeFeatures(false, true, true);
return aNew;
}
if(aMsgAttr->isConcealment()) {
validators()->registerConcealment(aMsgAttr->featureId(), aMsgAttr->attributeId());
}
-
+ if (!aMsgAttr->caseId().empty()) {
+ validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(),
+ aMsgAttr->switchId(), aMsgAttr->caseId());
+ }
}
}
// plugins information was started to load, so, it will be loaded
return;
// Read plugins information from XML files
- Config_ModuleReader aXMLReader(Config_FeatureMessage::MODEL_EVENT());
- aXMLReader.readAll();
+ Config_ModuleReader aModuleReader(Config_FeatureMessage::MODEL_EVENT());
+ aModuleReader.readAll();
+ std::set<std::string> aFiles = aModuleReader.modulePluginFiles();
+ std::set<std::string>::iterator it = aFiles.begin();
+ for ( ; it != aFiles.end(); it++ ) {
+ Config_ValidatorReader aValidatorReader (*it);
+ aValidatorReader.readAll();
+ };
+
}
void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)