From 033334474ca02f75b4aa0e8b543c81ae27c08bf4 Mon Sep 17 00:00:00 2001 From: Peter Lama Date: Sat, 28 Oct 2017 10:47:26 -0700 Subject: [PATCH] Rename superPlacement property to AttachmentOffset The name Attachment Offset gives a better picture of what the property does. --- src/Mod/Part/App/AttachEnginePy.xml | 6 +- src/Mod/Part/App/AttachEnginePyImp.cpp | 12 +- src/Mod/Part/App/AttachExtension.cpp | 21 ++- src/Mod/Part/App/AttachExtension.h | 3 +- src/Mod/Part/App/Attacher.cpp | 20 +-- src/Mod/Part/App/Attacher.h | 4 +- src/Mod/Part/App/DatumFeature.cpp | 5 + src/Mod/Part/App/DatumFeature.h | 1 + src/Mod/Part/App/Part2DObject.cpp | 2 + src/Mod/Part/App/PrimitiveFeature.cpp | 3 + .../AttachmentEditor/TaskAttachmentEditor.py | 58 ++++---- .../AttachmentEditor/TaskAttachmentEditor.ui | 30 ++-- src/Mod/Part/Gui/TaskAttacher.cpp | 136 +++++++++--------- src/Mod/Part/Gui/TaskAttacher.h | 16 +-- src/Mod/Part/Gui/TaskAttacher.ui | 30 ++-- src/Mod/PartDesign/App/FeaturePrimitive.cpp | 5 + src/Mod/PartDesign/App/FeaturePrimitive.h | 1 + src/Mod/PartDesign/Gui/Utils.cpp | 2 +- .../PartDesign/PartDesignTests/TestDatum.py | 2 +- 19 files changed, 192 insertions(+), 165 deletions(-) diff --git a/src/Mod/Part/App/AttachEnginePy.xml b/src/Mod/Part/App/AttachEnginePy.xml index a1a577a329..7cac9de944 100644 --- a/src/Mod/Part/App/AttachEnginePy.xml +++ b/src/Mod/Part/App/AttachEnginePy.xml @@ -34,11 +34,11 @@ - + Current attachment mode. - + @@ -105,7 +105,7 @@ calculateAttachedPlacement(orig_placement): returns result of attachment, based -on current Mode, References, etc. SuperPlacment is included. +on current Mode, References, etc. AttachmentOffset is included. original_placement is the previous placement of the object being attached. It is used to preserve orientation for Translate attachment mode. For other modes, diff --git a/src/Mod/Part/App/AttachEnginePyImp.cpp b/src/Mod/Part/App/AttachEnginePyImp.cpp index a0a312fb79..b93571acca 100644 --- a/src/Mod/Part/App/AttachEnginePyImp.cpp +++ b/src/Mod/Part/App/AttachEnginePyImp.cpp @@ -123,21 +123,21 @@ void AttachEnginePy::setReferences(Py::Object arg) } ATTACHERPY_STDCATCH_ATTR; } -Py::Object AttachEnginePy::getSuperPlacement(void) const +Py::Object AttachEnginePy::getAttachmentOffset(void) const { try { AttachEngine &attacher = *(this->getAttachEnginePtr()); - return Py::Object(new Base::PlacementPy(new Base::Placement(attacher.superPlacement)),true); + return Py::Object(new Base::PlacementPy(new Base::Placement(attacher.attachmentOffset)),true); } ATTACHERPY_STDCATCH_ATTR; } -void AttachEnginePy::setSuperPlacement(Py::Object arg) +void AttachEnginePy::setAttachmentOffset(Py::Object arg) { try { AttachEngine &attacher = *(this->getAttachEnginePtr()); if (PyObject_TypeCheck(arg.ptr(), &(Base::PlacementPy::Type))) { const Base::PlacementPy* plmPy = static_cast(arg.ptr()); - attacher.superPlacement = *(plmPy->getPlacementPtr()); + attacher.attachmentOffset = *(plmPy->getPlacementPtr()); } else { std::string error = std::string("type must be 'Placement', not "); error += arg.type().as_string(); @@ -519,7 +519,7 @@ PyObject* AttachEnginePy::readParametersFromFeature(PyObject* args) feat->MapReversed.getValue(), feat->MapPathParameter.getValue(), 0.0,0.0, - feat->superPlacement.getValue()); + feat->AttachmentOffset.getValue()); return Py::new_reference_to(Py::None()); } ATTACHERPY_STDCATCH_METH; } @@ -543,7 +543,7 @@ PyObject* AttachEnginePy::writeParametersToFeature(PyObject* args) feat->MapMode.setValue(attacher.mapMode); feat->MapReversed.setValue(attacher.mapReverse); feat->MapPathParameter.setValue(attacher.attachParameter); - feat->superPlacement.setValue(attacher.superPlacement); + feat->AttachmentOffset.setValue(attacher.attachmentOffset); return Py::new_reference_to(Py::None()); } ATTACHERPY_STDCATCH_METH; } diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index 45edc7130d..8ca7a5fad5 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -57,12 +57,12 @@ AttachExtension::AttachExtension() EXTENSION_ADD_PROPERTY_TYPE(MapPathParameter, (0.0), "Attachment", App::Prop_None, "Sets point of curve to map the sketch to. 0..1 = start..end"); - EXTENSION_ADD_PROPERTY_TYPE(superPlacement, (Base::Placement()), "Attachment", App::Prop_None, "Extra placement to apply in addition to attachment (in local coordinates)"); + EXTENSION_ADD_PROPERTY_TYPE(AttachmentOffset, (Base::Placement()), "Attachment", App::Prop_None, "Extra placement to apply in addition to attachment (in local coordinates)"); // Only show these properties when applicable. Controlled by extensionOnChanged this->MapPathParameter.setStatus(App::Property::Status::Hidden, true); this->MapReversed.setStatus(App::Property::Status::Hidden, true); - this->superPlacement.setStatus(App::Property::Status::Hidden, true); + this->AttachmentOffset.setStatus(App::Property::Status::Hidden, true); setAttacher(new AttachEngine3D);//default attacher initExtensionType(AttachExtension::getExtensionClassTypeId()); @@ -164,7 +164,7 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) || prop == &MapMode || prop == &MapPathParameter || prop == &MapReversed - || prop == &superPlacement)){ + || prop == &AttachmentOffset)){ bool bAttached = false; try{ @@ -194,7 +194,7 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached); - this->superPlacement.setStatus(App::Property::Status::Hidden, !bAttached); + this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached); getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. } @@ -207,6 +207,15 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) App::DocumentObjectExtension::extensionOnChanged(prop); } +void AttachExtension::extHandleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName) +{ + // Was superPlacement + Base::Type type = Base::Type::fromName(TypeName); + if (AttachmentOffset.getClassTypeId() == type && strcmp(PropName, "superPlacement") == 0) { + AttachmentOffset.Restore(reader); + } +} + void AttachExtension::onExtendedDocumentRestored() { try { @@ -230,7 +239,7 @@ void AttachExtension::onExtendedDocumentRestored() this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached); - this->superPlacement.setStatus(App::Property::Status::Hidden, !bAttached); + this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached); getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. } catch (Base::Exception&) { @@ -248,7 +257,7 @@ void AttachExtension::updateAttacherVals() this->MapReversed.getValue(), this->MapPathParameter.getValue(), 0.0,0.0, - this->superPlacement.getValue()); + this->AttachmentOffset.getValue()); } App::PropertyPlacement& AttachExtension::getPlacement() { diff --git a/src/Mod/Part/App/AttachExtension.h b/src/Mod/Part/App/AttachExtension.h index 533b908541..b3cfe70923 100644 --- a/src/Mod/Part/App/AttachExtension.h +++ b/src/Mod/Part/App/AttachExtension.h @@ -82,7 +82,7 @@ public: App::PropertyLinkSubList Support; App::PropertyEnumeration MapMode; //see AttachEngine::eMapMode App::PropertyBool MapReversed; //inverts Z and X internal axes - App::PropertyPlacement superPlacement; + App::PropertyPlacement AttachmentOffset; /** * @brief MapPathParameter is a parameter value for mmNormalToPath (the @@ -107,6 +107,7 @@ public: protected: virtual void extensionOnChanged(const App::Property* /*prop*/); + virtual void extHandleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName); App::PropertyPlacement& getPlacement(); diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index d31c68b82e..f12190cbfa 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -177,7 +177,7 @@ void AttachEngine::setUp(const App::PropertyLinkSubList &references, eMapMode mapMode, bool mapReverse, double attachParameter, double surfU, double surfV, - const Base::Placement &superPlacement) + const Base::Placement &attachmentOffset) { this->references.Paste(references); this->mapMode = mapMode; @@ -185,7 +185,7 @@ void AttachEngine::setUp(const App::PropertyLinkSubList &references, this->attachParameter = attachParameter; this->surfU = surfU; this->surfV = surfV; - this->superPlacement = superPlacement; + this->attachmentOffset = attachmentOffset; } void AttachEngine::setUp(const AttachEngine &another) @@ -196,7 +196,7 @@ void AttachEngine::setUp(const AttachEngine &another) another.attachParameter, another.surfU, another.surfV, - another.superPlacement); + another.attachmentOffset); } Base::Placement AttachEngine::placementFactory(const gp_Dir &ZAxis, @@ -1017,7 +1017,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(sh)); Base::Placement plm = Base::Placement(); plm.setPosition(Base::Vector3d(p.X(), p.Y(), p.Z())); - plm.setPosition(plm.getPosition() + this->superPlacement.getPosition()); + plm.setPosition(plm.getPosition() + this->attachmentOffset.getPosition()); plm.setRotation(origPlacement.getRotation()); return plm; } break; @@ -1552,7 +1552,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP Base::Placement plm = Base::Placement(Base::Vector3d(SketchBasePoint.X(), SketchBasePoint.Y(), SketchBasePoint.Z()), rot); - plm *= this->superPlacement; + plm *= this->attachmentOffset; return plm; } break; default: @@ -1568,7 +1568,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP /*makeYVertical = */ false, /*makeLegacyFlatFaceOrientation = */ mmode == mmFlatFace, &Place); - plm *= this->superPlacement; + plm *= this->attachmentOffset; return plm; } @@ -1905,11 +1905,11 @@ Base::Placement AttachEngineLine::calculateAttachedPlacement(Base::Placement ori AttachEngine3D attacher3D; attacher3D.setUp(*this); attacher3D.mapMode = mmode; - attacher3D.superPlacement = Base::Placement(); //superplacement is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice! + attacher3D.attachmentOffset = Base::Placement(); //AttachmentOffset is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice! plm = attacher3D.calculateAttachedPlacement(origPlacement); plm *= presuperPlacement; } - plm *= this->superPlacement; + plm *= this->attachmentOffset; return plm; } @@ -2080,10 +2080,10 @@ Base::Placement AttachEnginePoint::calculateAttachedPlacement(Base::Placement or AttachEngine3D attacher3D; attacher3D.setUp(*this); attacher3D.mapMode = mmode; - attacher3D.superPlacement = Base::Placement(); //superplacement is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice! + attacher3D.attachmentOffset = Base::Placement(); //AttachmentOffset is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice! plm = attacher3D.calculateAttachedPlacement(origPlacement); } - plm *= this->superPlacement; + plm *= this->attachmentOffset; return plm; } diff --git a/src/Mod/Part/App/Attacher.h b/src/Mod/Part/App/Attacher.h index 1c66c41c5e..96f8698e83 100644 --- a/src/Mod/Part/App/Attacher.h +++ b/src/Mod/Part/App/Attacher.h @@ -222,7 +222,7 @@ public: //methods bool mapReverse = false, double attachParameter = 0.0, double surfU = 0.0, double surfV = 0.0, - const Base::Placement &superPlacement = Base::Placement()); + const Base::Placement &attachmentOffset = Base::Placement()); virtual void setUp(const AttachEngine &another); virtual AttachEngine* copy() const = 0; virtual Base::Placement calculateAttachedPlacement(Base::Placement origPlacement) const = 0; @@ -370,7 +370,7 @@ public: //members bool mapReverse; double attachParameter; double surfU, surfV; - Base::Placement superPlacement; + Base::Placement attachmentOffset; /** * @brief modeEnabled is an indicator, whether some mode is ever suggested diff --git a/src/Mod/Part/App/DatumFeature.cpp b/src/Mod/Part/App/DatumFeature.cpp index bdb62317cb..6d29603b60 100644 --- a/src/Mod/Part/App/DatumFeature.cpp +++ b/src/Mod/Part/App/DatumFeature.cpp @@ -61,3 +61,8 @@ TopoDS_Shape Datum::getShape() const Base::Vector3d Datum::getBasePoint () const { return Placement.getValue().getPosition(); } + +void Datum::handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName) +{ + extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension +} diff --git a/src/Mod/Part/App/DatumFeature.h b/src/Mod/Part/App/DatumFeature.h index aeadf38172..455f621a26 100644 --- a/src/Mod/Part/App/DatumFeature.h +++ b/src/Mod/Part/App/DatumFeature.h @@ -56,6 +56,7 @@ public: protected: void onDocumentRestored(); + void handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName); }; } //namespace Part diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index f572e97c81..cfaaa18047 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -243,6 +243,8 @@ void Part2DObject::Restore(Base::XMLReader &reader) } this->MapMode.setValue(Attacher::mmFlatFace); } + } else { + extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension } } catch (const Base::XMLParseException&) { diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index ac83b19896..ab2eeb3142 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -151,6 +151,9 @@ void Primitive::Restore(Base::XMLReader &reader) static_cast(prop)->setValue(floatProp.getValue()); } } + else { + extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension + } } catch (const Base::XMLParseException&) { throw; // re-throw diff --git a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py index 8592aed18b..8f01e13bf2 100644 --- a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py +++ b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py @@ -161,7 +161,7 @@ class AttachmentEditorTaskPanel(FrozenClass): self.block = False #when True, event handlers return without doing anything (instead of doing-undoing blockSignals to everything) self.refLines = [] #reference lineEdit widgets, packed into a list for convenience self.refButtons = [] #buttons next to reference lineEdits - self.superPlacementEdits = [] #all edit boxes related to superplacement + self.attachmentOffsetEdits = [] #all edit boxes related to attachmentOffset self.i_active_ref = -1 #index of reference being selected (-1 means no reaction to selecting) self.auto_next = False #if true, references being selected are appended ('Selecting' state is automatically advanced to next button) @@ -237,12 +237,12 @@ class AttachmentEditorTaskPanel(FrozenClass): self.form.buttonRef2, self.form.buttonRef3, self.form.buttonRef4] - self.superPlacementEdits = [self.form.superplacementX, - self.form.superplacementY, - self.form.superplacementZ, - self.form.superplacementYaw, - self.form.superplacementPitch, - self.form.superplacementRoll] + self.attachmentOffsetEdits = [self.form.attachmentOffsetX, + self.form.attachmentOffsetY, + self.form.attachmentOffsetZ, + self.form.attachmentOffsetYaw, + self.form.attachmentOffsetPitch, + self.form.attachmentOffsetRoll] self.block = False @@ -252,8 +252,8 @@ class AttachmentEditorTaskPanel(FrozenClass): for i in range(len(self.refLines)): QtCore.QObject.connect(self.refButtons[i], QtCore.SIGNAL('clicked()'), lambda i=i: self.refButtonClicked(i)) - for i in range(len(self.superPlacementEdits)): - QtCore.QObject.connect(self.superPlacementEdits[i], QtCore.SIGNAL('valueChanged(double)'), lambda val, i=i: self.superplacementChanged(i,val)) + for i in range(len(self.attachmentOffsetEdits)): + QtCore.QObject.connect(self.attachmentOffsetEdits[i], QtCore.SIGNAL('valueChanged(double)'), lambda val, i=i: self.attachmentOffsetChanged(i,val)) QtCore.QObject.connect(self.form.checkBoxFlip, QtCore.SIGNAL('clicked()'), self.checkBoxFlipClicked) @@ -362,33 +362,33 @@ class AttachmentEditorTaskPanel(FrozenClass): # slots - def superplacementChanged(self, index, value): + def attachmentOffsetChanged(self, index, value): if self.block: return - plm = self.attacher.SuperPlacement + plm = self.attacher.AttachmentOffset pos = plm.Base if index==0: - pos.x = Q(self.form.superplacementX.text()).getValueAs(mm) + pos.x = Q(self.form.attachmentOffsetX.text()).getValueAs(mm) if index==1: - pos.y = Q(self.form.superplacementY.text()).getValueAs(mm) + pos.y = Q(self.form.attachmentOffsetY.text()).getValueAs(mm) if index==2: - pos.z = Q(self.form.superplacementZ.text()).getValueAs(mm) + pos.z = Q(self.form.attachmentOffsetZ.text()).getValueAs(mm) if index >= 0 and index <= 2: plm.Base = pos rot = plm.Rotation; (yaw, pitch, roll) = rot.toEuler() if index==3: - yaw = Q(self.form.superplacementYaw.text()).getValueAs(deg) + yaw = Q(self.form.attachmentOffsetYaw.text()).getValueAs(deg) if index==4: - pitch = Q(self.form.superplacementPitch.text()).getValueAs(deg) + pitch = Q(self.form.attachmentOffsetPitch.text()).getValueAs(deg) if index==5: - roll = Q(self.form.superplacementRoll.text()).getValueAs(deg) + roll = Q(self.form.attachmentOffsetRoll.text()).getValueAs(deg) if index >= 3 and index <= 5: rot = App.Rotation(yaw,pitch,roll) plm.Rotation = rot - self.attacher.SuperPlacement = plm + self.attacher.AttachmentOffset = plm self.updatePreview() @@ -432,16 +432,16 @@ class AttachmentEditorTaskPanel(FrozenClass): if self.obj_is_attachable: self.attacher.readParametersFromFeature(self.obj) - plm = self.attacher.SuperPlacement + plm = self.attacher.AttachmentOffset try: old_selfblock = self.block self.block = True - self.form.superplacementX.setText ((plm.Base.x * mm).UserString) - self.form.superplacementY.setText ((plm.Base.y * mm).UserString) - self.form.superplacementZ.setText ((plm.Base.z * mm).UserString) - self.form.superplacementYaw.setText ((plm.Rotation.toEuler()[0] * deg).UserString) - self.form.superplacementPitch.setText((plm.Rotation.toEuler()[1] * deg).UserString) - self.form.superplacementRoll.setText ((plm.Rotation.toEuler()[2] * deg).UserString) + self.form.attachmentOffsetX.setText ((plm.Base.x * mm).UserString) + self.form.attachmentOffsetY.setText ((plm.Base.y * mm).UserString) + self.form.attachmentOffsetZ.setText ((plm.Base.z * mm).UserString) + self.form.attachmentOffsetYaw.setText ((plm.Rotation.toEuler()[0] * deg).UserString) + self.form.attachmentOffsetPitch.setText((plm.Rotation.toEuler()[1] * deg).UserString) + self.form.attachmentOffsetRoll.setText ((plm.Rotation.toEuler()[2] * deg).UserString) self.form.checkBoxFlip.setChecked(self.attacher.Reverse) @@ -592,11 +592,11 @@ class AttachmentEditorTaskPanel(FrozenClass): self.form.message.setText(_translate('AttachmentEditor',"Error: {err}",None).format(err= str(err))) if new_plm is not None: - self.form.groupBox_superplacement.setTitle(_translate('AttachmentEditor',"Extra placement:",None)) - self.form.groupBox_superplacement.setEnabled(True) + self.form.groupBox_AttachmentOffset.setTitle(_translate('AttachmentEditor',"Attachment Offset:",None)) + self.form.groupBox_AttachmentOffset.setEnabled(True) else: - self.form.groupBox_superplacement.setTitle(_translate('AttachmentEditor',"Extra placement (inactive - not attached):",None)) - self.form.groupBox_superplacement.setEnabled(False) + self.form.groupBox_AttachmentOffset.setTitle(_translate('AttachmentEditor',"Attachment Offset (inactive - not attached):",None)) + self.form.groupBox_AttachmentOffset.setEnabled(False) def cleanUp(self): '''stuff that needs to be done when dialog is closed.''' diff --git a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui index ec2d894e28..7275a38aa0 100644 --- a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui +++ b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui @@ -110,7 +110,7 @@ - + 0 @@ -118,10 +118,10 @@ - Mirror of superPlacement property. Extra placement is expressed in local space of object being attached. + AttachmentOffset property. The placement is expressed in local space of object being attached. - Extra placement: + Attachment Offset: @@ -154,7 +154,7 @@ - + 0 @@ -183,7 +183,7 @@ - + 0 @@ -238,7 +238,7 @@ - + 0 @@ -254,7 +254,7 @@ - + 0 @@ -276,7 +276,7 @@ - + 0 @@ -298,7 +298,7 @@ - + 0 @@ -355,12 +355,12 @@ buttonRef4 lineRef4 listOfModes - superplacementX - superplacementY - superplacementZ - superplacementYaw - superplacementPitch - superplacementRoll + attachmentOffsetX + attachmentOffsetY + attachmentOffsetZ + attachmentOffsetYaw + attachmentOffsetPitch + attachmentOffsetRoll checkBoxFlip diff --git a/src/Mod/Part/Gui/TaskAttacher.cpp b/src/Mod/Part/Gui/TaskAttacher.cpp index 103b3c86bd..e616dd9976 100644 --- a/src/Mod/Part/Gui/TaskAttacher.cpp +++ b/src/Mod/Part/Gui/TaskAttacher.cpp @@ -120,12 +120,12 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject *ViewProvider,QWidget ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - connect(ui->superplacementX, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementXChanged(double))); - connect(ui->superplacementY, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementYChanged(double))); - connect(ui->superplacementZ, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementZChanged(double))); - connect(ui->superplacementYaw, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementYawChanged(double))); - connect(ui->superplacementPitch, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementPitchChanged(double))); - connect(ui->superplacementRoll, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementRollChanged(double))); + connect(ui->attachmentOffsetX, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetXChanged(double))); + connect(ui->attachmentOffsetY, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetYChanged(double))); + connect(ui->attachmentOffsetZ, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetZChanged(double))); + connect(ui->attachmentOffsetYaw, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetYawChanged(double))); + connect(ui->attachmentOffsetPitch, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetPitchChanged(double))); + connect(ui->attachmentOffsetRoll, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetRollChanged(double))); connect(ui->checkBoxFlip, SIGNAL(toggled(bool)), this, SLOT(onCheckFlip(bool))); connect(ui->buttonRef1, SIGNAL(clicked(bool)), @@ -196,11 +196,11 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject *ViewProvider,QWidget autoNext = false; } - ui->superplacementX->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Base.x"))); - ui->superplacementY->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Base.y"))); - ui->superplacementZ->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Base.z"))); + ui->attachmentOffsetX->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Base.x"))); + ui->attachmentOffsetY->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Base.y"))); + ui->attachmentOffsetZ->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Base.z"))); visibilityAutomation(true); - updateSuperplacementUI(); + updateAttachmentOffsetUI(); updateReferencesUI(); updateListOfModes(); selectMapMode(eMapMode(pcAttach->MapMode.getValue())); @@ -295,9 +295,9 @@ bool TaskAttacher::updatePreview() ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: green;}")); } } - QString splmLabelText = attached ? tr("Extra placement:") : tr("Extra placement (inactive - not attached):"); - ui->groupBox_superplacement->setTitle(splmLabelText); - ui->groupBox_superplacement->setEnabled(attached); + QString splmLabelText = attached ? tr("Attachment Offset:") : tr("Attachment Offset (inactive - not attached):"); + ui->groupBox_AttachmentOffset->setTitle(splmLabelText); + ui->groupBox_AttachmentOffset->setEnabled(attached); return attached; } @@ -399,20 +399,20 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg) } } -void TaskAttacher::onSuperplacementChanged(double /*val*/, int idx) +void TaskAttacher::onAttachmentOffsetChanged(double /*val*/, int idx) { Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType(); - Base::Placement pl = pcAttach->superPlacement.getValue(); + Base::Placement pl = pcAttach->AttachmentOffset.getValue(); Base::Vector3d pos = pl.getPosition(); if (idx == 0) { - pos.x = ui->superplacementX->value().getValueAs(Base::Quantity::MilliMetre); + pos.x = ui->attachmentOffsetX->value().getValueAs(Base::Quantity::MilliMetre); } if (idx == 1) { - pos.y = ui->superplacementY->value().getValueAs(Base::Quantity::MilliMetre); + pos.y = ui->attachmentOffsetY->value().getValueAs(Base::Quantity::MilliMetre); } if (idx == 2) { - pos.z = ui->superplacementZ->value().getValueAs(Base::Quantity::MilliMetre); + pos.z = ui->attachmentOffsetZ->value().getValueAs(Base::Quantity::MilliMetre); } if (idx >= 0 && idx <= 2){ pl.setPosition(pos); @@ -422,46 +422,46 @@ void TaskAttacher::onSuperplacementChanged(double /*val*/, int idx) double yaw, pitch, roll; rot.getYawPitchRoll(yaw, pitch, roll); if (idx == 3) { - yaw = ui->superplacementYaw->value().getValueAs(Base::Quantity::Degree); + yaw = ui->attachmentOffsetYaw->value().getValueAs(Base::Quantity::Degree); } if (idx == 4) { - pitch = ui->superplacementPitch->value().getValueAs(Base::Quantity::Degree); + pitch = ui->attachmentOffsetPitch->value().getValueAs(Base::Quantity::Degree); } if (idx == 5) { - roll = ui->superplacementRoll->value().getValueAs(Base::Quantity::Degree); + roll = ui->attachmentOffsetRoll->value().getValueAs(Base::Quantity::Degree); } if (idx >= 3 && idx <= 5){ rot.setYawPitchRoll(yaw,pitch,roll); pl.setRotation(rot); } - pcAttach->superPlacement.setValue(pl); + pcAttach->AttachmentOffset.setValue(pl); updatePreview(); } -void TaskAttacher::onSuperplacementXChanged(double val) +void TaskAttacher::onAttachmentOffsetXChanged(double val) { - onSuperplacementChanged(val, 0); + onAttachmentOffsetChanged(val, 0); } -void TaskAttacher::onSuperplacementYChanged(double val) +void TaskAttacher::onAttachmentOffsetYChanged(double val) { - onSuperplacementChanged(val, 1); + onAttachmentOffsetChanged(val, 1); } -void TaskAttacher::onSuperplacementZChanged(double val) +void TaskAttacher::onAttachmentOffsetZChanged(double val) { - onSuperplacementChanged(val, 2); + onAttachmentOffsetChanged(val, 2); } -void TaskAttacher::onSuperplacementYawChanged(double val) +void TaskAttacher::onAttachmentOffsetYawChanged(double val) { - onSuperplacementChanged(val, 3); + onAttachmentOffsetChanged(val, 3); } -void TaskAttacher::onSuperplacementPitchChanged(double val) +void TaskAttacher::onAttachmentOffsetPitchChanged(double val) { - onSuperplacementChanged(val, 4); + onAttachmentOffsetChanged(val, 4); } -void TaskAttacher::onSuperplacementRollChanged(double val) +void TaskAttacher::onAttachmentOffsetRollChanged(double val) { - onSuperplacementChanged(val, 5); + onAttachmentOffsetChanged(val, 5); } void TaskAttacher::onCheckFlip(bool on) @@ -648,57 +648,57 @@ void TaskAttacher::updateRefButton(int idx) } } -void TaskAttacher::updateSuperplacementUI() +void TaskAttacher::updateAttachmentOffsetUI() { Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType(); - Base::Placement pl = pcAttach->superPlacement.getValue(); + Base::Placement pl = pcAttach->AttachmentOffset.getValue(); Base::Vector3d pos = pl.getPosition(); Base::Rotation rot = pl.getRotation(); double yaw, pitch, roll; rot.getYawPitchRoll(yaw, pitch, roll); bool bBlock = true; - ui->superplacementX->blockSignals(bBlock); - ui->superplacementY->blockSignals(bBlock); - ui->superplacementZ->blockSignals(bBlock); - ui->superplacementYaw->blockSignals(bBlock); - ui->superplacementPitch->blockSignals(bBlock); - ui->superplacementRoll->blockSignals(bBlock); + ui->attachmentOffsetX->blockSignals(bBlock); + ui->attachmentOffsetY->blockSignals(bBlock); + ui->attachmentOffsetZ->blockSignals(bBlock); + ui->attachmentOffsetYaw->blockSignals(bBlock); + ui->attachmentOffsetPitch->blockSignals(bBlock); + ui->attachmentOffsetRoll->blockSignals(bBlock); - ui->superplacementX->setValue(Base::Quantity(pos.x,Base::Unit::Length)); - ui->superplacementY->setValue(Base::Quantity(pos.y,Base::Unit::Length)); - ui->superplacementZ->setValue(Base::Quantity(pos.z,Base::Unit::Length)); - ui->superplacementYaw->setValue(yaw); - ui->superplacementPitch->setValue(pitch); - ui->superplacementRoll->setValue(roll); + ui->attachmentOffsetX->setValue(Base::Quantity(pos.x,Base::Unit::Length)); + ui->attachmentOffsetY->setValue(Base::Quantity(pos.y,Base::Unit::Length)); + ui->attachmentOffsetZ->setValue(Base::Quantity(pos.z,Base::Unit::Length)); + ui->attachmentOffsetYaw->setValue(yaw); + ui->attachmentOffsetPitch->setValue(pitch); + ui->attachmentOffsetRoll->setValue(roll); auto expressions = ViewProvider->getObject()->ExpressionEngine.getExpressions(); bool bRotationBound = false; bRotationBound = bRotationBound || - expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Angle"))) != expressions.end(); + expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Angle"))) != expressions.end(); bRotationBound = bRotationBound || - expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Axis.x"))) != expressions.end(); + expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Axis.x"))) != expressions.end(); bRotationBound = bRotationBound || - expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Axis.y"))) != expressions.end(); + expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Axis.y"))) != expressions.end(); bRotationBound = bRotationBound || - expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Axis.z"))) != expressions.end(); + expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Axis.z"))) != expressions.end(); - ui->superplacementYaw->setEnabled(!bRotationBound); - ui->superplacementPitch->setEnabled(!bRotationBound); - ui->superplacementRoll->setEnabled(!bRotationBound); + ui->attachmentOffsetYaw->setEnabled(!bRotationBound); + ui->attachmentOffsetPitch->setEnabled(!bRotationBound); + ui->attachmentOffsetRoll->setEnabled(!bRotationBound); - QString tooltip = bRotationBound ? tr("Not editable because rotation part of superplacement is bound by expressions.") : QString(); - ui->superplacementYaw->setToolTip(tooltip); - ui->superplacementPitch->setToolTip(tooltip); - ui->superplacementRoll->setToolTip(tooltip); + QString tooltip = bRotationBound ? tr("Not editable because rotation part of AttachmentOffset is bound by expressions.") : QString(); + ui->attachmentOffsetYaw->setToolTip(tooltip); + ui->attachmentOffsetPitch->setToolTip(tooltip); + ui->attachmentOffsetRoll->setToolTip(tooltip); bBlock = false; - ui->superplacementX->blockSignals(bBlock); - ui->superplacementY->blockSignals(bBlock); - ui->superplacementZ->blockSignals(bBlock); - ui->superplacementYaw->blockSignals(bBlock); - ui->superplacementPitch->blockSignals(bBlock); - ui->superplacementRoll->blockSignals(bBlock); + ui->attachmentOffsetX->blockSignals(bBlock); + ui->attachmentOffsetY->blockSignals(bBlock); + ui->attachmentOffsetZ->blockSignals(bBlock); + ui->attachmentOffsetYaw->blockSignals(bBlock); + ui->attachmentOffsetPitch->blockSignals(bBlock); + ui->attachmentOffsetRoll->blockSignals(bBlock); } void TaskAttacher::updateListOfModes() @@ -964,11 +964,11 @@ bool TaskDlgAttacher::accept() std::string name = ViewProvider->getObject()->getNameInDocument(); //DeepSOIC: changed this to heavily rely on dialog constantly updating feature properties - if (pcAttach->superPlacement.isTouched()){ - Base::Placement plm = pcAttach->superPlacement.getValue(); + if (pcAttach->AttachmentOffset.isTouched()){ + Base::Placement plm = pcAttach->AttachmentOffset.getValue(); double yaw, pitch, roll; plm.getRotation().getYawPitchRoll(yaw,pitch,roll); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.superPlacement = App.Placement(App.Vector(%.10f, %.10f, %.10f), App.Rotation(%.10f, %.10f, %.10f))", + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.AttachmentOffset = App.Placement(App.Vector(%.10f, %.10f, %.10f), App.Rotation(%.10f, %.10f, %.10f))", name.c_str(), plm.getPosition().x, plm.getPosition().y, plm.getPosition().z, yaw, pitch, roll); diff --git a/src/Mod/Part/Gui/TaskAttacher.h b/src/Mod/Part/Gui/TaskAttacher.h index af1cd1c14e..7cac9e647f 100644 --- a/src/Mod/Part/Gui/TaskAttacher.h +++ b/src/Mod/Part/Gui/TaskAttacher.h @@ -67,13 +67,13 @@ public: bool isCompleted() const { return completed; } private Q_SLOTS: - void onSuperplacementChanged(double, int idx); - void onSuperplacementXChanged(double); - void onSuperplacementYChanged(double); - void onSuperplacementZChanged(double); - void onSuperplacementYawChanged(double); - void onSuperplacementPitchChanged(double); - void onSuperplacementRollChanged(double); + void onAttachmentOffsetChanged(double, int idx); + void onAttachmentOffsetXChanged(double); + void onAttachmentOffsetYChanged(double); + void onAttachmentOffsetZChanged(double); + void onAttachmentOffsetYawChanged(double); + void onAttachmentOffsetPitchChanged(double); + void onAttachmentOffsetRollChanged(double); void onCheckFlip(bool); void onRefName1(const QString& text); void onRefName2(const QString& text); @@ -104,7 +104,7 @@ private: void onButtonRef(const bool checked, unsigned idx); void onRefName(const QString& text, unsigned idx); void updateRefButton(int idx); - void updateSuperplacementUI(); + void updateAttachmentOffsetUI(); /** * @brief updateListOfModes Fills the mode list with modes that apply to diff --git a/src/Mod/Part/Gui/TaskAttacher.ui b/src/Mod/Part/Gui/TaskAttacher.ui index d3130c6af5..175f6cea99 100644 --- a/src/Mod/Part/Gui/TaskAttacher.ui +++ b/src/Mod/Part/Gui/TaskAttacher.ui @@ -110,7 +110,7 @@ - + 0 @@ -118,10 +118,10 @@ - Mirror of superPlacement property. Extra placement is expressed in local space of object being attached. + AttachmentOffset property. The placement is expressed in local space of object being attached. - Extra placement: + Attachment Offset: @@ -154,7 +154,7 @@ - + 0 @@ -183,7 +183,7 @@ - + 0 @@ -238,7 +238,7 @@ - + 0 @@ -254,7 +254,7 @@ - + 0 @@ -276,7 +276,7 @@ - + 0 @@ -298,7 +298,7 @@ - + 0 @@ -353,12 +353,12 @@ buttonRef4 lineRef4 listOfModes - superplacementX - superplacementY - superplacementZ - superplacementYaw - superplacementPitch - superplacementRoll + attachmentOffsetX + attachmentOffsetY + attachmentOffsetZ + attachmentOffsetYaw + attachmentOffsetPitch + attachmentOffsetRoll checkBoxFlip diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp index a5f17ef147..a60befb757 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.cpp +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -160,6 +160,11 @@ void FeaturePrimitive::onChanged(const App::Property* prop) FeatureAddSub::onChanged(prop); } +void FeaturePrimitive::handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName) +{ + extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension +} + PYTHON_TYPE_DEF(PrimitivePy, PartDesign::FeaturePy) PYTHON_TYPE_IMP(PrimitivePy, PartDesign::FeaturePy) diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.h b/src/Mod/PartDesign/App/FeaturePrimitive.h index 9cbaa498f0..14fa002cd0 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.h +++ b/src/Mod/PartDesign/App/FeaturePrimitive.h @@ -64,6 +64,7 @@ public: return PartDesign::FeatureAddSub::execute(); } protected: + void handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName); //make the boolean ops with the primitives provided by the derived features App::DocumentObjectExecReturn* execute(const TopoDS_Shape& primitiveShape); Type primitiveType = Box; diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index aa595e88b9..0232506fac 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -258,7 +258,7 @@ void fixSketchSupport (Sketcher::SketchObject* sketch) Datum.c_str(), refStr.toStdString().c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.MapMode = '%s'", Datum.c_str(), AttachEngine::getModeName(Attacher::mmFlatFace).c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.superPlacement.Base.z = %f", + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.AttachmentOffset.Base.z = %f", Datum.c_str(), offset); Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.insertObject(App.activeDocument().%s, App.activeDocument().%s)", diff --git a/src/Mod/PartDesign/PartDesignTests/TestDatum.py b/src/Mod/PartDesign/PartDesignTests/TestDatum.py index 554d52e24b..43f18264fb 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestDatum.py +++ b/src/Mod/PartDesign/PartDesignTests/TestDatum.py @@ -35,7 +35,7 @@ class TestDatumPoint(unittest.TestCase): self.DatumPoint.MapMode = 'ObjectOrigin' self.Body.addObject(self.DatumPoint) self.Doc.recompute() - self.assertEqual(self.DatumPoint.superPlacement.Base, App.Vector(0)) + self.assertEqual(self.DatumPoint.AttachmentOffset.Base, App.Vector(0)) def tearDown(self): #closing doc