Sketcher: Bspline: Fix degree visibility, default value and combobox not updating with methode change.

This commit is contained in:
PaddleStroke
2024-06-27 15:24:01 +02:00
committed by Chris Hennes
parent fe007b205b
commit 5e4ab51c02
2 changed files with 23 additions and 5 deletions

View File

@@ -456,13 +456,14 @@ private:
/// Syncs the construction method selection in the combobox to the handler selection
void syncConstructionMethodComboboxToHandler()
{
if constexpr (PFirstComboboxIsConstructionMethod == true) {
auto constructionmethod = toolWidget->getComboboxIndex(WCombobox::FirstCombo);
auto actualconstructionmethod = static_cast<int>(handler->constructionMethod());
if (constructionmethod != actualconstructionmethod) {
boost::signals2::shared_connection_block combobox_block(
connectionComboboxSelectionChanged);
toolWidget->setComboboxIndex(WCombobox::FirstCombo, actualconstructionmethod);
}
}

View File

@@ -890,14 +890,21 @@ void DSHBSplineController::configureToolWidget()
toolWidget->setParameterLabel(
WParameter::First,
QApplication::translate("ToolWidgetManager_p4", "Degree (+'U'/ -'J')"));
toolWidget->setParameter(WParameter::First, handler->SplineDegree);
toolWidget->configureParameterUnit(WParameter::First, Base::Unit());
toolWidget->configureParameterMin(WParameter::First, 1.0); // NOLINT
// We set a reasonable max to avoid the spinbox from being very large
toolWidget->configureParameterMax(WParameter::First, Geom_BSplineCurve::MaxDegree());
toolWidget->configureParameterDecimals(WParameter::First, 0);
}
toolWidget->configureParameterMax(WParameter::First, Geom_BSplineCurve::MaxDegree()); // NOLINT
if (handler->constructionMethod() == ConstructionMethod::ControlPoints) {
toolWidget->setParameter(WParameter::First, handler->SplineDegree);
toolWidget->setParameterVisible(WParameter::First, true);
}
else {
// We still set the value in case user change of mode.
toolWidget->setParameterWithoutPassingFocus(WParameter::First, handler->SplineDegree);
toolWidget->setParameterVisible(WParameter::First, false);
}
onViewParameters[OnViewParameter::First]->setLabelType(Gui::SoDatumLabel::DISTANCEX);
onViewParameters[OnViewParameter::Second]->setLabelType(Gui::SoDatumLabel::DISTANCEY);
@@ -1076,9 +1083,19 @@ void DSHBSplineController::doChangeDrawSketchHandlerMode()
template<>
bool DSHBSplineControllerBase::resetOnConstructionMethodeChanged()
void DSHBSplineController::doConstructionMethodChanged()
{
handler->changeConstructionMethode();
syncConstructionMethodComboboxToHandler();
bool byCtrlPoints = handler->constructionMethod() == ConstructionMethod::ControlPoints;
toolWidget->setParameterVisible(WParameter::First, byCtrlPoints);
}
template<>
bool DSHBSplineControllerBase::resetOnConstructionMethodeChanged()
{
return false;
}