+ fixes #0001225: Allow User to Rotate Arc Radius Constraint Text and Leader

This commit is contained in:
wmayer 2015-01-02 21:26:03 +01:00
parent fe994efa66
commit 08828e5dc0
2 changed files with 22 additions and 6 deletions

View File

@ -143,6 +143,9 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
} }
else if (strcmp("Radius",ConstraintType) == 0) { else if (strcmp("Radius",ConstraintType) == 0) {
this->getConstraintPtr()->Type = Radius; this->getConstraintPtr()->Type = Radius;
// set a value that is out of range of result of atan2
// this value is handled in ViewProviderSketch
this->getConstraintPtr()->LabelPosition = 10;
valid = true; valid = true;
} }
if (valid) { if (valid) {

View File

@ -1163,10 +1163,17 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo
} else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { } else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>(geo); const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>(geo);
double radius = arc->getRadius(); double radius = arc->getRadius();
p1 = arc->getCenter();
double angle = Constr->LabelPosition;
if (angle == 10) {
double startangle, endangle; double startangle, endangle;
arc->getRange(startangle, endangle); arc->getRange(startangle, endangle);
double angle = (startangle + endangle)/2; angle = (startangle + endangle)/2;
p1 = arc->getCenter(); }
else {
Base::Vector3d tmpDir = Base::Vector3d(toPos.fX, toPos.fY, 0) - p1;
angle = atan2(tmpDir.y, tmpDir.x);
}
p2 = p1 + radius * Base::Vector3d(cos(angle),sin(angle),0.); p2 = p1 + radius * Base::Vector3d(cos(angle),sin(angle),0.);
} }
else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) {
@ -3742,9 +3749,12 @@ Restart:
if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>(geo); const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>(geo);
double radius = arc->getRadius(); double radius = arc->getRadius();
double angle = (double) Constr->LabelPosition;
if (angle == 10) {
double startangle, endangle; double startangle, endangle;
arc->getRange(startangle, endangle); arc->getRange(startangle, endangle);
double angle = (startangle + endangle)/2; angle = (startangle + endangle)/2;
}
pnt1 = arc->getCenter(); pnt1 = arc->getCenter();
pnt2 = pnt1 + radius * Base::Vector3d(cos(angle),sin(angle),0.); pnt2 = pnt1 + radius * Base::Vector3d(cos(angle),sin(angle),0.);
} }
@ -3752,6 +3762,9 @@ Restart:
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geo); const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geo);
double radius = circle->getRadius(); double radius = circle->getRadius();
double angle = (double) Constr->LabelPosition; double angle = (double) Constr->LabelPosition;
if (angle == 10) {
angle = 0;
}
pnt1 = circle->getCenter(); pnt1 = circle->getCenter();
pnt2 = pnt1 + radius * Base::Vector3d(cos(angle),sin(angle),0.); pnt2 = pnt1 + radius * Base::Vector3d(cos(angle),sin(angle),0.);
} }