From: vsv Date: Fri, 25 Sep 2015 08:57:12 +0000 (+0300) Subject: Improve viewer performance X-Git-Tag: V_1.4.0_demo1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8265a72ffc4629fde76928773cffbca1db07e2dd;p=modules%2Fshaper.git Improve viewer performance --- diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b41682090..4ddd90572 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -96,7 +96,7 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS } XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) - : myWorkshop(theWorkshop), myEnableUpdateViewer(true) + : myWorkshop(theWorkshop), myEnableUpdateViewer(true), myNeedUpdate(false) { enableUpdateViewer(true); myCustomPrs = std::shared_ptr(new XGUI_CustomPrs()); @@ -689,7 +689,10 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled) bool aWasEnabled = myEnableUpdateViewer; myEnableUpdateViewer = isEnabled; - + if (myNeedUpdate && myEnableUpdateViewer) { + updateViewer(); + myNeedUpdate = false; + } return aWasEnabled; } @@ -700,6 +703,8 @@ void XGUI_Displayer::updateViewer() const if (!aContext.IsNull() && myEnableUpdateViewer) { myWorkshop->viewer()->Zfitall(); aContext->UpdateCurrentViewer(); + } else { + myNeedUpdate = true; } } diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index b189189f6..3cd6f9c73 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -141,6 +141,8 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// \param isEnabled a boolean value bool enableUpdateViewer(const bool isEnabled); + bool isUpdateEnabled() const { return myEnableUpdateViewer; } + /// Updates the viewer void updateViewer() const; @@ -307,7 +309,10 @@ private: QIntList myActiveSelectionModes; /// the enable update viewer flag - bool myEnableUpdateViewer; + bool myEnableUpdateViewer; + + /// A flag that update was requested but not done + mutable bool myNeedUpdate; }; #endif diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 434b6cdd8..e5c95c78b 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -191,7 +191,6 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& // the viewer's update context is unblocked, the viewer's update works XGUI_Displayer* aDisplayer = workshop()->displayer(); aDisplayer->enableUpdateViewer(true); - aDisplayer->updateViewer(); } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) { std::shared_ptr aUpdMsg = std::dynamic_pointer_cast(theMessage);