Commit 1a58aa83 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[orangecontrib][transformation] Save settings for magnification and rsm values

parent 802a3048
Pipeline #50695 passed with stage
in 2 minutes and 13 seconds
...@@ -26,9 +26,10 @@ ...@@ -26,9 +26,10 @@
__authors__ = ["J. Garriga"] __authors__ = ["J. Garriga"]
__license__ = "MIT" __license__ = "MIT"
__date__ = "14/06/2021" __date__ = "16/07/2021"
from Orange.widgets.settings import Setting
from silx.gui import qt from silx.gui import qt
from Orange.widgets.widget import OWWidget, Input, Output from Orange.widgets.widget import OWWidget, Input, Output
from darfix.gui.magnificationWidget import MagnificationWidget from darfix.gui.magnificationWidget import MagnificationWidget
...@@ -52,8 +53,13 @@ class TransformationWidgetOW(OWWidget): ...@@ -52,8 +53,13 @@ class TransformationWidgetOW(OWWidget):
class Outputs: class Outputs:
dataset = Output("dataset", tuple) dataset = Output("dataset", tuple)
magnification = Setting(float(), schema_only=True)
pixelSize = Setting(str(), schema_only=True)
rotate = Setting(bool(), schema_only=True)
def __init__(self): def __init__(self):
super().__init__() super().__init__()
qt.QLocale.setDefault(qt.QLocale("en_US"))
self._widget = None self._widget = None
@Inputs.dataset @Inputs.dataset
...@@ -71,8 +77,13 @@ class TransformationWidgetOW(OWWidget): ...@@ -71,8 +77,13 @@ class TransformationWidgetOW(OWWidget):
else: else:
if dataset[0].dims.ndim == 1: if dataset[0].dims.ndim == 1:
self._widget = RSMWidget(parent=self) self._widget = RSMWidget(parent=self)
if self.pixelSize:
self._widget.pixelSize = self.pixelSize
self._widget.rotate = self.rotate
else: else:
self._widget = MagnificationWidget(parent=self) self._widget = MagnificationWidget(parent=self)
if self.magnification:
self._widget.magnification = self.magnification
self._widget.sigComputed.connect(self._sendSignal) self._widget.sigComputed.connect(self._sendSignal)
self.controlArea.layout().addWidget(self._widget) self.controlArea.layout().addWidget(self._widget)
self._widget.setDataset(*dataset) self._widget.setDataset(*dataset)
...@@ -86,5 +97,10 @@ class TransformationWidgetOW(OWWidget): ...@@ -86,5 +97,10 @@ class TransformationWidgetOW(OWWidget):
""" """
Emits the signal with the new dataset. Emits the signal with the new dataset.
""" """
if hasattr(self._widget, 'magnification'):
self.magnification = self._widget.magnification
elif hasattr(self._widget, 'pixelSize'):
self.pixelSize = self._widget.pixelSize
self.rotate = self._widget.rotate
self.close() self.close()
self.Outputs.dataset.send(self._widget.getDataset()) self.Outputs.dataset.send(self._widget.getDataset())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment