aniplot/graph_window.py
def _hold_bounds(self):
        """ anchores and releases right window edge to last sample. bounds zooms and movements. """
        adc_channel = self.graph_renderer.channels[0]
        if self.sx2 > adc_channel.size():
            self.anchored = True

        if self.anchored:
            # anchor right side of the window to the last graph sample. so the graph always animates, grows out from
            # the right side of the window. (anchor sx2 to adc_channel.size())
            dx = self.sx2 - adc_channel.size()
            dxw = self.wsx2 - adc_channel.size()
            self.sx1 -= dx
            self.sx2 -= dx
            self.wsx1 -= dxw
            self.wsx2 -= dxw

        # eliminate integer overflow problems. only allow indices smaller than a 32bit integer value. and then divide
        # it by four just to be sure.. maybe it's not necessary, but maybe there are some other tricks used in the
        # graph rendering..
        bound = 0xffffffff / 4
        # hmm. this allows only 12 days of data with ~960Hz. time to go 64bit?
        self.sx1 = max(self.sx1, -bound)
        self.sy1 = max(self.sy1, -bound)
        self.sx1 = min(self.sx1,  bound)
        self.sy1 = min(self.sy1,  bound)
        self.sx2 = max(self.sx2, -bound)
        self.sy2 = max(self.sy2, -bound)
        self.sx2 = min(self.sx2,  bound)
        self.sy2 = min(self.sy2,  bound)
        self.wsx1 = max(self.wsx1, -bound)
        self.wsy1 = max(self.wsy1, -bound)
        self.wsx1 = min(self.wsx1,  bound)
        self.wsy1 = min(self.wsy1,  bound)
        self.wsx2 = max(self.wsx2, -bound)
        self.wsy2 = max(self.wsy2, -bound)
        self.wsx2 = min(self.wsx2,  bound)
        self.wsy2 = min(self.wsy2,  bound)

        # limit horizontal zoom to 2 samples. can't zoom in anymore if less than one sample stays on screen.
        # don't have time to implement and test line segment cutting, if one sample is outside the window, and another
        # is inside.
        if self.wsx2 - self.wsx1 < 2.:
            self.wsx2 = self.wsx1 + 2.
        if self.sx2 - self.sx1 < 2.:
            self.sx2 = self.sx1 + 2.

        #
        # limit vertical movement and vertical zoom
        #

        val_min = adc_channel.value_min
        val_max = adc_channel.value_max

        # allow offset of this percent/100 of the screen
        overlap = .30

        # top of the screen has smaller sample values than bottom of the screen. inverted graph.
        # sy1 is top pixel, sy2 bottom. bottom-left coordinat is (0, 0)
        if self.sy1 < self.sy2:
            val_top    = val_min + (self.wsy1 - self.wsy2) * overlap
            val_bottom = val_max - (self.wsy1 - self.wsy2) * overlap
            if self.wsy1 < val_top:
                self.wsy2 -= self.wsy1 - val_top
                self.wsy1 = val_top
            if self.wsy2 > val_bottom:
                self.wsy1 += val_bottom - self.wsy2
                self.wsy2 = val_bottom
            if self.wsy1 < val_top:
                self.wsy1 = val_top
            if self.wsy2 > val_bottom:
                self.wsy2 = val_bottom
        else:
            val_bottom = val_min - (self.wsy1 - self.wsy2) * overlap
            val_top    = val_max + (self.wsy1 - self.wsy2) * overlap
            if self.wsy1 > val_top:
                self.wsy2 -= self.wsy1 - val_top
                self.wsy1 = val_top
            if self.wsy2 < val_bottom:
                self.wsy1 += val_bottom - self.wsy2
                self.wsy2 = val_bottom
            if self.wsy1 > val_top:
                self.wsy1 = val_top
            if self.wsy2 < val_bottom:
                self.wsy2 = val_bottom
 anchores and releases right window edge to last sample. bounds zooms and movements. 
