Salome HOME
Fix compilation on Linux
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.cpp
index dc56812fc3bc3da50f36fa2dd1fc2cb4f1fa4eb3..8a85cd6f49d438e2419fb271686611e9721d456d 100644 (file)
@@ -32,6 +32,7 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
       myIsEditing(false),
       myState(Stored),
       myIsValueStateBlocked(false),
+      myFlushUpdateBlocked(false),
       myWidgetValidator(0)
 {
   myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false);
@@ -86,7 +87,7 @@ QString ModuleBase_ModelWidget::getValueStateError() const
   return anError;
 }
 
-QString ModuleBase_ModelWidget::getError() const
+QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const
 {
   QString anError;
 
@@ -109,7 +110,7 @@ QString ModuleBase_ModelWidget::getError() const
   }
 
   anError = QString::fromStdString(anErrorMsg);
-  if (anError.isEmpty())
+  if (anError.isEmpty() && theValueStateChecked)
     anError = getValueStateError();
 
   return anError;
@@ -138,11 +139,16 @@ void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted)
   }
 }
 
-void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue)
+void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue,
+                                        const bool isUpdateFlushed)
 {
+  /// it is possible to give this flag as parameter in storeValue/storeCustomValue
+  /// after debug, it may be corrected
+  myFlushUpdateBlocked = !isUpdateFlushed;
   myFeature = theFeature;
   if (theToStoreValue)
     storeValue();
+  myFlushUpdateBlocked = false;
 }
 
 bool ModuleBase_ModelWidget::focusTo()
@@ -285,13 +291,12 @@ bool ModuleBase_ModelWidget::restoreValue()
   return isDone;
 }
 
-void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj)
+void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
 {
-  blockUpdateViewer(true);
-
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-
-  blockUpdateViewer(false);
+  if (!myFlushUpdateBlocked) {
+    ModuleBase_Tools::flushUpdated(theObject);
+    emit objectUpdated();
+  }
 }
 
 void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
@@ -360,23 +365,3 @@ void ModuleBase_ModelWidget::onWidgetValuesModified()
 {
   setValueState(ModifiedInPP);
 }
-
-//**************************************************************
-void ModuleBase_ModelWidget::blockUpdateViewer(const bool theValue)
-{
-  // the viewer update should be blocked in order to avoid the temporary feature content
-  // when the solver processes the feature, the redisplay message can be flushed
-  // what caused the display in the viewer preliminary states of object
-  // e.g. fillet feature, angle value change
-  std::shared_ptr<Events_Message> aMsg;
-  if (theValue) {
-    aMsg = std::shared_ptr<Events_Message>(
-        new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
-  }
-  else {
-    // the viewer update should be unblocked
-    aMsg = std::shared_ptr<Events_Message>(
-        new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
-  }
-  Events_Loop::loop()->send(aMsg);
-}