From: nds Date: Tue, 30 Jun 2015 10:12:59 +0000 (+0300) Subject: Issue #690 Application hangs up when Create Arc after Rotation X-Git-Tag: V_1.3.0~150^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ab1bda83012eb4d966504330bde07d18d0bbf3d0;p=modules%2Fshaper.git Issue #690 Application hangs up when Create Arc after Rotation preselection of external vertex - constraint is not created. --- diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 5b5659a1c..62709442b 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -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 aData = aFeature->data(); + + std::shared_ptr aRef1 = std::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); + AttributePtr aThisAttr = feature()->data()->attribute(attributeID()); + std::shared_ptr aThisPoint = + std::dynamic_pointer_cast(aThisAttr); + aRef1->setAttr(aThisPoint); + + std::shared_ptr 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 aData = aFeature->data(); - - std::shared_ptr aRef1 = std::dynamic_pointer_cast< - ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - AttributePtr aThisAttr = feature()->data()->attribute(attributeID()); - std::shared_ptr aThisPoint = - std::dynamic_pointer_cast(aThisAttr); - aRef1->setAttr(aThisPoint); - - std::shared_ptr 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; diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index 77ead09c2..6e9ba6003 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -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