The function is called when setting the position of the marker interactively If the parameter `marker_position` is `None`, then don't set or change the value. Just make the marker visible.
(self, marker_position=None, mouse_clicked=False)
| 644 | (self.line_vertical_marker,) = self._ax.plot(x_v, y_v, color="blue") |
| 645 | |
| 646 | def set_plot_vertical_marker(self, marker_position=None, mouse_clicked=False): |
| 647 | """ |
| 648 | The function is called when setting the position of the marker interactively |
| 649 | |
| 650 | If the parameter `marker_position` is `None`, then don't set or change the value. |
| 651 | Just make the marker visible. |
| 652 | """ |
| 653 | |
| 654 | # Ignore the new value if it is outside the range of selected energies. |
| 655 | # If 'marker_position' is None, then show the marker at its current location. |
| 656 | # Totally ignore clicks if 'marker_position' is outside the range (but still |
| 657 | # display the marker if 'mouse_clicked' is False. |
| 658 | marker_in_range = True |
| 659 | if marker_position is not None: |
| 660 | e_low = self.param_model.param_new["non_fitting_values"]["energy_bound_low"]["value"] |
| 661 | e_high = self.param_model.param_new["non_fitting_values"]["energy_bound_high"]["value"] |
| 662 | if e_low <= marker_position <= e_high or not mouse_clicked: |
| 663 | # If the function was called to display marker (e.g. for existing peak) outside |
| 664 | # the selected range, then show it. If button was clicked, then ignore it. |
| 665 | self.vertical_marker_kev = marker_position |
| 666 | else: |
| 667 | marker_in_range = False |
| 668 | |
| 669 | if marker_in_range: |
| 670 | # Make the marker visible |
| 671 | self.vertical_marker_is_visible = True |
| 672 | |
| 673 | # Compute peak intensity. The displayed value will change only for user defined peak, |
| 674 | # since it is moved to the position of the marker. |
| 675 | self.compute_manual_peak_intensity() |
| 676 | |
| 677 | # Update the location of the marker and the canvas |
| 678 | self.plot_vertical_marker() |
| 679 | self._update_canvas() |
| 680 | |
| 681 | if mouse_clicked: |
| 682 | try: |
| 683 | self.report_marker_state(True) # This is an externally set callback function |
| 684 | except Exception: |
| 685 | pass |
| 686 | |
| 687 | def hide_plot_vertical_marker(self, mouse_clicked=False): |
| 688 | """Hide vertical marker""" |
no test coverage detected