Skip to content

Commit 55f9d29

Browse files
committed
enh: remember plot size when manually resizing
1 parent 468358a commit 55f9d29

3 files changed

Lines changed: 41 additions & 7 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- reg: filters not applied in final plots since 2.25.1
33
- fix: prevent `pipeline.lock` deadlocks via Qt signal cluttering
44
- fix: update axes ranges when "Auto XY-range" is selected in plotting
5+
- enh: remember plot size when manually resizing
56
- enh: increase default disk store size from 2GB to 9GB
67
- enh: reduce delay after selecting axes in the Plot view
78
- ref: incorporate `PipelinePlot` into sender-receiver signal pyramid

dcscope/gui/analysis/ana_plot.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,37 @@ def on_plot_removed(self):
508508
@QtCore.pyqtSlot(dict)
509509
def on_pp_mod_recv(self, data):
510510
"""We received a signal that something changed"""
511-
pp_dict = data.get("pipeline")
512-
if pp_dict:
513-
if self.isVisible():
511+
if self.isVisible():
512+
pp_dict = data.get("pipeline", {})
513+
if "plot_added" in pp_dict:
514514
plot_id = pp_dict.get("plot_added")
515515
if plot_id is not None:
516516
plot_index = self.pipeline.plot_ids.index(plot_id)
517517
else:
518518
plot_index = None
519519
self.update_content(plot_index)
520520

521+
pr_dict = data.get("pipeline-rendering", {})
522+
if "plot_size_changed" in pr_dict:
523+
plot_id = pr_dict.get("plot_size_changed")
524+
plot_index = self.pipeline.plot_ids.index(plot_id)
525+
state = self.pipeline.plots[plot_index].__getstate__()
526+
self.spinBox_size_x.setValue(state["layout"]["size x"])
527+
self.spinBox_size_y.setValue(state["layout"]["size y"])
528+
elif "plot_range_corrected" in pr_dict:
529+
plot_id = pr_dict.get("plot_range_corrected")
530+
plot_index = self.pipeline.plot_ids.index(plot_id)
531+
state = self.pipeline.plots[plot_index].__getstate__()
532+
for nm, rc in [("range x", self.widget_range_x),
533+
("range y", self.widget_range_y)]:
534+
rc.blockSignals(True)
535+
rc.write_pipeline_state({
536+
"active": True,
537+
"start": state["general"][nm][0],
538+
"end": state["general"][nm][1],
539+
})
540+
rc.blockSignals(False)
541+
521542
@QtCore.pyqtSlot()
522543
@show_wait_cursor
523544
def on_spacing_auto(self):

dcscope/gui/pipeline_plot.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ def on_pp_mod_recv(self, data):
8484
"plot_created", self.identifier) != self.identifier
8585
# A plot was removed.
8686
or pip_data.get("plot_removed")
87-
# We are emitting this signal ourself
88-
or pip_data.get("plot_range_corrected")
8987
):
9088
pass
9189
else:
@@ -94,8 +92,22 @@ def on_pp_mod_recv(self, data):
9492
self.update_content()
9593
if plot.__getstate__() != plot_state:
9694
# Updated the range controls
97-
self.pp_mod_send.emit({"pipeline": {
98-
"plot_range_corrected": self.identifier}})
95+
self.pp_mod_send.emit({"pipeline-rendering": {
96+
"plot_range_corrected": self.identifier,
97+
}})
98+
99+
@QtCore.pyqtSlot(QtGui.QResizeEvent)
100+
def resizeEvent(self, event: QtGui.QResizeEvent):
101+
if self.identifier:
102+
# Update the plot parameters
103+
plot_index = self.pipeline.plot_ids.index(self.identifier)
104+
with self.pipeline.lock:
105+
state = self.pipeline.plots[plot_index].__getstate__()
106+
state["layout"]["size x"] = event.size().width()
107+
state["layout"]["size y"] = event.size().height()
108+
self.pipeline.plots[plot_index].__setstate__(state)
109+
self.pp_mod_send.emit(
110+
{"pipeline-rendering": {"plot_size_changed": self.identifier}})
99111

100112
@QtCore.pyqtSlot()
101113
def update_content(self):

0 commit comments

Comments
 (0)