From: nds Date: Fri, 3 Jul 2015 13:46:23 +0000 (+0300) Subject: Shape plane filter should process shapes of objects selected in object browser. X-Git-Tag: V_1.3.0~111 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ed8328e26b6e8f5ecedc8348b5eb7d650c065564;p=modules%2Fshaper.git Shape plane filter should process shapes of objects selected in object browser. 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] --- diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 0f653f631..1de791add 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -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 diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index 957b970e9..70d555c8c 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -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; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index e8acbcbfc..dcfb86bec 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -142,6 +142,9 @@ void ModuleBase_WidgetSelector::activateCustom() } //******************************************************************** +#include +#include +#include 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(); + + 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; } diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 29d81e6c2..889817706 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 4e6b9aa73..f1caa0905 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -100,6 +100,7 @@ protected: private: QList myValidPrs; QList myInvalidPrs; + bool isValidateBlocked; }; #endif /* MODULEBASE_WIDGETVALIDATED_H_ */ diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 8a14e7d18..cd7379944 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -43,6 +43,24 @@ QList 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(); + } + } + return anIO; +} + void XGUI_Selection::getSelectedInViewer(QList& thePresentations) const { Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index caf1088f7..a768c132b 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -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