X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Document.cpp;h=ec0c236f6f0389ab60177023a65ab8e30a399696;hb=6a7e53a3d3b52f1f798b7e3aa3c48de9c870d92b;hp=ee8cebc14c9d0274a1dd486a1638fca540450c17;hpb=f367061802012d6909c2619ef6b6c4cba86fc503;p=modules%2Fshaper.git diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index ee8cebc14..ec0c236f6 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -13,8 +13,10 @@ #include #include #include +#include #include #include + #include #include @@ -403,13 +405,13 @@ void Model_Document::abortOperation() 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 aSubs = subDocuments(true); std::set::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 @@ -555,12 +557,18 @@ FeaturePtr Model_Document::addFeature(std::string theID) { TDF_Label anEmptyLab; FeaturePtr anEmptyFeature; - FeaturePtr aFeature = ModelAPI_Session::get()->createFeature(theID); + std::shared_ptr aSession = + std::dynamic_pointer_cast(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(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(aSession->moduleDocument()).get(); + } else { + aDocToAdd = this; + } } else { // if customized is not presented, add to "this" document aDocToAdd = this; } @@ -696,6 +704,8 @@ void Model_Document::removeFeature(FeaturePtr theFeature/*, const bool theCheck* } // event: feature is deleted ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group()); + // the redisplay signal should be flushed in order to erase the feature presentation in the viewer + Events_Loop::loop()->flush(EVENT_DISP); } } @@ -981,9 +991,9 @@ void Model_Document::synchronizeFeatures( FeaturePtr aFeature; if (!myObjs.IsBound(aFeatureLabel)) { // a new feature is inserted // create a feature - aFeature = ModelAPI_Session::get()->createFeature( + aFeature = std::dynamic_pointer_cast(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(); @@ -1220,6 +1230,23 @@ std::shared_ptr Model_Document::createGroup( return aResult; } +std::shared_ptr Model_Document::createParameter( + const std::shared_ptr& 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 aResult; + if (anOldObject) { + aResult = std::dynamic_pointer_cast(anOldObject); + } + if (!aResult) { + aResult = std::shared_ptr(new Model_ResultParameter); + storeResult(theFeatureData, aResult, theIndex); + } + return aResult; +} + std::shared_ptr Model_Document::feature( const std::shared_ptr& theResult) {