(cs, inline, inline_spacing, event)
| 28 | |
| 29 | |
| 30 | def _contour_labeler_event_handler(cs, inline, inline_spacing, event): |
| 31 | canvas = cs.axes.get_figure(root=True).canvas |
| 32 | is_button = event.name == "button_press_event" |
| 33 | is_key = event.name == "key_press_event" |
| 34 | # Quit (even if not in infinite mode; this is consistent with |
| 35 | # MATLAB and sometimes quite useful, but will require the user to |
| 36 | # test how many points were actually returned before using data). |
| 37 | if (is_button and event.button == MouseButton.MIDDLE |
| 38 | or is_key and event.key in ["escape", "enter"]): |
| 39 | canvas.stop_event_loop() |
| 40 | # Pop last click. |
| 41 | elif (is_button and event.button == MouseButton.RIGHT |
| 42 | or is_key and event.key in ["backspace", "delete"]): |
| 43 | # Unfortunately, if one is doing inline labels, then there is currently |
| 44 | # no way to fix the broken contour - once humpty-dumpty is broken, he |
| 45 | # can't be put back together. In inline mode, this does nothing. |
| 46 | if not inline: |
| 47 | cs.pop_label() |
| 48 | canvas.draw() |
| 49 | # Add new click. |
| 50 | elif (is_button and event.button == MouseButton.LEFT |
| 51 | # On macOS/gtk, some keys return None. |
| 52 | or is_key and event.key is not None): |
| 53 | if cs.axes.contains(event)[0]: |
| 54 | cs.add_label_near(event.x, event.y, transform=False, |
| 55 | inline=inline, inline_spacing=inline_spacing) |
| 56 | canvas.draw() |
| 57 | |
| 58 | |
| 59 | class ContourLabeler: |
nothing calls this directly
no test coverage detected
searching dependent graphs…