From eef738b312af80682d1f5b319757f121b3c6f5f9 Mon Sep 17 00:00:00 2001 From: George Peden Date: Tue, 2 Sep 2025 20:58:56 -0700 Subject: [PATCH] Feature/sketcher constraint symbol size (#23366) * Sketcher: Initial wiring up of independent contraint symbol size. * Sketcher: Align constraint symbol size controls with other preferences - Refactored the Sketcher preferences UI to place the "Constraint symbol size" checkbox and spinbox in separate grid columns, matching the layout of other settings. - Ensured the spinbox aligns visually with other value fields for a more consistent and professional appearance. - Preserved the enable/disable behavior of the spinbox based on the checkbox state. * Update constraint size label * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * style: simplify constraint icon size logic and remove stray blank line * Sketcher: optional constraint symbol size defaults to font size preference (per PR comment) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/Sketcher/Gui/EditModeCoinManager.cpp | 16 +++- src/Mod/Sketcher/Gui/SketcherSettings.cpp | 4 + .../Sketcher/Gui/SketcherSettingsDisplay.ui | 94 ++++++++++++++++--- 3 files changed, 96 insertions(+), 18 deletions(-) diff --git a/src/Mod/Sketcher/Gui/EditModeCoinManager.cpp b/src/Mod/Sketcher/Gui/EditModeCoinManager.cpp index 27ca746d59..a90abfc0bf 100644 --- a/src/Mod/Sketcher/Gui/EditModeCoinManager.cpp +++ b/src/Mod/Sketcher/Gui/EditModeCoinManager.cpp @@ -373,6 +373,8 @@ void EditModeCoinManager::ParameterObserver::updateElementSizeParameters( Client.defaultApplicationFontSizePixels(); // returns height in pixels, not points int sketcherfontSize = hGrp->GetInt("EditSketcherFontSize", defaultFontSizePixels); + int constraintSymbolSizePref = hGrp->GetInt("ConstraintSymbolSize", defaultFontSizePixels); + bool useConstraintSymbolSize = hGrp->GetBool("UseConstraintSymbolSize", false); double dpi = Client.getApplicationLogicalDPIX(); double devicePixelRatio = Client.getDevicePixelRatio(); @@ -385,11 +387,15 @@ void EditModeCoinManager::ParameterObserver::updateElementSizeParameters( // internally. Coin, at least our coin at this time, takes pixels, not points. Client.drawingParameters.coinFontSize = - std::lround(sketcherfontSize * devicePixelRatio); // in pixels - Client.drawingParameters.labelFontSize = - std::lround(sketcherfontSize * devicePixelRatio * 72.0f - / dpi); // in points, as SoDatumLabel uses points - Client.drawingParameters.constraintIconSize = std::lround(0.8 * sketcherfontSize); + std::lround(sketcherfontSize * devicePixelRatio); // in pixels (Coin uses pixels) + Client.drawingParameters.labelFontSize = std::lround( + sketcherfontSize * devicePixelRatio * 72.0f / dpi); // in points (SoDatumLabel uses points) + + // Constraint icon size: legacy derives 0.8 * font (when override disabled); if override + // enabled we use the stored absolute pixel size (defaulting to full font size initially). + int symbolSizeToUse = + useConstraintSymbolSize ? constraintSymbolSizePref : std::lround(0.8 * sketcherfontSize); + Client.drawingParameters.constraintIconSize = std::lround(symbolSizeToUse * devicePixelRatio); auto supportedsizes = Gui::Inventor::MarkerBitmaps::getSupportedSizes("CIRCLE_LINE"); auto scaledMarkerSize = std::lround(markerSize * devicePixelRatio); diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index 11db4327d2..cb81f2978c 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -432,6 +432,8 @@ SketcherSettingsDisplay::~SketcherSettingsDisplay() void SketcherSettingsDisplay::saveSettings() { ui->EditSketcherFontSize->onSave(); + ui->checkBoxUseConstraintSymbolSize->onSave(); + ui->ConstraintSymbolSize->onSave(); ui->viewScalingFactor->onSave(); ui->SegmentsPerGeometry->onSave(); ui->dialogOnDistanceConstraint->onSave(); @@ -453,6 +455,8 @@ void SketcherSettingsDisplay::saveSettings() void SketcherSettingsDisplay::loadSettings() { ui->EditSketcherFontSize->onRestore(); + ui->checkBoxUseConstraintSymbolSize->onRestore(); + ui->ConstraintSymbolSize->onRestore(); ui->viewScalingFactor->onRestore(); ui->SegmentsPerGeometry->onRestore(); ui->dialogOnDistanceConstraint->onRestore(); diff --git a/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui index 553096f918..c048cbc384 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui @@ -19,8 +19,56 @@ Sketch Editing - - + + + + + + Enable a custom pixel size for constraint symbols (otherwise the font size is used). + + + Use custom constraint symbol size + + + false + + + UseConstraintSymbolSize + + + View + + + + + + + Pixel size used to render constraint symbols + + + px + + + 6 + + + 96 + + + 15 + + + false + + + ConstraintSymbolSize + + + View + + + + @@ -36,7 +84,7 @@ - + Scales the 3D view based on this factor @@ -67,7 +115,7 @@ - + The number of polygons used for geometry approximation @@ -86,7 +134,7 @@ - + Displays names of dimensional constraints, if they exist @@ -105,7 +153,7 @@ - + The format of the dimensional constraint string presentation. @@ -128,7 +176,7 @@ Defaults to: %N = %V - + Segments per geometry @@ -138,7 +186,7 @@ Defaults to: %N = %V - + Keeps the current Sketcher tool active after creating geometry @@ -182,7 +230,8 @@ Defaults to: %N = %V - + + Base length units will not be displayed in constraints or cursor coordinates. @@ -215,7 +264,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'. - + Keeps the current Sketcher constraint tool active after creating geometry @@ -234,7 +283,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'. - + Displays cursor position coordinates next to the cursor while editing a sketch @@ -253,7 +302,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'. - + Opens a dialog to input a value for new dimensional constraints after creation @@ -272,7 +321,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'. - + Cursor coordinates will use the system decimals setting instead of the short form @@ -516,12 +565,15 @@ Works only when "Restore camera position after editing" is enabled. EditSketcherFontSize + ConstraintSymbolSize viewScalingFactor SegmentsPerGeometry dialogOnDistanceConstraint continueMode constraintMode checkBoxHideUnits + checkBoxShowCursorCoords + checkBoxUseSystemDecimals checkBoxShowDimensionalName prefDimensionalStringFormat checkBoxTVHideDependent @@ -550,5 +602,21 @@ Works only when "Restore camera position after editing" is enabled. + + checkBoxUseConstraintSymbolSize + toggled(bool) + ConstraintSymbolSize + setEnabled(bool) + + + 0 + 0 + + + 0 + 0 + + +