Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        """ Register to receive lasso events. 

            cache_segment is typically set to receive the results of all data
            selection operations, as though it were a plot, so that the
            current plot state can be subset. The instantiator of this class
            should set the target of a data emitter to
            payload_lasso.cache_segment.cache_segment(), The target of the
            cache segment is a lasso_filter, followed by the addition of the
            payload, and finally, the target kwarg passed when this class is
            instantiated.

            On receiving a new lasso, trigger a resend of the cached data 
            to the dataset modifier.
        """
        self.target = kwargs.pop('target', None)
        self._payload = None
        self.lasso_filter = LassoFilter(target=self.add_payload_value(
            target=self.target))
        self.lasso_xchg = get_exchange('B4D_panel_lasso_drawn')
        self.lasso_xchg.attach(self)
        self.cache_segment = CachedTriggerableSegment(
            target=self.lasso_filter.filter())
Esempio n. 2
0
    def __init__(self,
                 duration,
                 outlets,
                 variable='time',
                 limits=(0, 1),
                 branchpoint_data_source=None):
        """ Limits are usually the bounds of the current view in *variable* 
        
            Outlets are a set of coroutines that receive subsetted arrays to be drawn.
            
            The data array to be animated should come from branchpoint_data_source, 
            an instance of pipeline.Branchpoint
        """
        self.tstart = time.time()
        self.duration = duration
        self.outlets = outlets
        self.branchpoint_data_source = branchpoint_data_source

        self.filterer = self._filter_to_fraction(variable, limits)

        self.cache_trigger = CachedTriggerableSegment(target=self.filterer)
        self.cache_segment = self.cache_trigger.cache_segment()
        if branchpoint_data_source is not None:
            branchpoint_data_source.targets.add(self.cache_segment)