diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index e5b7fa494..f80498d4a 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -133,20 +133,20 @@ double Constraint::getValue() const return Value; } -double Constraint::getPresentationValue() const +Quantity Constraint::getPresentationValue() const { switch (Type) { case Distance: case Radius: - return Value; + return Quantity(Value, Unit::Length); case DistanceX: case DistanceY: if (FirstPos == Sketcher::none || Second != Sketcher::Constraint::GeoUndef) - return Value; + return Quantity(Value, Unit::Length); else - return Value; + return Quantity(Value, Unit::Length); case Angle: - return Base::toDegrees(Value); + return Quantity(toDegrees(Value), Unit::Angle); case SnellsLaw: return Value; default: diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index 90f18b9f6..e4492adb4 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -26,6 +26,7 @@ #include +#include #include #include @@ -89,7 +90,7 @@ public: virtual PyObject *getPyObject(void); void setValue(double newValue); - double getPresentationValue() const; + Base::Quantity getPresentationValue() const; double getValue() const; friend class Sketch; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index c6f09e7e1..b55ff5faf 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -123,22 +123,14 @@ public: case Sketcher::Symmetric: break; case Sketcher::Distance: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(constraint->getPresentationValue(),Base::Unit::Length).getUserString()); - break; case Sketcher::DistanceX: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(constraint->getPresentationValue(),Base::Unit::Length).getUserString()); - break; case Sketcher::DistanceY: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(constraint->getPresentationValue(),Base::Unit::Length).getUserString()); - break; case Sketcher::Radius: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(constraint->getPresentationValue(),Base::Unit::Length).getUserString()); - break; case Sketcher::Angle: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(constraint->getPresentationValue(),Base::Unit::Angle).getUserString()); + name = QString::fromLatin1("%1 (%2)").arg(name).arg(constraint->getPresentationValue().getUserString()); break; case Sketcher::SnellsLaw: { - double v = constraint->getPresentationValue(); + double v = constraint->getPresentationValue().getValue(); double n1 = 1.0; double n2 = 1.0; if (fabs(v) >= 1) { diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 731b76f5d..e1941ff46 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3526,7 +3526,7 @@ Restart: break; SoDatumLabel *asciiText = dynamic_cast(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_MATERIAL_OR_DATUMLABEL)); - asciiText->string = SbString(Base::Quantity(Constr->getPresentationValue(),Base::Unit::Length).getUserString().toUtf8().constData()); + asciiText->string = SbString(Constr->getPresentationValue().getUserString().toUtf8().constData()); if (Constr->Type == Distance) asciiText->datumtype = SoDatumLabel::DISTANCE; @@ -3825,7 +3825,7 @@ Restart: break; SoDatumLabel *asciiText = dynamic_cast(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_MATERIAL_OR_DATUMLABEL)); - asciiText->string = SbString(Base::Quantity(Constr->getPresentationValue(),Base::Unit::Angle).getUserString().toUtf8().constData()); + asciiText->string = SbString(Constr->getPresentationValue().getUserString().toUtf8().constData()); asciiText->datumtype = SoDatumLabel::ANGLE; asciiText->param1 = Constr->LabelDistance; asciiText->param2 = startangle; @@ -3879,7 +3879,7 @@ Restart: SbVec3f p2(pnt2.x,pnt2.y,zConstr); SoDatumLabel *asciiText = dynamic_cast(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_MATERIAL_OR_DATUMLABEL)); - asciiText->string = SbString(Base::Quantity(Constr->getPresentationValue(),Base::Unit::Length).getUserString().toUtf8().constData()); + asciiText->string = SbString(Constr->getPresentationValue().getUserString().toUtf8().constData()); asciiText->datumtype = SoDatumLabel::RADIUS; asciiText->param1 = Constr->LabelDistance;