Skip to content

Commit

Permalink
[Sketcher] Allow user to revert to legacy axes size via Preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Syres916 authored Jan 22, 2025
1 parent 433a51b commit b99d33c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
25 changes: 25 additions & 0 deletions src/Mod/Sketcher/Gui/EditModeCoinManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,13 @@ void EditModeCoinManager::processGeometryConstraintsInformationOverlay(

processGeometryInformationOverlay(geolistfacade);

ParameterGrp::handle hGrpskg = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Sketcher");

if (hGrpskg->GetBool("UseLegacyAxes", false)) {
updateLegacyAxesLength();
}

pEditModeConstraintCoinManager->processConstraints(geolistfacade);
}

Expand Down Expand Up @@ -864,6 +871,24 @@ void EditModeCoinManager::updateAxesLength(const Base::BoundBox2d& bb)
SbVec3f(0.0f, bb.MaxY, zCrossH));
}

void EditModeCoinManager::updateLegacyAxesLength()
{
auto zCrossH = ViewProviderSketchCoinAttorney::getViewOrientationFactor(viewProvider)
* drawingParameters.zCross;
editModeScenegraphNodes.RootCrossCoordinate->point.set1Value(
0,
SbVec3f(-analysisResults.boundingBoxMagnitudeOrder, 0.0f, zCrossH));
editModeScenegraphNodes.RootCrossCoordinate->point.set1Value(
1,
SbVec3f(analysisResults.boundingBoxMagnitudeOrder, 0.0f, zCrossH));
editModeScenegraphNodes.RootCrossCoordinate->point.set1Value(
2,
SbVec3f(0.0f, -analysisResults.boundingBoxMagnitudeOrder, zCrossH));
editModeScenegraphNodes.RootCrossCoordinate->point.set1Value(
3,
SbVec3f(0.0f, analysisResults.boundingBoxMagnitudeOrder, zCrossH));
}

void EditModeCoinManager::updateColor()
{
auto geolistfacade = ViewProviderSketchCoinAttorney::getGeoListFacade(viewProvider);
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Sketcher/Gui/EditModeCoinManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ class SketcherGuiExport EditModeCoinManager
// Updates the Axes extension to span the specified area.
void updateAxesLength(const Base::BoundBox2d& bb);

// updates the Axes length to extend beyond the calculated bounding box magnitude
void updateLegacyAxesLength();

private:
// This function populates the coin nodes with the information of the current geometry
void processGeometry(const GeoListFacade& geolistfacade);
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Sketcher/Gui/SketcherSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ void SketcherSettingsDisplay::saveSettings()
ui->checkBoxUseSystemDecimals->onSave();
ui->checkBoxShowDimensionalName->onSave();
ui->prefDimensionalStringFormat->onSave();
ui->checkBoxUseLegacyAxes->onSave();
ui->checkBoxTVHideDependent->onSave();
ui->checkBoxTVShowLinks->onSave();
ui->checkBoxTVShowSupport->onSave();
Expand All @@ -444,6 +445,7 @@ void SketcherSettingsDisplay::loadSettings()
ui->checkBoxUseSystemDecimals->onRestore();
ui->checkBoxShowDimensionalName->onRestore();
ui->prefDimensionalStringFormat->onRestore();
ui->checkBoxUseLegacyAxes->onRestore();
ui->checkBoxTVHideDependent->onRestore();
ui->checkBoxTVShowLinks->onRestore();
ui->checkBoxTVShowSupport->onRestore();
Expand Down
16 changes: 16 additions & 0 deletions src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@ Defaults to: %N = %V
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxUseLegacyAxes">
<property name="toolTip">
<string>If checked, reverts to the legacy method for setting the size of the axes.</string>
</property>
<property name="text">
<string>Use Legacy Axes (non-infinite length)</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseLegacyAxes</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
Expand Down
19 changes: 12 additions & 7 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3546,13 +3546,18 @@ void ViewProviderSketch::onCameraChanged(SoCamera* cam)
Base::Interpreter().runStringObject(cmdStr.toLatin1());
}

// Stretch the axes to cover the whole viewport.
Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>(this->getActiveView());
if (view) {
Base::Placement plc = getEditingPlacement();
const Base::BoundBox2d vpBBox = view->getViewer()
->getViewportOnXYPlaneOfPlacement(plc);
editCoinManager->updateAxesLength(vpBBox);
ParameterGrp::handle hGrpskg = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Sketcher");

if (!hGrpskg->GetBool("UseLegacyAxes", false)) {
// Stretch the axes to cover the whole viewport.
Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>(this->getActiveView());
if (view) {
Base::Placement plc = getEditingPlacement();
const Base::BoundBox2d vpBBox = view->getViewer()
->getViewportOnXYPlaneOfPlacement(plc);
editCoinManager->updateAxesLength(vpBBox);
}
}

drawGrid(true);
Expand Down

0 comments on commit b99d33c

Please sign in to comment.