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

3127 adding custom text to a graph causes it to go blank #3128

Merged

Conversation

jamescrake-merani
Copy link
Contributor

Description

Fixes #3127

How Has This Been Tested?

Tested on Ubuntu. Haven't had a chance to test it on Mac but will do later.

Review Checklist:

[if using the editor, use [x] in place of [ ] to check a box]

Documentation (check at least one)

  • There is nothing that needs documenting
  • Documentation changes are in this PR
  • There is an issue open for the documentation (link?)

Installers

  • There is a chance this will affect the installers, if so
    • Windows installer (GH artifact) has been tested (installed and worked)
    • MacOSX installer (GH artifact) has been tested (installed and worked)

Licencing (untick if necessary)

  • The introduced changes comply with SasView license (BSD 3-Clause)

Copy link
Contributor

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

It's not clear to me why this fixes the issue based on the changes, but Mac plots were blanking when adding text in RC2, and are displaying properly here.

Would it be possible to add some in-line comments? That might give others a better understanding of why these changes were made.

@jamescrake-merani
Copy link
Contributor Author

Good point! I will add comments. After which, if they look good to you then I think this PR is ready to merge.

The bug seems to have been the culprit of two issues:

  • The style of the font was being set but the wrong value was being passed into the set_style method. This should have caused an exception but it looks like there was some exception handling that just ignored the exception, and continued. This left the plot in a broken state, and I think whenever Matplotlib tried to draw the graph again, it wouldn't be able to properly. This might also explain why the behaviour differs between operating system; it might have something to do with how the graph is being drawn.
  • There was also a problem with how the position of the text was being retrieved. Normally, when someone left clicks on the graph, it will update the xclick, and yclick positions. However, this only works on a left click; not a right click. You need to right click to access the context menu in order to add text but if you never left clicked, there would be no position to add the text to. My fix simply updates these coordinates on every click so that, after accessing the context menu, there should be a position to add the text to now.

@jamescrake-merani
Copy link
Contributor Author

Added the comments. @krzywon Please could you check if they are ok, and then please merge if they are :)

@krzywon krzywon merged commit 5b53850 into release_6.0.0 Oct 18, 2024
37 checks passed
@krzywon krzywon deleted the 3127-adding-custom-text-to-a-graph-causes-it-to-go-blank branch October 18, 2024 14:58
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.

2 participants