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 =
}
-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;
}
//*************************************************************************************
-//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.;