2424from qwt import QwtPlotItem
2525
2626from plotpy .config import CONF , _
27+ from plotpy .coords import canvas_to_axes
2728from plotpy .interfaces import IBasePlotItem , ISerializableType , IShapeItemType
2829from plotpy .items .curve .base import CurveItem
2930from plotpy .styles .label import LabelParam
@@ -428,18 +429,20 @@ def move_local_shape(self, old_pos: QPointF, new_pos: QPointF) -> None:
428429 old_pos: Old position
429430 new_pos: New position
430431 """
432+ plot = self .plot ()
433+ if plot is None :
434+ return
431435 if self .G in ANCHORS or not self .labelparam .move_anchor :
432436 # Move canvas offset
433437 lx , ly = self .C
434438 lx += new_pos .x () - old_pos .x ()
435439 ly += new_pos .y () - old_pos .y ()
436440 self .C = lx , ly
437441 self .labelparam .xc , self .labelparam .yc = lx , ly
442+ lx0 , ly0 = canvas_to_axes (self , old_pos )
443+ lx1 , ly1 = canvas_to_axes (self , new_pos )
438444 else :
439445 # Move anchor
440- plot = self .plot ()
441- if plot is None :
442- return
443446 lx0 , ly0 = self .G
444447 cx = plot .transform (self .xAxis (), lx0 )
445448 cy = plot .transform (self .yAxis (), ly0 )
@@ -449,7 +452,7 @@ def move_local_shape(self, old_pos: QPointF, new_pos: QPointF) -> None:
449452 ly1 = plot .invTransform (self .yAxis (), cy )
450453 self .G = lx1 , ly1
451454 self .labelparam .xg , self .labelparam .yg = lx1 , ly1
452- plot .SIG_ITEM_MOVED .emit (self , lx0 , ly0 , lx1 , ly1 )
455+ plot .SIG_ITEM_MOVED .emit (self , lx0 , ly0 , lx1 , ly1 )
453456
454457 def move_with_selection (self , delta_x : float , delta_y : float ) -> None :
455458 """Translate the item together with other selected items
0 commit comments