Sketcher: Added support for expressions.
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "ConstraintPy.h"
|
||||
@@ -42,10 +42,10 @@ TYPESYSTEM_SOURCE(Sketcher::Constraint, Base::Persistence)
|
||||
const int Constraint::GeoUndef = -2000;
|
||||
|
||||
Constraint::Constraint()
|
||||
: Type(None),
|
||||
: Value(0.0),
|
||||
Type(None),
|
||||
AlignmentType(Undef),
|
||||
Name(""),
|
||||
Value(0.0),
|
||||
First(GeoUndef),
|
||||
FirstPos(none),
|
||||
Second(GeoUndef),
|
||||
@@ -56,13 +56,24 @@ Constraint::Constraint()
|
||||
LabelPosition(0.f),
|
||||
isDriving(true)
|
||||
{
|
||||
// Initialize a random number generator, to avoid Valgrind false positives.
|
||||
static boost::mt19937 ran;
|
||||
static bool seeded = false;
|
||||
|
||||
if (!seeded) {
|
||||
ran.seed(QDateTime::currentMSecsSinceEpoch() & 0xffffffff);
|
||||
seeded = true;
|
||||
}
|
||||
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
|
||||
|
||||
tag = gen();
|
||||
}
|
||||
|
||||
Constraint::Constraint(const Constraint& from)
|
||||
: Type(from.Type),
|
||||
: Value(from.Value),
|
||||
Type(from.Type),
|
||||
AlignmentType(from.AlignmentType),
|
||||
Name(from.Name),
|
||||
Value(from.Value),
|
||||
First(from.First),
|
||||
FirstPos(from.FirstPos),
|
||||
Second(from.Second),
|
||||
@@ -71,7 +82,8 @@ Constraint::Constraint(const Constraint& from)
|
||||
ThirdPos(from.ThirdPos),
|
||||
LabelDistance(from.LabelDistance),
|
||||
LabelPosition(from.LabelPosition),
|
||||
isDriving(from.isDriving)
|
||||
isDriving(from.isDriving),
|
||||
tag(from.tag)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -89,6 +101,31 @@ PyObject *Constraint::getPyObject(void)
|
||||
return new ConstraintPy(new Constraint(*this));
|
||||
}
|
||||
|
||||
void Constraint::setValue(double newValue)
|
||||
{
|
||||
Value = newValue;
|
||||
}
|
||||
|
||||
double Constraint::getValue() const
|
||||
{
|
||||
switch (Type) {
|
||||
case Distance:
|
||||
case Radius:
|
||||
return std::abs(Value);
|
||||
case DistanceX:
|
||||
case DistanceY:
|
||||
if (FirstPos == Sketcher::none || Second != Sketcher::Constraint::GeoUndef)
|
||||
return std::abs(Value);
|
||||
else
|
||||
return Value;
|
||||
case Angle:
|
||||
case SnellsLaw:
|
||||
return Value;
|
||||
default:
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Constraint::getMemSize (void) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user