From e8d76d49bf3f78d63e1be4929dc341d1ea6206c1 Mon Sep 17 00:00:00 2001 From: donovaly Date: Sat, 9 Jan 2021 03:21:51 +0100 Subject: [PATCH] [TD] some fixes - the setting "Standard and Style" only affects new dimensions, thus it must be italic - fix bug that the Property 'LockPosition' appears for dimensions -> this is an option for views and thus must be hidden for dimensions - since tolerances are in the vast majority fractions of a millimeter/inch, set its stepsize to 0.1 (I hope I did it right in handleChangedPropertyType.) - fix inconsistent newlines in TaskBalloon.h - improve wording for a heading --- src/Mod/TechDraw/App/DrawViewDimension.cpp | 20 ++++++++++++++ src/Mod/TechDraw/App/DrawViewDimension.h | 26 +++++++++---------- .../Gui/DlgPrefsTechDrawDimensions.ui | 5 ++++ src/Mod/TechDraw/Gui/TaskBalloon.h | 4 +-- .../TechDraw/Gui/ViewProviderDimension.cpp | 2 +- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index 88c25c4a4c..ed0c6d1bee 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -116,10 +116,15 @@ DrawViewDimension::DrawViewDimension(void) ADD_PROPERTY(MeasureType, ((long)1)); //Projected (or True) measurement ADD_PROPERTY_TYPE(TheoreticalExact,(false), "", App::Prop_Output, "Set for theoretical exact (basic) dimension"); ADD_PROPERTY_TYPE(EqualTolerance, (true), "", App::Prop_Output, "If over- and undertolerance are equal"); + + // constraint to set the step size to 0.1 + static const App::PropertyQuantityConstraint::Constraints ToleranceConstraint = { -DBL_MAX, DBL_MAX, 0.1 }; ADD_PROPERTY_TYPE(OverTolerance, (0.0), "", App::Prop_Output, "Overtolerance value\nIf 'Equal Tolerance' is true this is also the value for 'Under Tolerance'"); OverTolerance.setUnit(Base::Unit::Length); + OverTolerance.setConstraints(&ToleranceConstraint); ADD_PROPERTY_TYPE(UnderTolerance, (0.0), "", App::Prop_Output, "Undertolerance value\nIf 'Equal Tolerance' it will be replaced by 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"); //hide the DrawView properties that don't apply to Dimensions @@ -130,6 +135,7 @@ DrawViewDimension::DrawViewDimension(void) Rotation.setStatus(App::Property::ReadOnly, true); Rotation.setStatus(App::Property::Hidden, true); Caption.setStatus(App::Property::Hidden, true); + LockPosition.setStatus(App::Property::Hidden, true); // by default EqualTolerance is true, thus make UnderTolerance read-only UnderTolerance.setStatus(App::Property::ReadOnly, true); @@ -266,6 +272,20 @@ void DrawViewDimension::handleChangedPropertyType(Base::XMLReader &reader, const else { TechDraw::DrawView::handleChangedPropertyType(reader, TypeName, prop); } + + // Over/Undertolerance were further changed from App::PropertyQuantity to App::PropertyQuantityConstraint + if ((prop == &OverTolerance) && (strcmp(TypeName, "App::PropertyQuantity") == 0)) { + App::PropertyQuantity OverToleranceProperty; + // restore the PropertyQuantity to be able to set its value + OverToleranceProperty.Restore(reader); + OverTolerance.setValue(OverToleranceProperty.getValue()); + } + else if ((prop == &UnderTolerance) && (strcmp(TypeName, "App::PropertyQuantity") == 0)) { + App::PropertyQuantity UnderToleranceProperty; + // restore the PropertyQuantity to be able to set its value + UnderToleranceProperty.Restore(reader); + UnderTolerance.setValue(UnderToleranceProperty.getValue()); + } } diff --git a/src/Mod/TechDraw/App/DrawViewDimension.h b/src/Mod/TechDraw/App/DrawViewDimension.h index 16cd078522..8876bb5356 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.h +++ b/src/Mod/TechDraw/App/DrawViewDimension.h @@ -94,20 +94,20 @@ public: DrawViewDimension(); virtual ~DrawViewDimension(); - App::PropertyEnumeration MeasureType; //True/Projected - App::PropertyLinkSubList References2D; //Points to Projection SubFeatures - App::PropertyLinkSubList References3D; //Points to 3D Geometry SubFeatures - App::PropertyEnumeration Type; //DistanceX,DistanceY,Diameter, etc + App::PropertyEnumeration MeasureType; //True/Projected + App::PropertyLinkSubList References2D; //Points to Projection SubFeatures + App::PropertyLinkSubList References3D; //Points to 3D Geometry SubFeatures + App::PropertyEnumeration Type; //DistanceX, DistanceY, Diameter, etc. - App::PropertyBool TheoreticalExact; - App::PropertyBool Inverted; - App::PropertyString FormatSpec; - App::PropertyString FormatSpecTolerance; - App::PropertyBool Arbitrary; - App::PropertyBool ArbitraryTolerances; - App::PropertyBool EqualTolerance; - App::PropertyQuantity OverTolerance; - App::PropertyQuantity UnderTolerance; + App::PropertyBool TheoreticalExact; + App::PropertyBool Inverted; + App::PropertyString FormatSpec; + App::PropertyString FormatSpecTolerance; + App::PropertyBool Arbitrary; + App::PropertyBool ArbitraryTolerances; + App::PropertyBool EqualTolerance; + App::PropertyQuantityConstraint OverTolerance; + App::PropertyQuantityConstraint UnderTolerance; enum RefType{ invalidRef, diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui index f578208f0e..8dc2bb2060 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui @@ -111,6 +111,11 @@ 0 + + + true + + Standard and Style diff --git a/src/Mod/TechDraw/Gui/TaskBalloon.h b/src/Mod/TechDraw/Gui/TaskBalloon.h index b292557c06..bb8e62d26f 100644 --- a/src/Mod/TechDraw/Gui/TaskBalloon.h +++ b/src/Mod/TechDraw/Gui/TaskBalloon.h @@ -58,8 +58,8 @@ private Q_SLOTS: void onFontsizeChanged(); void onBubbleShapeChanged(); void onShapeScaleChanged(); - void onEndSymbolChanged(); - void onEndSymbolScaleChanged(); + void onEndSymbolChanged(); + void onEndSymbolScaleChanged(); void onLineVisibleChanged(); void onLineWidthChanged(); void onKinkLengthChanged(); diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp index adc0940ae2..4adcaefb8e 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp @@ -65,7 +65,7 @@ ViewProviderDimension::ViewProviderDimension() { sPixmap = "TechDraw_Dimension"; - static const char *group = "Dim Format"; + static const char *group = "Dimension Format"; ADD_PROPERTY_TYPE(Font, (Preferences::labelFont().c_str()), group, App::Prop_None, "The name of the font to use");