diff --git a/.gitignore b/.gitignore index 5ddf8dd8a313..1c7e4a1b1fd3 100644 --- a/.gitignore +++ b/.gitignore @@ -138,4 +138,4 @@ tmp/ scratch/ notes/drafts/ __pycache__/ -*.pytest_cache/ +*.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 d1a01e4621f2..b52d8f18289b 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,14 @@ 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), + "", + 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 +456,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 +692,27 @@ 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); + 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; + } + } 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 963fdfff1bfd..8fa25afd7161 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,7 @@ 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; App::PropertyString FormatSpecUnderTolerance; @@ -266,6 +273,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) {