Sketcher: Fixed keeping sign of constraints.
This commit is contained in:
parent
f53a691bba
commit
b68ae65f56
|
@ -108,6 +108,11 @@ void Constraint::setValue(double newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
double Constraint::getValue() const
|
double Constraint::getValue() const
|
||||||
|
{
|
||||||
|
return Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Constraint::getPresentationValue() const
|
||||||
{
|
{
|
||||||
switch (Type) {
|
switch (Type) {
|
||||||
case Distance:
|
case Distance:
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
virtual PyObject *getPyObject(void);
|
virtual PyObject *getPyObject(void);
|
||||||
|
|
||||||
void setValue(double newValue);
|
void setValue(double newValue);
|
||||||
|
double getPresentationValue() const;
|
||||||
double getValue() const;
|
double getValue() const;
|
||||||
|
|
||||||
friend class Sketch;
|
friend class Sketch;
|
||||||
|
@ -103,6 +104,7 @@ public:
|
||||||
float LabelDistance;
|
float LabelDistance;
|
||||||
float LabelPosition;
|
float LabelPosition;
|
||||||
bool isDriving;
|
bool isDriving;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
boost::uuids::uuid tag;
|
boost::uuids::uuid tag;
|
||||||
};
|
};
|
||||||
|
|
|
@ -466,7 +466,7 @@ const Constraint * PropertyConstraintList::getConstraint(const ObjectIdentifier
|
||||||
|
|
||||||
const boost::any PropertyConstraintList::getPathValue(const ObjectIdentifier &path) const
|
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
|
const ObjectIdentifier PropertyConstraintList::canonicalPath(const ObjectIdentifier &p) const
|
||||||
|
|
|
@ -123,22 +123,22 @@ public:
|
||||||
case Sketcher::Symmetric:
|
case Sketcher::Symmetric:
|
||||||
break;
|
break;
|
||||||
case Sketcher::Distance:
|
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;
|
break;
|
||||||
case Sketcher::DistanceX:
|
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;
|
break;
|
||||||
case Sketcher::DistanceY:
|
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;
|
break;
|
||||||
case Sketcher::Radius:
|
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;
|
break;
|
||||||
case Sketcher::Angle:
|
case Sketcher::Angle:
|
||||||
name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(Base::toDegrees<double>(std::abs(constraint->getValue())),Base::Unit::Angle).getUserString());
|
name = QString::fromLatin1("%1 (%2)").arg(name).arg(Base::Quantity(Base::toDegrees<double>(std::abs(constraint->getPresentationValue())),Base::Unit::Angle).getUserString());
|
||||||
break;
|
break;
|
||||||
case Sketcher::SnellsLaw: {
|
case Sketcher::SnellsLaw: {
|
||||||
double v = constraint->getValue();
|
double v = constraint->getPresentationValue();
|
||||||
double n1 = 1.0;
|
double n1 = 1.0;
|
||||||
double n2 = 1.0;
|
double n2 = 1.0;
|
||||||
if (fabs(v) >= 1) {
|
if (fabs(v) >= 1) {
|
||||||
|
|
|
@ -3524,9 +3524,9 @@ Restart:
|
||||||
if ((Constr->Type == DistanceX || Constr->Type == DistanceY) &&
|
if ((Constr->Type == DistanceX || Constr->Type == DistanceY) &&
|
||||||
Constr->FirstPos != Sketcher::none && Constr->Second == Constraint::GeoUndef)
|
Constr->FirstPos != Sketcher::none && Constr->Second == Constraint::GeoUndef)
|
||||||
// display negative sign for absolute coordinates
|
// 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
|
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)
|
if (Constr->Type == Distance)
|
||||||
asciiText->datumtype = SoDatumLabel::DISTANCE;
|
asciiText->datumtype = SoDatumLabel::DISTANCE;
|
||||||
|
@ -3825,7 +3825,7 @@ Restart:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SoDatumLabel *asciiText = dynamic_cast<SoDatumLabel *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_MATERIAL_OR_DATUMLABEL));
|
SoDatumLabel *asciiText = dynamic_cast<SoDatumLabel *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_MATERIAL_OR_DATUMLABEL));
|
||||||
asciiText->string = SbString(Base::Quantity(Base::toDegrees<double>(std::abs(Constr->getValue())),Base::Unit::Angle).getUserString().toUtf8().constData());
|
asciiText->string = SbString(Base::Quantity(Base::toDegrees<double>(std::abs(Constr->getPresentationValue())),Base::Unit::Angle).getUserString().toUtf8().constData());
|
||||||
asciiText->datumtype = SoDatumLabel::ANGLE;
|
asciiText->datumtype = SoDatumLabel::ANGLE;
|
||||||
asciiText->param1 = Constr->LabelDistance;
|
asciiText->param1 = Constr->LabelDistance;
|
||||||
asciiText->param2 = startangle;
|
asciiText->param2 = startangle;
|
||||||
|
@ -3879,7 +3879,7 @@ Restart:
|
||||||
SbVec3f p2(pnt2.x,pnt2.y,zConstr);
|
SbVec3f p2(pnt2.x,pnt2.y,zConstr);
|
||||||
|
|
||||||
SoDatumLabel *asciiText = dynamic_cast<SoDatumLabel *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_MATERIAL_OR_DATUMLABEL));
|
SoDatumLabel *asciiText = dynamic_cast<SoDatumLabel *>(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->datumtype = SoDatumLabel::RADIUS;
|
||||||
asciiText->param1 = Constr->LabelDistance;
|
asciiText->param1 = Constr->LabelDistance;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user