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

45 Move the view of the viewbox to a given position #57

Merged
merged 11 commits into from
Jul 20, 2024

Conversation

mariehartung
Copy link
Collaborator

resolves #45

This draft PR will be transformed into a full pull request as soon as issue 10 is merged into main. Therefore, this can already be reviewed.

View of the viewbox can be moved using normalized coordinates

The following changes were implemented in the class MainW in cellpose/gui/gui.py:

  • method center_view_on_position was created
  • method takes normalized coordinates as input
  • height and width of image are extracted using self.img.image.shape and used to calculate new positions
  • current zoom is calculated using view-range self.p0.viewRange(): used to calculate width and height of view range to maintain zoom level
  • new view range with given coordinates as center is calculated and implemented

Information for testing

This issue is part of the former ticket 13. The extraction of the coordinates will be implemented in ticket 44. Ticket 46 will combine the two features.
For testing the functionality of this implementation, I recommend calling the function using self.center_view_on_position(0.5, 0.5) in the method minimap_window in gui.py.
The parameters 0.5, 0.5 refer to normalized x- and y-coordinates; this will put the center of the current image at the center of the view box. When using the minimap_window method, the minimap button in the menu will have to be (un)toggled to call this method.
I suggest trying out different values (between 0 and 1) as well as different zoom levels.

Showcase

Zoom
For a picture zoomed out, this should look (when using 0.5, 0.5) similar to this:
image
And for a picture zoomed in, similar to this:
image
Coordinates
When using different values than 0.5, 0.5, other parts of the picture should be at the center:
E.g. for 0,0, the upper left corner should be at the center:
image

@mariehartung mariehartung self-assigned this Jul 15, 2024
@mariehartung mariehartung marked this pull request as ready for review July 16, 2024 15:23
@RenzoRichter RenzoRichter added this to the Minimap milestone Jul 17, 2024
@RukiyyeE RukiyyeE self-requested a review July 17, 2024 16:02
RukiyyeE
RukiyyeE previously approved these changes Jul 17, 2024
Copy link
Collaborator

@RukiyyeE RukiyyeE left a comment

Choose a reason for hiding this comment

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

It looks good! I tested the function as described with different coordinates in minimap_window, and the images are centered as expected. The code is well documented and structured. Running Cellpose does not produce any error messages, and the code does not cause any issues. I don't have any suggestions for changes anymore and would therefore approve it. Great job :)

@mariehartung mariehartung dismissed RukiyyeE’s stale review July 17, 2024 16:04

The merge-base changed after approval.

@RukiyyeE RukiyyeE self-requested a review July 18, 2024 18:25
RukiyyeE
RukiyyeE previously approved these changes Jul 19, 2024
@mariehartung mariehartung dismissed RukiyyeE’s stale review July 19, 2024 09:46

The merge-base changed after approval.

@mariehartung mariehartung marked this pull request as draft July 19, 2024 22:45
@github-actions github-actions bot added size/XXL and removed size/M labels Jul 20, 2024
@mariehartung mariehartung marked this pull request as ready for review July 20, 2024 08:42
Copy link
Collaborator

@NicolasDelgadoL NicolasDelgadoL left a comment

Choose a reason for hiding this comment

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

Great job! The code has a very clear structure and is well commented, it reflects how the problem was broken down into smaller steps and makes it easy to understand whats happening. I also didn't encounter any bugs or errors while testing and would approve 👍

@RukiyyeE RukiyyeE self-requested a review July 20, 2024 13:22
@mariehartung mariehartung merged commit f6f9fdb into main Jul 20, 2024
2 checks passed
@mariehartung mariehartung deleted the 45_move_the_view_of_the_viewbox branch July 20, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

move the view of the viewbox to a given position (minimap navigation)
4 participants