@@ -758,24 +758,26 @@ def get_zoom_param(
758758 Args:
759759 plot: instance of BasePlot to use as a reference.
760760 pos: position on the plot canvas of the current hotspot.
761- factor: factor by which to zoom.
761+ factor: factor by which to zoom (zero-centered) .
762762
763763 Returns:
764764 Returns two tuples of four floats each, representing the parameters used
765765 by BasePlot.do_zoom_view.
766766 """
767- rect_width = plot .contentsRect ().width ()
767+ rect = plot .contentsRect ()
768+ w , h = rect .width (), rect .height ()
769+ x , y = pos .x (), pos .y ()
768770 dx = (
769- pos . x () * factor ,
770- pos . x () ,
771- pos . x () ,
772- rect_width ,
771+ x + ( w * factor ) ,
772+ x ,
773+ x ,
774+ w ,
773775 )
774776 dy = (
775- pos . y () * factor ,
776- pos . y () ,
777- pos . y () ,
778- rect_width ,
777+ y + ( h * factor ) ,
778+ y ,
779+ y ,
780+ h ,
779781 )
780782 return dx , dy
781783
@@ -813,12 +815,12 @@ def move(self, filter: StatefulEventFilter, event: QW.QGestureEvent) -> None:
813815
814816 center_point = self .get_glob_position (event )
815817 center_point = filter .plot .canvas ().mapFromGlobal (center_point .toPoint ())
816- scale_factor = np .clip (gesture .scaleFactor (), 0.90 , 1.1 )
818+ scale_factor = np .clip (gesture .scaleFactor (), 0.95 , 1.05 ) - 1
817819
818820 pan_dx , pan_dy = self .get_pan_param (plot , center_point )
819821 zoom_dx , zoom_dy = self .get_zoom_param (plot , center_point , scale_factor )
820- plot .do_zoom_view ( zoom_dx , zoom_dy , replot = False )
821- plot .do_pan_view ( pan_dx , pan_dy )
822+ plot .do_pan_view ( pan_dx , pan_dy , replot = True )
823+ plot .do_zoom_view ( zoom_dx , zoom_dy , lock_aspect_ratio = True )
822824
823825 def stop_tracking (
824826 self , _filter : StatefulEventFilter , _event : QW .QGestureEvent
0 commit comments