[TD] Refactor DrawViewDimension getFormatedValue() into two functions.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user