From b68ae65f5607f5d910584dfb61d8c67b1b94addd Mon Sep 17 00:00:00 2001 From: Eivind Kvedalen Date: Mon, 5 Oct 2015 00:02:41 +0200 Subject: [PATCH] Sketcher: Fixed keeping sign of constraints. --- src/Mod/Sketcher/App/Constraint.cpp | 5 +++++ src/Mod/Sketcher/App/Constraint.h | 2 ++ src/Mod/Sketcher/App/PropertyConstraintList.cpp | 2 +- src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp | 12 ++++++------ src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 8 ++++---- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 7dbc2a173..1fd90f435 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -108,6 +108,11 @@ void Constraint::setValue(double newValue) } double Constraint::getValue() const +{ + return Value; +} + +double Constraint::getPresentationValue() const { switch (Type) { case Distance: diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index 26673cb74..11102e7f8 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -83,6 +83,7 @@ public: virtual PyObject *getPyObject(void); void setValue(double newValue); + double getPresentationValue() const; double getValue() const; friend class Sketch; @@ -103,6 +104,7 @@ public: float LabelDistance; float LabelPosition; bool isDriving; + protected: boost::uuids::uuid tag; }; diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.cpp b/src/Mod/Sketcher/App/PropertyConstraintList.cpp index e7790fc2b..0743e6796 100644 --- a/src/Mod/Sketcher/App/PropertyConstraintList.cpp +++ b/src/Mod/Sketcher/App/PropertyConstraintList.cpp @@ -466,7 +466,7 @@ const Constraint * PropertyConstraintList::getConstraint(const ObjectIdentifier const boost::any PropertyConstraintList::getPathValue(const ObjectIdentifier &path) const { - return boost::any(getConstraint(path)->getValue()); + return boost::any(getConstraint(path)->getPresentationValue()); } const ObjectIdentifier PropertyConstraintList::canonicalPath(const ObjectIdentifier &p) const diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index 684071967..290c31230 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -123,22 +123,22 @@ public: case Sketcher::Symmetric: break; case Sketcher::Distance: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(constraint->getValue(),Base::Unit::Length).getUserString()); + 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(std::abs(constraint->getValue()),Base::Unit::Length).getUserString()); + name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(std::abs(constraint->getPresentationValue()),Base::Unit::Length).getUserString()); break; case Sketcher::DistanceY: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(std::abs(constraint->getValue()),Base::Unit::Length).getUserString()); + name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(std::abs(constraint->getPresentationValue()),Base::Unit::Length).getUserString()); break; case Sketcher::Radius: - name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(constraint->getValue(),Base::Unit::Length).getUserString()); + 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(Base::toDegrees(std::abs(constraint->getValue())),Base::Unit::Angle).getUserString()); + name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(Base::toDegrees(std::abs(constraint->getPresentationValue())),Base::Unit::Angle).getUserString()); break; case Sketcher::SnellsLaw: { - double v = constraint->getValue(); + double v = constraint->getPresentationValue(); 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 225f1fb17..d56be3bf3 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3524,9 +3524,9 @@ Restart: if ((Constr->Type == DistanceX || Constr->Type == DistanceY) && Constr->FirstPos != Sketcher::none && Constr->Second == Constraint::GeoUndef) // display negative sign for absolute coordinates - asciiText->string = SbString(Base::Quantity(Constr->getValue(),Base::Unit::Length).getUserString().toUtf8().constData()); + asciiText->string = SbString(Base::Quantity(Constr->getPresentationValue(),Base::Unit::Length).getUserString().toUtf8().constData()); else // hide negative sign - asciiText->string = SbString(Base::Quantity(std::abs(Constr->getValue()),Base::Unit::Length).getUserString().toUtf8().constData()); + asciiText->string = SbString(Base::Quantity(std::abs(Constr->getPresentationValue()),Base::Unit::Length).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(Base::toDegrees(std::abs(Constr->getValue())),Base::Unit::Angle).getUserString().toUtf8().constData()); + asciiText->string = SbString(Base::Quantity(Base::toDegrees(std::abs(Constr->getPresentationValue())),Base::Unit::Angle).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->getValue(),Base::Unit::Length).getUserString().toUtf8().constData()); + asciiText->string = SbString(Base::Quantity(Constr->getPresentationValue(),Base::Unit::Length).getUserString().toUtf8().constData()); asciiText->datumtype = SoDatumLabel::RADIUS; asciiText->param1 = Constr->LabelDistance;