Call update in history of attribute created for the external part selection.
/// Updates the arguments of selection if something was affected by creation
/// or reorder of features upper in the history line (issue #1757)
/// Returns theRemove true if this attribute must be removed (become deleted)
- MODEL_EXPORT virtual void updateInHistory(bool& theRemove);
+ MODEL_EXPORT virtual void updateInHistory(bool& theRemove) override;
// Implementation of the name generator method from the Selector package
// This method returns the context name by the label of the sub-selected shape
bool Model_Objects::isLater(FeaturePtr theLater, FeaturePtr theCurrent) const
{
+ if (theLater->getKind() == "InternalSelectionInPartFeature")
+ return true;
std::shared_ptr<Model_Data> aLaterD = std::static_pointer_cast<Model_Data>(theLater->data());
std::shared_ptr<Model_Data> aCurrentD = std::static_pointer_cast<Model_Data>(theCurrent->data());
if (aLaterD.get() && aLaterD->isValid() && aCurrentD.get() && aCurrentD->isValid()) {
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
#include <Model_Document.h>
#include <Model_Data.h>
#include <Model_Objects.h>
-#include <Model_AttributeSelection.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
(*anObj)->data()->attributes(ModelAPI_AttributeSelection::typeId());
std::list<AttributePtr>::iterator aRefsIter = aRefs.begin();
for (; aRefsIter != aRefs.end(); aRefsIter++) {
- std::shared_ptr<Model_AttributeSelection> aSel =
- std::dynamic_pointer_cast<Model_AttributeSelection>(*aRefsIter);
+ AttributeSelectionPtr aSel =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
bool aRemove = false;
aSel->updateInHistory(aRemove);
}
std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
for(int a = aSel->size() - 1; a >= 0; a--) {
- std::shared_ptr<Model_AttributeSelection> aSelAttr =
- std::dynamic_pointer_cast<Model_AttributeSelection>(aSel->value(a));
+ AttributeSelectionPtr aSelAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
if (aSelAttr.get()) {
- bool theRemove = false;
- aSelAttr->updateInHistory(theRemove);
- if (theRemove) {
+ bool aRemove = false;
+ aSelAttr->updateInHistory(aRemove);
+ if (aRemove) {
aRemoveSet.insert(a);
}
}
Test19058.py
Test19217.py
Test19707.py
+ Test19726.py
)
/// Makes the current local selection becomes all sub-shapes with same base geometry.
MODELAPI_EXPORT virtual void combineGeometrical() = 0;
+ /// Updates the arguments of selection if something was affected by creation
+ /// or reorder of features upper in the history line.
+ /// Returns theRemove true if this attribute must be removed (become deleted)
+ MODELAPI_EXPORT virtual void updateInHistory(bool& theRemove) = 0;
+
protected:
/// Objects are created for features automatically
MODELAPI_EXPORT ModelAPI_AttributeSelection();
--- /dev/null
+# Copyright (C) 2014-2020 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+from ModelAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchCircle_1 = Sketch_1.addCircle(18.39021699364881, 11.50401662688171, 4.123179523509023)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
+model.do()
+Translation_1 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], axis = model.selection("EDGE", "Part_1/([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])"), distance = 20, keepSubResults = True)
+aName1 = Translation_1.axisObject().namingName()
+model.end()
+
+# update the extrusion in the part, so, outside the part selection must be moved in history
+model.begin()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = 45)
+model.do()
+aSession = ModelAPI_Session.get()
+aSession.setActiveDocument(partSet)
+model.end()
+
+# check that name was changed to the rotation
+aName2 = Translation_1.axisObject().namingName()
+assert(aName1 != aName2)
+assert(len(aName2) > 7)
+
+assert(model.checkPythonDump())