]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2219: keep the order of remove-shape sub-elements after deselection of some...
authormpv <mpv@opencascade.com>
Thu, 20 Jul 2017 12:07:53 +0000 (15:07 +0300)
committermpv <mpv@opencascade.com>
Thu, 20 Jul 2017 12:08:19 +0000 (15:08 +0300)
src/Model/Model_AttributeSelectionList.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h

index e091a6e9e6fa09505864ebea062e9e3bc702d11e..5207a112024deb535b0e860b5e072f7b7dea05e5 100644 (file)
@@ -237,7 +237,7 @@ bool Model_AttributeSelectionList::isInList(const ResultPtr& theContext,
       std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aShapes = aContext->second.begin();
       for(; aShapes != aContext->second.end(); aShapes++) {
         if (!theSubShape.get()) {
-          if (!aShapes->get())
+          if (!aShapes->get() || (*aShapes)->isSame(aContext->first->shape()))
             return true;
         } else {
           // we need to call here isSame instead of isEqual to do not check shapes orientation
@@ -254,13 +254,13 @@ bool Model_AttributeSelectionList::isInList(const ResultPtr& theContext,
     if (anAttr.get()) {
       if (anAttr->context() == theContext) { // contexts are equal, so, check that values are also
         std::shared_ptr<GeomAPI_Shape> aValue = anAttr->value();
-        if (!aValue.get()) {
-          if (!theSubShape.get()) { // both are null
+        if (!theSubShape.get()) {
+          if (!aValue.get() || aValue->isSame(theContext->shape())) { // both are null
             return true;
           }
         } else {
           // we need to call here isSame instead of isEqual to do not check shapes orientation
-          if (aValue->isSame(theSubShape)) // shapes are equal
+          if (theSubShape->isSame(aValue)) // shapes are equal
             return true;
         }
       }
index 2d0a1225c56446e1b6db14210006f0b68e494824..1c5153c0605e6b52b058915731a7a53acdd5078d 100755 (executable)
@@ -825,11 +825,16 @@ std::map<ObjectPtr, std::set<GeomShapePtr> > ModuleBase_WidgetMultiSelector::con
 }
 
 bool ModuleBase_WidgetMultiSelector::findInSelection(const ObjectPtr& theObject,
-                              const GeomShapePtr& theShape,
+                              GeomShapePtr theShape,
                               const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection)
 {
   bool aFound = false;
   GeomShapePtr anEmptyShape(new GeomAPI_Shape());
+  if (theShape.get()) { // treat shape equal to context as null: 2219, keep order of shapes in list
+    const ResultPtr aContext = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aContext.get() && aContext->shape()->isEqual(theShape))
+      theShape.reset();
+  }
   GeomShapePtr aShape = theShape.get() ? theShape : anEmptyShape;
   if (theGeomSelection.find(theObject) != theGeomSelection.end()) {// found
     const std::set<GeomShapePtr>& aShapes = theGeomSelection.at(theObject);
index 1716cc307c2d5f88e2958e3dac1e942aea539d93..2fecf4ed46412deafbb965906a60dd236930aaf5 100755 (executable)
@@ -186,7 +186,7 @@ protected:
   /// \param theGeomSelection a map built on selection
   /// \return boolean result
   static bool findInSelection(const ObjectPtr& theObject,
-                            const GeomShapePtr& theShape,
+                            GeomShapePtr theShape,
                             const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection);
 
 protected: