]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2024 - Redesign of circle and arc of circle: fill Reference Attribute
authornds <nds@opencascade.com>
Mon, 20 Mar 2017 12:25:34 +0000 (15:25 +0300)
committerdbv <dbv@opencascade.com>
Mon, 27 Mar 2017 06:56:52 +0000 (09:56 +0300)
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
src/PartSet/PartSet_WidgetPoint2d.h

index 2a8d1a0aa718e4e2de3a7de1f9d1ca3414d178e0..cb727289ee6c9dd6eb9ef888354566e4c89037d9 100644 (file)
@@ -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<GeomAPI_IPresentable>(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<ModelAPI_Data> aData = myFeature->data();
-  AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(attributeID()));
-  std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
-  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);
+  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<ModelAPI_Data> aData = myFeature->data();
+    AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+        aData->attribute(attributeID()));
+    std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
+    if (anAISShape.get())
+      aFoundPoint = shapeExploreHasVertex(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 = 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<GeomAPI_Pnt2d>& thePoint,
-                                               const CompositeFeaturePtr& theSketch)
+bool PartSet_WidgetPoint2D::shapeExploreHasVertex(const GeomShapePtr& theShape,
+                                                  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint,
+                                                  const CompositeFeaturePtr& theSketch)
 {
   std::shared_ptr<GeomAPI_Pnt> 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
index b54b76c0a6153b4ee2a9db4ccbc1081ce0e21614..679813437b6a7b817fc5f99a35b5313109e3f499 100755 (executable)
@@ -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<GeomAPI_Shape>& theShape,
-                                  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint,
-                                  const CompositeFeaturePtr& theSketch);
+   static bool shapeExploreHasVertex(const std::shared_ptr<GeomAPI_Shape>& theShape,
+                                     const std::shared_ptr<GeomAPI_Pnt2d>& 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