예제 #1
0
 def isLookupTrivial(self):
     """Return True if the gradient has exactly two stops in it: black at 0.0 and white at 1.0"""
     ticks = self.listTicks()
     if len(ticks) != 2:
         return False
     if ticks[0][1] != 0.0 or ticks[1][1] != 1.0:
         return False
     c1 = fn.colorTuple(ticks[0][0].color)
     c2 = fn.colorTuple(ticks[1][0].color)
     if c1 != (0,0,0,255) or c2 != (255,255,255,255):
         return False
     return True
예제 #2
0
 def isLookupTrivial(self):
     """Return True if the gradient has exactly two stops in it: black at 0.0 and white at 1.0"""
     ticks = self.listTicks()
     if len(ticks) != 2:
         return False
     if ticks[0][1] != 0.0 or ticks[1][1] != 1.0:
         return False
     c1 = fn.colorTuple(ticks[0][0].color)
     c2 = fn.colorTuple(ticks[1][0].color)
     if c1 != (0,0,0,255) or c2 != (255,255,255,255):
         return False
     return True
예제 #3
0
    def map(self, data):
        data = data[self.fieldName]
        colors = np.empty((len(data), 4))
        default = np.array(fn.colorTuple(self['Default'])) / 255.
        colors[:] = default

        for v in self.param('Values'):
            mask = data == v.maskValue
            c = np.array(fn.colorTuple(v.value())) / 255.
            colors[mask] = c
        #scaled = np.clip((data-self['Min']) / (self['Max']-self['Min']), 0, 1)
        #cmap = self.value()
        #colors = cmap.map(scaled, mode='float')

        #mask = np.isnan(data) | np.isinf(data)
        #nanColor = self['NaN']
        #nanColor = (nanColor.red()/255., nanColor.green()/255., nanColor.blue()/255., nanColor.alpha()/255.)
        #colors[mask] = nanColor

        return colors
예제 #4
0
 def map(self, data):
     data = data[self.fieldName]
     colors = np.empty((len(data), 4))
     default = np.array(fn.colorTuple(self['Default'])) / 255.
     colors[:] = default
     
     for v in self.param('Values'):
         mask = data == v.maskValue
         c = np.array(fn.colorTuple(v.value())) / 255.
         colors[mask] = c
     #scaled = np.clip((data-self['Min']) / (self['Max']-self['Min']), 0, 1)
     #cmap = self.value()
     #colors = cmap.map(scaled, mode='float')
     
     #mask = np.isnan(data) | np.isinf(data)
     #nanColor = self['NaN']
     #nanColor = (nanColor.red()/255., nanColor.green()/255., nanColor.blue()/255., nanColor.alpha()/255.)
     #colors[mask] = nanColor
     
     return colors
예제 #5
0
    def getSymbolCoords(self, opts):
        """
        Given a list of spot records, return an object representing the coordinates of that symbol within the atlas
        """
        coords = np.empty(len(opts), dtype=object)
        for i, rec in enumerate(opts):
            symbol, size, pen, brush = rec['symbol'], rec['size'], rec[
                'pen'], rec['brush']
            pen = fn.mkPen(pen) if not isinstance(pen, QtGui.QPen) else pen
            brush = fn.mkBrush(brush) if not isinstance(
                pen, QtGui.QBrush) else brush
            key = (symbol, size, fn.colorTuple(pen.color()), pen.widthF(),
                   pen.style(), fn.colorTuple(brush.color()))
            if key not in self.symbolMap:
                newCoords = SymbolAtlas.SymbolCoords()
                self.symbolMap[key] = newCoords
                self.atlasValid = False
                #try:
                #self.addToAtlas(key)  ## squeeze this into the atlas if there is room
                #except:
                #self.buildAtlas()  ## otherwise, we need to rebuild

            coords[i] = self.symbolMap[key]
        return coords
예제 #6
0
 def getSymbolCoords(self, opts):
     """
     Given a list of spot records, return an object representing the coordinates of that symbol within the atlas
     """
     coords = np.empty(len(opts), dtype=object)
     for i, rec in enumerate(opts):
         symbol, size, pen, brush = rec['symbol'], rec['size'], rec['pen'], rec['brush']
         pen = fn.mkPen(pen) if not isinstance(pen, QtGui.QPen) else pen
         brush = fn.mkBrush(brush) if not isinstance(pen, QtGui.QBrush) else brush
         key = (symbol, size, fn.colorTuple(pen.color()), pen.width(), pen.style(), fn.colorTuple(brush.color()))
         if key not in self.symbolMap:
             newCoords = SymbolAtlas.SymbolCoords()
             self.symbolMap[key] = newCoords
             self.atlasValid = False
             #try:
                 #self.addToAtlas(key)  ## squeeze this into the atlas if there is room
             #except:
                 #self.buildAtlas()  ## otherwise, we need to rebuild
         
         coords[i] = self.symbolMap[key]
     return coords
예제 #7
0
 def saveState(self):
     return functions.colorTuple(self._color)
예제 #8
0
 def saveState(self):
     return functions.colorTuple(self._color)
예제 #9
0
 def saveColorState(self):
     state = Parameter.saveState(self)
     state['value'] = fn.colorTuple(self.value())
     return state
예제 #10
0
 def saveColorState(self):
     state = Parameter.saveState(self)
     state['value'] = fn.colorTuple(self.value())
     return state