aPnt_A = aPoint_A->pnt();
aPnt_B = aPoint_B->pnt();
} else if (!aPoint_A && aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine) {
- aPnt_B = aPoint_B->pnt();
- aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
- }
+ //std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+ // aData, SketchPlugin_Constraint::ENTITY_A());
+ //if (aLine) {
+ // aPnt_B = aPoint_B->pnt();
+ // aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
+ //}
} else if (aPoint_A && !aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine) {
- aPnt_A = aPoint_A->pnt();
- aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
- }
+ //std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+ // aData, SketchPlugin_Constraint::ENTITY_B());
+ //if (aLine) {
+ // aPnt_A = aPoint_A->pnt();
+ // aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
+ //}
}
if (!aPnt_A || !aPnt_B)
return false;
if (aPointA && aPointB) { // both points
aDistance = aPointA->pnt()->distance(aPointB->pnt());
} else {
- if (!aPointA && aPointB) { //Line and point
- std::shared_ptr<SketchPlugin_Line> aLine =
- SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine) {
- aDistance = aLine->distanceToPoint(aPointB->pnt());
- }
- } else if (aPointA && !aPointB) { // Point and line
- std::shared_ptr<SketchPlugin_Line> aLine =
- SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine) {
- aDistance = aLine->distanceToPoint(aPointA->pnt());
- }
- }
+// if (!aPointA && aPointB) { //Line and point
+// std::shared_ptr<SketchPlugin_Line> aLine =
+// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
+// if (aLine) {
+// aDistance = aLine->distanceToPoint(aPointB->pnt());
+// }
+// } else if (aPointA && !aPointB) { // Point and line
+// std::shared_ptr<SketchPlugin_Line> aLine =
+// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
+// if (aLine) {
+// aDistance = aLine->distanceToPoint(aPointA->pnt());
+// }
+// }
}
return aDistance;
}
return aDelta;
}
+const std::string& SketchPlugin_Line::getKind()
+{
+ static std::string MY_KIND = SketchPlugin_Line::ID();
+ return MY_KIND;
+}
+
bool SketchPlugin_Line::isFixed() {
return data()->selection(EXTERNAL_ID())->context().get() != NULL;
}
}
/// Returns the kind of a feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
- {
- static std::string MY_KIND = SketchPlugin_Line::ID();
- return MY_KIND;
- }
+ SKETCHPLUGIN_EXPORT virtual const std::string& getKind();
/// Returns true is sketch element is under the rigid constraint
SKETCHPLUGIN_EXPORT virtual bool isFixed();
aPnt_A = aPoint_A->pnt();
aPnt_B = aPoint_B->pnt();
} else if (!aPoint_A && aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine) {
- aPnt_B = aPoint_B->pnt();
- aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
- }
+// std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+// aData, SketchPlugin_Constraint::ENTITY_A());
+// if (aLine) {
+// aPnt_B = aPoint_B->pnt();
+// aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
+// }
} else if (aPoint_A && !aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine) {
- aPnt_A = aPoint_A->pnt();
- aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
- }
+// std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+// aData, SketchPlugin_Constraint::ENTITY_B());
+// if (aLine) {
+// aPnt_A = aPoint_A->pnt();
+// aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
+// }
}
if (!aPnt_A || !aPnt_B)
return false;
}
//*************************************************************************************
-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;
-}
+//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;
+//}
//*************************************************************************************
-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 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);
+//}
static double MyArrowSize = 30.;
MyArrowSize = theSize;
}
-};
\ No newline at end of file
+};
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
const std::string& theAttrName);
- SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
- const std::shared_ptr<SketchPlugin_Line>& theLine,
- const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
+// SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
+// const std::shared_ptr<SketchPlugin_Line>& theLine,
+// const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
- SKETCHERPRS_EXPORT std::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
- const std::string& theAttribute);
+// SKETCHERPRS_EXPORT std::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
+// const std::string& theAttribute);
/// Obtain the point object from specified constraint parameter
SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
SKETCHERPRS_EXPORT void setArrowSize(double theSize);
};
-#endif
\ No newline at end of file
+#endif