From cfd44d0795f017350cfcc8e472087477499a69c9 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 14 Apr 2016 17:47:52 +0300 Subject: [PATCH] 1. Correction for perfomance problem by Apply button state update: do not flush updated signal for each widget filling for the feature when operation is started. Do it once after the widgets are filled by feature on start operation. --- src/ModuleBase/ModuleBase_ModelWidget.cpp | 14 +++++++++++--- src/ModuleBase/ModuleBase_ModelWidget.h | 6 +++++- src/XGUI/XGUI_Workshop.cpp | 5 ++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index b1d5b5a46..cf6721992 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -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); @@ -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() @@ -287,8 +293,10 @@ bool ModuleBase_ModelWidget::restoreValue() void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject) { - ModuleBase_Tools::flushUpdated(theObject); - emit objectUpdated(); + if (!myFlushUpdateBlocked) { + ModuleBase_Tools::flushUpdated(theObject); + emit objectUpdated(); + } } void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index def9a3fcb..6face1021 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -180,7 +180,9 @@ Q_OBJECT /// Set feature which is processing by active operation /// \param theFeature a feature object /// \param theToStoreValue a value about necessity to store the widget value to the feature - void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false); + /// \param isUpdateFlushed a flag if update should be flushed on store value + void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false, + const bool isUpdateFlushed = true); /// Editing mode depends on mode of current operation. This value is defined by it. virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; } @@ -320,6 +322,8 @@ private: bool myUseReset; /// blocked flag of modification of the value state bool myIsValueStateBlocked; + /// do not flush updated signal + bool myFlushUpdateBlocked; }; #endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 0e20e9ab1..1b601779c 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -485,13 +485,16 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation) return; } } + // for performance purpose, flush should be done after all controls are filled + bool isUpdateFlushed = false; foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { bool isStoreValue = !aFOperation->isEditOperation() && !aWidget->getDefaultValue().empty() && !aWidget->isComputedDefault(); - aWidget->setFeature(aFeature, isStoreValue); + aWidget->setFeature(aFeature, isStoreValue, isUpdateFlushed); aWidget->enableFocusProcessing(); } + ModuleBase_Tools::flushUpdated(aFeature); // update visible state of Preview button #ifdef HAVE_SALOME -- 2.39.2