Skip to content

Commit

Permalink
Merge pull request #347 from jnsebgosselin/add_visual_cue_when_select…
Browse files Browse the repository at this point in the history
…ing_brf

PR: Add visual cue when selecting BRF period
  • Loading branch information
jnsebgosselin committed Oct 7, 2020
2 parents 518d2c7 + bc8f49c commit d3dc43a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions gwhat/HydroCalc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ def _draw_mouse_cursor(self, x, y):
self.vguide.set_xdata(x)
self.fig.axes[0].draw_artist(self.vguide)

# ----- Handlers: Mouse events
# ----- Mouse Event Handlers
def is_all_btn_raised(self):
"""
Return whether all of the tool buttons that can block the panning and
Expand Down Expand Up @@ -1386,12 +1386,11 @@ def on_mouse_move(self, event):
fig = self.fig
fig.canvas.restore_region(self.__figbckground)

# ---- Draw the cursor guide and the xy coordinates on the graph.

# Trace a red vertical guide (line) that folows the mouse marker :

# Draw the vertical cursor guide.
x, y = event.xdata, event.ydata
self._draw_mouse_cursor(x, y)

# Draw the xy coordinates on the graph.
if all((x, y)):
self.xycoord.set_visible(True)
if self.dformat == 0:
Expand All @@ -1403,7 +1402,6 @@ def on_mouse_move(self, event):
y, date[2], date[1], date[0]))
ax0.draw_artist(self.xycoord)
else:
self.vguide.set_visible(False)
self.xycoord.set_visible(False)

if self.rect_select_is_active and self.__mouse_btn_is_pressed:
Expand Down Expand Up @@ -1452,6 +1450,8 @@ def onrelease(self, event):
been clicked.
"""
self.__mouse_btn_is_pressed = False
self.vguide.set_color('black')

# Disconnect the pan and zoom callback before drawing the canvas again.
if self.pan_is_active:
self.toolbar.release_pan(event)
Expand Down Expand Up @@ -1542,6 +1542,9 @@ def onclick(self, event):
self.draw()
elif self.brf_eval_widget.is_brfperiod_selection_toggled():
self._selected_brfperiod[0] = event.xdata
self.vguide.set_color('red')
self.draw()
self.on_mouse_move(event)
elif self.rect_select_is_active:
self._rect_selection[0] = (event.xdata, event.ydata)
else:
Expand Down

0 comments on commit d3dc43a

Please sign in to comment.