Techdraw: Smart Dimension: Fixes and simplifies code

This commit is contained in:
PaddleStroke
2024-04-22 16:59:55 +02:00
parent 41650a78d4
commit cc393632e1
12 changed files with 306 additions and 219 deletions

View File

@@ -91,9 +91,6 @@ std::string DimensionFormatter::formatValue(const qreal value,
QString qMultiValueStr;
QString qBasicUnit = Base::Tools::fromStdString(Base::UnitsApi::getBasicLengthUnit());
if (areaMeasure) {
qBasicUnit = qBasicUnit + QString::fromUtf8("²");
}
QString formattedValue;
if (isMultiValueSchema() && partial == 0) {
@@ -138,6 +135,10 @@ std::string DimensionFormatter::formatValue(const qreal value,
else {
double convertValue = Base::Quantity::parse(QString::fromLatin1("1") + qBasicUnit).getValue();
userVal = asQuantity.getValue() / convertValue;
if (areaMeasure) {
userVal = userVal / convertValue; // divide again as area is length²
qBasicUnit = qBasicUnit + QString::fromUtf8("²");
}
}
if (isTooSmall(userVal, formatSpecifier)) {

View File

@@ -265,15 +265,7 @@ Part::TopoShape ReferenceEntry::asTopoShapeEdge(const TopoDS_Edge &edge)
Part::TopoShape ReferenceEntry::asTopoShapeFace(const TopoDS_Face &face)
{
// Base::Console().Message("RE::asTopoShapeFace()\n");
TopoDS_Face unscaledFace = face;
if (!is3d()) {
// 2d reference - projected and scaled. scale might have changed, so we need to unscale
auto dvp = static_cast<TechDraw::DrawViewPart*>(getObject());
TopoDS_Shape unscaledShape = ShapeUtils::scaleShape(face, 1.0 / dvp->getScale());
unscaledFace = TopoDS::Face(unscaledShape);
}
return { unscaledFace };
return { face };
}
std::string ReferenceEntry::geomType() const