Skip to content

Commit

Permalink
Add getToleranceMultiplier.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenD98 committed Jan 31, 2025
1 parent d8c6997 commit aa21c33
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
28 changes: 25 additions & 3 deletions src/qml/CoordinateLocator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ Item {
if (!rubberbandModel) {
return;
}
const MINIMAL_PIXEL_DISTANCE_TRESHOLD = 20;
const SOFT_CONSTRAINT_TOLERANCE_DEGREES = 20;
const SOFT_CONSTRAINT_TOLERANCE_PIXEL = 40;
const MINIMAL_PIXEL_DISTANCE_TRESHOLD = 20 * getToleranceMultiplier();
const SOFT_CONSTRAINT_TOLERANCE_DEGREES = 20 * getToleranceMultiplier();
const SOFT_CONSTRAINT_TOLERANCE_PIXEL = 40 * getToleranceMultiplier();
const rubberbandPointsCount = rubberbandModel.vertexCount;
const targetPoint = mapCanvas.mapSettings.coordinateToScreen(forwardMode ? rubberbandModel.firstCoordinate : rubberbandModel.lastCoordinate);
const minimumDigitizedPoints = forwardMode ? 3 : 2;
Expand Down Expand Up @@ -446,6 +446,28 @@ Item {
}
}

/** Function to get the multiplier based on the selected tolerance
*
* - Narrow tolerance (index 0) divides by 2.
* - Normal tolerance (index 1) keeps unchanged.
* - Large tolerance (index 2) multiplies by 4.
*/
function getToleranceMultiplier() {
switch (snappingTolerance) {
case 0 // Narrow
:
return 0.5;
case 1 // Normal
:
return 1;
case 2 // Large
:
return 4;
default:
return 1;
}
}

/**
* Computes a new point that forms a common angle
*
Expand Down
5 changes: 3 additions & 2 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1747,9 +1747,10 @@ ApplicationWindow {
width: (angles.width - ((angles.count - 1) * angles.spacing)) / angles.count
height: width
radius: width / 2
color: selected ? Theme.mainColor : Theme.darkTheme ? Theme.gray : Theme.lightGray
color: selected ? Theme.mainColor : "transparent" // Theme.darkTheme ? Theme.gray : Theme.lightGray
enabled: !selected

// border.color: Theme.darkTheme ? Theme.gray : Theme.lightGray
property bool selected: modelData === coordinateLocator.snappingAngleDegrees

Text {
Expand Down Expand Up @@ -1817,7 +1818,7 @@ ApplicationWindow {
width: (tolorences.width - (tolorences.spacing * (tolorences.count - 1))) / tolorences.count
height: 35
radius: 4
color: selected ? Theme.mainColor : Theme.darkTheme ? Theme.gray : Theme.lightGray
color: selected ? Theme.mainColor : "transparent"
enabled: !selected

property bool selected: index === coordinateLocator.snappingTolerance
Expand Down

0 comments on commit aa21c33

Please sign in to comment.