]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Optimization of the movement: call move event for point 2d dragging: the solver will...
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 19 Dec 2014 11:56:35 +0000 (14:56 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 19 Dec 2014 11:56:35 +0000 (14:56 +0300)
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/SketchSolver/SketchSolver_ConstraintManager.h

index 5ca4cd03bd886d764b7ff778751bc2db152cc156..79b00dfe2071fb892d6c3d3799377ad17f3ac438 100644 (file)
@@ -84,7 +84,6 @@ bool ModuleBase_ModelWidget::focusTo()
   return true;
 }
 
-
 void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
 {
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
@@ -92,6 +91,13 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
 }
 
+void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) const
+{
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
+  ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
+  Events_Loop::loop()->flush(anEvent);
+}
+
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 {
   QWidget* aWidget = qobject_cast<QWidget*>(theObject);
index e7a9f24c5b3ea6bdcea127e486100f7524bcead8..e2f23438474bb32d0d1e91f814f507a7eac47633 100644 (file)
@@ -146,6 +146,7 @@ signals:
   }
 
   void updateObject(ObjectPtr theObj) const;
+  void moveObject(ObjectPtr theObj) const;
 
  protected:
   std::string myAttributeID; /// the attribute name of the model feature
index 146dfa692d083494a06a0e2d78a946295cbd7c56..4d84d816834264352a3cb0d1f20b934df7133ec6 100644 (file)
@@ -522,8 +522,8 @@ void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* t
           ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
         }
       }
+      // after movement the solver will call the update event: optimization
       Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
-      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
     }
     myDragDone = true;
     myCurX = aX;
index 104c9cfb5db9928eb2a20363cb69146ad6b70d5d..8079d4885d32cdcf3295c06d15d9673c37c1f302 100644 (file)
@@ -138,7 +138,8 @@ bool PartSet_WidgetPoint2D::storeValue() const
   double _Y = myYSpin->value();
 #endif
   aPoint->setValue(myXSpin->value(), myYSpin->value());
-  updateObject(myFeature);
+  // after movement the solver will call the update event: optimization
+  moveObject(myFeature);
   aPoint->setImmutable(isImmutable);
   that->blockSignals(isBlocked);
 
index e54a41292763daec52ac101d8d6bbbe10bcccbeb..71f062c392a6a3de9537a2c31ed20066c6a36929 100644 (file)
@@ -114,7 +114,7 @@ void SketchSolver_ConstraintManager::processEvent(
     }
 
     // Solve the set of constraints
-    resolveConstraints();
+    resolveConstraints(isMovedEvt); // send update for movement in any case
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
     std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
@@ -372,7 +372,7 @@ std::shared_ptr<ModelAPI_CompositeFeature> SketchSolver_ConstraintManager
 //  Class:    SketchSolver_Session
 //  Purpose:  change entities according to available constraints
 // ============================================================================
-void SketchSolver_ConstraintManager::resolveConstraints()
+void SketchSolver_ConstraintManager::resolveConstraints(const bool theForceUpdate)
 {
   myIsComputed = true;
   bool needToUpdate = false;
@@ -388,12 +388,15 @@ void SketchSolver_ConstraintManager::resolveConstraints()
     if ((*aGroupIter)->resolveConstraints())
       needToUpdate = true;
 
-  // Features may be updated => now send events, btu for all changed at once
+  // Features may be updated => now send events, but for all changed at once
   if (isUpdateFlushed) {
     Events_Loop::loop()->setFlushed(anUpdateEvent, true);
   }
-  if (needToUpdate)
-    Events_Loop::loop()->flush(anUpdateEvent);
+  // Must be before flush because on "Updated" flush the results may be produced
+  // and the creation event is appeared with many new objects. If myIsComputed these
+  // events are missed in processEvents and some elements are not added.
   myIsComputed = false;
+  if (needToUpdate || theForceUpdate)
+    Events_Loop::loop()->flush(anUpdateEvent);
 }
 
index 164308356959094d234b1101f51dd86b1d1f2f24..4604a52b11d7dc233a53e86ae2b12f6753ae6ad2 100644 (file)
@@ -82,8 +82,9 @@ class SketchSolver_ConstraintManager : public Events_Listener
   void updateEntity(std::shared_ptr<SketchPlugin_Feature> theFeature);
 
   /** \brief Goes through the list of groups and solve the constraints
+   *  \param theForceUpdate flushes the update event in any case: something changed or not
    */
-  void resolveConstraints();
+  void resolveConstraints(const bool theForceUpdate);
 
  private:
   /** \brief Searches list of groups which interact with specified feature