From becc1a15a997fd99fa62de570032e95ba5194996 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Mon, 24 Jul 2023 17:38:55 +0200 Subject: [PATCH] move shift/scale to container; closes #102 --- src/gui_qt/data/container.py | 10 ++++++++++ src/gui_qt/main/management.py | 7 ++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui_qt/data/container.py b/src/gui_qt/data/container.py index 82dabc6..913ad7e 100644 --- a/src/gui_qt/data/container.py +++ b/src/gui_qt/data/container.py @@ -463,6 +463,16 @@ class ExperimentContainer(QtCore.QObject): return offset + @plot_update + def shift_scale(self, shift_factor: tuple[float, float], scaling_factor: tuple[float, float]): + scale_x, scale_y = scaling_factor + shift_x, shift_y = shift_factor + self.data.x = self.data.x * scale_x + shift_x + self.data.y = self.data.y * scale_y + shift_y + self.data.y_err = self.data.y_err * scale_y + + self.update({'shift': scaling_factor, 'scale': shift_factor}) + def get_namespace(self, i: int = None, j: int = None) -> dict: if (i is None) and (j is None): prefix = '' diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py index 191fe7c..5e2966b 100644 --- a/src/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -841,13 +841,10 @@ class UpperManagement(QtCore.QObject): d_k = self.data[k] if copy_data is None: - d_k.x = d_k.x*v[1][0] + v[0][0] - d_k.y = d_k.y*v[1][1] + v[0][1] + d_k.shift_scale(v[0], v[1]) else: new_data = d_k.copy(full=True) - new_data.update({'shift': v[0], 'scale': v[1]}) - new_data.data.x = new_data.x*v[1][0] + v[0][0] - new_data.y = new_data.y*v[1][1] + v[0][1] + new_data.shift_scale(v[0], v[1]) sid = self.add(new_data) sid_list.append(sid)