From 55d2963c10ef8bafa9c747686b5c2ee37e81961f Mon Sep 17 00:00:00 2001 From: dragonfruit-blue Date: Mon, 2 Mar 2026 14:49:48 +0530 Subject: [PATCH 1/2] fix: issue-4 implementation --- .gitignore | 2 + src/Mod/TechDraw/App/DrawViewDimension.cpp | 61 +++++++++++++++---- src/Mod/TechDraw/App/DrawViewDimension.h | 11 +++- src/Mod/TechDraw/Gui/QGIViewDimension.cpp | 5 +- .../TechDraw/Gui/ViewProviderDimension.cpp | 2 +- 5 files changed, 66 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 5ddf8dd8a313..b5bff222aa70 100644 --- a/.gitignore +++ b/.gitignore @@ -139,3 +139,5 @@ scratch/ notes/drafts/ __pycache__/ *.pytest_cache/ + +data/* \ No newline at end of file diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index d1a01e4621f2..35be20c6faf3 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -102,6 +102,8 @@ const char* DrawViewDimension::TypeEnums[] = {"Distance", const char* DrawViewDimension::MeasureTypeEnums[] = {"True", "Projected", nullptr}; +const char* DrawViewDimension::AngleModeEnums[] = {"Normal", "Inverted", "Complementary", "Supplementary", nullptr}; + // constraint to set the step size to 0.1 static const App::PropertyQuantityConstraint::Constraints ToleranceConstraint = { -std::numeric_limits::max(), std::numeric_limits::max(), 0.1}; @@ -180,11 +182,19 @@ DrawViewDimension::DrawViewDimension() "negative value of 'Over Tolerance'"); UnderTolerance.setUnit(Base::Unit::Length); UnderTolerance.setConstraints(&ToleranceConstraint); - ADD_PROPERTY_TYPE(Inverted, - (false), - "", - App::Prop_Output, - "The dimensional value is displayed inverted"); + // ADD_PROPERTY_TYPE(Inverted, + // (false), + // "", + // App::Prop_Output, + // "The dimensional value is displayed inverted"); + + AngleMode.setEnums(AngleModeEnums); + ADD_PROPERTY(AngleMode, + ((long)0), + "", + App::Prop_Output, + "How the angle is displayed: Normal, Inverted, Complementary (90 degree angle), Supplementary (180 degree angle)"; + ); ADD_PROPERTY_TYPE(AngleOverride, (false), @@ -451,6 +461,15 @@ void DrawViewDimension::handleChangedPropertyType(Base::XMLReader& reader, UnderToleranceProperty.Restore(reader); UnderTolerance.setValue(UnderToleranceProperty.getValue()); } + else if (prop == &AngleMode && strcmp(TypeName, "App::PropertyEnumeration") == 0) { + App::PropertyBool InvertedProperty; + InvertedProperty.Restore(reader); + // If the old value was Inverted, set the AngleMode to Inverted (1) + + // otherwise set the AngleMode to Normal (0) + AngleMode.setValue(InvertedProperty.getValue() ? Inverted : Normal); + } + } short DrawViewDimension::mustExecute() const @@ -678,12 +697,32 @@ double DrawViewDimension::getDimValue() } result = fabs(result); - if (Inverted.getValue()) { - if (Type.isValue("Angle") || Type.isValue("Angle3Pt")) { - result = CircleDegrees - result; - } - else { - result = -result; + // if (Inverted.getValue()) { + // if (Type.isValue("Angle") || Type.isValue("Angle3Pt")) { + // result = CircleDegrees - result; + // } + // else { + // result = -result; + // } + // } + + // Apply angle mode transformations for angle dimensions + if (Type.isValue("Angle") || Type.isValue("Angle3Pt")) { + constexpr double RightAngle(90.0); + constexpr double StraightAngle(180.0); + switch ( static_cast(AngleMode.getValue())) { + case Inverted: + result = CircleDegrees - result; + break; + case Complementary: + result = RightAngle - result; + break; + case Supplementary: + result = StraightAngle - result; + break; + case Normal: + default: + break; } } return result; diff --git a/src/Mod/TechDraw/App/DrawViewDimension.h b/src/Mod/TechDraw/App/DrawViewDimension.h index 963fdfff1bfd..70270035fa00 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.h +++ b/src/Mod/TechDraw/App/DrawViewDimension.h @@ -70,6 +70,13 @@ class TechDrawExport DrawViewDimension: public TechDraw::DrawView Angle3Pt }; + enum AngleModeType + { + Normal, + Inverted, + Complementary, + Supplementary + }; /// Constructor DrawViewDimension(); ~DrawViewDimension() override; @@ -80,7 +87,8 @@ class TechDrawExport DrawViewDimension: public TechDraw::DrawView App::PropertyEnumeration Type; // DistanceX, DistanceY, Diameter, etc. App::PropertyBool TheoreticalExact; - App::PropertyBool Inverted; + // App::PropertyBool Inverted; + App::PropertyEnumeration AngleMode; App::PropertyString FormatSpec; App::PropertyString FormatSpecOverTolerance; App::PropertyString FormatSpecUnderTolerance; @@ -266,6 +274,7 @@ class TechDrawExport DrawViewDimension: public TechDraw::DrawView Measure::Measurement* measurement; static const char* TypeEnums[]; //NOLINT static const char* MeasureTypeEnums[]; //NOLINT + static const char* AngleModeEnums[]; //NOLINT void dumpRefs2D(const char* text) const; // Dimension "geometry" pointPair m_linearPoints; diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index a275c821be17..2178c20dcb4d 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -2052,9 +2052,10 @@ void QGIViewDimension::drawAngle(TechDraw::DrawViewDimension* dimension, ? 2 : 1; - // Inverted dimensions display reflex angles (fi > PI), regular ones oblique angles (fi <= PI/2) + // Inverted mode displays reflex angles (fi > PI), regular ones oblique angles (fi <= PI/2) + bool showReflexAngle = (dimension->AngleMode.getValue() == TechDraw::DrawViewDimension::AngleModeType::Inverted); double startRotation = - DrawUtil::angleDifference(startAngle, endAngle, dimension->Inverted.getValue()); + DrawUtil::angleDifference(startAngle, endAngle, showReflexAngle); if (arrowCount < 2) { // For single arrow, the effective angle span is 0, but still we need to know // the angle orientation. Floating point positive/negative zero comes to rescue... diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp index 85d01a6dd05b..fd203d843126 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp @@ -179,7 +179,7 @@ void ViewProviderDimension::updateData(const App::Property* prop) prop == &(getViewObject()->EqualTolerance) || prop == &(getViewObject()->OverTolerance) || prop == &(getViewObject()->UnderTolerance) || - prop == &(getViewObject()->Inverted)) { + prop == &(getViewObject()->AngleMode)) { QGIView* qgiv = getQView(); if (qgiv) { From a3f301a37ae53868bfdcc6d3fa7684a6da9c95b7 Mon Sep 17 00:00:00 2001 From: dragonfruit-blue Date: Wed, 25 Mar 2026 11:42:57 +0530 Subject: [PATCH 2/2] Removed commented code blocks, and made changes in .gitignore --- .gitignore | 4 +--- src/Mod/TechDraw/App/DrawViewDimension.cpp | 20 +++++--------------- src/Mod/TechDraw/App/DrawViewDimension.h | 1 - 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index b5bff222aa70..1c7e4a1b1fd3 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,4 @@ tmp/ scratch/ notes/drafts/ __pycache__/ -*.pytest_cache/ - -data/* \ No newline at end of file +*.pytest_cache/ \ No newline at end of file diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index 35be20c6faf3..b52d8f18289b 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -182,12 +182,7 @@ DrawViewDimension::DrawViewDimension() "negative value of 'Over Tolerance'"); UnderTolerance.setUnit(Base::Unit::Length); UnderTolerance.setConstraints(&ToleranceConstraint); - // ADD_PROPERTY_TYPE(Inverted, - // (false), - // "", - // App::Prop_Output, - // "The dimensional value is displayed inverted"); - + AngleMode.setEnums(AngleModeEnums); ADD_PROPERTY(AngleMode, ((long)0), @@ -697,15 +692,6 @@ double DrawViewDimension::getDimValue() } result = fabs(result); - // if (Inverted.getValue()) { - // if (Type.isValue("Angle") || Type.isValue("Angle3Pt")) { - // result = CircleDegrees - result; - // } - // else { - // result = -result; - // } - // } - // Apply angle mode transformations for angle dimensions if (Type.isValue("Angle") || Type.isValue("Angle3Pt")) { constexpr double RightAngle(90.0); @@ -724,6 +710,10 @@ double DrawViewDimension::getDimValue() default: break; } + } else { + if (Inverted.getValue()) { + result = -result; + } } return result; } diff --git a/src/Mod/TechDraw/App/DrawViewDimension.h b/src/Mod/TechDraw/App/DrawViewDimension.h index 70270035fa00..8fa25afd7161 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.h +++ b/src/Mod/TechDraw/App/DrawViewDimension.h @@ -87,7 +87,6 @@ class TechDrawExport DrawViewDimension: public TechDraw::DrawView App::PropertyEnumeration Type; // DistanceX, DistanceY, Diameter, etc. App::PropertyBool TheoreticalExact; - // App::PropertyBool Inverted; App::PropertyEnumeration AngleMode; App::PropertyString FormatSpec; App::PropertyString FormatSpecOverTolerance;