-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New snapping modes: Centroid and middle of a segment (midpoint) #33622
Conversation
Very nice -- that's a welcome addition! |
Nice. How does the advanced snapping mode's layers list widget looks like now? |
@lbartoletti , if I wasn't clear, here's what I meant to refer to: |
@lbartoletti , could you replace "snapping active" with a list of active snapping types? |
@nirvn It was my first intentention, but I removed it becaus I thought that was a too long text when there is more than two For ex modes, "vertex, segment, middle, centroid". But I agree that it would be better than "active snapping". Do you have any ideas? |
@lbartoletti , what about clipping the string list to two items if more than two are selected? For e.g., "vertex, segment, etc." |
Done. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a nice addition, love it :)
I am mainly commenting on the API and project.
I would let @wonder-sk look at the core snapping part.
I have some minor requests.
This is such an incredible quality-of-life improvement. Thank you, so, so much! |
@@ -238,6 +256,35 @@ This method is either blocking or non blocking according to ``relaxed`` paramete | |||
.. versionadded:: 3.6 | |||
%End | |||
|
|||
MatchList centroidsInRect( const QgsRectangle &rect, QgsPointLocator::MatchFilter *filter = 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MatchList centroidsInRect( const QgsRectangle &rect, QgsPointLocator::MatchFilter *filter = 0 ); | |
MatchList centroidsInRectangle( const QgsRectangle &rectangle, QgsPointLocator::MatchFilter *filter = 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also with the other newly added methods)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. But was to match with older methods, and I think it's better to be consistent with the old ways, isn't it? Maybe a note fore QGIS 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say better do it now in this case, less refactoring is not bad :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it's an API break?
QgsGeometry *geom = mLocator->mGeoms.value( id ); | ||
QgsPointXY pt; | ||
int afterVertex; | ||
double sqrDist = geom->closestSegmentWithContext( mSrcPoint, pt, afterVertex, nullptr, POINT_LOC_EPSILON ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm -- the closest segment won't necessarily equate to the closest segment's midpoint, will it? (Think a close but very long segment vs a slightly more distant but very short segment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, All my manuals tests worked well (tm)
But I'm interested in exploring it further if it comes to be confirmed.
c72650e
to
9877642
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering what is the meaning of snapping to area - is it actually useful to have it as an option? Do I understand correctly that it would snap to any point within a polygon?
9877642
to
336dfcc
Compare
Honnestyl, I discover it when I started to work on this feature... Yes it snaps to any point within a polygon. |
One use case I can see for snap to area is the possibility to draw a line or point on(to) a polygon and use attributes from this polygon in the default value expression trough |
ab69591
to
e53347b
Compare
@lbartoletti A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged. Please update the description (not the comments) with helpful description and screenshot to help the work from documentors. Thank you! |
7506787
to
272565f
Compare
272565f
to
dd7a822
Compare
@nyalldawson it's too late to be merged in 3.12? |
@lbartoletti that's not my decision to make -- you'll need to ask @jef-n |
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
|
@3nids Denis, please, can you remove the "requested changes" since I can use scoped enum with QT 5.9? @3nids @nyalldawson I bumped the version in my last commit but I'm not sure if it's OK if we want to merge it now? |
for the parts I was involved, I'm for a merge. |
Thanks Denis. |
@lbartoletti |
@lbartoletti I've pushed the button, thanks for your work ! |
Description
This PR is part of my proposal to improve snapping modes in QGIS by getting closer to the experience of CAD tools.
It proposes two new modes. Snapping on the center of a geometry (centroid) and the middle of a segment.
To allow the selection of these new modes, I changed the interface of the combo box allowing to select several modes at the same time.
I took the opportunity to display the snap on an area that was present in previous versions but not selectable.
On the code side, QgsSnappingConfig::SnappingType become flags. It also changes the project file. I added a control in QgsSnappingConfig::readProject
The order of preference for snapping is as follows:
Sponsored by: Qwat group / Ville de Lausanne ( @ponceta @dsavary ) / Oslandia and some spare time
Checklist
Fixes #11111
at the bottom of the commit messagescripts/prepare-commit.sh
script before each commit