diff --git a/src/Mod/TechDraw/App/AppTechDrawPy.cpp b/src/Mod/TechDraw/App/AppTechDrawPy.cpp index 2db2be0711..6cfecbf6bb 100644 --- a/src/Mod/TechDraw/App/AppTechDrawPy.cpp +++ b/src/Mod/TechDraw/App/AppTechDrawPy.cpp @@ -639,7 +639,7 @@ private: double parentX = dvp->X.getValue() + grandParentX; double parentY = dvp->Y.getValue() + grandParentY; Base::Vector3d parentPos(parentX,parentY,0.0); - std::string sDimText = dvd->getFormatedValue(); + std::string sDimText = dvd->getFormattedDimensionValue(); char* dimText = &sDimText[0u]; //hack for const-ness float gap = 5.0; //hack. don't know font size here. layerName = dvd->getNameInDocument(); diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index 23d12f51c6..5f1a7b367a 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -530,23 +530,17 @@ bool DrawViewDimension::isMultiValueSchema(void) const return result; } -std::string DrawViewDimension::getFormatedValue(int partial) +std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int partial) { -// Base::Console().Message("DVD::getFormatedValue(%d)\n", partial); std::string result; - if (Arbitrary.getValue()) { - return FormatSpec.getStrValue(); - } bool multiValueSchema = false; - QString qFormatSpec = QString::fromUtf8(FormatSpec.getStrValue().data(),FormatSpec.getStrValue().size()); - double val = getDimValue(); QString qUserStringUnits; QString formattedValue; bool angularMeasure = false; Base::Quantity asQuantity; - asQuantity.setValue(val); + asQuantity.setValue(value); if ( (Type.isValue("Angle")) || (Type.isValue("Angle3Pt")) ) { angularMeasure = true; @@ -686,8 +680,20 @@ std::string DrawViewDimension::getFormatedValue(int partial) } return result; + } +std::string DrawViewDimension::getFormattedDimensionValue(int partial) +{ +// Base::Console().Message("DVD::getFormattedValue(%d)\n", partial); + QString qFormatSpec = QString::fromUtf8(FormatSpec.getStrValue().data(),FormatSpec.getStrValue().size()); + + if (Arbitrary.getValue()) { + return FormatSpec.getStrValue(); + } + + return formatValue(getDimValue(), qFormatSpec, partial); +} QStringList DrawViewDimension::getPrefixSuffixSpec(QString fSpec) { diff --git a/src/Mod/TechDraw/App/DrawViewDimension.h b/src/Mod/TechDraw/App/DrawViewDimension.h index c156c4316c..0a34ff493a 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.h +++ b/src/Mod/TechDraw/App/DrawViewDimension.h @@ -133,7 +133,9 @@ public: //return PyObject as DrawViewDimensionPy virtual PyObject *getPyObject(void) override; - virtual std::string getFormatedValue(int partial = 0); + virtual std::string getFormattedDimensionValue(int partial = 0); + virtual std::string formatValue(qreal value, QString qFormatSpec, int partial = 0); + virtual double getDimValue(); QStringList getPrefixSuffixSpec(QString fSpec); diff --git a/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp b/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp index b41e80f59c..4a6e82fa41 100644 --- a/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp @@ -61,7 +61,7 @@ PyObject* DrawViewDimensionPy::getText(PyObject* args) // return 0; // } DrawViewDimension* dvd = getDrawViewDimensionPtr(); - std::string textString = dvd->getFormatedValue(); + std::string textString = dvd->getFormattedDimensionValue(); //TODO: check multiversion code! #if PY_MAJOR_VERSION >= 3 PyObject* pyText = Base::PyAsUnicodeObject(textString); diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index b0e35c7b25..420b91e928 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -352,7 +352,7 @@ void QGIDatumLabel::setTolString() } QString tolSuffix; if ((dim->Type.isValue("Angle")) || (dim->Type.isValue("Angle3Pt"))) { - tolSuffix = QString::fromUtf8(dim->getFormatedValue(2).c_str()); //just the unit + tolSuffix = QString::fromUtf8(dim->getFormattedDimensionValue(2).c_str()); //just the unit } QString overFormat; @@ -626,18 +626,18 @@ void QGIViewDimension::updateDim() return; } -// QString labelText = QString::fromUtf8(dim->getFormatedValue().c_str()); +// QString labelText = QString::fromUtf8(dim->getFormattedDimensionValue().c_str()); //want this split into value and unit QString labelText; QString unitText; if (dim->Arbitrary.getValue()) { - labelText = QString::fromUtf8(dim->getFormatedValue(1).c_str()); //just the number pref/spec/suf + labelText = QString::fromUtf8(dim->getFormattedDimensionValue(1).c_str()); //just the number pref/spec/suf } else { if (dim->isMultiValueSchema()) { - labelText = QString::fromUtf8(dim->getFormatedValue(0).c_str()); //don't format multis + labelText = QString::fromUtf8(dim->getFormattedDimensionValue(0).c_str()); //don't format multis } else { - labelText = QString::fromUtf8(dim->getFormatedValue(1).c_str()); //just the number pref/spec/suf - unitText = QString::fromUtf8(dim->getFormatedValue(2).c_str()); //just the unit + labelText = QString::fromUtf8(dim->getFormattedDimensionValue(1).c_str()); //just the number pref/spec/suf + unitText = QString::fromUtf8(dim->getFormattedDimensionValue(2).c_str()); //just the unit } } QFont font = datumLabel->getFont();