+
+ myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop);
+}
+
+bool PartSet_WidgetPoint2D::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& theValue)
+{
+ bool aValid = true;
+
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ if (aModule->sketchReentranceMgr()->isInternalEditActive())
+ return true; /// when internal edit is started a new feature is created. I has not results, AIS
+
+ // workaround for feature, where there is no results
+ //if (myFeature->getKind() == "SketchRectangle")
+ // return true;
+
+ /// the selection is not possible if the current feature has no presentation for the current
+ /// attribute not in AIS not in results. If so, no object in current feature where make
+ /// coincidence, so selection is not necessary
+ std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
+ std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(attributeID()));
+ std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
+
+ bool aFoundPoint = false;
+ GeomShapePtr anAISShape;
+ GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(myFeature);
+ if (aPrs.get()) {
+ AISObjectPtr anAIS;
+ anAIS = aPrs->getAISObject(anAIS);
+ if (anAIS.get()) {
+ anAISShape = anAIS->getShape();
+ }
+ }
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = myFeature->results();
+ if (!anAISShape.get() && aResults.empty())
+ return true;
+
+ /// analysis of AIS
+ if (anAISShape.get())
+ aFoundPoint = shapeContainsPoint(anAISShape, aPoint, mySketch);
+
+ /// analysis of results
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
+ for (; aRIter != aResults.cend() && !aFoundPoint; aRIter++) {
+ ResultPtr aResult = *aRIter;
+ if (aResult.get() && aResult->shape().get()) {
+ GeomShapePtr aShape = aResult->shape();
+ aFoundPoint = shapeContainsPoint(aShape, aPoint, mySketch);
+ }
+ }
+ return aFoundPoint;