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

In georeferencer, allow to move and delete GCPs without perfect aiming #37256

Closed
wants to merge 4 commits into from

Conversation

uclaros
Copy link
Contributor

@uclaros uclaros commented Jun 16, 2020

Description

In the georeferencer, one has to aim frustratingly good in order to use the Delete GCP and Move GCP point tool.
This PR fixes this by allowing a manhattan distance of 10 between the mouse cursor and the actual GCP, similarly to the way the vertex tool works.

QgsGeorefDataPoint::contains is no longer used; should I remove it?

@github-actions github-actions bot added this to the 3.14.0 milestone Jun 16, 2020
@nirvn
Copy link
Contributor

nirvn commented Jun 17, 2020

Nice, that's a nice PITA taken care of.

@uclaros uclaros closed this Jun 17, 2020
@uclaros uclaros reopened this Jun 17, 2020
// This is the manhattan length from mouse cursor point to GCP
// We will use this distance to pick the closest GCP to the cursor
// GCPs farther than the initial minDistance are too far and are ignored
qreal minDistance = 10;
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of the hardcoded value -- could we use QgsMapTool::searchRadiusMU/QgsMapTool::searchRadiusMM() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we could, but is there a real benefit from it?
AFAICT, searchRadiusMM is pretty much tied to the identify tool, so the options and code comment descriptions will have to be adapted too.
I can imagine someone raising this value to identify multiple features at once, or minimizing it for better identify precision, and then struggle with the georeferencer and his strange searchRadiusMM value choice!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm - I think we need an equivalent central method for map editing tools then. My concern with a hardcoded pixel value is that it's going to be completely inappropriate for certain setups (e.g. hidpi screens). We need something which accounts for dpi also, which is why a mm based size would be preferable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is also the Search radius for vertex edits setting (/qgis/digitizing/search_radius_vertex_edit) that looks more appropriate, but it can also be set for map units which makes no sense for the georeferencer case...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nyalldawson I think the easiest solution is to just set the hardcoded value to a larger number if 10 is too small for hidpi displays (I cannot test).
A too small value will make the tool function like it does now, needing better aiming from the user.
A slightly large value will cause no real issue, since the GCP closest to the click point will be moved, the user will still expect this GCP to be moved.
A huge value could be a little strange as the closest GCP might be very far from the click position and the user might not make the connection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave qreal minDistance = mCanvas->physicalDpiX() / 10; a shot and it works nice though slightly different on each of my two displays. Could you please test it on a hidpi setup?

Copy link
Member

Choose a reason for hiding this comment

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

Gives around 7mm radius here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also get around 7mm on a 24" 1920x1080 display and around 3mm on a 13" 1366x768 display.
Both values are very usable, way better than the current 0.1mm imho! =p
What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think having involving dpi is a very good thing. And the number 10 should be configurable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, if it's configurable then there is no need for it to be dpi dependent, is it?

@nyalldawson nyalldawson modified the milestones: 3.14.0, 3.16.0 Jun 19, 2020
@stale
Copy link

stale bot commented Jul 3, 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 stale Uh oh! Seems this work is abandoned, and the PR is about to close. and removed stale Uh oh! Seems this work is abandoned, and the PR is about to close. labels Jul 3, 2020
@stale
Copy link

stale bot commented Aug 29, 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 Aug 29, 2020
@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 4, 2020
@uclaros uclaros closed this Sep 7, 2020
@uclaros uclaros reopened this Sep 7, 2020
@stale
Copy link

stale bot commented Oct 4, 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 Oct 4, 2020
@uclaros
Copy link
Contributor Author

uclaros commented Oct 9, 2020

Do you think this is on the right track? Should I un-stale it or should I let it go?

@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Oct 9, 2020
@m-kuhn
Copy link
Member

m-kuhn commented Oct 10, 2020

I think this is on a good track. But we need the factor (10) to be configurable (visual impairment or other specific environment). Still for a good default value or multi screen setups the dpi needs to be taken into account. I.e. the config should reflect distance in mm, not pixels. Ideally this is shared with another setting as discussed earlier.

@nyalldawson nyalldawson modified the milestones: 3.16.0, 3.18 (Feature) Oct 23, 2020
@stale
Copy link

