[3d] add snapping support to the measure line tool#64662
[3d] add snapping support to the measure line tool#64662ptitjano wants to merge 10 commits intoqgis:masterfrom
Conversation
92826ef to
bd32f4c
Compare
🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. 🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. |
bd32f4c to
ef66d19
Compare
Co-authored-by: Jean Felder <jean.felder@oslandia.com>
Co-authored-by: Jean Felder <jean.felder@oslandia.com>
ef66d19 to
5d70c8a
Compare
|
@ptitjano Thank you for dissociating the highlight and snapping code, the PR is now much easier to browse and the structure is clearer. I have been looking into the method used for collecting snap candidates, which is a critical part of the design. Based on the code, the logic appears to be:
While this works for basic vertex snapping, relying on the existing ray casting introduces several architectural limitations that might prevent us from achieving full feature parity with 2D snapping:
I have discussed these challenges with @wonder-sk. We believe a more robust approach would be to move away from ray casting and implement a "picking texture" workflow. This would involve a separate render target (enabled only during snapping) to encode snapping data, similar to a depth buffer. Each pixel in the texture would store a key to recover the Layer ID, Feature ID, and Snapping Type for that location. On a minor note, it would be beneficial to dissociate the snapping functionality from the Measurement Tool and integrate it into a parent class. This would allow the new Python-exposed 3D map tools to utilize snapping as well. |
| * In case such triangle index does not match any feature, FID_NULL is returned. | ||
| */ | ||
| QgsFeatureId triangleIndexToFeatureId( uint triangleIndex ) const; | ||
| QgsFeatureId triangleIndexToFeatureId( uint triangleIndex, QVector3D ( *facePoints )[3] = nullptr ) const; |
There was a problem hiding this comment.
a comment to explain the optional returned facePoints vector could be added.
| Copyright : (C) 2025 by Benoit De Mezzo | ||
| Email : benoit dot de dot mezzo at oslandia dot com |
There was a problem hiding this comment.
| Copyright : (C) 2025 by Benoit De Mezzo | |
| Email : benoit dot de dot mezzo at oslandia dot com | |
| Copyright : (C) 2025 by Oslandia | |
| Email : benoit dot de dot mezzo at oslandia dot com, jean dot felder at oslandia dot com |
| Copyright : (C) 2025 by Benoit De Mezzo | ||
| Email : benoit dot de dot mezzo at oslandia dot com |
There was a problem hiding this comment.
| Copyright : (C) 2025 by Benoit De Mezzo | |
| Email : benoit dot de dot mezzo at oslandia dot com | |
| Copyright : (C) 2025 by Oslandia | |
| Email : benoit dot de dot mezzo at oslandia dot com, jean dot felder at oslandia dot com |
| copyright : (C) 2025 Oslandia | ||
| email : benoit dot de dot mezzo at oslandia dot com |
There was a problem hiding this comment.
| copyright : (C) 2025 Oslandia | |
| email : benoit dot de dot mezzo at oslandia dot com | |
| Copyright : (C) 2025 by Oslandia | |
| Email : benoit dot de dot mezzo at oslandia dot com, jean dot felder at oslandia dot com |
| copyright : (C) 2025 Oslandia | ||
| email : benoit dot de dot mezzo at oslandia dot com |
There was a problem hiding this comment.
| copyright : (C) 2025 Oslandia | |
| email : benoit dot de dot mezzo at oslandia dot com | |
| Copyright : (C) 2025 by Oslandia | |
| Email : benoit dot de dot mezzo at oslandia dot com, jean dot felder at oslandia dot com |
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|


Description
This PR adds snapping support to the measure line tool for vector layers. Contrary to #64329, this does not contain any vector highlight capability.
Snapping ToolBar
A Snapping toolbar is added to the 3D window. It allows to :
The following snapping options are handled:
Snapping Manager (Qgs3DSnappingManager)
Qgs3DSnappingManageris introduced to handle the 3D snapping and its options.If no snapping is found or if the snapping is disabled, the closest point is simply returned.
If a snapping is found:
With this change the snapping manager has two purposes:
The snapping manager is created by
Qgs3DMapCanvasWidget. It can then be passed to the different tools which need it. The snapping options are retrieved by the values sets through the snapping toolbarRay tracing changes
QgsRayContextandQgsRayCastHitare extended to retrieve the vertex faces on hits. It allows to get the closest face, segments and points from the mouse cursor. It is then consumed byQgs3DSnappingManagerMeasure line tools changes
QgsMeasureLineToolis adapted to consume the results ofQgs3DSnappingManagerand manage it:Other changes
QgsRubberband3Dis extended to handle more shapes. As a result, the marker shaped is stored asQgis::MarkerShapeinstead of the customQgsRubberBand3D::MarkerTypeDemo
Kooha-2026-01-22-19-55-05.mp4
Funded by Stadt Frankfurt am Main