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]
//! \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
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;
}
//********************************************************************
+#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);
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;
}
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)
{
}
return aValid;
}
+ if (isValidateBlocked)
+ return true;
+ isValidateBlocked = true;
+
DataPtr aData = myFeature->data();
AttributePtr anAttribute = myFeature->attribute(attributeID());
aLoop->flush(aRedispEvent);
storeValidState(theValue, aValid);
+ isValidateBlocked = false;
return aValid;
}
private:
QList<ModuleBase_ViewerPrs> myValidPrs;
QList<ModuleBase_ViewerPrs> myInvalidPrs;
+ bool isValidateBlocked;
};
#endif /* MODULEBASE_WIDGETVALIDATED_H_ */
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();
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