X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultPart.cpp;h=bb12b10756fffa3c95096e4eda37a3d8ca10f63d;hb=77b93142eb8ba33bfb9a42040c2fd8926ffea5c8;hp=96957848aa88043dc3419ed34bce058356d5c5c2;hpb=82d3fff7d0ed2c089da5aa6b106789be076081f3;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 96957848a..bb12b1075 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -25,36 +26,48 @@ #include #include +#define baseRef() std::dynamic_pointer_cast(data()->reference(BASE_REF_ID())->value()) + void Model_ResultPart::initAttributes() { // append the color attribute. It is empty, the attribute will be filled by a request data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId()); data()->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId()); + data()->addAttribute(BASE_REF_ID(), ModelAPI_AttributeReference::typeId()); } std::shared_ptr Model_ResultPart::partDoc() { - return data()->document("PartDocument")->value(); -} - -std::shared_ptr Model_ResultPart::owner() -{ - return std::shared_ptr(); // return empty pointer + if (myTrsf.get()) { + return baseRef()->partDoc(); + } + DocumentPtr aRes = data()->document(DOC_REF())->value(); + if (!aRes.get() && myIsInLoad) { // trying to get this document from the session + aRes = document()->subDocument(data()->name()); + } + return aRes; } Model_ResultPart::Model_ResultPart() { - myIsDisabled = true; // by default it is not initialized and false to be after created - setIsConcealed(false); + myIsInLoad = false; } void Model_ResultPart::activate() { + if (myTrsf.get()) { + baseRef()->activate(); + return; + } + std::shared_ptr aDocRef = data()->document(DOC_REF()); if (!aDocRef->value().get()) { // create (or open) a document if it is not yet created + myIsInLoad = true; std::shared_ptr aDoc = document()->subDocument(data()->name()); + myIsInLoad = false; if (aDoc) { + aDoc->synchronizeTransactions(); aDocRef->setValue(aDoc); } } @@ -72,8 +85,20 @@ void Model_ResultPart::activate() } } +std::shared_ptr Model_ResultPart::original() +{ + if (myTrsf.get()) { + return baseRef()->original(); + } + return std::dynamic_pointer_cast(data()->owner()); +} + bool Model_ResultPart::isActivated() { + if (myTrsf.get()) { + return baseRef()->isActivated(); + } + std::shared_ptr aDocRef = data()->document(DOC_REF()); return aDocRef->value().get() != NULL; } @@ -85,9 +110,9 @@ bool Model_ResultPart::setDisabled(std::shared_ptr theThis, if (!myTrsf.get()) { // disable of base result part DocumentPtr aDoc = Model_ResultPart::partDoc(); if (aDoc.get() && aDoc->isOpened()) { + std::shared_ptr anIntDoc = std::dynamic_pointer_cast(aDoc); // make the current feature the last in any case: to update shapes defore deactivation too - FeaturePtr aLastFeature = std::dynamic_pointer_cast(aDoc->object( - ModelAPI_Feature::group(), aDoc->size(ModelAPI_Feature::group()) - 1)); + FeaturePtr aLastFeature = anIntDoc->lastFeature(); aDoc->setCurrentFeature(aLastFeature, false); if (theFlag) { // disable, so make all features disabled too // update the shape just before the deactivation: it will be used outside of part @@ -106,8 +131,7 @@ std::shared_ptr Model_ResultPart::shape() { std::shared_ptr aResult(new GeomAPI_Shape); if (myTrsf.get()) { // get shape of the base result and apply the transformation - ResultPtr anOrigResult = - std::dynamic_pointer_cast(data()->attribute(COLOR_ID())->owner()); + ResultPtr anOrigResult = baseRef(); std::shared_ptr anOrigShape = anOrigResult->shape(); if (anOrigShape.get()) { TopoDS_Shape aShape = anOrigShape->impl(); @@ -165,8 +189,7 @@ std::string Model_ResultPart::nameInPart(const std::shared_ptr& t theIndex = 0; // not initialized if (myTrsf.get()) { // if this is moved copy of part => return the name of original shape - ResultPartPtr anOrigResult = - std::dynamic_pointer_cast(data()->attribute(COLOR_ID())->owner()); + ResultPartPtr anOrigResult = baseRef(); // searching in the origin the shape equal to the given but with myTrsf TopoDS_Shape aSelection = theShape->impl(); gp_Trsf aSelTrsf = aSelection.Location().Transformation();