From: vsv Date: Mon, 29 Jul 2019 14:29:39 +0000 (+0300) Subject: Issue #2972: Restore selection modes after filter item editing X-Git-Tag: VEDF2019Lot4~80 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3f066c11279ec63c380e4aa491e65649577d314e;p=modules%2Fshaper.git Issue #2972: Restore selection modes after filter item editing --- diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index 66fbca9d8..56ca62630 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -147,6 +147,11 @@ Q_OBJECT //! \param isEnabled new state of the viewer update virtual bool enableUpdateViewer(bool isEnabled) = 0; + //! The methods applys current defined selection modes to given AIS presentation. + //! The AIS presentation has to be already displayed. After activation viewer has to be updated + //! \param theAIS the object which has to be activated + virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS) = 0; + signals: /// Signal selection changed. void selectionChanged(); diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp index 868ae81c4..d7e3d15de 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp @@ -303,15 +303,21 @@ ModuleBase_WidgetSelectionFilter::~ModuleBase_WidgetSelectionFilter() Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext(); aCtx->Remove(myPreview, false); myPreview.Nullify(); - if (myShowBtn->isChecked()) { + if (myListIO.Size() > 0) { + Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext(); AIS_ListOfInteractive::const_iterator aIt; Handle(AIS_Shape) aShapeIO; for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) { aShapeIO = Handle(AIS_Shape)::DownCast(*aIt); if (!aShapeIO.IsNull()) { aCtx->Display(aShapeIO, false); + std::shared_ptr anAISObj = AISObjectPtr(new GeomAPI_AISObject()); + anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO)); + myWorkshop->applyCurrentSelectionModes(anAISObj); } } + myListIO.Clear(); + myShowBtn->setChecked(false); } aCtx->UpdateCurrentViewer(); } @@ -512,8 +518,12 @@ void ModuleBase_WidgetSelectionFilter::onShowOnly(bool theShow) if (!aShapeIO.IsNull()) { if (theShow) aCtx->Erase(aShapeIO, false); - else + else { aCtx->Display(aShapeIO, false); + std::shared_ptr anAISObj = AISObjectPtr(new GeomAPI_AISObject()); + anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO)); + myWorkshop->applyCurrentSelectionModes(anAISObj); + } } } aCtx->UpdateCurrentViewer(); @@ -617,6 +627,7 @@ QString ModuleBase_WidgetSelectionFilter::getError(const bool theValueStateCheck void ModuleBase_WidgetSelectionFilter::onObjectUpdated() { + myShowBtn->setChecked(false); clearCurrentSelection(true); updateNumberSelected(); updateObject(myFeature); diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index be83f401c..61bc814f4 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -225,4 +225,11 @@ QObjectPtrList XGUI_ModuleConnector::displayedObjects() const bool XGUI_ModuleConnector::enableUpdateViewer(bool isEnabled) { return myWorkshop->displayer()->enableUpdateViewer(isEnabled); +} + + +void XGUI_ModuleConnector::applyCurrentSelectionModes(const AISObjectPtr& theAIS) +{ + Handle(AIS_InteractiveObject) anIO = theAIS->impl(); + myWorkshop->selectionActivate()->activate(anIO, false); } \ No newline at end of file diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 6080c893e..41415fdf3 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -131,6 +131,11 @@ Q_OBJECT //! Returns workshop XGUI_Workshop* workshop() const { return myWorkshop; } + //! The methods applys current defined selection modes to given AIS presentation. + //! The AIS presentation has to be already displayed. After activation viewer has to be updated + //! \param theAIS the object which has to be activated + virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS); + private: QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;