From 2a2324d7f59b999fe92a26ef067c893d7b7fbffe Mon Sep 17 00:00:00 2001 From: hokieengr Date: Tue, 3 Jul 2018 08:26:29 -0400 Subject: [PATCH] WIP. Added logic to hide units on distance dimensions. More of a prototype than anything else right now. Will find a better way to add this functionality to the rest of Sketcher. --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 00a6a76f37..0b0b005df7 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3351,6 +3351,12 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer ParameterGrp::handle hGrpsk = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); + // Get parameter group that includes HideUnits option + Base::Reference hGrpSketcher = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Sketcher"); + + // Get value for HideUnits option + bool iHideUnits = hGrpSketcher->GetBool("HideUnits", 0l); // default is false + std::vector bsplineGeoIds; double combrepscale = 0; // the repscale that would correspond to this comb based only on this calculation. @@ -4602,7 +4608,19 @@ Restart: break; SoDatumLabel *asciiText = static_cast(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_MATERIAL_OR_DATUMLABEL)); - asciiText->string = SbString(Constr->getPresentationValue().getUserString().toUtf8().constData()); + + // Strip units if requested. MOVE TO ITS OWN FUNCTION WHEN POSSIBLE. Example code from: + // Mod/TechDraw/App/DrawViewDimension.cpp:372 + QString userStr = Constr->getPresentationValue().getUserString(); + + if( iHideUnits ) + { + // Strip units + QRegExp rxUnits(QString::fromUtf8(" \\D*$")); //space + any non digits at end of string + userStr.remove(rxUnits); //getUserString(defaultDecimals) without units + + } + asciiText->string = SbString(userStr.toUtf8().constData()); if (Constr->Type == Distance) asciiText->datumtype = SoDatumLabel::DISTANCE;