void Model_Document::finishOperation()
{
// just to be sure that everybody knows that changes were performed
+
+ if (!myDoc->HasOpenCommand() && myNestedNum != -1)
+ boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
+ setCheckTransactions(false); // for nested transaction commit
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ if (!myDoc->HasOpenCommand() && myNestedNum != -1)
+ boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
+ setCheckTransactions(true); // for nested transaction commit
if (myNestedNum != -1) // this nested transaction is owervritten
myNestedNum++;
aDocToAdd->initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
// keep the feature ID to restore document later correctly
TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str());
- aDocToAdd->setUniqueName(aFeature);
aDocToAdd->myObjs.Bind(aFeatureLab, aFeature);
// store feature in the history of features array
if (aFeature->isInHistory()) {
ObjectPtr Model_Document::object(TDF_Label theLabel)
{
- TDF_Label aFeatureLabel = theLabel.Father().Father();
- FeaturePtr aFeature = feature(aFeatureLabel);
+ // try feature by label
+ FeaturePtr aFeature = feature(theLabel);
+ if (aFeature)
+ return feature(theLabel);
+ TDF_Label aFeatureLabel = theLabel.Father().Father(); // let's suppose it is result
+ aFeature = feature(aFeatureLabel);
if (aFeature) {
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
for(; aRIter != aResults.cend(); aRIter++) {
boost::shared_ptr<Model_Data> aResData =
boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
- if (aResData->label().IsEqual(theLabel))
+ if (aResData->label().Father().IsEqual(theLabel))
return *aRIter;
}
}
void Model_Document::setUniqueName(FeaturePtr theFeature)
{
+ if (!theFeature->data()->name().empty()) return; // not needed, name is already defined
std::string aName; // result
// first count all objects of such kind to start with index = count + 1
int aNumObjects = 0;
boost::shared_ptr<ModelAPI_Document> aThis =
Model_Application::getApplication()->getDocument(myID);
boost::shared_ptr<Model_Data> aData(new Model_Data);
- aData->setLabel(theLab.FindChild(theTag + 1));
+ aData->setLabel(theLab.FindChild(theTag));
aData->setObject(theObj);
theObj->setDoc(aThis);
theObj->setData(aData);
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
- if (aFeature) aFeature->initAttributes();
+ if (aFeature) {
+ setUniqueName(aFeature); // must be before "initAttributes" because duplicate part uses name
+ aFeature->initAttributes();
+ }
}
void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
boost::shared_ptr<ModelAPI_Document> aThis =
Model_Application::getApplication()->getDocument(myID);
theResult->setDoc(aThis);
- initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
- label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex);
+ initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->label().
+ Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theResultIndex + 1), TAG_FEATURE_ARGUMENTS);
if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name
theResult->data()->setName(theFeatureData->name());
}
{
boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResult->data());
if (aData) {
- TDF_Label aFeatureLab = aData->label().Father().Father();
+ TDF_Label aFeatureLab = aData->label().Father().Father().Father();
return feature(aFeatureLab);
}
return FeaturePtr();