Revert "Part: Remove mode from Offset, keep in Offset2D"

This reverts commit b13b78b2e1.
This commit is contained in:
Benjamin Nauck
2025-09-09 06:12:56 +02:00
parent 05224215bf
commit c4f08b1144
4 changed files with 24 additions and 26 deletions

View File

@@ -33,6 +33,7 @@
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)
@@ -41,6 +42,8 @@ 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");
@@ -58,6 +61,8 @@ short Offset::mustExecute() const
return 1;
if (Value.isTouched())
return 1;
if (Mode.isTouched())
return 1;
if (Join.isTouched())
return 1;
if (Intersection.isTouched())
@@ -78,28 +83,25 @@ 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<JoinType>(Join.getValue());
this->Shape.setValue(TopoShape(0).makeElementOffset(
shape,offset,tol,inter,self,0,join,fill ? FillType::fill : FillType::noFill));
shape,offset,tol,inter,self,mode,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.
}
@@ -137,6 +139,8 @@ 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<JoinType>(Join.getValue());
auto fill = Fill.getValue() ? FillType::fill : FillType::noFill;
bool inter = Intersection.getValue();

View File

@@ -41,6 +41,7 @@ public:
App::PropertyLink Source;
App::PropertyFloat Value;
App::PropertyEnumeration Mode;
App::PropertyEnumeration Join;
App::PropertyBool Intersection;
App::PropertyBool SelfIntersection;
@@ -57,6 +58,7 @@ public:
//@}
private:
static const char* ModeEnums[];
static const char* JoinEnums[];
};
@@ -67,8 +69,6 @@ public:
Offset2D();
~Offset2D() override;
App::PropertyEnumeration Mode;
/** @name methods override feature */
//@{
/// recalculate the feature
@@ -78,9 +78,6 @@ public:
return "PartGui::ViewProviderOffset2D";
}
//@}
private:
static const char* ModeEnums[];
};
}

View File

@@ -71,16 +71,8 @@ OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent)
bool is_2d = d->offset->isDerivedFrom<Part::Offset2D>();
d->ui.selfIntersection->setVisible(!is_2d);
// 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<Part::Offset2D*>(offset);
long mode = offset2d->Mode.getValue();
if (mode >= 0 && mode < d->ui.modeType->count())
d->ui.modeType->setCurrentIndex(mode);
}
if(is_2d)
d->ui.modeType->removeItem(2);//remove Recto-Verso mode, not supported by 2d offset
//block signals to fill values read out from feature...
bool block = true;
@@ -96,7 +88,9 @@ 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);
@@ -152,11 +146,9 @@ void OffsetWidget::onSpinOffsetValueChanged(double val)
void OffsetWidget::onModeTypeActivated(int val)
{
if (auto* offset2d = freecad_cast<Part::Offset2D*>(d->offset)) {
offset2d->Mode.setValue(val);
if (d->ui.updateView->isChecked())
d->offset->getDocument()->recomputeFeature(d->offset);
}
d->offset->Mode.setValue(val);
if (d->ui.updateView->isChecked())
d->offset->getDocument()->recomputeFeature(d->offset);
}
void OffsetWidget::onJoinTypeActivated(int val)

View File

@@ -47,6 +47,11 @@
<string>Pipe</string>
</property>
</item>
<item>
<property name="text">
<string>Recto verso</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">