MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / throwIfOutOfRange

Method throwIfOutOfRange

src/Gui/Dialogs/DlgExpressionInput.cpp:289–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289void NumberRange::throwIfOutOfRange(const Base::Quantity& value) const
290{
291 if (!defined) {
292 return;
293 }
294
295 auto toQString = [](const Base::Quantity& v) {
296 return QString::fromStdString(v.getUserString());
297 };
298
299 if (value.getValue() < minimum || value.getValue() > maximum) {
300 Base::Quantity minVal(minimum, value.getUnit());
301 Base::Quantity maxVal(maximum, value.getUnit());
302
303 const QString fmt
304 = QCoreApplication::translate("Exceptions", "Value out of range (%1 out of [%2, %3])");
305 const QString msg = fmt.arg(toQString(value), toQString(minVal), toQString(maxVal));
306 THROWM(Base::ValueError, msg.toStdString());
307 }
308}
309
310void DlgExpressionInput::setRange(double minimum, double maximum)
311{

Callers 1

checkExpressionMethod · 0.80

Calls 5

toStdStringMethod · 0.80
translateFunction · 0.50
getUserStringMethod · 0.45
getValueMethod · 0.45
getUnitMethod · 0.45

Tested by

no test coverage detected