Salome HOME
Hide "by general equation" case for plane creation
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetValidated.cpp
index 97723530bd21371533a04ec5474ced4baa4936f1..0c84fa8e9ad0e4b86512fe7b60ccb88dfa32a470 100644 (file)
@@ -11,6 +11,8 @@
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 
+#include <Events_Loop.h>
+
 #include <QWidget>
 
 ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent,
@@ -24,27 +26,47 @@ ModuleBase_WidgetValidated::~ModuleBase_WidgetValidated()
 {
 }
 
+//********************************************************************
 bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue)
 {
   bool isDone = false;
 
-  Handle(SelectMgr_EntityOwner) anOwner = theValue.owner();
-  if (isValid(anOwner)) {
-    setSelection(anOwner);
+  if (isValidSelection(theValue)) {
+    isDone = setSelectionCustom(theValue);
     updateObject(myFeature);
     emit valuesChanged();
   }
   return isDone;
 }
 
-bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& theOwner)
+//********************************************************************
+bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue)
 {
-  backupAttributeValue(true);
+  DataPtr aData = myFeature->data();
+  AttributePtr anAttribute = myFeature->attribute(attributeID());
+
+  // stores the current values of the widget attribute
+  Events_Loop* aLoop = Events_Loop::loop();
+  // blocks the flush signals to avoid the temporary objects visualization in the viewer
+  // they should not be shown in order to do not lose highlight by erasing them
+  aLoop->activateFlushes(false);
+
+  aData->blockSendAttributeUpdated(true);
+  bool isAttributeBlocked = anAttribute->blockSetInitialized(true);
+  storeAttributeValue();
+
+  // saves the owner value to the widget attribute
+  bool aValid = setSelectionCustom(theValue);
 
-  setSelection(theOwner);
-  bool aValid = isValidAttribute();
+  if (aValid)
+    // checks the attribute validity
+    aValid = isValidAttribute();
 
-  backupAttributeValue(false);
+  // restores the current values of the widget attribute
+  restoreAttributeValue(aValid);
+  aData->blockSendAttributeUpdated(false);
+  anAttribute->blockSetInitialized(isAttributeBlocked);
+  aLoop->activateFlushes(true);
 
   return aValid;
 }
@@ -61,9 +83,6 @@ bool ModuleBase_WidgetValidated::isValidAttribute() const
   DataPtr aData = myFeature->data();
   AttributePtr anAttribute = myFeature->attribute(attributeID());
 
-  aData->blockSendAttributeUpdated(true);
-
-    // 3. check the acceptability of the current values
   std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
   std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
   bool aValid = true;
@@ -74,8 +93,6 @@ bool ModuleBase_WidgetValidated::isValidAttribute() const
       aValid = aAttrValidator->isValid(anAttribute, *aArgs);
     }
   }
-  aData->blockSendAttributeUpdated(false);
-
   return aValid;
 }