From d48cb022ea8263c47120dfc6787156cf663eede0 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 24 Jun 2014 13:19:00 +0400 Subject: [PATCH] refs #80 - Sketch base GUI: create/draw point, circle and arc Use the features to set the default value in the constraint. --- src/ModuleBase/ModuleBase_WidgetFeature.cpp | 1 + .../SketchPlugin_ConstraintDistance.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index dd33700f0..37ed734c0 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -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); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index afb764a5d..d6e2b0075 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -24,6 +24,24 @@ void SketchPlugin_ConstraintDistance::initAttributes() void SketchPlugin_ConstraintDistance::execute() { + boost::shared_ptr aData = data(); + + boost::shared_ptr anAttr_A = + boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::shared_ptr anAttr_B = + boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_B)); + + AttributeDoublePtr anAttribute = + boost::dynamic_pointer_cast(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& SketchPlugin_ConstraintDistance::preview() -- 2.39.2