#include <Model_ResultConstruction.h>
#include <Model_ResultBody.h>
#include <Model_ResultGroup.h>
+#include <Model_ResultParameter.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_CompositeFeature.h>
+
#include <Events_Loop.h>
#include <Events_Error.h>
myDoc->Undo();
myDoc->ClearRedos();
}
- // references were not changed since transaction start
- synchronizeFeatures(true, false, isRoot());
- // abort for all subs
+ // abort for all subs, flushes will be later, in the end of root abort
const std::set<std::string> aSubs = subDocuments(true);
std::set<std::string>::iterator aSubIter = aSubs.begin();
for (; aSubIter != aSubs.end(); aSubIter++)
subDoc(*aSubIter)->abortOperation();
+ // references may be changed because they are set in attributes on the fly
+ synchronizeFeatures(true, true, isRoot());
}
bool Model_Document::isOperation() const
{
TDF_Label anEmptyLab;
FeaturePtr anEmptyFeature;
- FeaturePtr aFeature = ModelAPI_Session::get()->createFeature(theID);
+ std::shared_ptr<Model_Session> aSession =
+ std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get());
+ FeaturePtr aFeature = aSession->createFeature(theID, this);
if (!aFeature)
return aFeature;
Model_Document* aDocToAdd;
- if (aFeature->documentToAdd().get()) { // use the customized document to add
- aDocToAdd = std::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd()).get();
+ if (!aFeature->documentToAdd().empty()) { // use the customized document to add
+ if (aFeature->documentToAdd() != kind()) { // the root document by default
+ aDocToAdd = std::dynamic_pointer_cast<Model_Document>(aSession->moduleDocument()).get();
+ } else {
+ aDocToAdd = this;
+ }
} else { // if customized is not presented, add to "this" document
aDocToAdd = this;
}
FeaturePtr aFeature;
if (!myObjs.IsBound(aFeatureLabel)) { // a new feature is inserted
// create a feature
- aFeature = ModelAPI_Session::get()->createFeature(
+ aFeature = std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get())->createFeature(
TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
- .ToCString());
+ .ToCString(), this);
if (!aFeature) { // somethig is wrong, most probably, the opened document has invalid structure
Events_Error::send("Invalid type of object in the document");
aLabIter.Value()->Label().ForgetAllAttributes();
return aResult;
}
+std::shared_ptr<ModelAPI_ResultParameter> Model_Document::createParameter(
+ const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+ TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+ TDataStd_Comment::Set(aLab, ModelAPI_ResultParameter::group().c_str());
+ ObjectPtr anOldObject = object(aLab);
+ std::shared_ptr<ModelAPI_ResultParameter> aResult;
+ if (anOldObject) {
+ aResult = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(anOldObject);
+ }
+ if (!aResult) {
+ aResult = std::shared_ptr<ModelAPI_ResultParameter>(new Model_ResultParameter);
+ storeResult(theFeatureData, aResult, theIndex);
+ }
+ return aResult;
+}
+
std::shared_ptr<ModelAPI_Feature> Model_Document::feature(
const std::shared_ptr<ModelAPI_Result>& theResult)
{