Salome HOME
Exclude links to SketchPlugin
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Tools.cpp
index e154f8000f89d366cfbafc8528fbd5caba6290bd..47468899ec7d2d7685b561f1277707b93d5c7bd8 100644 (file)
@@ -20,7 +20,7 @@
 
 namespace SketcherPrs_Tools {
 
-ObjectPtr getResult(SketchPlugin_Constraint* theFeature, const std::string& theAttrName)
+ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName)
 {
   std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
@@ -40,8 +40,8 @@ std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject)
 }
 
 
-std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
-                                               const std::string& theAttribute)
+std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
+                                        const std::string& theAttribute)
 {
   std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
 
@@ -100,38 +100,37 @@ std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
 }
 
 //*************************************************************************************
-//std::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
-//                                                  const std::string& theAttribute)
-//{
-//  std::shared_ptr<SketchPlugin_Line> aLine;
-//  if (!theData)
-//    return aLine;
-//
-//  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
-//      ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
-//  if (anAttr) {
-//    FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
-//    if (aFeature && aFeature->getKind() == SketchPlugin_Line::ID()) {
-//      aLine = std::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
-//    }
-//  }
-//  return aLine;
-//}
+FeaturePtr getFeatureLine(DataPtr theData,
+                          const std::string& theAttribute)
+{
+  FeaturePtr aLine;
+  if (!theData)
+    return aLine;
+
+  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
+  if (anAttr) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
+    if (aFeature && aFeature->getKind() == SketchPlugin_Line::ID()) {
+      return aFeature;
+    }
+  }
+  return aLine;
+}
 
 //*************************************************************************************
-//std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
-//    const std::shared_ptr<SketchPlugin_Line>& theLine,
-//    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
-//{
-//  std::shared_ptr<ModelAPI_Data> aData = theLine->data();
-//  std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-//      aData->attribute(SketchPlugin_Line::START_ID()));
-//  std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-//      aData->attribute(SketchPlugin_Line::END_ID()));
-//
-//  GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y());
-//  return aLin2d.project(thePoint);
-//}
+std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const FeaturePtr theLine,
+                                                  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+{
+  DataPtr aData = theLine->data();
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aData->attribute(SketchPlugin_Line::START_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aData->attribute(SketchPlugin_Line::END_ID()));
+
+  GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y());
+  return aLin2d.project(thePoint);
+}
 
 
 static double MyArrowSize = 30.;