Salome HOME
Fix for the issue #2588 : Invalid selection when select feature
authormpv <mpv@opencascade.com>
Wed, 22 Aug 2018 14:17:16 +0000 (17:17 +0300)
committermpv <mpv@opencascade.com>
Wed, 22 Aug 2018 14:17:34 +0000 (17:17 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp
src/FeaturesPlugin/Test/Test2588.py [new file with mode: 0644]

index db68e4533fe601b9aa9e4567733b8f986a192aec..47fea06c91e01b291ca8416a837cc55d7d0f0770 100644 (file)
@@ -325,4 +325,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestBooleanCommon_CompSolidCompound_CompSolidCompound.py
                Test2596.py
                Test2592.py
+               Test2588.py
 )
index 3bd55a63a6e37509e87e02b399bc1269dd31e220..5f8870f5952bb4799b2cf337555b26e35b7a766c 100644 (file)
@@ -135,7 +135,7 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
@@ -277,7 +277,7 @@ void FeaturesPlugin_MultiRotation::performRotation2D()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     std::shared_ptr<GeomAPI_Dir> aDir =
       GeomAlgoAPI_ShapeTools::buildDirFromAxisAndShape(aBaseShape, anAxis);
index 4ef723603299564637fa36297c252bfbd352059f..d23742c6df621107ffa698b33a2287421fa3024d 100644 (file)
@@ -136,7 +136,7 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
@@ -291,7 +291,7 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
index 96b9d01fcecd6a7ac42e801ab21d23d3e610b5ee..ab932f01d6c21ac5993a434a9846b0253f926bda 100644 (file)
@@ -160,7 +160,7 @@ void FeaturesPlugin_Placement::execute()
       anObjectsIt++, aContext++) {
 
     // for part results just set transformation
-    if ((*aContext)->groupName() == ModelAPI_ResultPart::group()) {
+    if (aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group()) {
       ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
       ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
       aResultPart->setTrsf(aContextRes, aTrsf);
index 1c6daf73293bd2b355a9114436552e0632f7fd92..07d2d575c109924f51fbb72a73d1174913faded6 100755 (executable)
@@ -123,7 +123,7 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
index 16e184688f85c6d12b2a7ed0a455ef7747f7126a..d50b74aa2088b65f7e4930cac773dc6ab1a69163 100644 (file)
@@ -139,7 +139,7 @@ void FeaturesPlugin_Symmetry::performSymmetryByPoint()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
@@ -216,7 +216,7 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
@@ -295,7 +295,7 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
index f2978df942527eb5da3beb253cb8a83e4fbe44de..0da4b6acc7fcfa4f99de679fa38c1efd7db4e183 100644 (file)
@@ -136,7 +136,7 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
@@ -218,7 +218,7 @@ void FeaturesPlugin_Translation::performTranslationByDimensions()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
@@ -313,7 +313,7 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
 
     // Setting result.
     if (isPart) {
index 13a0292e0d0bdb60f2576c569ddb7b5b59cb0833..694915de7ed847a676e92e267d98f8f2a761610d 100755 (executable)
@@ -51,9 +51,20 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute
     std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
     ResultPtr aResult = aSelAttribute->context();
     if (!aResult) {
+      // this could be a whole feature selected
+      FeaturePtr aFeature = aSelAttribute->contextFeature();
+      if (aFeature.get() && aFeature->results().size() > 0) {
+        if (aFeature->firstResult()->groupName() != ModelAPI_ResultBody::group()) {
+          anErrorGroupName = aFeature->firstResult()->groupName();
+          aValid = false;
+          break;
+        }
+        continue;
+      }
       theError = "Invalid selection.";
       return false;
-    } if (isPartSetDocument) // PartSet document: Result Part is valid
+    }
+    if (isPartSetDocument) // PartSet document: Result Part is valid
       aValid = aResult->groupName() == ModelAPI_ResultPart::group();
     else { // Part document: Result CompSolid is valid
       aValid = aResult->groupName() == ModelAPI_ResultBody::group();
diff --git a/src/FeaturesPlugin/Test/Test2588.py b/src/FeaturesPlugin/Test/Test2588.py
new file mode 100644 (file)
index 0000000..6b8f476
--- /dev/null
@@ -0,0 +1,49 @@
+## Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+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("YOZ"))
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 2)
+SketchCircle_1.result().setColor(225, 0, 0)
+SketchCircle_1.results()[1].setColor(225, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchPoint_1.result().setColor(170, 0, 225)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates())
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 2)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0)
+Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchCircle_1-SketchProjection_1-SketchPoint_1"), True)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "all-in-Symmetry_1")], model.selection("EDGE", "PartSet/OY"), 5, 3)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-LinearCopy_1")], model.selection("EDGE", "PartSet/OZ"), 45, 8)
+model.end()
+
+from GeomAPI import  GeomAPI_Shape
+
+model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.SOLID, [48])
+
+assert(model.checkPythonDump())