From f3eba9945c9879eaf14950b634ad9ceebba27cd3 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 20 Mar 2017 15:25:34 +0300 Subject: [PATCH] Issue #2024 - Redesign of circle and arc of circle: fill Reference Attribute 1. Do not call execute(), this is obsolete functionality done for Rectangle feature(as lines were created in execute(), now one is created in attribute changed). It is checked without execute that coincidence is set to rectangle's features to line/point selected. 2. shapeContains/shapeExploreHasVertex should not be called by preselection if feature contains reference attribute(coincidence will not be created by selection) --- src/PartSet/PartSet_WidgetPoint2d.cpp | 57 +++++++++++++-------------- src/PartSet/PartSet_WidgetPoint2d.h | 6 +-- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 2a8d1a0aa..cb727289e 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -67,8 +67,6 @@ const double MaxCoordinate = 1e12; static QStringList MyFeaturesForCoincedence; -#define DEBUG_SELECTION - PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData) @@ -146,7 +144,6 @@ bool PartSet_WidgetPoint2D::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr /// 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 - bool aFoundPoint = false; GeomShapePtr anAISShape; GeomPresentablePtr aPrs = std::dynamic_pointer_cast(myFeature); if (aPrs.get()) { @@ -160,24 +157,32 @@ bool PartSet_WidgetPoint2D::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr if (!anAISShape.get() && aResults.empty()) return true; - /// analysis of AIS - std::shared_ptr aData = myFeature->data(); - AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast( - aData->attribute(attributeID())); - std::shared_ptr aPoint = aPointAttr->pnt(); - if (anAISShape.get()) - aFoundPoint = shapeContainsPoint(anAISShape, aPoint, mySketch); - - /// analysis of results - std::list >::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); + AttributeRefAttrPtr aRefAttr = attributeRefAttr(); + if (!aRefAttr.get()) { + bool aFoundPoint = false; + /// Avoid coincidence build to passed point. Coincidence is build later only if there are no + /// reference attribute. + /// The condition is that the selected feature has shape that has after explore a point + /// equal to clicked one. + std::shared_ptr aData = myFeature->data(); + AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast( + aData->attribute(attributeID())); + std::shared_ptr aPoint = aPointAttr->pnt(); + if (anAISShape.get()) + aFoundPoint = shapeExploreHasVertex(anAISShape, aPoint, mySketch); + + /// analysis of results + std::list >::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 = shapeExploreHasVertex(aShape, aPoint, mySketch); + } } + return aFoundPoint; } - return aFoundPoint; + return true; } bool PartSet_WidgetPoint2D::resetCustom() @@ -574,10 +579,6 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo bool isAuxiliaryFeature = false; if (getPoint2d(aView, aShape, aX, aY)) { setPoint(aX, aY); -#ifndef DEBUG_SELECTION - feature()->execute(); -#endif - setConstraintToPoint(aX, aY); } else if (aShape.ShapeType() == TopAbs_EDGE) { @@ -770,9 +771,9 @@ bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature, return anOrphanPoint; } -bool PartSet_WidgetPoint2D::shapeContainsPoint(const GeomShapePtr& theShape, - const std::shared_ptr& thePoint, - const CompositeFeaturePtr& theSketch) +bool PartSet_WidgetPoint2D::shapeExploreHasVertex(const GeomShapePtr& theShape, + const std::shared_ptr& thePoint, + const CompositeFeaturePtr& theSketch) { std::shared_ptr aPoint = PartSet_Tools::point3D(thePoint, theSketch); @@ -784,11 +785,7 @@ bool PartSet_WidgetPoint2D::shapeContainsPoint(const GeomShapePtr& theShape, if (aVertex.get()) aContainPoint = aPoint->isEqual(aVertex->point()); } -#ifdef DEBUG_SELECTION - return true; -#else return aContainPoint; -#endif } AttributeRefAttrPtr PartSet_WidgetPoint2D::attributeRefAttr() const diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index b54b76c0a..679813437 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -201,9 +201,9 @@ protected: /// \param theShape a shape to be exploded /// \param thePoint a point /// \return boolean value - static bool shapeContainsPoint(const std::shared_ptr& theShape, - const std::shared_ptr& thePoint, - const CompositeFeaturePtr& theSketch); + static bool shapeExploreHasVertex(const std::shared_ptr& theShape, + const std::shared_ptr& thePoint, + const CompositeFeaturePtr& theSketch); /// Finds in the feature's sub-features first Point2D attribute with the given point coordinates /// \param theFeature a feature with sub-feature attributes -- 2.39.2