// Author: Natalia ERMOLAEVA
#include "ModuleBase_ModelWidget.h"
+#include "ModuleBase_ViewerPrs.h"
#include "ModuleBase_Tools.h"
+#include "ModuleBase_WidgetValidator.h"
#include <ModelAPI_Data.h>
#include <ModelAPI_Attribute.h>
: QWidget(theParent),
myIsEditing(false),
myState(Stored),
- myIsValueStateBlocked(false)
+ myIsValueStateBlocked(false),
+ myFlushUpdateBlocked(false),
+ myWidgetValidator(0)
{
myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false);
return anError;
}
-QString ModuleBase_ModelWidget::getError() const
+QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const
{
QString anError;
}
anError = QString::fromStdString(anErrorMsg);
- if (anError.isEmpty())
+ if (anError.isEmpty() && theValueStateChecked)
anError = getValueStateError();
return anError;
}
}
-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()
if (anAttribute.get() != NULL && !anAttribute->isInitialized())
initializeValueByActivate();
}
+
+ if (myWidgetValidator)
+ myWidgetValidator->activateFilters(true);
+
activateCustom();
}
if (myState == ModifiedInPP || myState == ModifiedInViewer)
storeValue();
myState = Stored;
+
+ if (myWidgetValidator)
+ myWidgetValidator->activateFilters(false);
}
void ModuleBase_ModelWidget::initializeValueByActivate()
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)
{
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);
-}