diff --git a/app/map/inputmapsettings.cpp b/app/map/inputmapsettings.cpp index a529313e3..2dfcfe09a 100644 --- a/app/map/inputmapsettings.cpp +++ b/app/map/inputmapsettings.cpp @@ -81,8 +81,13 @@ void InputMapSettings::setExtent( const QgsRectangle &extent ) if ( mMapSettings.extent() == extent ) return; + const bool scaleDidChange = !qgsDoubleNear( mMapSettings.extent().width(), extent.width() ); + mMapSettings.setExtent( extent ); emit extentChanged(); + + if ( scaleDidChange ) + emit scaleChanged(); } QgsPoint InputMapSettings::center() const diff --git a/app/map/inputmapsettings.h b/app/map/inputmapsettings.h index e8fac298e..a27e1883a 100644 --- a/app/map/inputmapsettings.h +++ b/app/map/inputmapsettings.h @@ -290,6 +290,9 @@ class InputMapSettings : public QObject //! \copydoc InputMapSettings::extent void extentChanged(); + //! Fired after extentChanged() if the new extent is on a different map scale + void scaleChanged(); + //! \copydoc InputMapSettings::destinationCrs void destinationCrsChanged(); diff --git a/app/maptools/recordingmaptool.cpp b/app/maptools/recordingmaptool.cpp index 6a8341ce2..740897cfe 100644 --- a/app/maptools/recordingmaptool.cpp +++ b/app/maptools/recordingmaptool.cpp @@ -1314,7 +1314,8 @@ QgsPoint RecordingMapTool::handlePoint( QgsPoint p1, QgsPoint p2 ) return QgsPoint(); } - double h = 15 * mapSettings()->mapUnitsPerPixel(); + constexpr int HANDLE_PIXEL_OFFSET = 42; + double h = HANDLE_PIXEL_OFFSET * mapSettings()->mapUnitsPerPixel(); double factor = QgsUnitTypes::fromUnitToUnitFactor( mapSettings()->destinationCrs().mapUnits(), mActiveLayer->crs().mapUnits() ); QgsDistanceArea da; da.setEllipsoid( QStringLiteral( "WGS84" ) ); diff --git a/app/maptools/recordingmaptool.h b/app/maptools/recordingmaptool.h index 0587fde9c..efc5d49ce 100644 --- a/app/maptools/recordingmaptool.h +++ b/app/maptools/recordingmaptool.h @@ -278,17 +278,19 @@ class RecordingMapTool : public AbstractMapTool public slots: void onPositionChanged(); - private slots: - void prepareEditing(); - void onFeatureAdded( QgsFeatureId newFeatureId ); - /** * Creates nodes index. Extracts existing geometry vertices and generates virtual * vertices representing midpoints (for lines and polygons) and start/end points * (for lines). + * This is also called whenever the map scale changes so that start/end point positions + * can have a stable pixel offset. Also to skip midpoints for segments below a size threshold. */ void collectVertices(); + private slots: + void prepareEditing(); + void onFeatureAdded( QgsFeatureId newFeatureId ); + /** * Creates geometries represeinting existing nodes, midpoints (for lines and polygons), * start/end points and "handles" (for lines) from the nodes index. diff --git a/app/qml/map/MMHighlight.qml b/app/qml/map/MMHighlight.qml index fb16f35a4..d52f8bd46 100644 --- a/app/qml/map/MMHighlight.qml +++ b/app/qml/map/MMHighlight.qml @@ -280,6 +280,10 @@ Item { id: shape anchors.fill: parent + // The newer CurveRenderer is used for dashed lines to avoid a bug causing off-screen lines to be generated as empty + // see https://github.com/MerginMaps/mobile/issues/2280 + preferredRendererType: highlight.lineStrokeStyle === ShapePath.DashLine ? Shape.CurveRenderer : Shape.UnknownRenderer + transform: Matrix4x4 { // the formula for x coordinate for map to screen coordinates conversion goes like this: // x_screen = (x_map + offset_x) * scale / ddp diff --git a/app/qml/map/MMMapController.qml b/app/qml/map/MMMapController.qml index 158700fd8..0ffce7e85 100644 --- a/app/qml/map/MMMapController.qml +++ b/app/qml/map/MMMapController.qml @@ -1239,6 +1239,16 @@ Item { } } + + Connections { + target: mapCanvas.mapSettings + function onScaleChanged() { + if ( recordingToolsLoader.active ) { + recordingToolsLoader.item.recordingMapTool.collectVertices() + } + } + } + Connections { target: __activeProject