Skip to content
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

Update vertex tool to base its snapping parameters on global ones #36231

Merged
merged 3 commits into from
Jun 4, 2020

Conversation

obrix
Copy link

@obrix obrix commented May 6, 2020

Update vertex tool to not override some of the global snapping parameters (especially snapping enabled on a scale range).

Keep some of the specific behavior of enabling snapping in priority on an active layer (ie creation of a specific layer settings, now based an existing one if present).

Should fix #36229

…ters (especially snapping enabled on a scale range).

Keep some of the specific behavior which is there for a reason (ie creation of of specific layer settings, now based on the existing one if present).
Should fix qgis#36229
@obrix obrix requested a review from troopa81 May 6, 2020 09:10
@obrix obrix self-assigned this May 6, 2020
@github-actions github-actions bot added this to the 3.14.0 milestone May 6, 2020
vlayer == currentVlayer, static_cast<QgsSnappingConfig::SnappingTypeFlag>( QgsSnappingConfig::VertexFlag | QgsSnappingConfig::SegmentFlag ), tol, QgsTolerance::ProjectUnits, 0.0, 0.0 ) );
QgsSnappingConfig::IndividualLayerSettings layerSettings;
SettingsHashMap::const_iterator existingSettings = oldLayerSettings.find( vlayer );
if ( existingSettings != oldLayerSettings.constEnd() )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be simpler to initialize config with oldconfig and just changing the IndividualLayerSettings enabled boolean according to whether its the currentLayer or not (or editable layer for the following code) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes probably if we are sure there is always an existing IndividualLayerSetting for each layer which I am not. Also tolerance, typeflag and units are overridden here for each setting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! I still wondering if it would not be better to initialize config with oldConfig one. If someone adds a new SnapingConfig parameter, it would not be takein into count here.

But maybe it's better this way

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think your are right for the initial config init with old config. I will do that.

@@ -94,7 +94,7 @@ bool QgsSnappingUtils::isIndexPrepared( QgsPointLocator *loc, const QgsRectangle
if ( mStrategy == IndexAlwaysFull && loc->hasIndex() )
return true;

if ( mStrategy == IndexExtent && loc->hasIndex() && loc->extent()->intersects( areaOfInterest ) )
if ( mStrategy == IndexExtent && loc->hasIndex() && ( !loc->extent() || loc->extent()->intersects( areaOfInterest ) ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be possible to get in a situation where the strategy is IndexExtent and the locator has no extent defined, isn't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I had to add this check to avoid snapping to crash, so yes It seems to be possible with the state of the code. I did not really understood why though. Might be worth it to spend further time to investigate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discuss, it could happen when some QgsPointLocator methods (nearestvertex for instance) are called first outside of QgsSnappingUtils (in QgsVertexTool basically).

Then, when prepareIndex is called and so isIndexPrepared, extent is null and strategy is IndexExtent. So, your modification make sense.

@stale
Copy link

stale bot commented Jun 2, 2020

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

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jun 2, 2020
@obrix obrix closed this Jun 3, 2020
@obrix obrix reopened this Jun 3, 2020
@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vertex tool override global snapping parameters
3 participants