Commit 4b146b4b authored by payno's avatar payno

[orange add-on][dimensions] add Setting

parent 9ed31f77
......@@ -32,8 +32,9 @@ from silx.gui import qt
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.canvas.registry.description import InputSignal, OutputSignal
from Orange.widgets.settings import Setting
from id06workflow.gui.dimensions import DimensionWidget
from id06workflow.core.experiment import Experiment
from id06workflow.core.experiment import Experiment, Dim
from functools import partial
import logging
......@@ -61,6 +62,8 @@ class DimensionOW(OWWidget):
resizing_enabled = True
compress_signal = False
_dims = Setting(dict())
def __init__(self):
super().__init__()
layout = gui.vBox(self.mainArea, 'dimensions').layout()
......@@ -85,6 +88,10 @@ class DimensionOW(OWWidget):
# expose API
self.setDims = self._widget.setDims
# load properties
_dims = self._convertDictToDim(self._dims)
self._widget.setDims(_dims)
@property
def _ndim(self):
return self._widget.ndim
......@@ -112,3 +119,24 @@ class DimensionOW(OWWidget):
else:
self.send("data", self._widget.experiment)
OWWidget.accept(self)
def updateProperties(self):
# as dim are named tuple we have to cast them to dict
self._dims = {}
if self._widget.ndim is 0:
return
else:
for _axis, _dim in self._widget.dims.items():
assert isinstance(_dim, Dim)
self._dims[_axis] = _dim.to_dict()
def _convertDictToDim(self, _dict):
if len(_dict) > 0:
_dims = {}
for _axis, _dim in _dict.items():
assert type(_dim) is dict
_dims[_axis] = Dim.from_dict(_dim)
return _dims
else:
return {}
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