File: Object3DConfig.py

package info (click to toggle)
pymca 5.4.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 44,320 kB
  • sloc: python: 140,671; ansic: 20,050; sh: 175; makefile: 133; xml: 55
file content (153 lines) | stat: -rw-r--r-- 6,563 bytes parent folder | download | duplicates (3)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#/*##########################################################################
# Copyright (C) 2004-2014 V.A. Sole, European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#
# Please contact the ESRF industrial unit (industry@esrf.fr) if this license
# is a problem for you.
#
#############################################################################*/
__author__ = "V.A. Sole - ESRF Data Analysis"
__contact__ = "sole@esrf.fr"
__license__ = "LGPL2+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
from . import Object3DQt as qt
from . import Object3DMovement
from . import Object3DProperties
from . import ClippingPlaneConfiguration
from . import Object3DColormap
from .VerticalSpacer import VerticalSpacer

class Object3DConfig(qt.QWidget):
    sigObject3DConfigSignal = qt.pyqtSignal(object)
    def __init__(self, parent = None):
        qt.QWidget.__init__(self, parent)
        self.mainLayout = qt.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(4, 4, 4, 4)
        self.mainLayout.setSpacing(4)

        #drawing
        self.mainTab = qt.QTabWidget(self)
        self.tabDrawing = qt.QWidget(self.mainTab)
        self.tabDrawing.mainLayout = qt.QVBoxLayout(self.tabDrawing)
        self.tabDrawing.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.tabDrawing.mainLayout.setSpacing(0)
        self.movementsWidget  = Object3DMovement.Object3DMovement(self.tabDrawing)
        self.scaleWidget      = Object3DProperties.Object3DScale(self.tabDrawing)
        self.propertiesWidget = Object3DProperties.Object3DProperties(self.tabDrawing)
        self.tabDrawing.mainLayout.addWidget(self.movementsWidget)
        self.tabDrawing.mainLayout.addWidget(self.scaleWidget)
        self.tabDrawing.mainLayout.addWidget(self.propertiesWidget)
        self.mainTab.addTab(self.tabDrawing, "DRAWING")

        #clipping
        self.tabClipping = qt.QWidget(self.mainTab)
        self.tabClipping.mainLayout = qt.QVBoxLayout(self.tabClipping)
        self.tabClipping.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.tabClipping.mainLayout.setSpacing(0)
        self.clippingPlaneWidget = ClippingPlaneConfiguration.ClippingPlaneWidget(self.tabClipping)
        self.colormapWidget = Object3DColormap.Object3DColormap(self.tabClipping)
        self.tabClipping.mainLayout.addWidget(self.clippingPlaneWidget)
        self.tabClipping.mainLayout.addWidget(self.colormapWidget)
        self.tabClipping.mainLayout.addWidget(VerticalSpacer())
        self.mainTab.addTab(self.tabClipping, "CLIP and COLOR")

        self.mainLayout.addWidget(self.mainTab)

        self.movementsWidget.sigObject3DMovementSignal.connect(\
                     self._movementsSlot)
        self.scaleWidget.sigObject3DScaleSignal.connect(\
                     self._scaleSlot)
        self.propertiesWidget.sigObject3DPropertiesSignal.connect(\
                     self._propertiesSlot)
        self.clippingPlaneWidget.sigClippingPlaneWidgetSignal.connect(\
                     self._clippingPlaneSlot)
        self.colormapWidget.sigObject3DColormapSignal.connect(\
                     self._colormapSlot)

    def _movementsSlot(self, ddict0):
        ddict = {}
        ddict['common'] = ddict0
        ddict['common'].update(self.propertiesWidget.getParameters())
        self._signal(ddict)

    def _scaleSlot(self, ddict0):
        ddict = {}
        event = ddict0['event']
        ddict['common'] = ddict0
        ddict['common'].update(self.scaleWidget.getParameters())

        #get the movement positions
        movementsDict = self.movementsWidget.getParameters()
        ddict['common'].update(movementsDict)
        if event == "xScaleUpdated":
            if ddict['common']['scale'][0] != 0.0:
                ddict['common']['translation'][0] /= ddict0['magnification']
        if event == "yScaleUpdated":
            if ddict['common']['scale'][1] != 0.0:
                ddict['common']['translation'][1] /= ddict0['magnification']
        if event == "zScaleUpdated":
            if ddict['common']['scale'][2] != 0.0:
                ddict['common']['translation'][2] /= ddict0['magnification']
        self.movementsWidget.setParameters(ddict['common'])
        self._signal(ddict)

    def _propertiesSlot(self, ddict):
        ddict['common'].update(self.movementsWidget.getParameters())
        ddict['common'].update(self.scaleWidget.getParameters())
        self._signal(ddict)

    def _clippingPlaneSlot(self, ddict0):
        ddict = {}
        ddict['common'] = ddict0
        self._signal(ddict)

    def _colormapSlot(self, ddict0):
        ddict = {}
        ddict['common'] = ddict0
        self._signal(ddict)

    def _signal(self, ddict):
        self.sigObject3DConfigSignal.emit(ddict)

    def getConfiguration(self):
        ddict = self.propertiesWidget.getParameters()
        ddict['common'].update(self.movementsWidget.getParameters())
        ddict['common'].update(self.scaleWidget.getParameters())
        ddict['common'].update(self.clippingPlaneWidget.getParameters())
        ddict['common'].update(self.colormapWidget.getParameters())
        return ddict

    def setConfiguration(self, ddict):
        self.movementsWidget.setParameters(ddict['common'])
        self.scaleWidget.setParameters(ddict['common'])
        self.propertiesWidget.setParameters(ddict)
        self.clippingPlaneWidget.setParameters(ddict['common'])
        self.colormapWidget.setParameters(ddict['common'])

if __name__ == "__main__":
    import sys
    app = qt.QApplication(sys.argv)
    def myslot(ddict):
        print("Signal received")
        print("dict = ", ddict)

    w = Object3DConfig()
    w.sigObject3DConfigSignal.connect(myslot)
    w.show()
    app.exec_()