]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Crash fix: start rectangle, click 1st point, click 2nd point over axis(to be external...
authornds <nds@opencascade.com>
Fri, 26 Feb 2016 18:11:29 +0000 (21:11 +0300)
committernds <nds@opencascade.com>
Fri, 26 Feb 2016 18:11:29 +0000 (21:11 +0300)
Fixed object was created, rectangle feature is used as an argument of coincidence constraint.
Solution: do not use rectangle feature in the coincidence creating.

src/ModuleBase/ModuleBase_OperationFeature.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp

index 950a20efa66a48108f84326212c7ac4af5920d19..6dcda35c2427655c54b216ec5c47338cbc385f31 100755 (executable)
 
 #include <QTimer>
 
+// the define to check the activated object as a sub-feature by argument of
+// the operation feature. E.g. rectangle feature(operation), line(in argument) to be not activated
+//#define DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE
+#ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE
+#include <ModelAPI_AttributeRefList.h>
+#endif
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
@@ -187,6 +194,25 @@ bool ModuleBase_OperationFeature::hasObject(ObjectPtr theObj) const
       if (theObj == (*aIt))
         return true;
     }
+#ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE
+    FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObj);
+    std::list<AttributePtr> anAttributes = aFeature->data()->attributes(
+                                            ModelAPI_AttributeRefList::typeId());
+    std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
+    bool aFoundObject = false;
+    for (; anIt != aLast && !aFoundObject; anIt++) {
+      std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
+                                       std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anIt);
+      for (int i = 0, aNb = aCurSelList->size(); i < aNb && !aFoundObject; i++) {
+        ObjectPtr anObject = aCurSelList->object(i);
+        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+        if (aFeature.get()) {
+          aFoundObject = anObjectFeature == aFeature;
+        }
+      }
+    }
+    return aFoundObject;
+#endif
   }
   return false;
 }
index 072143b246a068559e3934899894b8e41a769ef1..50ac3e3eeeaed11c766c01c4c12263aa7b89f56f 100644 (file)
@@ -410,6 +410,8 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
   if (theEvent->button() != Qt::LeftButton)
     return;
 
+  bool isCoincidenceEnabled = MyFeaturesForCoincedence.contains(myFeature->getKind().c_str());
+
   ModuleBase_ISelection* aSelection = myWorkshop->selection();
   Handle(V3d_View) aView = theWnd->v3dView();
   // TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
@@ -427,11 +429,13 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
       aSPFeature = std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
       if ((!aSPFeature && !aShape.IsNull()) ||
           (aSPFeature.get() && aSPFeature->isExternal())) {
-        anExternal = true;
-        ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
-        if (!aFixedObject.get())
-          aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
-
+          ResultPtr aFixedObject;
+          if (isCoincidenceEnabled) {
+          anExternal = true;
+          aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
+          if (!aFixedObject.get())
+            aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+        }
         double aX, aY;
         if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
           // do not create a constraint to the point, which already used by the feature
@@ -455,8 +459,8 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
               }
             }
           }
-
-          setConstraintWith(aFixedObject);
+          if (aFixedObject.get())
+            setConstraintWith(aFixedObject);
           // fignal updated should be flushed in order to visualize possible created external objects
           // e.g. selection of trihedron axis when input end arc point
           updateObject(feature());
@@ -486,7 +490,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
           PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
         }
         else if (aShape.ShapeType() == TopAbs_EDGE) {
-          if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str())) {
+          if (isCoincidenceEnabled) {
             setConstraintWith(aObject);
             setValueState(Stored); // in case of edge selection, Apply state should also be updated