def update_pipeline(self):         # Called when we drag filter under another VTK file
        debug('update_pipeline')
        """Override this method so that it *updates* the tvtk pipeline
        when data upstream is known to have changed.

        This method is invoked (automatically) when the input fires a
        `pipeline_changed` event.
        """
        # Do nothing if there is no input.
        if len(self.inputs) == 0:
            return

        magn = linalg.norm
        earth_radius = 6378000.0

        # By default we set the input to the first output of the first input
        self.grid = tvtk.UnstructuredGrid()
        self.grid.deep_copy(self.inputs[0].reader.output)  ## WAY OF DOING THIS WITHOUT A DEEP COPY?
        #self.inputs[0].outputs[0] ## DOESN'T WORK WITH update_data()

        # Split array by column into the cartesian coordinates
        xyz = array(self.grid.points)
        x = xyz[:,0]
        y = xyz[:,1]
        z = xyz[:,2]

        xyz_squared = xyz**2
        r_squared = xyz_squared.sum(axis=1)
        r = sqrt(r_squared)

        self.longitude = arctan2(y, x)
        self.colatitude = 1.3 * arccos(z/r)
        self.initial_depth = earth_radius - r

        # Now we do vector correction
        self.unit_r = column_stack((x/r, y/r, z/r))
        len_lon = sqrt(x**2 + y**2)
        self.unit_lon = column_stack((y/len_lon, -1*x/len_lon, zeros(len(x))))
        self.unit_lat = cross(self.unit_r, self.unit_lon)

        # Correct current vector array
        current_vector_array = self.inputs[0].outputs[0].point_data.vectors.name
        self._correct_vector_array(current_vector_array)

        self._apply_stretch()

        # Propagate the data_changed event - let modules that depend on this filter know that pipeline has changed
        self.pipeline_changed = True
    def update_data(self):             # Called when we change an option under VTK file, e.g. one of the vectors
        debug('update_data')
        """Override this method to do what is necessary when upstream
        data changes.

        This method is invoked (automatically) when any of the inputs
        sends a `data_changed` event.
        """
        # Do nothing if there is no input.
        if len(self.inputs) == 0:
            return

        if (self.inputs[0].reader.output.point_data.scalars):
            self.active_scalar = self.inputs[0].reader.output.point_data.scalars.name
        if (self.inputs[0].reader.output.point_data.vectors):
            self.active_vector = self.inputs[0].reader.output.point_data.vectors.name

        # Propagate the data_changed event - let modules that depend on this filter know that data has changed
        self.data_changed = True
 def setup_pipeline(self):
     debug('setup_pipeline')
     """Override this method so that it *creates* its tvtk
 def _scale_factor_changed(self, old, new):
     debug('_scale_factor_changed')
     self._apply_stretch()