File: Object3DConfig.py

package info (click to toggle)
pymca 4.7.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 52,352 kB
  • ctags: 9,570
  • sloc: python: 116,490; ansic: 18,322; cpp: 826; sh: 57; xml: 24; makefile: 19
file content (132 lines) | stat: -rw-r--r-- 5,475 bytes parent folder | download | duplicates (2)
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
import Object3DQt as qt
import Object3DMovement
import Object3DProperties
import ClippingPlaneConfiguration
import Object3DColormap
from VerticalSpacer import VerticalSpacer

class Object3DConfig(qt.QWidget):
    def __init__(self, parent = None):
        qt.QWidget.__init__(self, parent)
        self.mainLayout = qt.QVBoxLayout(self)
        self.mainLayout.setMargin(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.setMargin(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.setMargin(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.connect(self.movementsWidget,
                     qt.SIGNAL('Object3DMovementSignal'),
                     self._movementsSlot)
        self.connect(self.scaleWidget,
                     qt.SIGNAL('Object3DScaleSignal'),
                     self._scaleSlot)
        self.connect(self.propertiesWidget,
                     qt.SIGNAL('Object3DPropertiesSignal'),
                     self._propertiesSlot)
        self.connect(self.clippingPlaneWidget,
                     qt.SIGNAL('ClippingPlaneWidgetSignal'),
                     self._clippingPlaneSlot)

        self.connect(self.colormapWidget,
                     qt.SIGNAL('Object3DColormapSignal'),
                     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.emit(qt.SIGNAL('Object3DConfigSignal'), 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()
    qt.QObject.connect(w,
                       qt.SIGNAL('Object3DConfigSignal'),
                       myslot)
    w.show()    
    app.exec_()