Sketcher: Unit independent pole weight for B-Splines (Weight constraint)

========================================================================

Until now BSpline poles were circles relying on physical length units. This lead to several
problems:
- While the BSpline weight follows the circle size, weights do not have length units, but are adimensinal
- As representation of the BSpline depends on the physical size of the circle, the numerical value to be
  set to a pole circle differs from the numerical value of the weight.

The present commit:
1. Separates pole circle representation (physical size), from the numerical value used in the radius constraint,
so that the value in the constraint is the weight, the value representation is a factor of the weight value (in this
commit is getScaleFactor(), but this will change in the next commit). Dragging accounts for this scale factor too.
2. While Radius constraint button is used to constraint a B-Spline weight as before, this creates a Weight constraint,
which is a new type of constraint. This is done so that the value is truly adimensional and is so presented in all kind
of editors that rely on the units indicated by the constraint. It is obviously also shown as adimensional (thus without units),
in the 3D view and in the datum dialogs.
3. Because the circle of the pole of a B-Spline is not a geometric circle, but a graphical representation of the pole and how
it affects the corresponding B-Spline, constraint creation commands are limited so that no point on object, tangent, perpendicular
or SnellLaw constraints can be created on a B-Spline weight circle. This is also the case for the Diameter constraint, which won't
accept the circle. Equality constraints work either on only circles or only weights, but not on a mixture of them.

Bonus: This commit fixes a bug in master, that using the select equality constraint then click in two geometric elements mode, you
could make a circle equal to an ellipse resulting in malformed solver constraints.
This commit is contained in:
Abdullah Tahiri
2020-11-25 14:27:27 +01:00
committed by abdullahtahiriyo
parent 8080e8df90
commit 95c1a262b7
11 changed files with 444 additions and 85 deletions

View File

@@ -169,6 +169,13 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
this->getConstraintPtr()->LabelPosition = 10;
valid = true;
}
else if (strcmp("Weight",ConstraintType) == 0) {
this->getConstraintPtr()->Type = Weight;
// set a value that is out of range of result of atan2
// this value is handled in ViewProviderSketch
this->getConstraintPtr()->LabelPosition = 10;
valid = true;
}
if (valid) {
this->getConstraintPtr()->First = FirstIndex;
this->getConstraintPtr()->setValue(Value);
@@ -503,6 +510,7 @@ std::string ConstraintPy::representation(void) const
case Block : result << "'Block' (" << getConstraintPtr()->First << ")>";break;
case Radius : result << "'Radius'>";break;
case Diameter : result << "'Diameter'>";break;
case Weight : result << "'Weight'>";break;
case Parallel : result << "'Parallel'>";break;
case Tangent :
if (this->getConstraintPtr()->Third == Constraint::GeoUndef)
@@ -554,6 +562,7 @@ Py::String ConstraintPy::getType(void) const
case Block : return Py::String("Block");break;
case Radius : return Py::String("Radius");break;
case Diameter : return Py::String("Diameter");break;
case Weight : return Py::String("Weight");break;
case Parallel : return Py::String("Parallel");break;
case Tangent : return Py::String("Tangent");break;
case Perpendicular : return Py::String("Perpendicular");break;