From: vsv Date: Mon, 17 Jun 2019 12:29:31 +0000 (+0300) Subject: Implement 'Show Only' button in group operation X-Git-Tag: VEDF2019Lot4~101^2~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d111914dc87c2cbc0fdfe643b41d195473b8d1c8;p=modules%2Fshaper.git Implement 'Show Only' button in group operation --- diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index c3558145b..66fbca9d8 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -115,6 +115,9 @@ Q_OBJECT //! \param theObject a data object virtual bool isVisible(const ObjectPtr& theObject) const = 0; + //! Returns list of currently displayed objects + virtual QObjectPtrList displayedObjects() const = 0; + //! Select features clearing previous selection. //! If the list is empty then selection will be cleared //! \param theValues a list of presentations @@ -140,6 +143,10 @@ Q_OBJECT virtual void deactivateCurrentSelector() = 0; + //! Temporary enable or disable viewer update. Returns previous state of updating + //! \param isEnabled new state of the viewer update + virtual bool enableUpdateViewer(bool isEnabled) = 0; + signals: /// Signal selection changed. void selectionChanged(); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 11c502778..c403a8780 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -180,7 +180,9 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen aFltrLayout->addStretch(); QPushButton* aShowBtn = new QPushButton(tr("Show only"), aFltrWgt); - connect(aShowBtn, SIGNAL(clicked(bool)), SLOT(onShowOnly())); + aShowBtn->setCheckable(true); + aShowBtn->setChecked(false); + connect(aShowBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool))); aFltrLayout->addWidget(aShowBtn); aMainLay->addWidget(aFltrWgt); @@ -222,6 +224,8 @@ void ModuleBase_WidgetMultiSelector::activateCustom() void ModuleBase_WidgetMultiSelector::deactivate() { ModuleBase_WidgetSelector::deactivate(); + if (myVisibleObjects.size()) + onShowOnly(false); myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true); clearSelectedHistory(); @@ -1089,7 +1093,34 @@ void ModuleBase_WidgetMultiSelector::onSameTopology(bool theOn) } } -void ModuleBase_WidgetMultiSelector::onShowOnly() +void ModuleBase_WidgetMultiSelector::onShowOnly(bool theChecked) { + std::list aResults = myFeature->results(); + std::list::const_iterator aIt; + if (theChecked) { + myVisibleObjects = myWorkshop->displayedObjects(); + for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) { + myVisibleObjects.removeAll(*aIt); + } + } + foreach(ObjectPtr aObj, myVisibleObjects) { + aObj->setDisplayed(!theChecked); + } + + if (!theChecked) { + // Hide and show the group result in order to make it above all objects + bool aOldState = myWorkshop->enableUpdateViewer(false); + for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) { + (*aIt)->setDisplayed(false); + } + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) { + (*aIt)->setDisplayed(true); + } + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + myWorkshop->enableUpdateViewer(aOldState); + myVisibleObjects.clear(); + } else + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 651526ea8..1dec34d90 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -135,7 +135,7 @@ protected slots: void onSameTopology(bool theOn); - void onShowOnly(); + void onShowOnly(bool); protected: /// Returns true if the event is processed. The default implementation is empty, returns false. @@ -255,6 +255,8 @@ protected: QCheckBox* myGeomCheck; ModuleBase_FilterStarter* myFiltersWgt; + + QObjectPtrList myVisibleObjects; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index fee5e9fde..be83f401c 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -216,3 +216,13 @@ void XGUI_ModuleConnector::deactivateCurrentSelector() { myWorkshop->deactivateCurrentSelector(); } + +QObjectPtrList XGUI_ModuleConnector::displayedObjects() const +{ + return myWorkshop->displayer()->displayedObjects(); +} + +bool XGUI_ModuleConnector::enableUpdateViewer(bool isEnabled) +{ + return myWorkshop->displayer()->enableUpdateViewer(isEnabled); +} \ No newline at end of file diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 07fafe383..6080c893e 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -97,6 +97,9 @@ Q_OBJECT //! \param theObject a data object virtual bool isVisible(const ObjectPtr& theObject) const; + //! Returns list of currently displayed objects + virtual QObjectPtrList displayedObjects() const; + //! Select features clearing previous selection. //! If the list is empty then selection will be cleared virtual void setSelected(const QList>& theValues); @@ -121,6 +124,10 @@ Q_OBJECT virtual void deactivateCurrentSelector(); + //! Temporary enable or disable viewer update. Returns previous state of updating + //! \param isEnabled new state of the viewer update + virtual bool enableUpdateViewer(bool isEnabled); + //! Returns workshop XGUI_Workshop* workshop() const { return myWorkshop; }