[Sketcher] Do not allow B-spline degree to be too high

...depending on number of poles (and periodic status).

NOTE: It is still possible to run the command in console with a higher degree.
This commit is contained in:
Ajinkya Dahale
2023-01-11 20:24:20 +05:30
committed by abdullahtahiriyo
parent acb42e4109
commit bbce4cb4c4

View File

@@ -394,6 +394,8 @@ private:
int currentgeoid = getHighestCurveIndex();
unsigned int maxDegree = ConstrMethod == 0 ? (BSplinePoles.size()-1) : (BSplinePoles.size());
try {
//Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add B-spline curve"));
@@ -406,11 +408,11 @@ private:
// {"poles", "mults", "knots", "periodic", "degree", "weights", "CheckRational", NULL};
Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.BSplineCurve"
"(%s,None,None,%s,%d,None,False),%s)",
controlpoints.c_str(),
ConstrMethod == 0 ?"False":"True",
SplineDegree,
geometryCreationMode==Construction?"True":"False");
"(%s,None,None,%s,%d,None,False),%s)",
controlpoints.c_str(),
ConstrMethod == 0 ?"False":"True",
std::min(maxDegree, SplineDegree),
geometryCreationMode==Construction?"True":"False");
currentgeoid++;
@@ -500,7 +502,7 @@ protected:
std::vector<std::vector<AutoConstraint>> sugConstr;
int ConstrMethod;
int SplineDegree;
unsigned int SplineDegree;
bool IsClosed;
std::vector<int> poleGeoIds;
Base::Vector2d prevCursorPosition;