Salome HOME
Shape plane filter should process shapes of objects selected in object browser.
authornds <natalia.donis@opencascade.com>
Fri, 3 Jul 2015 13:46:23 +0000 (16:46 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 3 Jul 2015 15:23:42 +0000 (18:23 +0300)
Using geom algo plane in the plane filter for futher modifications.
Scenario: [crash] create sketch, create closed contour, create 2nd sketch, start translate operation, select with rectangle the prev sketch lines. Abort[sketch is selected in the OB]. Start translate again, crash[the sketch selected in OB is applyed to the multi selector control]

src/ModuleBase/ModuleBase_ISelection.h
src/ModuleBase/ModuleBase_ViewerFilters.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h

index 0f653f6315cea3b78cf421fca135b259f45e9365..1de791addbf2b364c9fa937933ec2879fd80b89f 100644 (file)
@@ -87,6 +87,11 @@ class ModuleBase_ISelection
   //! \return a shape
   MODULEBASE_EXPORT GeomShapePtr getShape(const ModuleBase_ViewerPrs& thePrs);
 
+  //! Return the IO from the viewer presentation.
+  //! \param thePrs a selected object
+  //! \return an interactive object
+  virtual MODULEBASE_EXPORT Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs) = 0;
+
   //! Wraps the object list into the viewer prs list
   //! \param theObjects a list of objects
   //! \return a list of prs, where only object is not empty
index 957b970e9e9aeaebf4a42cdc0bdaba1559717817..70d555c8cb1d8d1ff9166bdd7be2c2d18d32aefb 100644 (file)
@@ -92,8 +92,6 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti
           return aD1 && aD2 && aD3;
         }
       default:
-        // This is not object controlled by the filter
-        return Standard_True;
         // The object can be selected in Object browser and contain, for example, compound.
         // The compound could not belong to any plane, so the result is false
         return Standard_False;
index e8acbcbfc750022fbd07bed0cbf5a7850bb42f05..dcfb86bec31f814fce42413e07561fbfa6a4fd5b 100755 (executable)
@@ -142,6 +142,9 @@ void ModuleBase_WidgetSelector::activateCustom()
 }
 
 //********************************************************************
+#include <ModuleBase_IViewer.h>
+#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
+#include <StdSelect_BRepOwner.hxx>
 bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
 {
   GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
@@ -154,6 +157,30 @@ bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPr
     FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aResult);
     aValid = aSelectedFeature != myFeature;
   }
+  
+  // selection happens in the Object browser.
+  // it creates a selection owner and check whether the viewer filters process it
+  if (thePrs.owner().IsNull() && thePrs.object().get()) {
+    ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+    if (aResult.get())
+      aShape = aResult->shape();
+
+    const TopoDS_Shape aTDShape = aShape->impl<TopoDS_Shape>();
+
+    Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
+    Handle(StdSelect_BRepOwner) aShapeOwner = new StdSelect_BRepOwner(aTDShape, anIO);
+
+    const SelectMgr_ListOfFilter& aFilters = myWorkshop->viewer()->AISContext()->Filters();
+    SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
+    for (; anIt.More() && aValid; anIt.Next()) {
+      Handle(SelectMgr_Filter) aFilter = anIt.Value();
+      if (aFilter == myWorkshop->validatorFilter())
+        continue;
+
+      aValid = aFilter->IsOk(aShapeOwner);
+    }
+    aShapeOwner.Nullify();
+  }
   return aValid;
 }
 
index 29d81e6c20f0205cdc0c76dba994171657fc2234..889817706c8c12849cd3d0a88231d4e414f81756 100644 (file)
@@ -22,7 +22,7 @@
 ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent,
                                                        const Config_WidgetAPI* theData,
                                                        const std::string& theParentId)
- : ModuleBase_ModelWidget(theParent, theData, theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId), isValidateBlocked(false)
 {
 }
 
@@ -64,6 +64,10 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th
     return aValid;
   }
 
+  if (isValidateBlocked)
+    return true;
+  isValidateBlocked = true;
+
   DataPtr aData = myFeature->data();
   AttributePtr anAttribute = myFeature->attribute(attributeID());
 
@@ -100,6 +104,7 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th
   aLoop->flush(aRedispEvent);
 
   storeValidState(theValue, aValid);
+  isValidateBlocked = false;
   return aValid;
 }
 
index 4e6b9aa73cfba0334d6732c2e812e1929083bf9e..f1caa0905984d5d2a265b52dd60a11af5a6d8f0b 100644 (file)
@@ -100,6 +100,7 @@ protected:
 private:
   QList<ModuleBase_ViewerPrs> myValidPrs;
   QList<ModuleBase_ViewerPrs> myInvalidPrs;
+  bool isValidateBlocked;
 };
 
 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */
index 8a14e7d1800510dc8e497c2b9c561edb9735d03f..cd7379944763add298976d7252fd582007d2476d 100644 (file)
@@ -43,6 +43,24 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(const SelectionPlace& th
   return aPresentations;
 }
 
+Handle(AIS_InteractiveObject) XGUI_Selection::getIO(const ModuleBase_ViewerPrs& thePrs)
+{
+  Handle(AIS_InteractiveObject) anIO = thePrs.interactive();
+  if (anIO.IsNull()) {
+    Handle(SelectMgr_EntityOwner) anOwner = thePrs.owner();
+    if (!anOwner.IsNull())
+      anIO = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+
+    if (anIO.IsNull() && thePrs.object()) {
+      XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+      AISObjectPtr anAISObject = aDisplayer->getAISObject(thePrs.object());
+      if (anAISObject.get())
+        anIO = anAISObject->impl<Handle(AIS_InteractiveObject)>();
+    }
+  }
+  return anIO;
+}
+
 void XGUI_Selection::getSelectedInViewer(QList<ModuleBase_ViewerPrs>& thePresentations) const
 {
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
index caf1088f7bd3d1b523e91e9bcbcf2408ab693775..a768c132be95b1ca1a4e2e1c9a0cb4e4dc699573 100644 (file)
@@ -88,6 +88,11 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
   void entityOwners(const Handle_AIS_InteractiveObject& theObject,
                     SelectMgr_IndexedMapOfOwner& theOwners) const;
 
+  //! Return the IO from the viewer presentation.
+  //! \param thePrs a selected object
+  //! \return an interactive object
+  virtual Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs);
+
 protected:
   /// Fills the list of presentations by objects selected in the viewer.
   /// \param thePresentations an output list of presentation