]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 14:08:25 +0000 (18:08 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 14:08:25 +0000 (18:08 +0400)
It replaces findPoint() method by using attributes(type) data model method.

18 files changed:
src/Model/Model_Data.cpp
src/PartSet/PartSet_ConstraintDistancePrs.cpp
src/PartSet/PartSet_ConstraintDistancePrs.h
src/PartSet/PartSet_ConstraintLengthPrs.cpp
src/PartSet/PartSet_ConstraintLengthPrs.h
src/PartSet/PartSet_ConstraintRadiusPrs.cpp
src/PartSet/PartSet_ConstraintRadiusPrs.h
src/PartSet/PartSet_FeatureArcPrs.cpp
src/PartSet/PartSet_FeatureArcPrs.h
src/PartSet/PartSet_FeatureCirclePrs.cpp
src/PartSet/PartSet_FeatureCirclePrs.h
src/PartSet/PartSet_FeatureLinePrs.cpp
src/PartSet/PartSet_FeatureLinePrs.h
src/PartSet/PartSet_FeaturePointPrs.cpp
src/PartSet/PartSet_FeaturePointPrs.h
src/PartSet/PartSet_FeaturePrs.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h

index 60b7b540e7c4f554d12e3cab5924a5b2f89cf5f4..80eba05b0e5a4cac492a4c0930e6d2e2100fca5e 100644 (file)
@@ -213,6 +213,7 @@ list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = myAttrs.begin();
   for(; anAttrsIter != myAttrs.end(); anAttrsIter++) {
     if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
+      aResult.push_back(anAttrsIter->second);
     }
   }
   return aResult;
index de33104313347ebb60f5885b84c46d0b7679127e..8dc195a94693f0f3d01c0a3b695152cf1625fda7 100644 (file)
@@ -125,13 +125,6 @@ PartSet_SelectionMode PartSet_ConstraintDistancePrs::getNextMode(const std::stri
   return SM_FirstPoint;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index 30c6923a521eadde2e9d03e973f08c65ed88b9ec..8d711540b00d4319cf07b784da31a6200a2eaa0c 100644 (file)
@@ -55,12 +55,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
 protected:
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
index 67b989c3be4e25f99a25b48471a035cea55c4c83..4607b732b71ee40a33f58e2bbd637193204622fe 100644 (file)
@@ -120,13 +120,6 @@ PartSet_SelectionMode PartSet_ConstraintLengthPrs::getNextMode(const std::string
   return SM_FirstPoint;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index ba1db99f49dcc2e71b70360714b31d1cde399aa5..e00b5494a76c888e2136a9677e1b85a878aee8c6 100644 (file)
@@ -55,12 +55,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
 protected:
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
index a5430b8da2136805caa900e6e698e178915fada0..b8f2a80103754912500c59d95995b07a97bb5e5c 100644 (file)
@@ -243,13 +243,6 @@ PartSet_SelectionMode PartSet_ConstraintRadiusPrs::getNextMode(const std::string
   return SM_FirstPoint;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index 5e87a5fee3a3b4bf71113d69c2503614d8ba78b9..e316ab1f0b2452dfb5ead5b783b54e72f9ba6ad6 100644 (file)
@@ -67,12 +67,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
   /// Project the view point on the feature. The output coordinates belong to the feature
   /// \param theFeature a feature
   /// \param theSketch the sketch feature
index ac90bf55794776ee062132124fe6f9c94338b487..440f5624efbeb8542c7d348a41dabab1c3bcc00c 100644 (file)
@@ -94,35 +94,6 @@ PartSet_SelectionMode PartSet_FeatureArcPrs::getNextMode(const std::string& theA
   return aMode;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureArcPrs::findPoint(FeaturePtr theFeature,
-                                                                        double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-      fabs(aPoint->y() - theY) < Precision::Confusion()) {
-    aPoint2D = aPoint;
-  }
-  if (!aPoint2D) {
-    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
-    if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-        fabs(aPoint->y() - theY) < Precision::Confusion())
-      aPoint2D = aPoint;
-  }
-  if (!aPoint2D) {
-    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_END));
-    if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-        fabs(aPoint->y() - theY) < Precision::Confusion())
-      aPoint2D = aPoint;
-  }
-  return aPoint2D;
-}
-
 void PartSet_FeatureArcPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
                                                   gp_Pnt& thePoint, Handle(V3d_View) theView,
                                                   double& theX, double& theY)
index a34a08d6f4747010229d8ded7c63baca17f23ba5..fd0bff9c3755783d43770b24645ca9c73711684b 100644 (file)
@@ -61,13 +61,6 @@ public:
   static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
                                     Handle_V3d_View theView, double& theX, double& theY);
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
-
   /// Computes the feature's radius
   /// \param theFeature an arc feature
   /// \return the double value
index 56e4f93b605b512ce3fa18de999cf42947f574ad..426d9f1e5e42fc9623a5cbba6cf452b60be2a20e 100644 (file)
@@ -92,22 +92,6 @@ PartSet_SelectionMode PartSet_FeatureCirclePrs::getNextMode(const std::string& t
   return aMode;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureCirclePrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
-    aPoint2D = aPoint;
-
-  return aPoint2D;
-}
-
 void PartSet_FeatureCirclePrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
                                                      gp_Pnt& thePoint, Handle(V3d_View) theView,
                                                      double& theX, double& theY)
