Skip to content

Commit

Permalink
SketcherToolDefaultWidget : add 3 parameter configuration functions.
Browse files Browse the repository at this point in the history
And remove the units from setParameter.
  • Loading branch information
PaddleStroke authored and abdullahtahiriyo committed Oct 24, 2023
1 parent 0b7e8c8 commit d19a16d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/Mod/Sketcher/Gui/SketcherToolDefaultWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void SketcherToolDefaultWidget::setParameterLabel(int parameterindex, const QStr
void SketcherToolDefaultWidget::setParameter(int parameterindex, double val)
{
if (parameterindex < nParameters) {
getParameterSpinBox(parameterindex)->setValue(Base::Quantity(val, Base::Unit::Length));
getParameterSpinBox(parameterindex)->setValue(val);

return;
}
Expand Down Expand Up @@ -424,6 +424,45 @@ void SketcherToolDefaultWidget::configureParameterUnit(int parameterindex, const
QT_TRANSLATE_NOOP("Exceptions", "ToolWidget parameter index out of range"));
}

void SketcherToolDefaultWidget::configureParameterDecimals(int parameterindex, int val)
{
Base::StateLocker lock(blockParameterSlots, true);
if (parameterindex < nParameters) {
getParameterSpinBox(parameterindex)->setDecimals(val);

return;
}

THROWM(Base::IndexError,
QT_TRANSLATE_NOOP("Exceptions", "ToolWidget parameter index out of range"));
}

void SketcherToolDefaultWidget::configureParameterMin(int parameterindex, double val)
{
Base::StateLocker lock(blockParameterSlots, true);
if (parameterindex < nParameters) {
getParameterSpinBox(parameterindex)->setMinimum(val);

return;
}

THROWM(Base::IndexError,
QT_TRANSLATE_NOOP("Exceptions", "ToolWidget parameter index out of range"));
}

void SketcherToolDefaultWidget::configureParameterMax(int parameterindex, double val)
{
Base::StateLocker lock(blockParameterSlots, true);
if (parameterindex < nParameters) {
getParameterSpinBox(parameterindex)->setMaximum(val);

return;
}

THROWM(Base::IndexError,
QT_TRANSLATE_NOOP("Exceptions", "ToolWidget parameter index out of range"));
}

void SketcherToolDefaultWidget::setParameterEnabled(int parameterindex, bool active)
{
if (parameterindex < nParameters) {
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Sketcher/Gui/SketcherToolDefaultWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class SketcherToolDefaultWidget: public QWidget
void setParameter(int parameterindex, double val);
void configureParameterInitialValue(int parameterindex, double value);
void configureParameterUnit(int parameterindex, const Base::Unit& unit);
void configureParameterDecimals(int parameterindex, int val);
void configureParameterMax(int parameterindex, double val);
void configureParameterMin(int parameterindex, double val);
double getParameter(int parameterindex);
bool isParameterSet(int parameterindex);
void
Expand Down

0 comments on commit d19a16d

Please sign in to comment.