From 3a57ab9e27fbc6df05f05da12146e3b346f2b3ee Mon Sep 17 00:00:00 2001 From: Pavlos Stephanos Bekiaris <36934614+Paulocracy@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:51:58 +0200 Subject: [PATCH] Scenario in clipboard (#512) * Add scenario values to clipboard * Simplifications and fixes * minor simplification --------- Co-authored-by: axelvonkamp --- cnapy/gui_elements/clipboard_calculator.py | 13 +++++++++++-- cnapy/gui_elements/main_window.py | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cnapy/gui_elements/clipboard_calculator.py b/cnapy/gui_elements/clipboard_calculator.py index 23f7a9a0..9aa8ef8e 100644 --- a/cnapy/gui_elements/clipboard_calculator.py +++ b/cnapy/gui_elements/clipboard_calculator.py @@ -38,7 +38,7 @@ def __init__(self, appdata: AppData): self.op.insertItem(1, "+") self.op.insertItem(2, "-") self.op.insertItem(3, "*") - self.op.insertItem(4, "\\") + self.op.insertItem(4, "/") op.addWidget(self.op) self.right = QVBoxLayout() self.r1 = QRadioButton("Current values") @@ -80,6 +80,9 @@ def compute(self): r_comp = {} if self.l1.isChecked(): l_comp = self.appdata.project.comp_values + + for (key, value) in self.appdata.project.scen_values.items(): + l_comp[key] = value elif self.l2.isChecked(): try: l_comp = self.appdata.clipboard_comp_values @@ -93,6 +96,9 @@ def compute(self): if self.r1.isChecked(): r_comp = self.appdata.project.comp_values + + for (key, value) in self.appdata.project.scen_values.items(): + r_comp[key] = value elif self.r2.isChecked(): r_comp = self.appdata.clipboard_comp_values @@ -109,6 +115,9 @@ def compute(self): rv_comp = r_comp[key] res = self.combine(lv_comp, rv_comp) + + if key in self.appdata.project.scen_values.keys(): + self.appdata.project.scen_values[key] = res self.appdata.project.comp_values[key] = res self.appdata.project.comp_values_type = 0 @@ -123,5 +132,5 @@ def combine(self, lv, rv): return (llb-rlb, lub-rub) if self.op.currentText() == "*": return (llb*rlb, lub*rub) - if self.op.currentText() == "\\": + if self.op.currentText() == "/": return (llb/rlb, lub/rub) diff --git a/cnapy/gui_elements/main_window.py b/cnapy/gui_elements/main_window.py index 3cf90432..5b087356 100644 --- a/cnapy/gui_elements/main_window.py +++ b/cnapy/gui_elements/main_window.py @@ -1576,9 +1576,15 @@ def on_tab_change(self, idx): def copy_to_clipboard(self): self.appdata.clipboard_comp_values = self.appdata.project.comp_values.copy() + for (key, value) in self.appdata.project.scen_values.items(): + self.appdata.clipboard_comp_values[key] = value + def paste_clipboard(self): try: self.appdata.project.comp_values = self.appdata.clipboard_comp_values.copy() + + for key in (self.appdata.project.scen_values.keys() & self.appdata.clipboard_comp_values.keys()): + self.appdata.project.scen_values[key] = self.appdata.clipboard_comp_values[key] except AttributeError: QMessageBox.warning( self,