]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 09:19:00 +0000 (13:19 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 09:19:00 +0000 (13:19 +0400)
Use the features to set the default value in the constraint.

src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp

index dd33700f02b0fd927fa947c9721e77864fe4daae..37ed734c03bc32deea16ecb277ca1e31e696518f 100644 (file)
@@ -50,6 +50,7 @@ bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
   //bool isBlocked = that->blockSignals(true);
   aRef->setFeature(myFeature);
+  theFeature->execute();
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
   //that->blockSignals(isBlocked);
 
index afb764a5dcfcc3654075ebf5847136f9b77e1a2c..d6e2b0075c7958cdbff8f71c55da53209fbd6f6f 100644 (file)
@@ -24,6 +24,24 @@ void SketchPlugin_ConstraintDistance::initAttributes()
 
 void SketchPlugin_ConstraintDistance::execute()
 {
+  boost::shared_ptr<ModelAPI_Data> aData = data();
+
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr_A = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr_B = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+
+  AttributeDoublePtr anAttribute =
+      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+
+  if (anAttr_A && anAttr_B && anAttribute->value() == 0)
+  {
+    FeaturePtr aFeature_A = anAttr_A->feature();
+    FeaturePtr aFeature_B = anAttr_B->feature();
+
+    double aValue = 40; // TODO
+    anAttribute->setValue(aValue);
+  }
 }
 
 const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintDistance::preview()