From: vsv Date: Fri, 5 Sep 2014 11:54:01 +0000 (+0400) Subject: Issue #106: Constraints creation fixed X-Git-Tag: V_0.4.4~78^2~3^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=befe2f6438631197ec075e66c34586d98cf5cce9;p=modules%2Fshaper.git Issue #106: Constraints creation fixed --- diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index 157ccb45d..5e447ef1d 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -110,8 +110,6 @@ bool ModuleBase_WidgetPoint2D::storeValue() const ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this; bool isBlocked = that->blockSignals(true); - double aX = myXSpin->value(); - double aY = myYSpin->value(); aPoint->setValue(myXSpin->value(), myYSpin->value()); updateObject(myFeature); that->blockSignals(isBlocked); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index e8ea4bfbe..97a08e134 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -36,26 +36,24 @@ void SketchPlugin_ConstraintDistance::execute() AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::VALUE())); - if (!anAttr_Value->isInitialized()) { - boost::shared_ptr aPoint_A = getFeaturePoint( - aData, SketchPlugin_Constraint::ENTITY_A()); - boost::shared_ptr aPoint_B = getFeaturePoint( - aData, SketchPlugin_Constraint::ENTITY_B()); + boost::shared_ptr aPoint_A = getFeaturePoint( + aData, SketchPlugin_Constraint::ENTITY_A()); + boost::shared_ptr aPoint_B = getFeaturePoint( + aData, SketchPlugin_Constraint::ENTITY_B()); - if (aPoint_A && aPoint_B) { // both points - anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt())); - } else { - if (!aPoint_A && aPoint_B) { //Line and point - boost::shared_ptr aLine = getFeatureLine( - aData, SketchPlugin_Constraint::ENTITY_A()); - if (aLine) - anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt())); - } else if (aPoint_A && !aPoint_B) { // Point and line - boost::shared_ptr aLine = getFeatureLine( - aData, SketchPlugin_Constraint::ENTITY_B()); - if (aLine) - anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt())); - } + if (aPoint_A && aPoint_B) { // both points + anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt())); + } else { + if (!aPoint_A && aPoint_B) { //Line and point + boost::shared_ptr aLine = getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_A()); + if (aLine) + anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt())); + } else if (aPoint_A && !aPoint_B) { // Point and line + boost::shared_ptr aLine = getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_B()); + if (aLine) + anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt())); } } } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 94f23ae87..e7ed5411c 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -31,25 +31,21 @@ void SketchPlugin_ConstraintLength::initAttributes() void SketchPlugin_ConstraintLength::execute() { - if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() - && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) { - - boost::shared_ptr aRef = boost::dynamic_pointer_cast< - ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); - if (aFeature) { - // set length value - boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast< - GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID())); - boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast< - GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID())); - - double aLenght = aPoint1->pnt()->distance(aPoint2->pnt()); - - boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< - ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); - aValueAttr->setValue(aLenght); - } + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); + if (aFeature) { + // set length value + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID())); + boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID())); + + double aLenght = aPoint1->pnt()->distance(aPoint2->pnt()); + + boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); + aValueAttr->setValue(aLenght); } } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index dcbd7c9ae..133bc91bb 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -34,32 +34,28 @@ void SketchPlugin_ConstraintRadius::initAttributes() void SketchPlugin_ConstraintRadius::execute() { - if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() - && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) { - - boost::shared_ptr aRef = boost::dynamic_pointer_cast< - ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); - if (aFeature) { - double aRadius = 0; - boost::shared_ptr aData = aFeature->data(); - if (aFeature->getKind() == SketchPlugin_Circle::ID()) { - AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Circle::RADIUS_ID())); - if (anAttribute) - aRadius = anAttribute->value(); - } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) { - boost::shared_ptr aCenterAttr = boost::dynamic_pointer_cast< - GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID())); - boost::shared_ptr aStartAttr = boost::dynamic_pointer_cast< - GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID())); - if (aCenterAttr && aStartAttr) - aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt()); - } - boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< - ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); - aValueAttr->setValue(aRadius); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); + if (aFeature) { + double aRadius = 0; + boost::shared_ptr aData = aFeature->data(); + if (aFeature->getKind() == SketchPlugin_Circle::ID()) { + AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Circle::RADIUS_ID())); + if (anAttribute) + aRadius = anAttribute->value(); + } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) { + boost::shared_ptr aCenterAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID())); + boost::shared_ptr aStartAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID())); + if (aCenterAttr && aStartAttr) + aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt()); } + boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); + aValueAttr->setValue(aRadius); } }