#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_ConstraintCoincidence.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Constraint.h>
+#include <SketchPlugin_Circle.h>
#include <GeomDataAPI_Point2D.h>
+#include <GeomAPI_Pnt2d.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
{
}
-void PartSet_FeatureCirclePrs::initFeature(FeaturePtr theFeature)
-{
- if (feature() && theFeature)
- {
- // use the last point of the previous feature as the first of the new one
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> anInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(LINE_ATTR_END));
- PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START);
- PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END);
-
- aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(LINE_ATTR_START));
- PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
- }
-}
-
PartSet_SelectionMode PartSet_FeatureCirclePrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
+ const PartSet_SelectionMode& theMode)
{
PartSet_SelectionMode aMode = theMode;
switch (theMode)
{
case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_START);
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
+ PartSet_Tools::setFeaturePoint(feature(), theX, theY, CIRCLE_ATTR_CENTER);
aMode = SM_SecondPoint;
}
break;
case SM_SecondPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
+ boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+ (aData->attribute(CIRCLE_ATTR_CENTER));
+ boost::shared_ptr<GeomAPI_Pnt2d> aCoordPoint(new GeomAPI_Pnt2d(theX, theY));
+ double aRadius = aCoordPoint->distance(aPoint->pnt());
+ PartSet_Tools::setFeatureValue(feature(), aRadius, CIRCLE_ATTR_RADIUS);
+
aMode = SM_DonePoint;
}
break;
switch (theMode)
{
case SM_FirstPoint:
- aAttribute = LINE_ATTR_START;
+ aAttribute = CIRCLE_ATTR_CENTER;
break;
case SM_SecondPoint:
- aAttribute = LINE_ATTR_END;
+ aAttribute = CIRCLE_ATTR_RADIUS;
break;
default:
break;
{
PartSet_SelectionMode aMode;
- if (theAttribute == LINE_ATTR_START)
+ if (theAttribute == CIRCLE_ATTR_CENTER)
aMode = SM_SecondPoint;
- else if (theAttribute == LINE_ATTR_END)
+ else if (theAttribute == CIRCLE_ATTR_RADIUS)
aMode = SM_DonePoint;
return aMode;
}
switch (theMode)
{
case SM_FirstPoint:
- aPointArg = LINE_ATTR_START;
- break;
- case SM_SecondPoint:
- aPointArg = LINE_ATTR_END;
+ aPointArg = CIRCLE_ATTR_CENTER;
break;
default:
break;