diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp index fedc34cb82..39b047e719 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.cpp +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -313,8 +313,10 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt std::string method2(Type2.getValueAsString()); // Validate parameters - double L = Length.getValue(); - double L2 = (Sidemethod == "Two sides" && method2 == "Length") ? Length2.getValue() : 0; + double L = method == "ThroughAll" ? getThroughAllLength() : Length.getValue(); + double L2 = Sidemethod == "Two sides" + ? method2 == "ThroughAll" ? getThroughAllLength() : Length2.getValue() + : 0; if ((Sidemethod == "One side" && method == "Length") || (Sidemethod == "Two sides" && method == "Length" && method2 == "Length")) { @@ -447,21 +449,19 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt sketchshape.move(invObjLoc); std::vector prisms; // Stores prisms, all in global CS - std::string sideTypeStr = SideType.getValueAsString(); - std::string method1 = Type.getValueAsString(); - double len1 = method1 == "ThroughAll" ? getThroughAllLength() : Length.getValue(); double taper1 = TaperAngle.getValue(); double offset1 = Offset.getValue(); - if (sideTypeStr == "One side") { + if (Sidemethod == "One side") { TopoShape prism1 = generateSingleExtrusionSide(sketchshape, - method1, len1, taper1, UpToFace, UpToShape, + method, L, taper1, UpToFace, UpToShape, dir, offset1, makeface, base); prisms.push_back(prism1); } - else if (sideTypeStr == "Symmetric") { + else if (Sidemethod == "Symmetric") { + L /= 2.0; TopoShape prism1 = generateSingleExtrusionSide(sketchshape, - method1, len1, taper1, UpToFace, UpToShape, + method, L, taper1, UpToFace, UpToShape, dir, offset1, makeface, base); prisms.push_back(prism1); @@ -472,10 +472,10 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt prisms.push_back(prism2); } - else if (sideTypeStr == "Two sides") { + else if (Sidemethod == "Two sides") { TopoShape prism1 = generateSingleExtrusionSide(sketchshape.makeElementCopy(), - method1, - len1, + method, + L, taper1, UpToFace, UpToShape, @@ -488,8 +488,6 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt } // Side 2 - std::string method2 = Type2.getValueAsString(); - double len2 = method2 == "ThroughAll" ? getThroughAllLength() : Length2.getValue(); double taper2 = TaperAngle2.getValue(); double offset2 = Offset2.getValue(); gp_Dir dir2 = dir; @@ -497,7 +495,7 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt TopoShape prism2 = generateSingleExtrusionSide(sketchshape.makeElementCopy(), method2, - len2, + L2, taper2, UpToFace2, UpToShape2, @@ -739,18 +737,18 @@ TopoShape FeatureExtrude::generateSingleExtrusionSide(const TopoShape& sketchsha return prism; } - -void FeatureExtrude::handleChangedPropertyType(Base::XMLReader& reader, - const char* TypeName, - App::Property* prop) +void FeatureExtrude::onDocumentRestored() { // property Type no longer has TwoLengths. - if (prop == &Type && strcmp(Type.getValueAsString(), "TwoLengths") == 0) { + if (strcmp(Type.getValueAsString(), "TwoLengths") == 0) { Type.setValue("Length"); Type2.setValue("Length"); SideType.setValue("Two sides"); } - else { - ProfileBased::handleChangedPropertyType(reader, TypeName, prop); + else if (Midplane.getValue()) { + Midplane.setValue(false); + SideType.setValue("Symmetric"); } + + ProfileBased::onDocumentRestored(); } diff --git a/src/Mod/PartDesign/App/FeatureExtrude.h b/src/Mod/PartDesign/App/FeatureExtrude.h index 62e5d7fea0..67b06e2b7e 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.h +++ b/src/Mod/PartDesign/App/FeatureExtrude.h @@ -73,7 +73,7 @@ public: static const char* SideTypesEnums[]; protected: - void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop) override; + void onDocumentRestored() override; Base::Vector3d computeDirection(const Base::Vector3d& sketchVector, bool inverse); bool hasTaperedAngle() const; diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index a21dd25529..e3fb856bb0 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -768,8 +768,10 @@ void TaskExtrudeParameters::updateWholeUI(Type type, Side side) // Side 2 is only visible if in TwoSides mode, and we pass whether it should receive focus. updateSideUI(m_side2, type, mode2, isSide2GroupVisible, (side == Side::Second)); - ui->checkBoxAlongDirection->setVisible(m_side1.lengthEdit->isVisible() - || m_side2.lengthEdit->isVisible()); + bool side1HasLength = (mode1 == Mode::Dimension); + bool side2HasLength = (sidesMode == SidesMode::TwoSides && mode2 == Mode::Dimension); + ui->checkBoxAlongDirection->setVisible(side1HasLength || side2HasLength); + ui->checkBoxReversed->setEnabled(sidesMode != SidesMode::Symmetric || mode1 != Mode::Dimension); } @@ -1363,3 +1365,4 @@ bool TaskDlgExtrudeParameters::reject() #include "moc_TaskExtrudeParameters.cpp" +