Skip to content

Commit

Permalink
Merge pull request #3128 from SasView/3127-adding-custom-text-to-a-gr…
Browse files Browse the repository at this point in the history
…aph-causes-it-to-go-blank

3127 adding custom text to a graph causes it to go blank
  • Loading branch information
krzywon authored Oct 18, 2024
2 parents 8b0da66 + 50bbddf commit 5b53850
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/sas/qtgui/Plotting/Plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,9 @@ def onAddText(self):
# MPL style names
styles = ['normal', 'italic', 'oblique']
# QFont::Style maps directly onto the above
try:
mpl_font.set_style(styles[extra_font.style()])
except:
pass
# Get an index of the font style which we can then lookup in the styles list.
font_index = extra_font.style().value
mpl_font.set_style(styles[font_index])

if len(extra_text) > 0:
new_text = self.ax.text(pos_x,
Expand Down Expand Up @@ -919,6 +918,13 @@ def onMplMouseDown(self, event):
"""
Left button down and ready to drag
"""
# Before checking if this mouse click is a left click, we need to update the position of the mouse regardless as
# this may be needed by other events (e.g. adding text)
try:
self.x_click = float(event.xdata) # / size_x
self.y_click = float(event.ydata) # / size_y
except:
self.position = None
# Check that the LEFT button was pressed
if event.button != 1:
return
Expand All @@ -930,11 +936,6 @@ def onMplMouseDown(self, event):
return
if event.inaxes is None:
return
try:
self.x_click = float(event.xdata) # / size_x
self.y_click = float(event.ydata) # / size_y
except:
self.position = None

x_str = GuiUtils.formatNumber(self.x_click)
y_str = GuiUtils.formatNumber(self.y_click)
Expand Down

0 comments on commit 5b53850

Please sign in to comment.