k_weight.py 3.48 KB
Newer Older
payno's avatar
payno committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/

__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "06/07/2019"

30
import logging
31
from ewokscore.hashing import MissingData
payno's avatar
payno committed
32
33
from Orange.widgets import gui
from silx.gui import qt
payno's avatar
payno committed
34
import est.core.process.pymca.k_weight
35
from orangecontrib.est.process import _ProcessForOrangeMixIn
Henri Payno's avatar
Henri Payno committed
36

payno's avatar
payno committed
37

payno's avatar
payno committed
38
39
40
_logger = logging.getLogger(__file__)


payno's avatar
payno committed
41
42
43
44
class KWeightWindow(qt.QMainWindow):
    def __init__(self, parent=None):
        qt.QMainWindow.__init__(self, parent)

45
        # k wright widget
payno's avatar
payno committed
46
        self._k_widget = qt.QWidget(parent=self)
payno's avatar
payno committed
47
        self._k_widget.setLayout(qt.QHBoxLayout())
payno's avatar
payno committed
48
        self._k_widget.layout().addWidget(qt.QLabel("k weight"))
payno's avatar
payno committed
49
50
51
52
53
54
55
56
        self._k_spin_box = qt.QSpinBox(parent=self)
        self._k_spin_box.setRange(0, 3)
        self._k_widget.layout().addWidget(self._k_spin_box)
        dockWidget = qt.QDockWidget(parent=self)
        dockWidget.setWidget(self._k_widget)
        self.addDockWidget(qt.Qt.RightDockWidgetArea, dockWidget)
        dockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
        dockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
57

58
59
        self.setWindowFlags(qt.Qt.Widget)

payno's avatar
payno committed
60

61
62
class KWeightOW(
    _ProcessForOrangeMixIn,
63
    ewokstaskclass=est.core.process.pymca.k_weight.PyMca_k_weight,
64
):
payno's avatar
payno committed
65
66
67
    """
    Widget used for signal extraction
    """
payno's avatar
payno committed
68

payno's avatar
payno committed
69
    name = "k weight"
payno's avatar
payno committed
70
    id = "orange.widgets.est.pymca.k_weight"
71
    description = "Progress k weight"
payno's avatar
payno committed
72
    icon = "icons/k_weight.png"
73
    priority = 2
payno's avatar
payno committed
74
75
76
77
78
79
80
81
    category = "esrfWidgets"
    keywords = ["spectroscopy", "signal", "k", "weight"]

    want_main_area = True
    resizing_enabled = True

    def __init__(self):
        super().__init__()
payno's avatar
payno committed
82
        layout = gui.vBox(self.mainArea, "k weight").layout()
payno's avatar
payno committed
83
84
        self._window = KWeightWindow(parent=self)
        layout.addWidget(self._window)
payno's avatar
payno committed
85

86
87
        k_weight = self.task_input_values.get("k_weight", MissingData)
        if k_weight is not MissingData:
88
            self._window._k_spin_box.setValue(k_weight)
payno's avatar
payno committed
89

payno's avatar
payno committed
90
91
92
93
        # signal / slot connection
        self._window._k_spin_box.valueChanged.connect(self._updateProcess)

    def _updateProcess(self, *arv, **kwargs):
94
        self.receiveDynamicInputs("k_weight", self._window._k_spin_box.value())
95
        self.handleNewSignals()