Salome HOME
Issue #2972: Restore selection modes after filter item editing
authorvsv <vsv@opencascade.com>
Mon, 29 Jul 2019 14:29:39 +0000 (17:29 +0300)
committervsv <vsv@opencascade.com>
Mon, 29 Jul 2019 14:29:39 +0000 (17:29 +0300)
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h

index 66fbca9d8f817774327f3cbc1a5779666bfa6385..56ca626301444da926d7014608a8bb3b5c1d50f6 100644 (file)
@@ -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();
index 868ae81c468fdf2f0faece0272c5c0e55280bb01..d7e3d15de55f4ac2c4ae05977f78a62c77a9d51e 100644 (file)
@@ -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<GeomAPI_AISObject> 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<GeomAPI_AISObject> 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);
index be83f401c0a653f9f4a03c7b4e6b2cd358273280..61bc814f47c7db8fdfb36ce8cc1bc2104faf7868 100644 (file)
@@ -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<Handle(AIS_InteractiveObject)>();
+  myWorkshop->selectionActivate()->activate(anIO, false);
 }
\ No newline at end of file
index 6080c893ea4e1cf5353838d890c4b4838b9607c8..41415fdf39be9daf4c70fd9d6eed77cd5c516dfb 100644 (file)
@@ -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;