@@ -47,8 +47,11 @@ def get_data(variable_size: bool) -> tuple[np.ndarray, np.ndarray]:
47
47
class CurveUpdateDialog (PlotDialog ):
48
48
"""Dialog box for curve update"""
49
49
50
- def __init__ (self , title : str , variable_size : bool = False ) -> None :
50
+ def __init__ (
51
+ self , title : str , variable_size : bool = False , auto_scale : bool = True
52
+ ) -> None :
51
53
self .variable_size = variable_size
54
+ self .auto_scale = auto_scale
52
55
options = PlotOptions (title = "-" , show_contrast = True , type = "curve" )
53
56
super ().__init__ (title = title , toolbar = True , edit = False , options = options )
54
57
self .resize (600 , 600 )
@@ -78,12 +81,23 @@ def populate_plot_layout(self) -> None:
78
81
variable_size_cb .setChecked (self .variable_size )
79
82
variable_size_cb .stateChanged .connect (self .toggle_variable_size )
80
83
self .add_widget (variable_size_cb , 0 , 2 )
84
+ auto_scale_cb = QW .QCheckBox ("Auto scale" )
85
+ auto_scale_cb .setChecked (True )
86
+ auto_scale_cb .stateChanged .connect (self .toggle_auto_scale )
87
+ self .add_widget (auto_scale_cb , 0 , 3 )
81
88
self .add_widget (self .plot_widget , 1 , 0 , 1 , 0 )
82
89
83
90
def toggle_variable_size (self , state : int ) -> None :
84
91
"""Toggle variable size"""
85
92
self .variable_size = state == QC .Qt .Checked
86
93
94
+ def toggle_auto_scale (self , state : int ) -> None :
95
+ """Toggle auto scale"""
96
+ self .auto_scale = state == QC .Qt .Checked
97
+ plot = self .get_plot ()
98
+ if self .auto_scale :
99
+ plot .do_autoscale ()
100
+
87
101
def start_curve_update (self ) -> None :
88
102
"""Start curve update"""
89
103
self .timer .timeout .connect (self .update_curve )
@@ -100,7 +114,10 @@ def update_curve(self) -> None:
100
114
plot = self .get_plot ()
101
115
self .item .set_data (data [0 ], data [1 ])
102
116
plot .set_title (f"Curve update { self .counter :03d} " )
103
- plot .replot ()
117
+ if self .auto_scale :
118
+ plot .do_autoscale ()
119
+ else :
120
+ plot .replot ()
104
121
105
122
def closeEvent (self , event : QG .QCloseEvent ) -> None :
106
123
"""Close the dialog and stop the timer"""
0 commit comments