From 0caee92b045249b15dd6df72d52b44335e05cc3f Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 23 Jul 2014 11:24:27 +0400 Subject: [PATCH] Avoid redisplay of sketcher while it is not finished --- src/ModuleBase/ModuleBase_Operation.cpp | 27 +++++++++++++++++---- src/ModuleBase/ModuleBase_Operation.h | 7 ++++-- src/PartSet/PartSet_OperationSketchBase.cpp | 8 +++--- src/XGUI/XGUI_Workshop.cpp | 7 ++++-- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index e967a1d49..0387105b7 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -69,7 +70,7 @@ void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget) void ModuleBase_Operation::startOperation() { if (!myIsEditing) - setFeature(createFeature()); + createFeature(); //emit callSlot(); //commit(); } @@ -104,10 +105,10 @@ void ModuleBase_Operation::flushCreated() FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage) { boost::shared_ptr aDoc = document(); - FeaturePtr aFeature = aDoc->addFeature(getDescription()->operationId().toStdString()); - if (aFeature) { // TODO: generate an error if feature was not created + myFeature = aDoc->addFeature(getDescription()->operationId().toStdString()); + if (myFeature) { // TODO: generate an error if feature was not created myIsModified = true; - aFeature->execute(); + myFeature->execute(); // Init default values /*QList aWidgets = getDescription()->modelWidgets(); QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); @@ -118,7 +119,7 @@ FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage) if (theFlushMessage) flushCreated(); - return aFeature; + return myFeature; } void ModuleBase_Operation::setFeature(FeaturePtr theFeature) @@ -131,3 +132,19 @@ void ModuleBase_Operation::setEditingFeature(FeaturePtr theFeature) setFeature(theFeature); myIsEditing = true; } + +bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const +{ + FeaturePtr aFeature = feature(); + if (aFeature) { + if (aFeature.get() == theObj.get()) + return true; + std::list aResults = aFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { + if ((*aIt).get() == theObj.get()) + return true; + } + } + return false; +} \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 6a95f0085..ae2250624 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -72,6 +72,9 @@ public: /// Sets the operation feature void setEditingFeature(FeaturePtr theFeature); + /// Returns True if the current operation works with the given object (feature or result) + virtual bool hasObject(ObjectPtr theObj) const; + public slots: /// Slots which listen the mode widget activation /// \param theWidget the model widget @@ -105,11 +108,11 @@ protected: /// \returns the created feature virtual FeaturePtr createFeature(const bool theFlushMessage = true); -private: +protected: /// Sets the operation feature void setFeature(FeaturePtr theFeature); -private: +protected: FeaturePtr myFeature; /// the operation feature to be handled }; diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index d82aae96b..5934e46d1 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -68,10 +68,10 @@ std::list PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeatu } FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) { - FeaturePtr aFeature = ModuleBase_Operation::createFeature(theFlushMessage); - if (aFeature) - emit featureConstructed(aFeature, FM_Activation); - return aFeature; + ModuleBase_Operation::createFeature(theFlushMessage); + if (myFeature) + emit featureConstructed(myFeature, FM_Activation); + return myFeature; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index de4c5af91..0ca48658f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -330,8 +330,11 @@ void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* the if (aPart) { aHasPart = true; } else { - myDisplayer->display(*aIt, false); - isDisplayed = true; + ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); + if (aOperation->hasObject(*aIt)) { // Display only current operation results + myDisplayer->display(*aIt, false); + isDisplayed = true; + } } } if (isDisplayed) -- 2.39.2