X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultPart.cpp;h=903f253f72971d5c6059cd1e9f7a65402223c3f1;hb=88ee9b2b81cf93a6324336b57e30cc8a3a487499;hp=e6dc4545382087425e5a3c64b5be7540b0f19dcd;hpb=f14192492e36f4febc93b2ad7ab7f866cbbdf71b;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index e6dc45453..903f253f7 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -36,6 +36,10 @@ #include +#include + +#include + #include #include #include @@ -91,7 +95,7 @@ void Model_ResultPart::activate() SessionPtr aMgr = ModelAPI_Session::get(); if (!aMgr->isOperation()) { // open transaction even document is not created to set current docs in setActiveDocument - std::string aMsg = "Activation " + ModelAPI_Tools::toString(data()->name()); + std::string aMsg = "Activation " + Locale::Convert::toString(data()->name()); aMgr->startOperation(aMsg); isNewTransaction = true; } @@ -185,6 +189,26 @@ bool Model_ResultPart::setDisabled(std::shared_ptr theThis, return false; } +static GeomShapePtr transformShape(const GeomShapePtr theShape, const gp_Trsf& theTrsf) +{ + GeomShapePtr aResult(new GeomAPI_Shape); + if (theTrsf.ScaleFactor() > 0) { + // just update the location of the shape in case of affine transformation + TopoDS_Shape aShape = theShape->impl(); + if (!aShape.IsNull()) { + aShape.Move(theTrsf); + aResult->setImpl(new TopoDS_Shape(aShape)); + } + } + else { + // all other transformations will modify the shape + GeomTrsfPtr aTrsf = std::make_shared(new gp_Trsf(theTrsf)); + GeomAlgoAPI_Transform aTransform(theShape, aTrsf); + aResult = aTransform.shape(); + } + return aResult; +} + std::shared_ptr Model_ResultPart::shape() { std::shared_ptr aResult(new GeomAPI_Shape); @@ -195,12 +219,8 @@ std::shared_ptr Model_ResultPart::shape() ResultPtr anOrigResult = baseRef(); std::shared_ptr anOrigShape = anOrigResult->shape(); if (anOrigShape.get()) { - TopoDS_Shape aShape = anOrigShape->impl(); - if (!aShape.IsNull()) { - aShape.Move(*(myTrsf.get())); - myShape = aShape; - aResult->setImpl(new TopoDS_Shape(aShape)); - } + aResult = transformShape(anOrigShape, *myTrsf); + myShape = aResult->impl(); } if (!myShape.IsNull() && aToSendUpdate) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -291,7 +311,7 @@ std::wstring Model_ResultPart::nameInPart(const std::shared_ptr& std::shared_ptr aDoc = std::dynamic_pointer_cast(partDoc()); if (!aDoc.get()) // the part document is not presented for the moment return L""; - TDF_Label anAccessLabel = aDoc->generalLabel(); + MAYBE_UNUSED TDF_Label anAccessLabel = aDoc->generalLabel(); // make the selection attribute anyway: // otherwise just by name it is not stable to search the result std::wstring aName; @@ -328,7 +348,11 @@ bool Model_ResultPart::updateInPart(const int theIndex) AttributeSelectionListPtr aSelAttr = aDoc->selectionInPartFeature(); AttributeSelectionPtr aThisAttr = aSelAttr->value(theIndex - 1); if (aThisAttr.get()) { - return aThisAttr->update(); + if (aThisAttr->update()) { + bool aRemove = false; + aThisAttr->updateInHistory(aRemove); + return true; // it was updated + } } } return false; // something is wrong