Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[modules/shaper.git] / src / PartSet / PartSet_FeatureLinePrs.cpp
index ef6e7c0059c4a3bfdbc974aafc197a62016b18a7..4aa747a997ce4208246531c72af5c9cd6f21c996 100644 (file)
@@ -58,9 +58,9 @@ PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY,
   return aMode;
 }
 
-bool PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+PartSet_SelectionMode PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
 {
-  bool aResult = false;
+  PartSet_SelectionMode aMode = theMode;
   if (feature() && theFeature && theMode == SM_FirstPoint)
   {
     // use the last point of the previous feature as the first of the new one
@@ -74,9 +74,9 @@ bool PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_Sel
     boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                                                  (aData->attribute(LINE_ATTR_START));
     PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
-    aResult = true;
+    aMode = SM_SecondPoint;
   }
-  return aResult;
+  return aMode;
 }
 
 std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const
@@ -107,21 +107,6 @@ PartSet_SelectionMode PartSet_FeatureLinePrs::getNextMode(const std::string& the
   return aMode;
 }
 
-void PartSet_FeatureLinePrs::move(double theDeltaX, double theDeltaY)
-{
-  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-  if (!aData->isValid())
-    return;
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-  aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
-}
-
 void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature,
                                                 const PartSet_SelectionMode& theMode,
                                                 const gp_Pnt& thePoint, Handle(V3d_View) theView,
@@ -163,33 +148,6 @@ void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature,
   }
 }
 
-double PartSet_FeatureLinePrs::distanceToPoint(FeaturePtr theFeature,
-                                      double theX, double theY)
-{
-  double aDelta = 0;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aDelta;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-
-  GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y());
-  boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
-
-  if (false/*projection*/) { // TODO: if it has not been necessary, remove this block
-    boost::shared_ptr<GeomAPI_Pnt2d> aResult = aLin2d.project(aPoint);
-    aDelta = aResult->distance(aPoint);
-  }
-  else { // distance
-    aDelta = aLin2d.distance(aPoint);
-  }
-
-  return aDelta;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLinePrs::findPoint(FeaturePtr theFeature,
                                                                          double theX, double theY)
 {