Salome HOME
Issue #2082: Sketch multiple rotation does not work as expected
authorazv <azv@opencascade.com>
Wed, 5 Apr 2017 07:58:58 +0000 (10:58 +0300)
committerazv <azv@opencascade.com>
Wed, 5 Apr 2017 10:50:38 +0000 (13:50 +0300)
Avoid blocking features in PlaneGCSSolver for a long time.

src/SketchPlugin/SketchPlugin_Trim.cpp
src/SketchSolver/SketchSolver_Manager.cpp
src/SketchSolver/SketchSolver_Manager.h

index 538f1b937dded160610dd96f491ebd9550bdf7e9..f2d2c4da8bc856f4ef3492a3152cf05b32eece81 100644 (file)
@@ -1045,7 +1045,6 @@ FeaturePtr SketchPlugin_Trim::trimArc(const std::shared_ptr<GeomAPI_Pnt2d>& theS
                                (aBaseFeature->attribute(aModifiedAttribute)));
 
     // equal Radius constraint for arcs
-    anNewFeature->execute(); // we need the created arc result to set equal constraint
     createConstraintForObjects(SketchPlugin_ConstraintEqual::ID(),
                                getFeatureResult(aBaseFeature),
                                getFeatureResult(anNewFeature));
@@ -1279,7 +1278,7 @@ FeaturePtr SketchPlugin_Trim::createArcFeature(const FeaturePtr& theBaseFeature,
     bool aReversed = theBaseFeature->boolean(SketchPlugin_Arc::REVERSED_ID())->value();
     aFeature->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(aReversed);
   }
-  //aFeature->execute(); // to obtain result
+  aFeature->execute(); // to obtain result (need to calculate arc parameters before sending Update)
   aFeature->data()->blockSendAttributeUpdated(aWasBlocked);
 
   #ifdef DEBUG_TRIM
index ec2f8d77bbb5be2f5047486ca7579ed016315d14..849c95b0c9eb6ac72de7010c53c2ec4abbb99b1a 100644 (file)
@@ -151,6 +151,7 @@ void SketchSolver_Manager::processEvent(
 
   // resolve constraints if needed
   bool needToUpdate = needToResolve && resolveConstraints();
+  releaseFeaturesIfEventsBlocked();
 
   // Features may be updated => now send events, but for all changed at once
   if (isUpdateFlushed)
@@ -238,11 +239,17 @@ bool SketchSolver_Manager::resolveConstraints()
   for (; aGroupIter != myGroups.end(); ++aGroupIter) {
     if ((*aGroupIter)->resolveConstraints())
       needToUpdate = true;
-    (*aGroupIter)->blockEvents(false);
   }
   return needToUpdate;
 }
 
+void SketchSolver_Manager::releaseFeaturesIfEventsBlocked() const
+{
+  std::list<SketchGroupPtr>::const_iterator aGroupIter = myGroups.begin();
+  for (; aGroupIter != myGroups.end(); ++aGroupIter)
+    (*aGroupIter)->blockEvents(false);
+}
+
 bool SketchSolver_Manager::stopSendUpdate() const
 {
 static const Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
index d69cccbfd4a8e5c8a1926aded8091b0a3fbb75a6..fc1b4222956f80db2f05942fc36b34cc9afa9530 100644 (file)
@@ -77,8 +77,11 @@ private:
   /// \brief Allow to send the Update event
   void allowSendUpdate() const;
 
+  /// \brief Allow send events about changing features in groups
+  void releaseFeaturesIfEventsBlocked() const;
+
 private:
-  std::list<SketchGroupPtr>   myGroups;  ///< Groups of constraints
+  std::list<SketchGroupPtr> myGroups; ///< Groups of constraints
   /// true if computation is performed and all "updates" are generated by this algo
   /// and needs no recomputation
   bool myIsComputed;