From 9fceb4bf51f95ed95ad506c0cfe2ac407c52b160 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 29 Aug 2025 18:54:40 +0200 Subject: [PATCH] Part: Remove mode from Offset, keep in Offset2D --- src/Mod/Part/App/FeatureOffset.cpp | 14 +++++--------- src/Mod/Part/App/FeatureOffset.h | 7 +++++-- src/Mod/Part/Gui/TaskOffset.cpp | 24 ++++++++++++++++-------- src/Mod/Part/Gui/TaskOffset.ui | 5 ----- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Mod/Part/App/FeatureOffset.cpp b/src/Mod/Part/App/FeatureOffset.cpp index 3cffec03fd..a27160e666 100644 --- a/src/Mod/Part/App/FeatureOffset.cpp +++ b/src/Mod/Part/App/FeatureOffset.cpp @@ -33,7 +33,6 @@ using namespace Part; -const char* Part::Offset::ModeEnums[]= {"Skin","Pipe", "RectoVerso",nullptr}; const char* Part::Offset::JoinEnums[]= {"Arc","Tangent", "Intersection",nullptr}; PROPERTY_SOURCE(Part::Offset, Part::Feature) @@ -42,8 +41,6 @@ Offset::Offset() { ADD_PROPERTY_TYPE(Source,(nullptr),"Offset",App::Prop_None,"Source shape"); ADD_PROPERTY_TYPE(Value,(1.0),"Offset",App::Prop_None,"Offset value"); - ADD_PROPERTY_TYPE(Mode,(long(0)),"Offset",App::Prop_None,"Mode"); - Mode.setEnums(ModeEnums); ADD_PROPERTY_TYPE(Join,(long(0)),"Offset",App::Prop_None,"Join type"); Join.setEnums(JoinEnums); ADD_PROPERTY_TYPE(Intersection,(false),"Offset",App::Prop_None,"Intersection"); @@ -61,8 +58,6 @@ short Offset::mustExecute() const return 1; if (Value.isTouched()) return 1; - if (Mode.isTouched()) - return 1; if (Join.isTouched()) return 1; if (Intersection.isTouched()) @@ -83,25 +78,28 @@ App::DocumentObjectExecReturn *Offset::execute() double tol = Precision::Confusion(); bool inter = Intersection.getValue(); bool self = SelfIntersection.getValue(); - short mode = (short)Mode.getValue(); bool fill = Fill.getValue(); auto shape = Feature::getTopoShape(source, ShapeOption::ResolveLink | ShapeOption::Transform); if(shape.isNull()) return new App::DocumentObjectExecReturn("Invalid source link"); auto join = static_cast(Join.getValue()); this->Shape.setValue(TopoShape(0).makeElementOffset( - shape,offset,tol,inter,self,mode,join,fill ? FillType::fill : FillType::noFill)); + shape,offset,tol,inter,self,0,join,fill ? FillType::fill : FillType::noFill)); return App::DocumentObject::StdReturn; } //------------------------------------------------------------------------------------------------------- +const char* Part::Offset2D::ModeEnums[]= {"Skin","Pipe",nullptr}; PROPERTY_SOURCE(Part::Offset2D, Part::Offset) Offset2D::Offset2D() { + ADD_PROPERTY_TYPE(Mode,(long(0)),"Offset",App::Prop_None,"Mode"); + Mode.setEnums(ModeEnums); + this->SelfIntersection.setStatus(App::Property::Status::Hidden, true); this->Mode.setValue(1); //switch to Pipe mode by default, because skin mode does not function properly on closed profiles. } @@ -139,8 +137,6 @@ App::DocumentObjectExecReturn *Offset2D::execute() double offset = Value.getValue(); short mode = (short)Mode.getValue(); auto openresult = mode == 0 ? OpenResult::allowOpenResult : OpenResult::noOpenResult; - if (mode == 2) - return new App::DocumentObjectExecReturn("Mode 'Recto-Verso' is not supported for 2D offset."); auto join = static_cast(Join.getValue()); auto fill = Fill.getValue() ? FillType::fill : FillType::noFill; bool inter = Intersection.getValue(); diff --git a/src/Mod/Part/App/FeatureOffset.h b/src/Mod/Part/App/FeatureOffset.h index ee3f6769a2..730ea726b0 100644 --- a/src/Mod/Part/App/FeatureOffset.h +++ b/src/Mod/Part/App/FeatureOffset.h @@ -41,7 +41,6 @@ public: App::PropertyLink Source; App::PropertyFloat Value; - App::PropertyEnumeration Mode; App::PropertyEnumeration Join; App::PropertyBool Intersection; App::PropertyBool SelfIntersection; @@ -58,7 +57,6 @@ public: //@} private: - static const char* ModeEnums[]; static const char* JoinEnums[]; }; @@ -69,6 +67,8 @@ public: Offset2D(); ~Offset2D() override; + App::PropertyEnumeration Mode; + /** @name methods override feature */ //@{ /// recalculate the feature @@ -78,6 +78,9 @@ public: return "PartGui::ViewProviderOffset2D"; } //@} + +private: + static const char* ModeEnums[]; }; } diff --git a/src/Mod/Part/Gui/TaskOffset.cpp b/src/Mod/Part/Gui/TaskOffset.cpp index 13548e85b7..94dd2fb6e8 100644 --- a/src/Mod/Part/Gui/TaskOffset.cpp +++ b/src/Mod/Part/Gui/TaskOffset.cpp @@ -71,8 +71,16 @@ OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent) bool is_2d = d->offset->isDerivedFrom(); d->ui.selfIntersection->setVisible(!is_2d); - if(is_2d) - d->ui.modeType->removeItem(2);//remove Recto-Verso mode, not supported by 2d offset + + // Offset mode is only supported in 2d offsets + d->ui.label_2->setVisible(is_2d); + d->ui.modeType->setVisible(is_2d); + if(is_2d) { + auto* offset2d = static_cast(offset); + long mode = offset2d->Mode.getValue(); + if (mode >= 0 && mode < d->ui.modeType->count()) + d->ui.modeType->setCurrentIndex(mode); + } //block signals to fill values read out from feature... bool block = true; @@ -88,9 +96,7 @@ OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent) d->ui.fillOffset->setChecked(offset->Fill.getValue()); d->ui.intersection->setChecked(offset->Intersection.getValue()); d->ui.selfIntersection->setChecked(offset->SelfIntersection.getValue()); - long mode = offset->Mode.getValue(); - if (mode >= 0 && mode < d->ui.modeType->count()) - d->ui.modeType->setCurrentIndex(mode); + long join = offset->Join.getValue(); if (join >= 0 && join < d->ui.joinType->count()) d->ui.joinType->setCurrentIndex(join); @@ -146,9 +152,11 @@ void OffsetWidget::onSpinOffsetValueChanged(double val) void OffsetWidget::onModeTypeActivated(int val) { - d->offset->Mode.setValue(val); - if (d->ui.updateView->isChecked()) - d->offset->getDocument()->recomputeFeature(d->offset); + if (auto* offset2d = freecad_cast(d->offset)) { + offset2d->Mode.setValue(val); + if (d->ui.updateView->isChecked()) + d->offset->getDocument()->recomputeFeature(d->offset); + } } void OffsetWidget::onJoinTypeActivated(int val) diff --git a/src/Mod/Part/Gui/TaskOffset.ui b/src/Mod/Part/Gui/TaskOffset.ui index fc1f192469..79eb9918b6 100644 --- a/src/Mod/Part/Gui/TaskOffset.ui +++ b/src/Mod/Part/Gui/TaskOffset.ui @@ -47,11 +47,6 @@ Pipe - - - Recto verso - -