stale bot commented Nov 7, 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 Nov 7, 2020
@uclaros
Copy link
Contributor Author

uclaros commented Nov 13, 2020

Giving this a last look before abandoning and noticed there could be a much simpler approach:
Right now, the gcp-clicked logic uses QgsGeorefDataPoint::contains() which in turn calls mGCPSourceItem->shape().contains(); . Contrary to what I thought at first, mGCPSourceItem->shape() is not the QPainterPath used to draw the point on the canvas, but a temporary QPainterPath with the same ellipse size, used only to perform this contains() query.
That means we could enlarge the ellipse returned by mGCPSourceItem->shape() by doubling or quadrupling its radii, without affecting the displayed point size while doubling or quadrupling the click distance uniformly for low dpi and hidpi layouts.
What do you think?

@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Nov 13, 2020
@nirvn
Copy link
Contributor

nirvn commented Nov 29, 2020

@uclaros , I'd love to see this pushed through the finish line. Are you able to take @m-kuhn 's comments into account and adjust the PR?

@uclaros
Copy link
Contributor Author

uclaros commented Dec 1, 2020

@nirvn

  • Regarding configurability, I can add a georeferencer specific setting.
  • Regarding mm instead of pixels, I am not sure how I can achieve that if not with mCanvas.physicalDpiX() or Y. Any input is welcome.
  • Regarding reusing other setting, there are two candidate settings but none of them is appropriate as discussed.

@m-kuhn
Copy link
Member

m-kuhn commented Dec 1, 2020

Can you remind me what's wrong with physicalDpi?

@uclaros
Copy link
Contributor Author

uclaros commented Dec 3, 2020

One problem is it does not work as I expected, I might be misunderstanding something:
Right now, I am using qreal minDistance = mCanvas->physicalDpiX() / 10; expecting a distance of 0.1inch or 2.5mm but, as I mentioned in the discussion, I get 7mm on a 24" 1920x1080 display and around 3mm on a 13" 1366x768 display.

Furthermore, I came to realize that we do not want this distance to be in mm. We want this distance to be measured in the smallest unit of the feedback of the user's interaction, ie the smallest distance one can move the mouse and see it moving on the screen.
For normal displays that unit is the pixel. Not sure what that is for hidpi, it could be pixel * mCanvas->devicePixelRatioF()?

@uclaros
Copy link
Contributor Author

uclaros commented Dec 7, 2020

Update:

  1. Added a georeferencer specific setting for the minimum point selection distance, with a default value of 10, minimum 4.
    image

  2. Multiplied the distance by mCanvas->devicePixelRatioF(), to increase the distance proportionally for hidpi

  3. Compare with the actual distance instead of the manhattan length so we have an theoretical circle instead of a rhombus.

  4. Added ctrl+e shortcut to move GCP. Add is ctrl+a, delete is ctrl+d. Ctrl+m was not used because it is not a one hand shortcut.

  5. Rebased

@uclaros
Copy link
Contributor Author

uclaros commented Dec 23, 2020

@nirvn or @m-kuhn could you please evaluate the latest changes on a hidpi setup?

@m-kuhn
Copy link
Member

m-kuhn commented Dec 23, 2020

devicePixelRatio is 1.0 here despite the HiDpi screen. This might be a local configuration issue though.
Can you give me your numbers for:

iface.mapCanvas().devicePixelRatioF()
1.0
iface.mapCanvas().physicalDpiX()
210

P.S.

Furthermore, I came to realize that we do not want this distance to be in mm. We want this distance to be measured in the smallest unit of the feedback of the user's interaction, ie the smallest distance one can move the mouse and see it moving on the screen.

I dare to challenge this statement. When a user is aiming for a point, it's his eye and hand which are the limitation. These sensors don't work in pixels, they work in real world distances. So we want the setting and default value to be in mm and the computer calculate the equivalent in pixels for us.

@uclaros
Copy link
Contributor Author

uclaros commented Dec 25, 2020

iface.mapCanvas().devicePixelRatioF() is 1.0 for all my screens.
iface.mapCanvas().physicalDpiX() is 118 for my laptop's 1366x768 13" screen and 72 for my desktop's 1920x1080 24" screen.

I dare to challenge this statement. When a user is aiming for a point, it's his eye and hand which are the limitation. These sensors don't work in pixels, they work in real world distances. So we want the setting and default value to be in mm and the computer calculate the equivalent in pixels for us.

