From e758a2354fc38299c022e8f07b48f4b764c97e44 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 2 Nov 2016 16:28:21 +0300 Subject: [PATCH] Issue #1828 No automatic fitall --- src/XGUI/XGUI_WorkshopListener.cpp | 54 +++++++++++++++++++----------- src/XGUI/XGUI_WorkshopListener.h | 9 ++++- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 640603e43..849466192 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -249,8 +249,9 @@ void XGUI_WorkshopListener:: XGUI_Workshop* aWorkshop = workshop(); XGUI_Displayer* aDisplayer = aWorkshop->displayer(); - bool aFirstVisualizedBody = false; - + //bool aFirstVisualizedBody = false; + bool aDoFitAll = false; + int aNbOfShownObjects = workshop()->displayer()->objectsCount(); bool aRedisplayed = false; //std::list aHiddenObjects; for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) { @@ -326,7 +327,9 @@ void XGUI_WorkshopListener:: aWorkshop->deactivateActiveObject(aObj, false); } } else { // display object if the current operation has it - if (displayObject(aObj, aFirstVisualizedBody)) { + if (displayObject(aObj)) { + aDoFitAll = aDoFitAll || neededFitAll(aObj, aNbOfShownObjects); + aRedisplayed = true; // Deactivate object of current operation from selection aWorkshop->deactivateActiveObject(aObj, false); @@ -343,8 +346,8 @@ void XGUI_WorkshopListener:: if (aRedisplayed || isCustomized) { Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)); - //VSV FitAll updated viewer by it self - if (aFirstVisualizedBody) + //VSV FitAll updated viewer by itself + if (aDoFitAll) myWorkshop->viewer()->fitAll(); else aDisplayer->updateViewer(); @@ -367,7 +370,8 @@ void XGUI_WorkshopListener:: .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str()); #endif - bool aFirstVisualizedBody = false; + bool aDoFitAll = false; + int aNbOfShownObjects = workshop()->displayer()->objectsCount(); //bool aHasPart = false; bool aDisplayed = false; @@ -406,7 +410,9 @@ void XGUI_WorkshopListener:: // with list of displayed objects if (myWorkshop->module()->canDisplayObject(anObject)) { anObject->setDisplayed(true); - aDisplayed = displayObject(*aIt, aFirstVisualizedBody); + aDisplayed = displayObject(anObject); + if (aDisplayed) + aDoFitAll = aDoFitAll || neededFitAll(anObject, aNbOfShownObjects); } else anObject->setDisplayed(false); } @@ -418,8 +424,8 @@ void XGUI_WorkshopListener:: // myObjectBrowser->processEvent(theMsg); if (aDisplayed) { Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)); - //VSV FitAll updated viewer by it self - if (aFirstVisualizedBody) + //VSV FitAll updated viewer by itself + if (aDoFitAll) myWorkshop->viewer()->fitAll(); else workshop()->displayer()->updateViewer(); @@ -470,7 +476,7 @@ bool XGUI_WorkshopListener::event(QEvent * theEvent) } //************************************************************** -bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody) +bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj) { #ifdef DEBUG_RESULT_COMPSOLID ResultPtr aRes = std::dynamic_pointer_cast(theObj); @@ -491,18 +497,26 @@ bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisual XGUI_Displayer* aDisplayer = aWorkshop->displayer(); int aNb = aDisplayer->objectsCount(); - aDisplayed = aDisplayer->display(theObj, false); - - ResultPtr aResult = std::dynamic_pointer_cast(theObj); - if (aNb == 0 && aResult.get()) { - std::string aResultGroupName = aResult->groupName(); - if (aResultGroupName == ModelAPI_ResultBody::group() || - aResultGroupName == ModelAPI_ResultGroup::group()) { - std::shared_ptr aShapePtr = ModelAPI_Tools::shape(aResult); - theFirstVisualizedBody = aShapePtr.get() != NULL; + return aDisplayer->display(theObj, false); +} + +//************************************************************** +bool XGUI_WorkshopListener::neededFitAll(ObjectPtr theObj, const int theNbOfShownObjects) +{ + bool aFirstVisualizedBody = false; + + if (theNbOfShownObjects == 0) { + ResultPtr aResult = std::dynamic_pointer_cast(theObj); + if (aResult.get()) { + std::string aResultGroupName = aResult->groupName(); + if (aResultGroupName == ModelAPI_ResultBody::group() || + aResultGroupName == ModelAPI_ResultGroup::group()) { + std::shared_ptr aShapePtr = ModelAPI_Tools::shape(aResult); + aFirstVisualizedBody = aShapePtr.get() != NULL; + } } } - return aDisplayed; + return aFirstVisualizedBody; } bool XGUI_WorkshopListener::customizeCurrentObject(const std::set& theObjects, diff --git a/src/XGUI/XGUI_WorkshopListener.h b/src/XGUI/XGUI_WorkshopListener.h index 0ad8c9787..abc801ec1 100755 --- a/src/XGUI/XGUI_WorkshopListener.h +++ b/src/XGUI/XGUI_WorkshopListener.h @@ -71,7 +71,14 @@ protected: /// \param theFirstVisualizedBody an output state whether there are not object displayed in the /// view and the displayed object is a body /// \return true if the object is displayed - bool displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody); + bool displayObject(ObjectPtr theObj); + + /// Answer if the viewer needed to be fit all after the object visualization + /// The condition is there is not shown objects and the object is a group or body result + /// \param theObject a shown object + /// \param theNbOfShownObjects a count of already shown objects in the viewer + /// \return true if fit all should be done + bool neededFitAll(ObjectPtr theObject, const int theNbOfShownObjects); /// Calls the module method of cusomize object for the feature of the current operation /// Perform cusomize if the force redisplay flag is true or the list of objects contains the -- 2.39.2