def _request_user_input(self): from hyperspy.signals import Image from hyperspy.drawing.widgets import SquareWidget mark = Image(self.metadata.marker, axes=self.model.axes_manager._get_navigation_axes_dicts()) mark.metadata.General.title = 'SAMFire marker' def update_when_triggered(): ind = self.model.axes_manager.indices[::-1] isgood = self.metadata.goodness_test.test(self.model, ind) self.active_strategy.update(ind, isgood, 0) mark.events.data_changed.trigger(mark) self.model.plot() self.model.events.fitted.connect(update_when_triggered, []) self.model._plot.signal_plot.events.closed.connect( lambda: self.model.events.fitted.disconnect(update_when_triggered), []) mark.plot(navigator='slider') w = SquareWidget(self.model.axes_manager) w.color = 'yellow' w.set_mpl_ax(mark._plot.signal_plot.ax) w.connect_navigate() def connect_other_navigation1(axes_manager): with mark.axes_manager.events.indices_changed.suppress_callback( connect_other_navigation2): for ax1, ax2 in zip(mark.axes_manager.navigation_axes, axes_manager.navigation_axes[2:]): ax1.value = ax2.value def connect_other_navigation2(axes_manager): with self.model.axes_manager.events.indices_changed.suppress_callback( connect_other_navigation1): for ax1, ax2 in zip( self.model.axes_manager.navigation_axes[2:], axes_manager.navigation_axes): ax1.value = ax2.value mark.axes_manager.events.indices_changed.connect( connect_other_navigation2, {'obj': 'axes_manager'}) self.model.axes_manager.events.indices_changed.connect( connect_other_navigation1, {'obj': 'axes_manager'}) self.model._plot.signal_plot.events.closed.connect( lambda: mark._plot.close, []) self.model._plot.signal_plot.events.closed.connect( lambda: self.model.axes_manager.events.indices_changed.disconnect( connect_other_navigation1), [])
def _request_user_input(self): from hyperspy.signals import Image from hyperspy.drawing.widgets import SquareWidget mark = Image(self.metadata.marker, axes=self.model.axes_manager._get_navigation_axes_dicts()) mark.metadata.General.title = 'SAMFire marker' def update_when_triggered(): ind = self.model.axes_manager.indices[::-1] isgood = self.metadata.goodness_test.test(self.model, ind) self.active_strategy.update(ind, isgood, 0) mark.events.data_changed.trigger(mark) self.model.plot() self.model.events.fitted.connect(update_when_triggered, []) self.model._plot.signal_plot.events.closed.connect( lambda: self.model.events.fitted.disconnect(update_when_triggered), []) mark.plot(navigator='slider') w = SquareWidget(self.model.axes_manager) w.color = 'yellow' w.set_mpl_ax(mark._plot.signal_plot.ax) w.connect_navigate() def connect_other_navigation1(axes_manager): with mark.axes_manager.events.indices_changed.suppress_callback( connect_other_navigation2): for ax1, ax2 in zip(mark.axes_manager.navigation_axes, axes_manager.navigation_axes[2:]): ax1.value = ax2.value def connect_other_navigation2(axes_manager): with self.model.axes_manager.events.indices_changed.suppress_callback( connect_other_navigation1): for ax1, ax2 in zip(self.model.axes_manager.navigation_axes[2:], axes_manager.navigation_axes): ax1.value = ax2.value mark.axes_manager.events.indices_changed.connect( connect_other_navigation2, {'obj': 'axes_manager'}) self.model.axes_manager.events.indices_changed.connect( connect_other_navigation1, {'obj': 'axes_manager'}) self.model._plot.signal_plot.events.closed.connect( lambda: mark._plot.close, []) self.model._plot.signal_plot.events.closed.connect( lambda: self.model.axes_manager.events.indices_changed.disconnect( connect_other_navigation1), [])