Merge pull request #25853 from 3x380V/reimplement_24749
TechDraw: Fix dimension formatter
This commit is contained in:
@@ -51,7 +51,7 @@ std::string DimensionFormatter::formatValue(const qreal value,
|
||||
const Format partial,
|
||||
const bool isDim) const
|
||||
{
|
||||
bool distanceMeasure{true};
|
||||
bool distanceMeasure{true};
|
||||
const bool angularMeasure =
|
||||
m_dimension->Type.isValue("Angle") || m_dimension->Type.isValue("Angle3Pt");
|
||||
const bool areaMeasure = m_dimension->Type.isValue("Area");
|
||||
@@ -77,7 +77,7 @@ std::string DimensionFormatter::formatValue(const qreal value,
|
||||
// won't give more than Global_Decimals precision
|
||||
std::string basicString = formatPrefix + asQuantity.getUserString() + formatSuffix;
|
||||
|
||||
if (isMultiValueSchema() && partial == Format::UNALTERED) {
|
||||
if (isMultiValueSchema() || partial == Format::UNALTERED) {
|
||||
return basicString; // Don't even try to use Alt Decimals or hide units
|
||||
}
|
||||
|
||||
@@ -101,7 +101,9 @@ std::string DimensionFormatter::formatValue(const qreal value,
|
||||
formatSpecifier.replace(QStringLiteral("%g"), newSpecifier, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
std::string unitText = Base::UnitsApi::getUnitText(asQuantity);
|
||||
double factor{1.0};
|
||||
std::string unitText{""};
|
||||
asQuantity.getUserString(factor, unitText);
|
||||
std::string super2{"²"};
|
||||
std::string squareTag{"^2"};
|
||||
|
||||
@@ -118,8 +120,7 @@ std::string DimensionFormatter::formatValue(const qreal value,
|
||||
double userVal = asQuantity.getValue();
|
||||
|
||||
if (distanceMeasure || areaMeasure) {
|
||||
const double convertValue = Base::Quantity::parse("1" + unitText).getValue();
|
||||
userVal /= convertValue;
|
||||
userVal /= factor;
|
||||
}
|
||||
|
||||
// convert ^2 to superscript 2 for display
|
||||
|
||||
@@ -273,22 +273,15 @@ void QGIViewDimension::updateDim()
|
||||
return;
|
||||
}
|
||||
|
||||
QString labelText =
|
||||
// what about fromStdString?
|
||||
QString::fromUtf8(dim->getFormattedDimensionValue(Format::FORMATTED).c_str());// pre value [unit] post
|
||||
if (dim->isMultiValueSchema()) {
|
||||
labelText =
|
||||
QString::fromUtf8(dim->getFormattedDimensionValue(Format::UNALTERED).c_str());//don't format multis
|
||||
}
|
||||
|
||||
QFont font = datumLabel->getFont();
|
||||
auto labelText = dim->getFormattedDimensionValue(Format::FORMATTED);
|
||||
auto font = datumLabel->getFont();
|
||||
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
|
||||
int fontSize = QGIView::exactFontSize(vp->Font.getValue(), std::max(1.0, vp->Fontsize.getValue()));
|
||||
font.setPixelSize(fontSize);
|
||||
datumLabel->setFont(font);
|
||||
|
||||
prepareGeometryChange();
|
||||
datumLabel->setDimString(labelText);
|
||||
datumLabel->setDimString(QString::fromStdString(labelText));
|
||||
datumLabel->setToleranceString();
|
||||
|
||||
datumLabel->setFramed(dim->TheoreticalExact.getValue());
|
||||
|
||||
Reference in New Issue
Block a user