Base: [skip ci] improve repr() for quantity
https://forum.freecadweb.org/viewtopic.php?f=10&t=43718 https://forum.freecadweb.org/viewtopic.php?f=10&t=43431&p=369556#p369575
This commit is contained in:
@@ -36,10 +36,21 @@ using namespace Base;
|
||||
std::string QuantityPy::representation(void) const
|
||||
{
|
||||
std::stringstream ret;
|
||||
#if 0
|
||||
//ret.precision(getQuantityPtr()->getFormat().precision);
|
||||
//ret.setf(std::ios::fixed, std::ios::floatfield);
|
||||
ret << getQuantityPtr()->getValue() << " ";
|
||||
ret << getQuantityPtr()->getUnit().getString().toUtf8().constData();
|
||||
#else
|
||||
double val= getQuantityPtr()->getValue();
|
||||
Unit unit = getQuantityPtr()->getUnit();
|
||||
|
||||
// Use Python's implementation to repr() a float
|
||||
Py::Float flt(val);
|
||||
ret << static_cast<std::string>(flt.repr());
|
||||
if (!unit.isEmpty())
|
||||
ret << " " << unit.getString().toUtf8().constData();
|
||||
#endif
|
||||
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user