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<ObjectPtr> aHiddenObjects;
for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
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);
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();
.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;
// 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);
}
// 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();
}
//**************************************************************
-bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody)
+bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
{
#ifdef DEBUG_RESULT_COMPSOLID
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
int aNb = aDisplayer->objectsCount();
- aDisplayed = aDisplayer->display(theObj, false);
-
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
- if (aNb == 0 && aResult.get()) {
- std::string aResultGroupName = aResult->groupName();
- if (aResultGroupName == ModelAPI_ResultBody::group() ||
- aResultGroupName == ModelAPI_ResultGroup::group()) {
- std::shared_ptr<GeomAPI_Shape> 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<ModelAPI_Result>(theObj);
+ if (aResult.get()) {
+ std::string aResultGroupName = aResult->groupName();
+ if (aResultGroupName == ModelAPI_ResultBody::group() ||
+ aResultGroupName == ModelAPI_ResultGroup::group()) {
+ std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
+ aFirstVisualizedBody = aShapePtr.get() != NULL;
+ }
}
}
- return aDisplayed;
+ return aFirstVisualizedBody;
}
bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
/// \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