This file is indexed.

/usr/share/pyshared/PyMca/PyMcaGLWindow.py is in pymca 4.5.0-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#/*##########################################################################
# Copyright (C) 2004-2011 European Synchrotron Radiation Facility
#
# This file is part of the PyMCA X-ray Fluorescence Toolkit developed at
# the ESRF by the Beamline Instrumentation Software Support (BLISS) group.
#
# This toolkit is free software; you can redistribute it and/or modify it 
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option) 
# any later version.
#
# PyMCA 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 General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# PyMCA; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307, USA.
#
# PyMCA follows the dual licensing model of Trolltech's Qt and Riverbank's PyQt
# and cannot be used as a free plugin for a non-free program. 
#
# Please contact the ESRF industrial unit (industry@esrf.fr) if this license 
# is a problem for you.
#############################################################################*/
import Object3D.Object3DScene
import numpy
DEBUG = 0

class SceneGLWindow(Object3D.Object3DScene.Object3DScene):
    def _addSelection(self, selectionlist, replot=True):
        if DEBUG:
            print("addSelection(self, selectionlist)",selectionlist)
        if type(selectionlist) == type([]):
            sellist = selectionlist
        else:
            sellist = [selectionlist]

        for sel in sellist:
            source = sel['SourceName']
            key    = sel['Key']
            legend = sel['legend'] #expected form sourcename + scan key
            dataObject = sel['dataobject']
            #one-dimensional selections not considered
            if dataObject.info["selectiontype"] == "1D":
                continue
            
            #there must be something to plot
            if not hasattr(dataObject, 'y'):
                continue
            #there must be an x for a scan selection to reach here
            if not hasattr(dataObject, 'x'):
                continue                

            if dataObject.x is None:
                numberOfXAxes = 0
            else:
                numberOfXAxes = len(dataObject.x)
                if numberOfXAxes > 1:
                    if DEBUG:
                        print("Mesh plots")
                else:
                    xdata = dataObject.x[0]

            #we have to loop for all y values
            ycounter = -1
            for ydata in dataObject.y:
                ycounter += 1
                ylegend = 'y%d' % ycounter
                if sel['selection'] is not None:
                    if type(sel['selection']) == type({}):
                        if sel['selection'].has_key('y'):
                            ilabel = sel['selection']['y'][ycounter]
                            ylegend = dataObject.info['LabelNames'][ilabel]
                object3Dlegend = legend + " " + ylegend
                ndata = len(ydata)
                object3D = self.addDataObject(dataObject,
                                       legend=object3Dlegend,
                                       update_scene=False)
        self.sceneControl.updateView()
        self.glWidget.setZoomFactor(self.glWidget.getZoomFactor())


    def _removeSelection(self, selectionlist):
        if DEBUG:
            print("_removeSelection(self, selectionlist)",selectionlist)
        if type(selectionlist) == type([]):
            sellist = selectionlist
        else:
            sellist = [selectionlist]

        for sel in sellist:
            source = sel['SourceName']
            key    = sel['Key']
            legend = sel['legend'] #expected form sourcename + scan key
            if sel['selection'].has_key('LabelNames'):
                labelNames = sel['selection']['LabelNames']
            else:
                labelNames = sel['selection']['cntlist']
            for ycounter in sel['selection']['y']:
                ylegend = labelNames[ycounter]
                object3Dlegend = legend + " " + ylegend
            self.removeObject(object3Dlegend, update_scene=False)
        self.sceneControl.updateView()
        self.glWidget.setZoomFactor(self.glWidget.getZoomFactor())
        

    def _replaceSelection(self, selectionlist):
        if DEBUG:
            print("_replaceSelection(self, selectionlist)",selectionlist)
        if type(selectionlist) == type([]):
            sellist = selectionlist
        else:
            sellist = [selectionlist]
        self.clear(update_scene=False)
        self._addSelection(selectionlist)

    def addDataObject(self, dataObject, legend=None, update_scene=True):
        if legend is None:
            legend = dataObject.info['legend']
            
        if (dataObject.m is None) or (dataObject.m == []):
            data = dataObject.y[0]
        else:
            #I would have to check for the presence of zeros in monitor
            data = dataObject.y[0]/dataObject.m[0]            

        if dataObject.x is None:
            if len(data.shape) == 3:
                object3D=self.stack(data,
                           legend=legend,
                           update_scene=False)
            else:
                object3D=self.mesh(data,
                          legend=legend,
                          update_scene=False)
            return object3D

        ndata = 1
        for dimension in data.shape:
            ndata *= dimension

        ndim = 1
        xDimList = []
        for dataset in dataObject.x:
            xdim = 1
            for dimension in dataset.shape:
                xdim *= dimension
            xDimList.append(xdim)
            ndim *=xdim

        if len(dataObject.x) == len(data.shape):
            #two possibilities, the product is equal to the dimension
            #or not
            if ndim == ndata:
                if len(data.shape) == 3:
                    if DEBUG:
                        print("CASE 1")
                    if (xDimList[0] != data.shape[0]) or\
                       (xDimList[1] != data.shape[1]) or\
                       (xDimList[2] != data.shape[2]):
                        text = "Wrong dimensions:"
                        text += " %dx%dx%d != (%d, %d, %d)" % (xDimList[0],
                                                               xDimList[1],
                                                               xDimList[2],
                                                               data.shape[0],
                                                               data.shape[1],
                                                               data.shape[2])
                        raise ValueError(text)
                    object3D = self.stack(data,
                                          x=dataObject.x[0],
                                          y=dataObject.x[1],
                                          z=dataObject.x[2],
                                          legend=legend,
                                          update_scene=update_scene)
                elif len(data.shape) == 2:
                    if DEBUG:
                        print("CASE 2")
                    object3D = self.mesh(data,
                                         x=dataObject.x[0],
                                         y=dataObject.x[1],
                                         z=0, #This is 2D   
                                         #z=data[:], #This is 3D
                                         legend=legend,
                                         update_scene=update_scene)
                elif len(data.shape) == 1:
                    if DEBUG:
                        print("CASE 3")
                    object3D = self.mesh(data,
                                         x=dataObject.x[0],
                                         y=numpy.zeros((1,1), numpy.float32),
                                         z=data[:],
                                         legend=legend,
                                         update_scene=update_scene)
                return object3D
        elif (len(data.shape) == 3) and (len(xDimList) == 2):
            print("WARNING Assuming last dimension")
            if DEBUG:
                print("CASE 1.1")
            if (xDimList[0] != data.shape[0]) or\
               (xDimList[1] != data.shape[1]):
                text = "Wrong dimensions:"
                text += " %dx%d != (%d, %d, %d)" % (xDimList[0],
                                                    xDimList[1],
                                                    data.shape[0],
                                                    data.shape[1],
                                                    data.shape[2])
                raise ValueError(text)
            z = numpy.arange(data.shape[2])
            object3D = self.stack(data,
                                  x=dataObject.x[0],
                                  y=dataObject.x[1],
                                  z=z,
                                  legend=legend,
                                  update_scene=update_scene)
            return object3D


        #I have to assume all the x are of 1 element or of as many elements as data
        xyzData = numpy.zeros((ndata, 3), numpy.float32)
        values  = numpy.zeros((ndata, 1), numpy.float32)
        values[:,0]  = data
        xdataCounter = 0
        for xdata in dataObject.x:
            ndim = 1
            for dimension in xdata.shape:
                ndim *= dimension
            if ndim == 1:
                xyzData[:,xdataCounter] = xdata * numpy.ones(ndata)
            else:
                xyzData[:,xdataCounter] = xdata
            xdataCounter += 1

        object3D = Object3D.Object3DScene.Object3DMesh.Object3DMesh(legend)
        #if the number of points is reasonable
        #I force a surface plot.
        if ndata < 200000:
            cfg = object3D.setConfiguration({'common':{'mode':3}})
        if DEBUG:
            print("DEFAULT CASE")
        object3D.setData(values, xyz=xyzData)
        self.addObject(object3D, legend, update_scene=update_scene)
        return object3D