From: azv Date: Thu, 2 Apr 2015 06:47:45 +0000 (+0300) Subject: Fix the problem with undoing fillet X-Git-Tag: V_1.1.0~63^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=40283a47dd172dc99edfe3591489f421d8d8f9e5;p=modules%2Fshaper.git Fix the problem with undoing fillet --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index 23d1858b6..79cac01e7 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -52,6 +52,7 @@ void SketchPlugin_ConstraintFillet::initAttributes() void SketchPlugin_ConstraintFillet::execute() { std::shared_ptr aData = data(); + ResultConstructionPtr aRC; // Check the base objects are initialized double aFilletRadius = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::VALUE()))->value(); @@ -65,12 +66,37 @@ void SketchPlugin_ConstraintFillet::execute() // Check the fillet shapes is not initialized yet AttributeRefListPtr aRefListOfFillet = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::ENTITY_C())); - if (aRefListOfFillet->size() > 0) + if (aRefListOfFillet->size() > 0) { + // update the Radius constraint + ObjectPtr aFilletArcObj = aRefListOfFillet->list().back(); + aRC = std::dynamic_pointer_cast(aFilletArcObj); + FeaturePtr aFilletArcFeature = aRC ? aRC->document()->feature(aRC) : + std::dynamic_pointer_cast(aFilletArcObj); + + int aNbSubs = sketch()->numberOfSubs(); + FeaturePtr aSubFeature; + for (int aSub = 0; aSub < aNbSubs; aSub++) { + aSubFeature = sketch()->subFeature(aSub); + if (aSubFeature->getKind() != SketchPlugin_ConstraintRadius::ID()) + continue; + AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast( + aSubFeature->attribute(SketchPlugin_Constraint::ENTITY_A())); + if (!aRefAttr || !aRefAttr->isObject()) + continue; + aRC = std::dynamic_pointer_cast(aRefAttr->object()); + FeaturePtr aFeature = aRC ? aRC->document()->feature(aRC) : + std::dynamic_pointer_cast(aRefAttr->object()); + if (aFeature == aFilletArcFeature) { + AttributeDoublePtr aRadius = std::dynamic_pointer_cast( + aSubFeature->attribute(SketchPlugin_Constraint::VALUE())); + aRadius->setValue(aFilletRadius); + } + } return; + } // Obtain features for the base objects FeaturePtr aFeatureA, aFeatureB; - ResultConstructionPtr aRC = - std::dynamic_pointer_cast(aBaseA->object()); + aRC = std::dynamic_pointer_cast(aBaseA->object()); if (aRC) aFeatureA = aRC->document()->feature(aRC); aRC = std::dynamic_pointer_cast(aBaseB->object()); if (aRC) aFeatureB = aRC->document()->feature(aRC); @@ -246,19 +272,18 @@ void SketchPlugin_ConstraintFillet::execute() ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent); } - // send events - ModelAPI_EventCreator::get()->sendUpdated(FeaturePtr(this), anUpdateEvent); - if (isUpdateFlushed) - Events_Loop::loop()->setFlushed(anUpdateEvent, true); - Events_Loop::loop()->flush(anUpdateEvent); - // make base features auxiliary static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); aFeatureA->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(true); aFeatureB->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(true); ModelAPI_EventCreator::get()->sendUpdated(aFeatureA, aRedisplayEvent); ModelAPI_EventCreator::get()->sendUpdated(aFeatureB, aRedisplayEvent); - Events_Loop::loop()->flush(aRedisplayEvent); +//// Events_Loop::loop()->flush(aRedisplayEvent); + + // send events + if (isUpdateFlushed) + Events_Loop::loop()->setFlushed(anUpdateEvent, true); + Events_Loop::loop()->flush(anUpdateEvent); } AISObjectPtr SketchPlugin_ConstraintFillet::getAISObject(AISObjectPtr thePrevious)