anchores and releases right window edge to last sample. bounds zooms and movements.
anchores and releases right window edge to last sample . bounds zooms and movements .
def _hold_bounds(self):
        adc_channel = self.graph_renderer.channels[0]
        if self.sx2 > adc_channel.size():
            self.anchored = True
        if self.anchored:
            dx = self.sx2 - adc_channel.size()
            dxw = self.wsx2 - adc_channel.size()
            self.sx1 -= dx
            self.sx2 -= dx
            self.wsx1 -= dxw
            self.wsx2 -= dxw
        bound = 0xffffffff / 4
        self.sx1 = max(self.sx1, -bound)
        self.sy1 = max(self.sy1, -bound)
        self.sx1 = min(self.sx1,  bound)
        self.sy1 = min(self.sy1,  bound)
        self.sx2 = max(self.sx2, -bound)
        self.sy2 = max(self.sy2, -bound)
        self.sx2 = min(self.sx2,  bound)
        self.sy2 = min(self.sy2,  bound)
        self.wsx1 = max(self.wsx1, -bound)
        self.wsy1 = max(self.wsy1, -bound)
        self.wsx1 = min(self.wsx1,  bound)
        self.wsy1 = min(self.wsy1,  bound)
        self.wsx2 = max(self.wsx2, -bound)
        self.wsy2 = max(self.wsy2, -bound)
        self.wsx2 = min(self.wsx2,  bound)
        self.wsy2 = min(self.wsy2,  bound)
        if self.wsx2 - self.wsx1 < 2.:
            self.wsx2 = self.wsx1 + 2.
        if self.sx2 - self.sx1 < 2.:
            self.sx2 = self.sx1 + 2.
         limit vertical movement and vertical zoom
        val_min = adc_channel.value_min
        val_max = adc_channel.value_max
         allow offset of this percent/100 of the screen
        overlap = .30
         top of the screen has smaller sample values than bottom of the screen. inverted graph.
         sy1 is top pixel, sy2 bottom. bottom-left coordinat is (0, 0)
        if self.sy1 < self.sy2:
            val_top    = val_min + (self.wsy1 - self.wsy2) * overlap
            val_bottom = val_max - (self.wsy1 - self.wsy2) * overlap
            if self.wsy1 < val_top:
                self.wsy2 -= self.wsy1 - val_top
                self.wsy1 = val_top
            if self.wsy2 > val_bottom:
                self.wsy1 += val_bottom - self.wsy2
                self.wsy2 = val_bottom
            if self.wsy1 < val_top:
                self.wsy1 = val_top
            if self.wsy2 > val_bottom:
                self.wsy2 = val_bottom
        else:
            val_bottom = val_min - (self.wsy1 - self.wsy2) * overlap
            val_top    = val_max + (self.wsy1 - self.wsy2) * overlap
            if self.wsy1 > val_top:
                self.wsy2 -= self.wsy1 - val_top
                self.wsy1 = val_top
            if self.wsy2 < val_bottom:
                self.wsy1 += val_bottom - self.wsy2
                self.wsy2 = val_bottom
            if self.wsy1 > val_top:
                self.wsy1 = val_top
            if self.wsy2 < val_bottom:
                self.wsy2 = val_bottom
def _hold_bounds ( self ) : adc_channel = self . graph_renderer . channels [ 0 ] if self . sx2 > adc_channel . size ( ) : self . anchored = True if self . anchored : dx = self . sx2 - adc_channel . size ( ) dxw = self . wsx2 - adc_channel . size ( ) self . sx1 -= dx self . sx2 -= dx self . wsx1 -= dxw self . wsx2 -= dxw bound = 0xffffffff / 4 self . sx1 = max ( self . sx1 , - bound ) self . sy1 = max ( self . sy1 , - bound ) self . sx1 = min ( self . sx1 , bound ) self . sy1 = min ( self . sy1 , bound ) self . sx2 = max ( self . sx2 , - bound ) self . sy2 = max ( self . sy2 , - bound ) self . sx2 = min ( self . sx2 , bound ) self . sy2 = min ( self . sy2 , bound ) self . wsx1 = max ( self . wsx1 , - bound ) self . wsy1 = max ( self . wsy1 , - bound ) self . wsx1 = min ( self . wsx1 , bound ) self . wsy1 = min ( self . wsy1 , bound ) self . wsx2 = max ( self . wsx2 , - bound ) self . wsy2 = max ( self . wsy2 , - bound ) self . wsx2 = min ( self . wsx2 , bound ) self . wsy2 = min ( self . wsy2 , bound ) if self . wsx2 - self . wsx1 < 2. : self . wsx2 = self . wsx1 + 2. if self . sx2 - self . sx1 < 2. : self . sx2 = self . sx1 + 2. val_min = adc_channel . value_min val_max = adc_channel . value_max overlap = .30 if self . sy1 < self . sy2 : val_top = val_min + ( self . wsy1 - self . wsy2 ) * overlap val_bottom = val_max - ( self . wsy1 - self . wsy2 ) * overlap if self . wsy1 < val_top : self . wsy2 -= self . wsy1 - val_top self . wsy1 = val_top if self . wsy2 > val_bottom : self . wsy1 += val_bottom - self . wsy2 self . wsy2 = val_bottom if self . wsy1 < val_top : self . wsy1 = val_top if self . wsy2 > val_bottom : self . wsy2 = val_bottom else : val_bottom = val_min - ( self . wsy1 - self . wsy2 ) * overlap val_top = val_max + ( self . wsy1 - self . wsy2 ) * overlap if self . wsy1 > val_top : self . wsy2 -= self . wsy1 - val_top self . wsy1 = val_top if self . wsy2 < val_bottom : self . wsy1 += val_bottom - self . wsy2 self . wsy2 = val_bottom if self . wsy1 > val_top : self . wsy1 = val_top if self . wsy2 < val_bottom : self . wsy2 = val_bottom
anchores and releases right window edge to last sample.
anchores and releases right window edge to last sample .
""" anchores and releases right window edge to last sample. bounds zooms and movements. """ # anchor right side of the window to the last graph sample. so the graph always animates, grows out from # the right side of the window. (anchor sx2 to adc_channel.size()) # eliminate integer overflow problems. only allow indices smaller than a 32bit integer value. and then divide # it by four just to be sure.. maybe it's not necessary, but maybe there are some other tricks used in the # graph rendering.. # hmm. this allows only 12 days of data with ~960Hz. time to go 64bit? # limit horizontal zoom to 2 samples. can't zoom in anymore if less than one sample stays on screen. # don't have time to implement and test line segment cutting, if one sample is outside the window, and another # is inside. # # limit vertical movement and vertical zoom # # allow offset of this percent/100 of the screen # top of the screen has smaller sample values than bottom of the screen. inverted graph. # sy1 is top pixel, sy2 bottom. bottom-left coordinat is (0, 0)
self