Skip to content

Commit

Permalink
AbstractShape: minor type hints fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Sep 19, 2024
1 parent abe42cc commit 5629287
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plotpy/items/shape/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from qtpy.QtCore import QPointF # helping out python_qt_documentation

from plotpy.interfaces import IItemType
from plotpy.plot import BasePlot
from plotpy.styles.base import ItemParameters


Expand Down Expand Up @@ -219,10 +220,10 @@ def move_local_point_to(
"""
pt = canvas_to_axes(self, pos)
self.move_point_to(handle, pt, ctrl)
if self.plot():
self.plot().SIG_ITEM_RESIZED.emit(self, 0, 0)
if self.plot():
self.plot().SIG_ITEM_HANDLE_MOVED.emit(self)
plot: BasePlot = self.plot()
if plot is not None:
plot.SIG_ITEM_RESIZED.emit(self, 0, 0)
plot.SIG_ITEM_HANDLE_MOVED.emit(self)

def move_local_shape(self, old_pos: QPointF, new_pos: QPointF) -> None:
"""Translate the shape such that old_pos becomes new_pos in canvas coordinates
Expand All @@ -234,8 +235,9 @@ def move_local_shape(self, old_pos: QPointF, new_pos: QPointF) -> None:
old_pt = canvas_to_axes(self, old_pos)
new_pt = canvas_to_axes(self, new_pos)
self.move_shape(old_pt, new_pt)
if self.plot():
self.plot().SIG_ITEM_MOVED.emit(self, *(old_pt + new_pt))
plot: BasePlot = self.plot()
if plot is not None:
plot.SIG_ITEM_MOVED.emit(self, *(old_pt + new_pt))

def move_with_selection(self, delta_x: float, delta_y: float) -> None:
"""Translate the item together with other selected items
Expand Down Expand Up @@ -270,7 +272,7 @@ def move_shape(self, old_pos: QPointF, new_pos: QPointF) -> None:

def invalidate_plot(self) -> None:
"""Invalidate the plot to force a redraw"""
plot = self.plot()
plot: BasePlot = self.plot()
if plot is not None:
plot.invalidate()

Expand Down

0 comments on commit 5629287

Please sign in to comment.