Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[modules/shaper.git] / src / PartSet / PartSet_FeatureArcPrs.cpp
index b742b64d7b67277691f068384f0a4bf7623f9946..440f5624efbeb8542c7d348a41dabab1c3bcc00c 100644 (file)
@@ -94,16 +94,17 @@ PartSet_SelectionMode PartSet_FeatureArcPrs::getNextMode(const std::string& theA
   return aMode;
 }
 
-void PartSet_FeatureArcPrs::projectPointOnArc(gp_Pnt& thePoint, Handle(V3d_View) theView,
-                                              double& theX, double& theY)
+void PartSet_FeatureArcPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
+                                                  gp_Pnt& thePoint, Handle(V3d_View) theView,
+                                                  double& theX, double& theY)
 {
-  FeaturePtr aSketch = sketch();
+  FeaturePtr aSketch = theSketch;
   if (aSketch) {
     double aX, anY;
     PartSet_Tools::convertTo2D(thePoint, aSketch, theView, aX, anY);
 
     // circle origin point and radius
-    boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+    boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
     boost::shared_ptr<GeomDataAPI_Point2D> aCenter = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                                               (aData->attribute(ARC_ATTR_CENTER));
     boost::shared_ptr<GeomDataAPI_Point2D> aStart = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
@@ -142,3 +143,18 @@ boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureArcPrs::featurePoint
                                                               (aData->attribute(aPointArg));
   return aPoint;
 }
+
+double PartSet_FeatureArcPrs::radius(FeaturePtr theFeature)
+{
+  if (!theFeature)
+    return 0;
+
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
+  boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
+  
+  return aCenterAttr->pnt()->distance(aStartAttr->pnt());
+}