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>
This commit is contained in:
George Peden
2025-09-02 20:58:56 -07:00
committed by GitHub
parent 04e085cba3
commit eef738b312
3 changed files with 96 additions and 18 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -19,8 +19,56 @@
<property name="title">
<string>Sketch Editing</string>
</property>
<layout class="QGridLayout" name="gridLayout_1">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_1">
<!-- Constraint symbol size -->
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxUseConstraintSymbolSize">
<property name="toolTip">
<string>Enable a custom pixel size for constraint symbols (otherwise the font size is used).</string>
</property>
<property name="text">
<string>Use custom constraint symbol size</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseConstraintSymbolSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefSpinBox" name="ConstraintSymbolSize">
<property name="toolTip">
<string>Pixel size used to render constraint symbols</string>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="minimum">
<number>6</number>
</property>
<property name="maximum">
<number>96</number>
</property>
<property name="value">
<number>15</number>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ConstraintSymbolSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_1">
<property name="minimumSize">
<size>
@@ -36,7 +84,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="Gui::PrefDoubleSpinBox" name="viewScalingFactor">
<property name="toolTip">
<string>Scales the 3D view based on this factor</string>
@@ -67,7 +115,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="Gui::PrefSpinBox" name="SegmentsPerGeometry">
<property name="toolTip">
<string>The number of polygons used for geometry approximation</string>
@@ -86,7 +134,7 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxShowDimensionalName">
<property name="toolTip">
<string>Displays names of dimensional constraints, if they exist</string>
@@ -105,7 +153,7 @@
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="Gui::PrefLineEdit" name="prefDimensionalStringFormat">
<property name="toolTip">
<string>The format of the dimensional constraint string presentation.
@@ -128,7 +176,7 @@ Defaults to: %N = %V
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Segments per geometry</string>
@@ -138,7 +186,7 @@ Defaults to: %N = %V
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="continueMode">
<property name="toolTip">
<string>Keeps the current Sketcher tool active after creating geometry</string>
@@ -182,7 +230,8 @@ Defaults to: %N = %V
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<!-- removed custom checkbox + dependent spin; replaced above with standalone PrefSpinBox -->
<item row="7" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="checkBoxHideUnits">
<property name="toolTip">
<string>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'.</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="constraintMode">
<property name="toolTip">
<string>Keeps the current Sketcher constraint tool active after creating geometry</string>
@@ -234,7 +283,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'.</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxShowCursorCoords">
<property name="toolTip">
<string>Displays cursor position coordinates next to the cursor while editing a sketch</string>
@@ -253,7 +302,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'.</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="dialogOnDistanceConstraint">
<property name="toolTip">
<string>Opens a dialog to input a value for new dimensional constraints after creation</string>
@@ -272,7 +321,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'.</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxUseSystemDecimals">
<property name="toolTip">
<string>Cursor coordinates will use the system decimals setting instead of the short form</string>
@@ -516,12 +565,15 @@ Works only when &quot;Restore camera position after editing&quot; is enabled.</s
</customwidgets>
<tabstops>
<tabstop>EditSketcherFontSize</tabstop>
<tabstop>ConstraintSymbolSize</tabstop>
<tabstop>viewScalingFactor</tabstop>
<tabstop>SegmentsPerGeometry</tabstop>
<tabstop>dialogOnDistanceConstraint</tabstop>
<tabstop>continueMode</tabstop>
<tabstop>constraintMode</tabstop>
<tabstop>checkBoxHideUnits</tabstop>
<tabstop>checkBoxShowCursorCoords</tabstop>
<tabstop>checkBoxUseSystemDecimals</tabstop>
<tabstop>checkBoxShowDimensionalName</tabstop>
<tabstop>prefDimensionalStringFormat</tabstop>
<tabstop>checkBoxTVHideDependent</tabstop>
@@ -550,5 +602,21 @@ Works only when &quot;Restore camera position after editing&quot; is enabled.</s
</hint>
</hints>
</connection>
<connection>
<sender>checkBoxUseConstraintSymbolSize</sender>
<signal>toggled(bool)</signal>
<receiver>ConstraintSymbolSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>0</x>
<y>0</y>
</hint>
<hint type="destinationlabel">
<x>0</x>
<y>0</y>
</hint>
</hints>
</connection>
</connections>
</ui>