Sketcher: App - Clang-format
This commit is contained in:
committed by
abdullahtahiriyo
parent
c33cdcd68a
commit
987b4bda2a
@@ -22,13 +22,13 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <QDateTime>
|
||||
#include <QDateTime>
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Writer.h>
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "ConstraintPy.h"
|
||||
@@ -41,21 +41,21 @@ using namespace Base;
|
||||
TYPESYSTEM_SOURCE(Sketcher::Constraint, Base::Persistence)
|
||||
|
||||
Constraint::Constraint()
|
||||
: Value(0.0),
|
||||
Type(None),
|
||||
AlignmentType(Undef),
|
||||
First(GeoEnum::GeoUndef),
|
||||
FirstPos(PointPos::none),
|
||||
Second(GeoEnum::GeoUndef),
|
||||
SecondPos(PointPos::none),
|
||||
Third(GeoEnum::GeoUndef),
|
||||
ThirdPos(PointPos::none),
|
||||
LabelDistance(10.f),
|
||||
LabelPosition(0.f),
|
||||
isDriving(true),
|
||||
InternalAlignmentIndex(-1),
|
||||
isInVirtualSpace(false),
|
||||
isActive(true)
|
||||
: Value(0.0),
|
||||
Type(None),
|
||||
AlignmentType(Undef),
|
||||
First(GeoEnum::GeoUndef),
|
||||
FirstPos(PointPos::none),
|
||||
Second(GeoEnum::GeoUndef),
|
||||
SecondPos(PointPos::none),
|
||||
Third(GeoEnum::GeoUndef),
|
||||
ThirdPos(PointPos::none),
|
||||
LabelDistance(10.f),
|
||||
LabelPosition(0.f),
|
||||
isDriving(true),
|
||||
InternalAlignmentIndex(-1),
|
||||
isInVirtualSpace(false),
|
||||
isActive(true)
|
||||
{
|
||||
// Initialize a random number generator, to avoid Valgrind false positives.
|
||||
static boost::mt19937 ran;
|
||||
@@ -70,14 +70,14 @@ Constraint::Constraint()
|
||||
tag = gen();
|
||||
}
|
||||
|
||||
Constraint *Constraint::clone() const
|
||||
Constraint* Constraint::clone() const
|
||||
{
|
||||
return new Constraint(*this);
|
||||
}
|
||||
|
||||
Constraint *Constraint::copy() const
|
||||
Constraint* Constraint::copy() const
|
||||
{
|
||||
Constraint *temp = new Constraint();
|
||||
Constraint* temp = new Constraint();
|
||||
temp->Value = this->Value;
|
||||
temp->Type = this->Type;
|
||||
temp->AlignmentType = this->AlignmentType;
|
||||
@@ -98,7 +98,7 @@ Constraint *Constraint::copy() const
|
||||
return temp;
|
||||
}
|
||||
|
||||
PyObject *Constraint::getPyObject()
|
||||
PyObject* Constraint::getPyObject()
|
||||
{
|
||||
return new ConstraintPy(new Constraint(*this));
|
||||
}
|
||||
@@ -107,80 +107,79 @@ Quantity Constraint::getPresentationValue() const
|
||||
{
|
||||
Quantity quantity;
|
||||
switch (Type) {
|
||||
case Distance:
|
||||
case Radius:
|
||||
case Diameter:
|
||||
case DistanceX:
|
||||
case DistanceY:
|
||||
quantity.setValue(Value);
|
||||
quantity.setUnit(Unit::Length);
|
||||
break;
|
||||
case Angle:
|
||||
quantity.setValue(toDegrees<double>(Value));
|
||||
quantity.setUnit(Unit::Angle);
|
||||
break;
|
||||
case SnellsLaw:
|
||||
case Weight:
|
||||
quantity.setValue(Value);
|
||||
break;
|
||||
default:
|
||||
quantity.setValue(Value);
|
||||
break;
|
||||
case Distance:
|
||||
case Radius:
|
||||
case Diameter:
|
||||
case DistanceX:
|
||||
case DistanceY:
|
||||
quantity.setValue(Value);
|
||||
quantity.setUnit(Unit::Length);
|
||||
break;
|
||||
case Angle:
|
||||
quantity.setValue(toDegrees<double>(Value));
|
||||
quantity.setUnit(Unit::Angle);
|
||||
break;
|
||||
case SnellsLaw:
|
||||
case Weight:
|
||||
quantity.setValue(Value);
|
||||
break;
|
||||
default:
|
||||
quantity.setValue(Value);
|
||||
break;
|
||||
}
|
||||
|
||||
QuantityFormat format = quantity.getFormat();
|
||||
format.option = QuantityFormat::None;
|
||||
format.format = QuantityFormat::Default;
|
||||
format.precision = 6; // QString's default
|
||||
format.precision = 6;// QString's default
|
||||
quantity.setFormat(format);
|
||||
return quantity;
|
||||
}
|
||||
|
||||
unsigned int Constraint::getMemSize () const
|
||||
unsigned int Constraint::getMemSize() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Constraint::Save (Writer &writer) const
|
||||
void Constraint::Save(Writer& writer) const
|
||||
{
|
||||
std::string encodeName = encodeAttribute(Name);
|
||||
writer.Stream() << writer.ind() << "<Constrain "
|
||||
<< "Name=\"" << encodeName << "\" "
|
||||
<< "Type=\"" << (int)Type << "\" ";
|
||||
if(this->Type==InternalAlignment)
|
||||
writer.Stream()
|
||||
<< "InternalAlignmentType=\"" << (int)AlignmentType << "\" "
|
||||
<< "InternalAlignmentIndex=\"" << InternalAlignmentIndex << "\" ";
|
||||
writer.Stream()
|
||||
<< "Value=\"" << Value << "\" "
|
||||
<< "First=\"" << First << "\" "
|
||||
<< "FirstPos=\"" << (int) FirstPos << "\" "
|
||||
<< "Second=\"" << Second << "\" "
|
||||
<< "SecondPos=\"" << (int) SecondPos << "\" "
|
||||
<< "Third=\"" << Third << "\" "
|
||||
<< "ThirdPos=\"" << (int) ThirdPos << "\" "
|
||||
<< "LabelDistance=\"" << LabelDistance << "\" "
|
||||
<< "LabelPosition=\"" << LabelPosition << "\" "
|
||||
<< "IsDriving=\"" << (int)isDriving << "\" "
|
||||
<< "IsInVirtualSpace=\"" << (int)isInVirtualSpace << "\" "
|
||||
<< "IsActive=\"" << (int)isActive << "\" />"
|
||||
writer.Stream() << writer.ind() << "<Constrain "
|
||||
<< "Name=\"" << encodeName << "\" "
|
||||
<< "Type=\"" << (int)Type << "\" ";
|
||||
if (this->Type == InternalAlignment)
|
||||
writer.Stream() << "InternalAlignmentType=\"" << (int)AlignmentType << "\" "
|
||||
<< "InternalAlignmentIndex=\"" << InternalAlignmentIndex << "\" ";
|
||||
writer.Stream() << "Value=\"" << Value << "\" "
|
||||
<< "First=\"" << First << "\" "
|
||||
<< "FirstPos=\"" << (int)FirstPos << "\" "
|
||||
<< "Second=\"" << Second << "\" "
|
||||
<< "SecondPos=\"" << (int)SecondPos << "\" "
|
||||
<< "Third=\"" << Third << "\" "
|
||||
<< "ThirdPos=\"" << (int)ThirdPos << "\" "
|
||||
<< "LabelDistance=\"" << LabelDistance << "\" "
|
||||
<< "LabelPosition=\"" << LabelPosition << "\" "
|
||||
<< "IsDriving=\"" << (int)isDriving << "\" "
|
||||
<< "IsInVirtualSpace=\"" << (int)isInVirtualSpace << "\" "
|
||||
<< "IsActive=\"" << (int)isActive << "\" />"
|
||||
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void Constraint::Restore(XMLReader &reader)
|
||||
void Constraint::Restore(XMLReader& reader)
|
||||
{
|
||||
reader.readElement("Constrain");
|
||||
Name = reader.getAttribute("Name");
|
||||
Type = static_cast<ConstraintType>(reader.getAttributeAsInteger("Type"));
|
||||
Value = reader.getAttributeAsFloat("Value");
|
||||
First = reader.getAttributeAsInteger("First");
|
||||
FirstPos = static_cast<PointPos>(reader.getAttributeAsInteger("FirstPos"));
|
||||
Second = reader.getAttributeAsInteger("Second");
|
||||
Name = reader.getAttribute("Name");
|
||||
Type = static_cast<ConstraintType>(reader.getAttributeAsInteger("Type"));
|
||||
Value = reader.getAttributeAsFloat("Value");
|
||||
First = reader.getAttributeAsInteger("First");
|
||||
FirstPos = static_cast<PointPos>(reader.getAttributeAsInteger("FirstPos"));
|
||||
Second = reader.getAttributeAsInteger("Second");
|
||||
SecondPos = static_cast<PointPos>(reader.getAttributeAsInteger("SecondPos"));
|
||||
|
||||
if(this->Type==InternalAlignment) {
|
||||
AlignmentType = static_cast<InternalAlignmentType>(reader.getAttributeAsInteger("InternalAlignmentType"));
|
||||
if (this->Type == InternalAlignment) {
|
||||
AlignmentType = static_cast<InternalAlignmentType>(
|
||||
reader.getAttributeAsInteger("InternalAlignmentType"));
|
||||
|
||||
if (reader.hasAttribute("InternalAlignmentIndex"))
|
||||
InternalAlignmentIndex = reader.getAttributeAsInteger("InternalAlignmentIndex");
|
||||
@@ -191,7 +190,7 @@ void Constraint::Restore(XMLReader &reader)
|
||||
|
||||
// read the third geo group if present
|
||||
if (reader.hasAttribute("Third")) {
|
||||
Third = reader.getAttributeAsInteger("Third");
|
||||
Third = reader.getAttributeAsInteger("Third");
|
||||
ThirdPos = static_cast<PointPos>(reader.getAttributeAsInteger("ThirdPos"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user