From 04dcca50b319e65e5141be7f6c329a2e1cf94718 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 15 Sep 2015 18:30:25 +0300 Subject: [PATCH] Synchronize displayed objects if Viewer was opened after displaying --- src/NewGeom/NewGeom_Module.cpp | 1 + src/XGUI/XGUI_Workshop.cpp | 26 ++++++++++++++++++++++++++ src/XGUI/XGUI_Workshop.h | 9 +++++++++ 3 files changed, 36 insertions(+) diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 0d2cdaa76..75f33a64f 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -275,6 +275,7 @@ void NewGeom_Module::onViewManagerAdded(SUIT_ViewManager* theMgr) if (!mySelector) { mySelector = createSelector(theMgr); myWorkshop->module()->activateSelectionFilters(); + myWorkshop->synchronizeViewer(); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 936057419..5d0e12c5d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1682,3 +1682,29 @@ QList XGUI_Workshop::processHistoryList(const std::list } return aResult; } + +void XGUI_Workshop::synchronizeViewer() +{ + SessionPtr aMgr = ModelAPI_Session::get(); + DocumentPtr aDoc = aMgr->activeDocument(); + + synchronizeGroupInViewer(aDoc, ModelAPI_ResultConstruction::group(), false); + synchronizeGroupInViewer(aDoc, ModelAPI_ResultBody::group(), false); + synchronizeGroupInViewer(aDoc, ModelAPI_ResultPart::group(), false); + synchronizeGroupInViewer(aDoc, ModelAPI_ResultGroup::group(), false); +} + +void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc, + const std::string& theGroup, + bool theUpdateViewer) +{ + ObjectPtr aObj; + int aSize = theDoc->size(theGroup); + for (int i = 0; i < aSize; i++) { + aObj = theDoc->object(theGroup, i); + if (aObj->isDisplayed()) + myDisplayer->display(aObj, false); + } + if (theUpdateViewer) + myDisplayer->updateViewer(); +} diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 91980355a..03195947a 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -245,6 +245,15 @@ Q_OBJECT /// \param theFeature a feature bool isFeatureOfNested(const FeaturePtr& theFeature); + /// Has to be called in order to display objects with visibility status = true + void synchronizeViewer(); + + /// Has to be called in order to display objects from a cpecifed group with visibility status = true + /// \param theDoc the document for objects synchronisation + /// \param theGroup the group name + /// \param theUpdateViewer update viewer flag + void synchronizeGroupInViewer(const DocumentPtr& theDoc, const std::string& theGroup, bool theUpdateViewer); + signals: /// Emitted when selection happens in Salome viewer void salomeViewerSelection(); -- 2.39.2