Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects

Add alignment gui 1d v1

Merged appel_c requested to merge feat/add_alignment_gui_1d_v1 into main
Compare and Show latest version
1 file
+ 42
10
Compare changes
  • Side-by-side
  • Inline
@@ -13,16 +13,28 @@ class BECIndicatorItem(QObject):
super().__init__(parent=parent)
self.accent_colors = get_accent_colors()
self.plot_item = plot_item
self._item_on_plot = False
self._pos = None
self.is_log_x = False
self.is_log_y = False
@property
def item_on_plot(self) -> bool:
"""Returns if the item is on the plot"""
return self._item_on_plot
@item_on_plot.setter
def item_on_plot(self, value: bool) -> None:
self._item_on_plot = value
def add_to_plot(self) -> None:
"""Add the item to the plot"""
self.item_on_plot = True
raise NotImplementedError("Method add_to_plot not implemented")
def remove_from_plot(self) -> None:
"""Remove the item from the plot"""
self.item_on_plot = False
raise NotImplementedError("Method remove_from_plot not implemented")
def set_position(self, pos: tuple[float, float] | float) -> None:
@@ -35,11 +47,6 @@ class BECIndicatorItem(QObject):
self.is_log_y = self.plot_item.ctrl.logYCheck.isChecked()
self.set_position(self._pos)
def cleanup(self) -> None:
"""Cleanup the item"""
self.remove_from_plot()
self.deleteLater()
class BECTickItem(BECIndicatorItem):
"""Class to create a tick item which can be added to a pyqtgraph plot.
@@ -51,7 +58,7 @@ class BECTickItem(BECIndicatorItem):
def __init__(self, plot_item: pg.PlotItem = None, parent=None):
super().__init__(plot_item=plot_item, parent=parent)
self.tick_item = pg.TickSliderItem(allowAdd=False, allowRemove=False)
self.tick_item = pg.TickSliderItem(parent=parent, allowAdd=False, allowRemove=False)
self.tick = None
# Set _pos to float
self._pos = 0
@@ -106,11 +113,24 @@ class BECTickItem(BECIndicatorItem):
self.plot_item.vb.sigXRangeChanged.connect(self.update_range)
self.plot_item.ctrl.logXCheck.checkStateChanged.connect(self.check_log)
self.plot_item.ctrl.logYCheck.checkStateChanged.connect(self.check_log)
self.item_on_plot = True
def remove_from_plot(self):
"""Remove the tick item from the view box or plot item."""
if self.plot_item.layout is not None:
self.plot_item.layout.removeItem(self.tick_item)
if self.plot_item is not None and self.item_on_plot is True:
self.plot_item.vb.sigXRangeChanged.disconnect(self.update_range)
self.plot_item.ctrl.logXCheck.checkStateChanged.disconnect(self.check_log)
self.plot_item.ctrl.logYCheck.checkStateChanged.disconnect(self.check_log)
if self.plot_item.layout is not None:
self.plot_item.layout.removeItem(self.tick_item)
self.item_on_plot = False
def cleanup(self) -> None:
"""Cleanup the item"""
self.remove_from_plot()
if self.tick_item is not None:
self.tick_item.clear()
self.tick_item = None
class BECArrowItem(BECIndicatorItem):
@@ -133,7 +153,7 @@ class BECArrowItem(BECIndicatorItem):
def __init__(self, plot_item: pg.PlotItem = None, parent=None):
super().__init__(plot_item=plot_item, parent=parent)
self.arrow_item = pg.ArrowItem()
self.arrow_item = pg.ArrowItem(parent=parent)
self._pos = (0, 0)
@Slot(dict)
@@ -183,14 +203,26 @@ class BECArrowItem(BECIndicatorItem):
self.plot_item.addItem(self.arrow_item)
self.plot_item.ctrl.logXCheck.checkStateChanged.connect(self.check_log)
self.plot_item.ctrl.logYCheck.checkStateChanged.connect(self.check_log)
self.item_on_plot = True
def remove_from_plot(self):
"""Remove the arrow item from the view box or plot item."""
if self.plot_item is not None:
if self.plot_item is not None and self.item_on_plot is True:
self.plot_item.ctrl.logXCheck.checkStateChanged.disconnect(self.check_log)
self.plot_item.ctrl.logYCheck.checkStateChanged.disconnect(self.check_log)
self.plot_item.removeItem(self.arrow_item)
self.item_on_plot = False
def check_log(self):
"""Checks if the x or y axis is in log scale and updates the internal state accordingly."""
self.is_log_x = self.plot_item.ctrl.logXCheck.isChecked()
self.is_log_y = self.plot_item.ctrl.logYCheck.isChecked()
self.set_position(self._pos)
def cleanup(self) -> None:
"""Cleanup the item"""
self.remove_from_plot()
if self.arrow_item is not None:
self.arrow_item.scene().removeItem(self.arrow_item)
self.arrow_item.clear()
self.arrow_item = None
Loading