From e5ae85e8fd0a4107f9637440907e2cd7cd8ab599 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Fri, 19 Jan 2024 19:32:29 -0500 Subject: [PATCH] [TD]protect against stretch factor == 0 --- src/Mod/TechDraw/App/DrawViewSection.cpp | 8 ++++++++ src/Mod/TechDraw/App/DrawViewSection.h | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 3d527715ae..01ab923556 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -125,6 +125,13 @@ const char* DrawViewSection::SectionDirEnums[] = const char* DrawViewSection::CutSurfaceEnums[] = {"Hide", "Color", "SvgHatch", "PatHatch", nullptr}; +constexpr double stretchMinimum{EWTOLERANCE}; +constexpr double stretchMaximum{std::numeric_limits::max()}; +constexpr double stretchStep{0.1}; + +App::PropertyFloatConstraint::Constraints DrawViewSection::stretchRange = { + stretchMinimum, stretchMaximum, stretchStep}; + //=========================================================================== // DrawViewSection //=========================================================================== @@ -230,6 +237,7 @@ DrawViewSection::DrawViewSection() ADD_PROPERTY_TYPE(SectionLineStretch, (1.0), agroup, App::Prop_None, "Adjusts the length of the section line. 1.0 is normal length. 1.1 would be 10% longer, 0.9 would be 10% shorter."); + SectionLineStretch.setConstraints(&stretchRange); getParameters(); diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 09eb87cfd7..ed311fe27b 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -104,7 +104,7 @@ public: App::PropertyBool TrimAfterCut;//new v021 App::PropertyBool UsePreviousCut; // new v022 - App::PropertyFloat SectionLineStretch; // new v022 + App::PropertyFloatConstraint SectionLineStretch; // new v022 bool isReallyInBox(const Base::Vector3d v, const Base::BoundBox3d bb) const; @@ -205,6 +205,9 @@ protected: bool m_waitingForCut; TopoDS_Shape m_cuttingTool; double m_shapeSize; + + static App::PropertyFloatConstraint::Constraints stretchRange; + }; using DrawViewSectionPython = App::FeaturePythonT;