]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #690 Application hangs up when Create Arc after Rotation
authornds <natalia.donis@opencascade.com>
Tue, 30 Jun 2015 10:12:59 +0000 (13:12 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 30 Jun 2015 10:13:33 +0000 (13:13 +0300)
preselection of external vertex - constraint is not created.

src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index 5b5659a1c63e2d4842ba886e282d80501bf87645..62709442b484c9bc4ed9d34f9f8053fcee24ce6d 100644 (file)
@@ -253,6 +253,25 @@ bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
   return false;
 }
 
+void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
+{
+  // Create point-edge coincedence
+  FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
+  std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+
+  std::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = std::dynamic_pointer_cast<
+      ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+  AttributePtr aThisAttr = feature()->data()->attribute(attributeID());
+  std::shared_ptr<GeomDataAPI_Point2D> aThisPoint = 
+    std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
+  aRef1->setAttr(aThisPoint);
+
+  std::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 = std::dynamic_pointer_cast<
+      ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
+  aRef2->setObject(theObject);
+
+  aFeature->execute();
+}
 
 void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
@@ -277,33 +296,21 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
       if ((!aSPFeature) && (!aShape.IsNull())) {
         ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
         if (!aFixedObject.get())
-          aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+          aObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+        setConstraintWith(aObject);
+        emit vertexSelected();
+        emit focusOutWidget(this);
+        return;
       }
     }
     double aX, aY;
     if (getPoint2d(aView, aShape, aX, aY)) {
-      setPoint(aX, aY);
-
       PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
       emit vertexSelected();
       emit focusOutWidget(this);
       return;
     } else if (aShape.ShapeType() == TopAbs_EDGE) {
-      // Create point-edge coincedence
-      FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
-      std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
-
-      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = std::dynamic_pointer_cast<
-          ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-      AttributePtr aThisAttr = feature()->data()->attribute(attributeID());
-      std::shared_ptr<GeomDataAPI_Point2D> aThisPoint = 
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
-      aRef1->setAttr(aThisPoint);
-
-      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 = std::dynamic_pointer_cast<
-          ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
-      aRef2->setObject(aObject);
-      aFeature->execute();
+      setConstraintWith(aObject);
       emit vertexSelected();
       emit focusOutWidget(this);
       return;
index 77ead09c2e9f8809fd753aa40cc2c5d1645ac8be..6e9ba600394b85dec9abac749e0b735da2a62ba9 100644 (file)
@@ -124,6 +124,10 @@ private slots:
    bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape, 
                    double& theX, double& theY) const;
 
+   /// Create a coincidence constraint between the attribute and the parameter object
+   /// \theObject a result object
+   void setConstraintWith(const ObjectPtr& theObject);
+
   ModuleBase_IWorkshop* myWorkshop;
   PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP