From fa3c6e1068267505d27fbad4e0e22a2fd8791cc9 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Sat, 5 Apr 2025 13:42:05 +0100 Subject: [PATCH] =?UTF-8?q?[PartDesign]=20Fix=20spelling=20of=20auxiliary?= =?UTF-8?q?=20and=20curvilinear=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …but also handle the properties name change from old files --- src/Mod/PartDesign/App/FeaturePipe.cpp | 40 ++++++++++++++---- src/Mod/PartDesign/App/FeaturePipe.h | 10 +++-- src/Mod/PartDesign/Gui/TaskPipeOrientation.ui | 4 +- src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 42 +++++++++---------- src/Mod/PartDesign/Gui/TaskPipeParameters.h | 2 +- src/Mod/PartDesign/Gui/Utils.cpp | 4 +- src/Mod/PartDesign/Gui/ViewProviderPipe.cpp | 6 +-- 7 files changed, 68 insertions(+), 40 deletions(-) diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index f5010885cf..7b60026224 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -72,11 +72,11 @@ Pipe::Pipe() ADD_PROPERTY_TYPE(Spine, (nullptr), "Sweep", App::Prop_None, "Path to sweep along"); ADD_PROPERTY_TYPE(SpineTangent, (false), "Sweep", App::Prop_None, "Include tangent edges into path"); - ADD_PROPERTY_TYPE(AuxillerySpine, (nullptr), "Sweep", App::Prop_None, + ADD_PROPERTY_TYPE(AuxiliarySpine, (nullptr), "Sweep", App::Prop_None, "Secondary path to orient sweep"); - ADD_PROPERTY_TYPE(AuxillerySpineTangent, (false), "Sweep", App::Prop_None, + ADD_PROPERTY_TYPE(AuxiliarySpineTangent, (false), "Sweep", App::Prop_None, "Include tangent edges into secondary path"); - ADD_PROPERTY_TYPE(AuxilleryCurvelinear, (true), "Sweep", App::Prop_None, + ADD_PROPERTY_TYPE(AuxiliaryCurvilinear, (true), "Sweep", App::Prop_None, "Calculate normal between equidistant points on both spines"); ADD_PROPERTY_TYPE(Mode, (long(0)), "Sweep", App::Prop_None, "Profile mode"); ADD_PROPERTY_TYPE(Binormal, (Base::Vector3d()), "Sweep", App::Prop_None, @@ -191,10 +191,10 @@ App::DocumentObjectExecReturn *Pipe::execute() // auxiliary TopoDS_Shape auxpath; if (Mode.getValue() == 3) { - App::DocumentObject* auxspine = AuxillerySpine.getValue(); + App::DocumentObject* auxspine = AuxiliarySpine.getValue(); if (!(auxspine && auxspine->isDerivedFrom())) return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No auxiliary spine linked.")); - std::vector auxsubedge = AuxillerySpine.getSubValues(); + std::vector auxsubedge = AuxiliarySpine.getSubValues(); const Part::TopoShape& auxshape = static_cast(auxspine)->Shape.getValue(); @@ -479,8 +479,8 @@ void Pipe::setupAlgorithm(BRepOffsetAPI_MakePipeShell& mkPipeShell, const TopoDS } if (auxiliary) { - mkPipeShell.SetMode(TopoDS::Wire(auxshape), AuxilleryCurvelinear.getValue()); - // mkPipeShell.SetMode(TopoDS::Wire(auxshape), AuxilleryCurvelinear.getValue(), + mkPipeShell.SetMode(TopoDS::Wire(auxshape), AuxiliaryCurvilinear.getValue()); + // mkPipeShell.SetMode(TopoDS::Wire(auxshape), AuxiliaryCurvilinear.getValue(), // BRepFill_ContactOnBorder); } } @@ -613,3 +613,29 @@ void Pipe::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeNa ProfileBased::handleChangedPropertyType(reader, TypeName, prop); } } + +void Pipe::handleChangedPropertyName(Base::XMLReader& reader, + const char* TypeName, + const char* PropName) +{ + // The AuxiliarySpine property was AuxillerySpine in the past + std::string strAuxillerySpine("AuxillerySpine"); + // The AuxiliarySpineTangent property was AuxillerySpineTangent in the past + std::string strAuxillerySpineTangent("AuxillerySpineTangent"); + // The AuxiliaryCurvilinear property was AuxilleryCurvelinear in the past + std::string strAuxilleryCurvelinear("AuxilleryCurvelinear"); + Base::Type type = Base::Type::fromName(TypeName); + if (AuxiliarySpine.getClassTypeId() == type && strAuxillerySpine == PropName) { + AuxiliarySpine.Restore(reader); + } + else if (AuxiliarySpineTangent.getClassTypeId() == type + && strAuxillerySpineTangent == PropName) { + AuxiliarySpineTangent.Restore(reader); + } + else if (AuxiliaryCurvilinear.getClassTypeId() == type && strAuxilleryCurvelinear == PropName) { + AuxiliaryCurvilinear.Restore(reader); + } + else { + ProfileBased::handleChangedPropertyName(reader, TypeName, PropName); + } +} diff --git a/src/Mod/PartDesign/App/FeaturePipe.h b/src/Mod/PartDesign/App/FeaturePipe.h index 227a869f36..8987d1453f 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.h +++ b/src/Mod/PartDesign/App/FeaturePipe.h @@ -39,9 +39,9 @@ public: App::PropertyLinkSub Spine; App::PropertyBool SpineTangent; - App::PropertyLinkSub AuxillerySpine; - App::PropertyBool AuxillerySpineTangent; - App::PropertyBool AuxilleryCurvelinear; + App::PropertyLinkSub AuxiliarySpine; + App::PropertyBool AuxiliarySpineTangent; + App::PropertyBool AuxiliaryCurvilinear; App::PropertyEnumeration Mode; App::PropertyVector Binormal; App::PropertyEnumeration Transition; @@ -59,7 +59,7 @@ public: const TopLoc_Location &invObjLoc = TopLoc_Location(), int transition = 0, const TopoShape &auxpath = TopoShape(), - bool auxCurveLinear = true, + bool auxCurviLinear = true, int mode = 2, const Base::Vector3d &binormalVector = Base::Vector3d(), int transformation = 0, @@ -74,6 +74,8 @@ protected: void setupAlgorithm(BRepOffsetAPI_MakePipeShell& mkPipeShell, const TopoDS_Shape& auxshape); /// handle changed property void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop) override; + void handleChangedPropertyName(Base::XMLReader& reader, const char* TypeName, + const char* PropName) override; private: static const char* TypeEnums[]; diff --git a/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui b/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui index 23c69f10c4..d1310ea473 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui +++ b/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui @@ -71,9 +71,9 @@ - + - Curvelinear equivalence + Curvilinear equivalence diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 31986fe5fe..d3656020ef 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -124,8 +124,8 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe* PipeView, bool /*newObj make2DLabel(pipe->Profile.getValue(), pipe->Profile.getSubValues())); } // the auxiliary spine - if (pipe->AuxillerySpine.getValue()) { - auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); + if (pipe->AuxiliarySpine.getValue()) { + auto* svp = doc->getViewProvider(pipe->AuxiliarySpine.getValue()); auxSpineShow = svp->isShow(); svp->show(); } @@ -432,8 +432,8 @@ void TaskPipeParameters::setVisibilityOfSpineAndProfile() profileVP->setVisible(profileShow); profileShow = false; } - if (pipe->AuxillerySpine.getValue()) { - auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); + if (pipe->AuxiliarySpine.getValue()) { + auto* svp = doc->getViewProvider(pipe->AuxiliarySpine.getValue()); svp->setVisible(auxSpineShow); auxSpineShow = false; } @@ -456,7 +456,7 @@ bool TaskPipeParameters::accept() bool extReference = false; App::DocumentObject* spine = pipe->Spine.getValue(); - App::DocumentObject* auxSpine = pipe->AuxillerySpine.getValue(); + App::DocumentObject* auxSpine = pipe->AuxiliarySpine.getValue(); // If a spine isn't set but user entered a label then search for the appropriate document object QString label = ui->spineBaseEdit->text(); @@ -509,12 +509,12 @@ bool TaskPipeParameters::accept() } else if (!pcActiveBody->hasObject(auxSpine) && !pcActiveBody->getOrigin()->hasObject(auxSpine)) { - pipe->AuxillerySpine.setValue( + pipe->AuxiliarySpine.setValue( PartDesignGui::TaskFeaturePick::makeCopy(auxSpine, "", dlg.radioIndependent->isChecked()), - pipe->AuxillerySpine.getSubValues()); - copies.push_back(pipe->AuxillerySpine.getValue()); + pipe->AuxiliarySpine.getSubValues()); + copies.push_back(pipe->AuxiliarySpine.getValue()); } std::vector subSets; @@ -597,8 +597,8 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, this, &TaskPipeOrientation::onClearButton); connect(ui->stackedWidget, &QStackedWidget::currentChanged, this, &TaskPipeOrientation::updateUI); - connect(ui->curvelinear, &QCheckBox::toggled, - this, &TaskPipeOrientation::onCurvelinearChanged); + connect(ui->curvilinear, &QCheckBox::toggled, + this, &TaskPipeOrientation::onCurvilinearChanged); connect(ui->doubleSpinBoxX, qOverload(&QDoubleSpinBox::valueChanged), this, &TaskPipeOrientation::onBinormalChanged); connect(ui->doubleSpinBoxY, qOverload(&QDoubleSpinBox::valueChanged), @@ -628,12 +628,12 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, PartDesign::Pipe* pipe = PipeView->getObject(); // add initial values - if (pipe->AuxillerySpine.getValue()) { + if (pipe->AuxiliarySpine.getValue()) { ui->profileBaseEdit->setText( - QString::fromUtf8(pipe->AuxillerySpine.getValue()->Label.getValue())); + QString::fromUtf8(pipe->AuxiliarySpine.getValue()->Label.getValue())); } - std::vector strings = pipe->AuxillerySpine.getSubValues(); + std::vector strings = pipe->AuxiliarySpine.getSubValues(); for (const auto& string : strings) { QString label = QString::fromStdString(string); QListWidgetItem* item = new QListWidgetItem(); @@ -643,7 +643,7 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, } ui->comboBoxMode->setCurrentIndex(pipe->Mode.getValue()); - ui->curvelinear->setChecked(pipe->AuxilleryCurvelinear.getValue()); + ui->curvilinear->setChecked(pipe->AuxiliaryCurvilinear.getValue()); // should be called after panel has become visible QMetaObject::invokeMethod(this, @@ -690,14 +690,14 @@ void TaskPipeOrientation::onClearButton() ui->profileBaseEdit->clear(); if (auto view = getViewObject()) { view->highlightReferences(ViewProviderPipe::AuxiliarySpine, false); - getObject()->AuxillerySpine.setValue(nullptr); + getObject()->AuxiliarySpine.setValue(nullptr); } } -void TaskPipeOrientation::onCurvelinearChanged(bool checked) +void TaskPipeOrientation::onCurvilinearChanged(bool checked) { if (auto pipe = getObject()) { - pipe->AuxilleryCurvelinear.setValue(checked); + pipe->AuxiliaryCurvilinear.setValue(checked); recomputeFeature(); } } @@ -795,7 +795,7 @@ bool TaskPipeOrientation::referenceSelected(const SelectionChanges& msg) const if (const auto pipe = getObject()) { // change the references const std::string subName(msg.pSubName); - std::vector refs = pipe->AuxillerySpine.getSubValues(); + std::vector refs = pipe->AuxiliarySpine.getSubValues(); const auto f = std::ranges::find(refs, subName); if (selectionMode == StateHandlerTaskPipe::SelectionModes::refAuxSpine) { @@ -817,7 +817,7 @@ bool TaskPipeOrientation::referenceSelected(const SelectionChanges& msg) const } App::Document* doc = pipe->getDocument(); - pipe->AuxillerySpine.setValue(doc->getObject(msg.pObjectName), refs); + pipe->AuxiliarySpine.setValue(doc->getObject(msg.pObjectName), refs); return true; } } @@ -847,13 +847,13 @@ void TaskPipeOrientation::onDeleteItem() // search inside the list of spines if (const auto pipe = getObject()) { - std::vector refs = pipe->AuxillerySpine.getSubValues(); + std::vector refs = pipe->AuxiliarySpine.getSubValues(); const std::string obj = data.constData(); // if something was found, delete it and update the spine list if (const auto f = std::ranges::find(refs, obj); f != refs.end()) { refs.erase(f); - pipe->AuxillerySpine.setValue(pipe->AuxillerySpine.getValue(), refs); + pipe->AuxiliarySpine.setValue(pipe->AuxiliarySpine.getValue(), refs); clearButtons(); recomputeFeature(); } diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.h b/src/Mod/PartDesign/Gui/TaskPipeParameters.h index 5577c91826..6cbb0b2f51 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.h @@ -125,7 +125,7 @@ private Q_SLOTS: void onOrientationChanged(int); void updateUI(int idx); void onClearButton(); - void onCurvelinearChanged(bool checked); + void onCurvilinearChanged(bool checked); void onBinormalChanged(double); void onDeleteItem(); diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 09346de5d7..e56b4d468f 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -504,7 +504,7 @@ bool isFeatureMovable(App::DocumentObject* const feat) } } - if (auto prop = dynamic_cast(prim->getPropertyByName("AuxillerySpine"))) { + if (auto prop = dynamic_cast(prim->getPropertyByName("AuxiliarySpine"))) { App::DocumentObject* auxSpine = prop->getValue(); if (auxSpine && !isFeatureMovable(auxSpine)) { return false; @@ -557,7 +557,7 @@ std::vector collectMovableDependencies(std::vector(prim->getPropertyByName("AuxillerySpine"))) { + if (auto prop = dynamic_cast(prim->getPropertyByName("AuxiliarySpine"))) { App::DocumentObject* axis = prop->getValue(); if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); diff --git a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp index 044a52dd85..02bf485cd6 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp @@ -62,7 +62,7 @@ std::vector ViewProviderPipe::claimChildren()const if (spine && spine->isDerivedFrom()) temp.push_back(spine); - App::DocumentObject* auxspine = pcPipe->AuxillerySpine.getValue(); + App::DocumentObject* auxspine = pcPipe->AuxiliarySpine.getValue(); if (auxspine && auxspine->isDerivedFrom()) temp.push_back(auxspine); @@ -120,8 +120,8 @@ void ViewProviderPipe::highlightReferences(ViewProviderPipe::Reference mode, boo pcPipe->Spine.getSubValuesStartsWith("Edge"), on); break; case AuxiliarySpine: - highlightReferences(dynamic_cast(pcPipe->AuxillerySpine.getValue()), - pcPipe->AuxillerySpine.getSubValuesStartsWith("Edge"), on); + highlightReferences(dynamic_cast(pcPipe->AuxiliarySpine.getValue()), + pcPipe->AuxiliarySpine.getSubValuesStartsWith("Edge"), on); break; case Profile: highlightReferences(dynamic_cast(pcPipe->Profile.getValue()),