//! \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
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();
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);
void ModuleBase_WidgetMultiSelector::deactivate()
{
ModuleBase_WidgetSelector::deactivate();
+ if (myVisibleObjects.size())
+ onShowOnly(false);
myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true);
clearSelectedHistory();
}
}
-void ModuleBase_WidgetMultiSelector::onShowOnly()
+void ModuleBase_WidgetMultiSelector::onShowOnly(bool theChecked)
{
+ std::list<ResultPtr> aResults = myFeature->results();
+ std::list<ResultPtr>::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));
}
//! \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<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
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; }