index 546fb5eb029ed8a5d15194bc44dbede9ae81e621..f9688b103966f7cb261594d72951bb512ec3a16b 100644 (file)
@@ -51,12 +51,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
   /// Project the view point on the feature. The output coordinates belong to the feature
   /// \param theFeature a feature
   /// \param theSketch the sketch feature
index 4aa747a997ce4208246531c72af5c9cd6f21c996..fe4c3a5c56c52798626156523871e9b5218a8f19 100644 (file)
@@ -148,28 +148,6 @@ void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature,
   }
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLinePrs::findPoint(FeaturePtr theFeature,
-                                                                         double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-      fabs(aPoint->y() - theY) < Precision::Confusion())
-    aPoint2D = aPoint;
-  else {
-    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-    if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-        fabs(aPoint->y() - theY) < Precision::Confusion())
-      aPoint2D = aPoint;
-  }
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomAPI_Lin2d> PartSet_FeatureLinePrs::createLin2d(FeaturePtr theFeature)
 {
   boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin;
index b4a16dc5c36176e784085da6f760be52111640c1..b9f2cfa42d63da47030db603d8d88e10c9dbe141 100644 (file)
@@ -69,13 +69,6 @@ public:
                           const gp_Pnt& thePoint, Handle_V3d_View theView,
                           double& theX, double& theY);
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
-
   /// Creates a lin 2d object on a base of the line feature
   /// \param theFeature the line feature
   static boost::shared_ptr<GeomAPI_Lin2d> createLin2d(FeaturePtr theFeature);
index fa33cd40ae3e5d84e0325232e87be91f885e04d6..818206b4787f305cf385dd30ed00b097a655c6a6 100644 (file)
@@ -71,22 +71,6 @@ PartSet_SelectionMode PartSet_FeaturePointPrs::getNextMode(const std::string& th
   return aMode;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::findPoint(FeaturePtr theFeature,
-                                                                          double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
-    aPoint2D = aPoint;
-
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index d43a8227221e3785ef449584ef9ae095aca00d2b..7fec848071d287508078486cdf23f432581fe8f4 100644 (file)
@@ -48,13 +48,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                          double theY);
-
 protected:
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
index 87fd3693bc3b4280882fc82e415aeb58194a3a24..9adf4a0a2a34cb6f7c90445f07d13bd59c08be6a 100644 (file)
@@ -59,13 +59,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const = 0;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY) = 0;
-
 protected:
   /// Returns the operation feature
   /// \return the feature
index 17f5be33b69f38b28bbbe07c0dacc1a483517f83..8c6f38832bfc3005773af18777ff8073b43750c3 100644 (file)
@@ -302,13 +302,14 @@ void PartSet_Tools::createConstraint(FeaturePtr theSketch,
 }
 
 void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
-                                   const std::string& theAttribute, double theX, double theY)
+                                   const std::string& theAttribute,
+                                   double theClickedX, double theClickedY)
 {
   // find a feature point by the selection mode
   //boost::shared_ptr<GeomDataAPI_Point2D> aPoint = featurePoint(theMode);
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+  boost::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
-  if (!aPoint)
+  if (!aFeaturePoint)
     return;
 
   // get all sketch features. If the point with the given coordinates belong to any sketch feature,
@@ -319,28 +320,28 @@ void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
 
   std::list<FeaturePtr > aFeatures = aRefList->list();
   std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+  std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes;
+  boost::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = boost::shared_ptr<GeomAPI_Pnt2d>
+                                                     (new GeomAPI_Pnt2d(theClickedX, theClickedY));
   for (; anIt != aLast; anIt++)
   {
     FeaturePtr aFeature = *anIt;
-    boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;// = aFeature->findPoint(theX, theY);
+    // find the given point in the feature attributes
+    anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+    std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
+                                                                      aLast = anAttiributes.end();
+    boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
+    for (;anIt!=aLast && !aFPoint; anIt++) {
+      boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
+                                          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+      if (aCurPoint && aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion())
+        aFPoint = aCurPoint;
+    }
     if (aFPoint)
-      PartSet_Tools::createConstraint(theSketch, aFPoint, aPoint);
+      PartSet_Tools::createConstraint(theSketch, aFPoint, aFeaturePoint);
   }
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findPoint(FeaturePtr theFeature,
-                                                                double theX, double theY)
-{
-  boost::shared_ptr<PartSet_FeaturePrs> aFeaturePrs = PartSet_Tools::createFeaturePrs(
-                                           theFeature->getKind(), FeaturePtr(), theFeature);
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (aFeaturePrs)
-    aPoint2D = aFeaturePrs->findPoint(theFeature, theX, theY);
-
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(FeaturePtr theSketch)
 {
   boost::shared_ptr<GeomAPI_Pln> aPlane;
index 7f407ac8c5427a37e32a8d0acf810593d5379389..6aebb10322b3bdb86b80bbe937fefed7b9f539b8 100644 (file)
@@ -114,17 +114,10 @@ public:
   /// \param theSketch a sketch feature
   /// \param theFeature a source feature
   /// \param theAttribute a name of the requried attribute attribute
-  /// \param theX the horizontal coordnate of the point
-  /// \param theY the vertical coordnate of the point
+  /// \param theClickedX the horizontal coordnate of the point
+  /// \param theClickedY the vertical coordnate of the point
   static void setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
-                             const std::string& theAttribute, double theX, double theY);
-
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  static boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                          double theY);
+                             const std::string& theAttribute, double theClickedX, double theClickedY);
 
   /// Create a sketch plane instance
   /// \param theSketch a sketch feature