]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #106: Constraints creation fixed
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 5 Sep 2014 11:54:01 +0000 (15:54 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 5 Sep 2014 11:54:01 +0000 (15:54 +0400)
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp

index 157ccb45d74fd5737bcdfd4387bc2dd7a2c090cc..5e447ef1deeeaa74f9fd8cc17ccc4dba815d6e4a 100644 (file)
@@ -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);
index e8ea4bfbed0c10497c1a1b40e82b36023e3b74cf..97a08e13403e3f60850dd654e88b9b832bfeb917 100644 (file)
@@ -36,26 +36,24 @@ void SketchPlugin_ConstraintDistance::execute()
   AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
       aData->attribute(SketchPlugin_Constraint::VALUE()));
 
-  if (!anAttr_Value->isInitialized()) {
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
-        aData, SketchPlugin_Constraint::ENTITY_A());
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
-        aData, SketchPlugin_Constraint::ENTITY_B());
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+      aData, SketchPlugin_Constraint::ENTITY_A());
+  boost::shared_ptr<GeomDataAPI_Point2D> 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<SketchPlugin_Line> 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<SketchPlugin_Line> 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<SketchPlugin_Line> 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<SketchPlugin_Line> aLine = getFeatureLine(
+          aData, SketchPlugin_Constraint::ENTITY_B());
+      if (aLine)
+        anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
     }
   }
 }
index 94f23ae872d71596462cfc77dc844f7ee91c4cbf..e7ed5411ccb608c54e03e606d0b20b994ed4c0dd 100644 (file)
@@ -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<ModelAPI_AttributeRefAttr> 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<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
-          GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
-      boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
-          GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
-
-      double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-
-      boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
-          ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
-      aValueAttr->setValue(aLenght);
-    }
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
+        GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
+        GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
+
+    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+
+    boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    aValueAttr->setValue(aLenght);
   }
 }
 
index dcbd7c9ae7fdd9b092edfcf10bf0526cf2b516a4..133bc91bb74e8639694c2193eb7e372e1b58518d 100644 (file)
@@ -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<ModelAPI_AttributeRefAttr> 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<ModelAPI_Data> aData = aFeature->data();
-      if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
-        AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-            aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
-        if (anAttribute)
-          aRadius = anAttribute->value();
-      } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
-        boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
-            GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
-        boost::shared_ptr<GeomDataAPI_Point2D> 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<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
-          ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
-      aValueAttr->setValue(aRadius);
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<ModelAPI_Data> aData = aFeature->data();
+    if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+      AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+          aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+      if (anAttribute)
+        aRadius = anAttribute->value();
+    } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+      boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+          GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+      boost::shared_ptr<GeomDataAPI_Point2D> 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<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    aValueAttr->setValue(aRadius);
   }
 }