(self, name, data)
Update data for an attribute variable.
Update data for an attribute variable.
Update data for an attribute variable .
def update_attribute(self, name, data):#, bounds=None):
        """Update data for an attribute variable."""
        variable = self.get_variable(name)
        
        if variable['sliced_attribute'].location < 0:
            log_debug(("Variable '%s' could not be updated, probably because "
                      "it is not used in the shaders") % name)
            return
        
        # handle reference variable
        olddata = variable.get('data', None)
        if isinstance(olddata, RefVar):
            raise ValueError("Unable to load data for a reference " +
                "attribute. Use the target variable directly.""")
        variable['data'] = data
        att = variable['sliced_attribute']
        
        if olddata is None:
            oldshape = 0
        else:
            oldshape = olddata.shape
        
        # print name, oldshape, data.shape
        
        # handle size changing
        if data.shape[0] != oldshape[0]:
            log_debug(("Creating new buffers for variable %s, old size=%s,"
                "new size=%d") % (name, oldshape[0], data.shape[0]))
            # update the size only when not using index arrays
            if self.use_index:
                newsize = self.slicer.size
            else:
                newsize = data.shape[0]
            # update the slicer size and bounds
            self.slicer.set_size(newsize, doslice=not(self.use_index))
            
            # HACK: update the bounds only if there are no bounds basically
            # (ie. 2 bounds only), otherwise we assume the bounds have been
            # changed explicitely
            if len(self.slicer.bounds) == 2:
                self.slicer.set_bounds()
                
            # delete old buffers
            att.delete_buffers()
            # create new buffers
            att.create()
            # load data
            att.load(data)
            # forget previous size
            # self.previous_size = None            
        else:
            # update data
            att.update(data)
def update_attribute ( self , name , data ) : #, bounds=None): variable = self . get_variable ( name ) if variable [ 'sliced_attribute' ] . location < 0 : log_debug ( ( "Variable '%s' could not be updated, probably because " "it is not used in the shaders" ) % name ) return # handle reference variable olddata = variable . get ( 'data' , None ) if isinstance ( olddata , RefVar ) : raise ValueError ( "Unable to load data for a reference " + "attribute. Use the target variable directly." "" ) variable [ 'data' ] = data att = variable [ 'sliced_attribute' ] if olddata is None : oldshape = 0 else : oldshape = olddata . shape # print name, oldshape, data.shape # handle size changing if data . shape [ 0 ] != oldshape [ 0 ] : log_debug ( ( "Creating new buffers for variable %s, old size=%s," "new size=%d" ) % ( name , oldshape [ 0 ] , data . shape [ 0 ] ) ) # update the size only when not using index arrays if self . use_index : newsize = self . slicer . size else : newsize = data . shape [ 0 ] # update the slicer size and bounds self . slicer . set_size ( newsize , doslice = not ( self . use_index ) ) # HACK: update the bounds only if there are no bounds basically # (ie. 2 bounds only), otherwise we assume the bounds have been # changed explicitely if len ( self . slicer . bounds ) == 2 : self . slicer . set_bounds ( ) # delete old buffers att . delete_buffers ( ) # create new buffers att . create ( ) # load data att . load ( data ) # forget previous size # self.previous_size = None             else : # update data att . update ( data )