Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ tmp/
scratch/
notes/drafts/
__pycache__/
*.pytest_cache/
*.pytest_cache/
51 changes: 40 additions & 11 deletions src/Mod/TechDraw/App/DrawViewDimension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>::max(), std::numeric_limits<double>::max(), 0.1};
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing the else clause here - the original code negated things that were marked as Inverted but were not "Angle" or "Angle3Pt".

constexpr double RightAngle(90.0);
constexpr double StraightAngle(180.0);
switch ( static_cast<AngleModeType>(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;
Expand Down
10 changes: 9 additions & 1 deletion src/Mod/TechDraw/App/DrawViewDimension.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ class TechDrawExport DrawViewDimension: public TechDraw::DrawView
Angle3Pt
};

enum AngleModeType
{
Normal,
Inverted,
Complementary,
Supplementary
};
/// Constructor
DrawViewDimension();
~DrawViewDimension() override;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/Mod/TechDraw/Gui/QGIViewDimension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/Gui/ViewProviderDimension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down