I do not agree. The hand and mouse sensor works in real world distances indeed, but it's all pixels once the pointer is displayed on the screen! You can see the mouse move less than a mm but you cannot see the mouse pointer move less than one pixel.
Here's a sample case with distance in mm to highlight the issue:
Let's say we wanted the default distance to be 10mm. That translates to 28 pixels on my 24" screen, not too big, not too small, nice ux.
On a 3.5" 1080p portable monitor 10mm would be like 130 pixels, allowing the mouse to move 5 times the distance on the mousepad than with the bigger screen.
Then on a 75" tv with the same resolution that would be almost 10 pixels, 3 times harder to point with the mouse than on the normal screen.

@m-kuhn
Copy link
Member

m-kuhn commented Dec 25, 2020

On a 3.5" 1080p portable monitor 10mm would be like 130 pixels, allowing the mouse to move 5 times the distance on the mousepad than with the bigger screen.

Are you sure that's how things work? I.e. the higher the physical dpi the slower your mouse moves on the screen?

@uclaros
Copy link
Contributor Author

uclaros commented Dec 25, 2020

AFAIK, same distance traveled by the mouse on the mouse pad results in same pixels traveled by the pointer on the screen, regardless of screen size or resolution (granted that no mouse acceleration setting is enabled of course).
You can test this by lowering your screen resolution, then checking that you can reach the screen bounds with smaller mouse movements.
Merry X-mas!

@m-kuhn
Copy link
Member

m-kuhn commented Dec 25, 2020

Even if this is true, the main reason for me stays visual recognition. What I perceive as "close enogh to snap" is not related to pixels.

@uclaros
Copy link
Contributor Author

uclaros commented Dec 25, 2020

What I perceive as "close enogh to snap" is not related to pixels.

It definitely is. If 10mm was your close enough to snap, would you be able to operate on a concert video wall where pixels are 10mm apart?

@m-kuhn
Copy link
Member

m-kuhn commented Dec 25, 2020

You are right,it's not perfect. But still better than px for the average everyday gis scenario I guess? And I cannot see a perfect solution unfortunately.

@uclaros
Copy link
Contributor Author

uclaros commented Dec 25, 2020

I am sorry, but I completely disagree. If it was in any way better than px then snapping tolerance would have been implemented in screen mm instead of px. Same for qt buttons and menus and widgets in general.

@nyalldawson
Copy link
Collaborator

@uclaros that's not quite right -- a lot of this stuff was in place from way before hidpi was even a concept, so we can't take past decisions as correct here.

For reference, all the qt docs describe best practice as basing screen sizes on font metrics (ie real world units like mm) instead of pixels.

@uclaros
Copy link
Contributor Author

uclaros commented Dec 25, 2020

font metrics (ie real world units like mm)

I don't think that is so. Font metrics actually mean pixels, after any scaling done by the os or the display driver. Hence, QFontMetrics and QFontMetricsF methods return values are in pixels

@nyalldawson
Copy link
Collaborator

Font metrics return pixels, but they are converted from fixed values in terms of character sizes (in real world units). That's why they are used as a conversion route from "how big should things actually appear on the screen" to "what size does this correspond to in pixels"

@uclaros
Copy link
Contributor Author

uclaros commented Dec 26, 2020

Wouldn't then a QFont font("times", 24); need to be the same size in mm on my phone, pc and videowall regardless of screen resolution?

@nyalldawson
Copy link
Collaborator

@uclaros you omit the font size -- ie.

QFontMetrics fm( QFont() );

that uses the default application font sizing then -- so basically ui elements and measurements are effectively specified in "multiple of menu/standard widget height" units. The thinking there is that for a videowall the user will have already set the default font size to a suitable size, using whatever scaling factors/dpi/font size settings their particular operating system offers.

@uclaros
Copy link
Contributor Author

uclaros commented Dec 26, 2020

Maybe I'm tired, but I still do not see where real world units are. Isn't the default application font defined by the application itself, regardless of display?

@github-actions
Copy link

github-actions bot commented Jan 9, 2021

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.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 9, 2021
@github-actions
Copy link

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Uh oh! Seems this work is abandoned, and the PR is about to close.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants