Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Thu, 2 Apr 2015 07:14:51 +0000 (10:14 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 2 Apr 2015 07:14:51 +0000 (10:14 +0300)
src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_ConstraintGroup.cpp

index 23d1858b66b1d247a9da7c2f18a034e74c92f5dd..79cac01e7d10411a328c68a2db727a9f3eb7e2ae 100644 (file)
@@ -52,6 +52,7 @@ void SketchPlugin_ConstraintFillet::initAttributes()
 void SketchPlugin_ConstraintFillet::execute()
 {
   std::shared_ptr<ModelAPI_Data> aData = data();
+  ResultConstructionPtr aRC;
   // Check the base objects are initialized
   double aFilletRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
       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<ModelAPI_AttributeRefList>(
       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<ModelAPI_ResultConstruction>(aFilletArcObj);
+    FeaturePtr aFilletArcFeature = aRC ? aRC->document()->feature(aRC) : 
+      std::dynamic_pointer_cast<ModelAPI_Feature>(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<ModelAPI_AttributeRefAttr>(
+          aSubFeature->attribute(SketchPlugin_Constraint::ENTITY_A()));
+      if (!aRefAttr || !aRefAttr->isObject())
+        continue;
+      aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aRefAttr->object());
+      FeaturePtr aFeature = aRC ? aRC->document()->feature(aRC) : 
+        std::dynamic_pointer_cast<ModelAPI_Feature>(aRefAttr->object());
+      if (aFeature == aFilletArcFeature) {
+        AttributeDoublePtr aRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+            aSubFeature->attribute(SketchPlugin_Constraint::VALUE()));
+        aRadius->setValue(aFilletRadius);
+      }
+    }
     return;
+  }
   // Obtain features for the base objects
   FeaturePtr aFeatureA, aFeatureB;
-  ResultConstructionPtr aRC =
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseA->object());
+  aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseA->object());
   if (aRC) aFeatureA = aRC->document()->feature(aRC);
   aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(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)
index 8301d9d181858ac16ff6e2cd3f53f2f8fe2e6e9b..caeb92d8d45f78528ad6fc4854d353f8f49fb901 100644 (file)
       </feature>
       
     <!--  SketchConstraintEqual  -->
-      <feature id="SketchConstraintEqual" title="Equal" tooltip="Create constraint defining equality of two objects" icon=":icons/equal.png">
+      <feature id="SketchConstraintEqual" title="Equal"
+        tooltip="Create constraint defining equal lengths of two lines or line and arc or equal radii of two arcs or two circles or arc and circle"
+        icon=":icons/equal.png">
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line, circle or arc" shape_types="edge">
         </sketch_constraint_shape_selector>
index f54067afa647d3c20c62e7a9d85a5bff5a328ade..6462775d46f17a05ea0c0154febb262994f98cf8 100644 (file)
@@ -662,6 +662,22 @@ bool SketchSolver_ConstraintGroup::changeMirrorConstraint(
 
   std::list<ObjectPtr> aBaseList = aBaseRefList->list();
   std::list<ObjectPtr> aMirroredList = aMirroredRefList->list();
+  // remove all empty items
+  std::list<ObjectPtr>::iterator anIt = aBaseList.begin();
+  std::list<ObjectPtr>::iterator aTmpIt;
+  while (anIt != aBaseList.end()) {
+    aTmpIt = anIt;
+    anIt++;
+    if (!(*aTmpIt))
+      aBaseList.erase(aTmpIt);
+  }
+  anIt = aMirroredList.begin();
+  while (anIt != aMirroredList.end()) {
+    aTmpIt = anIt;
+    anIt++;
+    if (!(*aTmpIt))
+      aMirroredList.erase(aTmpIt);
+  }
   if (aBaseList.empty() || aBaseList.size() != aMirroredList.size())
     return false;