Part: Circle variable name change to create consistency

Change variable names of the Circle from Angle0 to Angle1 to create consistency with all other named angle variables
This commit is contained in:
wmayer
2022-02-11 18:28:58 +01:00
parent 04bff76f1c
commit 29b940fb66
7 changed files with 68 additions and 38 deletions

View File

@@ -358,8 +358,8 @@ class Arc(gui_base_original.Creator):
_cmd += 'addObject("Part::Circle", "Circle")'
_cmd_list = ['circle = ' + _cmd,
'circle.Radius = ' + str(self.rad),
'circle.Angle0 = ' + str(sta),
'circle.Angle1 = ' + str(end),
'circle.Angle1 = ' + str(sta),
'circle.Angle2 = ' + str(end),
'pl = FreeCAD.Placement()',
'pl.Rotation.Q = ' + rot,
'pl.Base = ' + _base,

View File

@@ -42,10 +42,10 @@ PROPERTY_SOURCE(Part::Circle, Part::Primitive)
Circle::Circle()
{
ADD_PROPERTY(Radius,(2.0f));
ADD_PROPERTY(Angle0,(0.0f));
Angle0.setConstraints(&angleRange);
ADD_PROPERTY(Angle1,(360.0f));
ADD_PROPERTY(Angle1,(0.0f));
Angle1.setConstraints(&angleRange);
ADD_PROPERTY(Angle2,(360.0f));
Angle2.setConstraints(&angleRange);
}
Circle::~Circle()
@@ -54,8 +54,8 @@ Circle::~Circle()
short Circle::mustExecute() const
{
if (Angle0.isTouched() ||
Angle1.isTouched() ||
if (Angle1.isTouched() ||
Angle2.isTouched() ||
Radius.isTouched())
return 1;
return Part::Feature::mustExecute();
@@ -66,8 +66,8 @@ App::DocumentObjectExecReturn *Circle::execute(void)
gp_Circ circle;
circle.SetRadius(this->Radius.getValue());
BRepBuilderAPI_MakeEdge clMakeEdge(circle, Base::toRadians<double>(this->Angle0.getValue()),
Base::toRadians<double>(this->Angle1.getValue()));
BRepBuilderAPI_MakeEdge clMakeEdge(circle, Base::toRadians<double>(this->Angle1.getValue()),
Base::toRadians<double>(this->Angle2.getValue()));
const TopoDS_Edge& edge = clMakeEdge.Edge();
this->Shape.setValue(edge);
return Primitive::execute();
@@ -76,7 +76,7 @@ App::DocumentObjectExecReturn *Circle::execute(void)
void Circle::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
if (prop == &Radius || prop == &Angle0 || prop == &Angle1){
if (prop == &Radius || prop == &Angle1 || prop == &Angle2){
try {
App::DocumentObjectExecReturn *ret = recompute();
delete ret;
@@ -87,3 +87,28 @@ void Circle::onChanged(const App::Property* prop)
}
Part::Feature::onChanged(prop);
}
void Circle::Restore(Base::XMLReader &reader)
{
Base::ObjectStatusLocker<App::Property::Status, App::Property> lock(App::Property::User1, &Angle2, false);
Primitive::Restore(reader);
if (Angle2.testStatus(App::Property::User1)) {
double tmp = Angle1.getValue();
Angle1.setValue(Angle2.getValue());
Angle2.setValue(tmp);
}
}
void Circle::handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName)
{
Base::Type type = Base::Type::fromName(TypeName);
if (Angle2.getTypeId() == type && strcmp(PropName, "Angle0") == 0) {
Angle2.Restore(reader);
// set the flag to swap Angle1/Angle2 afterwards
Angle2.setStatus(App::Property::User1, true);
}
else {
Primitive::handleChangedPropertyName(reader, TypeName, PropName);
}
}

View File

@@ -38,8 +38,8 @@ public:
virtual ~Circle();
App::PropertyLength Radius;
App::PropertyAngle Angle0;
App::PropertyAngle Angle1;
App::PropertyAngle Angle2;
/** @name methods override feature */
//@{
@@ -52,6 +52,10 @@ public:
return "PartGui::ViewProviderCircleParametric";
}
protected:
void Restore(Base::XMLReader &reader);
void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName);
private:
static App::PropertyQuantityConstraint::Constraints angleRange;
//@}

View File

@@ -33,8 +33,9 @@
#include <TopoDS_Face.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
class gp_Dir;
#include <Mod/Part/PartGlobal.h>
class gp_Dir;
class BRepBuilderAPI_MakeShape;
namespace Part

View File

@@ -185,8 +185,8 @@ public:
return QString::fromLatin1(
"App.ActiveDocument.addObject(\"Part::Circle\",\"%1\")\n"
"App.ActiveDocument.%1.Radius=%2\n"
"App.ActiveDocument.%1.Angle0=%3\n"
"App.ActiveDocument.%1.Angle1=%4\n"
"App.ActiveDocument.%1.Angle1=%3\n"
"App.ActiveDocument.%1.Angle2=%4\n"
"App.ActiveDocument.%1.Placement=%5\n")
.arg(name)
.arg(circle->Radius(),0,'g',Base::UnitsApi::getDecimals())
@@ -279,8 +279,8 @@ DlgPrimitives::DlgPrimitives(QWidget* parent, Part::Primitive* feature)
ui->helixAngle->setRange(-90, 90);
// circle
ui->circleRadius->setRange(0, INT_MAX);
ui->circleAngle0->setRange(0, 360);
ui->circleAngle1->setRange(0, 360);
ui->circleAngle2->setRange(0, 360);
// ellipse
ui->ellipseMajorRadius->setRange(0, INT_MAX);
ui->ellipseMinorRadius->setRange(0, INT_MAX);
@@ -563,16 +563,16 @@ DlgPrimitives::DlgPrimitives(QWidget* parent, Part::Primitive* feature)
Part::Circle* circle = static_cast<Part::Circle*>(feature);
ui->circleRadius->setValue(circle->Radius.getQuantityValue());
ui->circleRadius->bind(circle->Radius);
ui->circleAngle0->setValue(circle->Angle0.getQuantityValue());
ui->circleAngle0->bind(circle->Angle0);
ui->circleAngle1->setValue(circle->Angle1.getQuantityValue());
ui->circleAngle1->bind(circle->Angle1);
ui->circleAngle2->setValue(circle->Angle2.getQuantityValue());
ui->circleAngle2->bind(circle->Angle2);
QSignalMapper* mapper = new QSignalMapper(this);
connect(mapper, SIGNAL(mapped(QWidget*)), this, SLOT(onChangeCircle(QWidget*)));
connectSignalMapper(ui->circleRadius, SIGNAL(valueChanged(double)), mapper);
connectSignalMapper(ui->circleAngle0, SIGNAL(valueChanged(double)), mapper);
connectSignalMapper(ui->circleAngle1, SIGNAL(valueChanged(double)), mapper);
connectSignalMapper(ui->circleAngle2, SIGNAL(valueChanged(double)), mapper);
}
else if (type == Part::Ellipse::getClassTypeId()) {
Part::Ellipse* ell = static_cast<Part::Ellipse*>(feature);
@@ -957,14 +957,14 @@ QString DlgPrimitives::createCircle(const QString& objectName, const QString& pl
return QString::fromLatin1(
"App.ActiveDocument.addObject(\"Part::Circle\",\"%1\")\n"
"App.ActiveDocument.%1.Radius=%2\n"
"App.ActiveDocument.%1.Angle0=%3\n"
"App.ActiveDocument.%1.Angle1=%4\n"
"App.ActiveDocument.%1.Angle1=%3\n"
"App.ActiveDocument.%1.Angle2=%4\n"
"App.ActiveDocument.%1.Placement=%5\n"
"App.ActiveDocument.%1.Label='%6'\n")
.arg(objectName)
.arg(Base::UnitsApi::toNumber(ui->circleRadius->value()))
.arg(Base::UnitsApi::toNumber(ui->circleAngle0->value()))
.arg(Base::UnitsApi::toNumber(ui->circleAngle1->value()))
.arg(Base::UnitsApi::toNumber(ui->circleAngle2->value()))
.arg(placement)
.arg(tr("Circle"));
}
@@ -1325,13 +1325,13 @@ QString DlgPrimitives::changeCircle(const QString& objectName, const QString& pl
{
return QString::fromLatin1(
"%1.Radius=%2\n"
"%1.Angle0=%3\n"
"%1.Angle1=%4\n"
"%1.Angle1=%3\n"
"%1.Angle2=%4\n"
"%1.Placement=%5\n")
.arg(objectName)
.arg(Base::UnitsApi::toNumber(ui->circleRadius->value()))
.arg(Base::UnitsApi::toNumber(ui->circleAngle0->value()))
.arg(Base::UnitsApi::toNumber(ui->circleAngle1->value()))
.arg(Base::UnitsApi::toNumber(ui->circleAngle2->value()))
.arg(placement);
}
@@ -1736,12 +1736,12 @@ void DlgPrimitives::onChangeCircle(QWidget* widget)
if (widget == ui->circleRadius) {
circle->Radius.setValue(ui->circleRadius->value().getValue());
}
else if (widget == ui->circleAngle0) {
circle->Angle0.setValue(ui->circleAngle0->value().getValue());
}
else if (widget == ui->circleAngle1) {
circle->Angle1.setValue(ui->circleAngle1->value().getValue());
}
else if (widget == ui->circleAngle2) {
circle->Angle2.setValue(ui->circleAngle2->value().getValue());
}
circle->recomputeFeature();
}

View File

@@ -1972,21 +1972,21 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="Angle0">
<widget class="QLabel" name="Angle1">
<property name="text">
<string>Angle 1:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="Angle1">
<widget class="QLabel" name="Angle2">
<property name="text">
<string>Angle 2:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="circleAngle0">
<widget class="Gui::QuantitySpinBox" name="circleAngle1">
<property name="keyboardTracking">
<bool>false</bool>
</property>
@@ -1996,7 +1996,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="circleAngle1">
<widget class="Gui::QuantitySpinBox" name="circleAngle2">
<property name="keyboardTracking">
<bool>false</bool>
</property>
@@ -2538,8 +2538,8 @@
<tabstop>spiralRotation</tabstop>
<tabstop>spiralRadius</tabstop>
<tabstop>circleRadius</tabstop>
<tabstop>circleAngle0</tabstop>
<tabstop>circleAngle1</tabstop>
<tabstop>circleAngle2</tabstop>
<tabstop>buttonCircleFromThreePoints</tabstop>
<tabstop>ellipseMajorRadius</tabstop>
<tabstop>ellipseMinorRadius</tabstop>

View File

@@ -1820,14 +1820,14 @@ If zero, it is equal to Radius2</string>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="Angle0">
<widget class="QLabel" name="Angle1">
<property name="text">
<string>Angle 1:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="circleAngle0">
<widget class="Gui::QuantitySpinBox" name="circleAngle1">
<property name="keyboardTracking">
<bool>false</bool>
</property>
@@ -1837,14 +1837,14 @@ If zero, it is equal to Radius2</string>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="Angle1">
<widget class="QLabel" name="Angle2">
<property name="text">
<string>Angle 2:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="circleAngle1">
<widget class="Gui::QuantitySpinBox" name="circleAngle2">
<property name="keyboardTracking">
<bool>false</bool>
</property>
@@ -1949,7 +1949,7 @@ If zero, it is equal to Radius2</string>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="ellipseAngle0">
<widget class="Gui::QuantitySpinBox" name="ellipseAngle1">
<property name="keyboardTracking">
<bool>false</bool>
</property>
@@ -1966,7 +1966,7 @@ If zero, it is equal to Radius2</string>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="ellipseAngle1">
<widget class="Gui::QuantitySpinBox" name="ellipseAngle2">
<property name="keyboardTracking">
<bool>false</bool>
</property>