aniplot/graph_renderer.py
def _render_grid_verlines(self, w, h, x2, y2, w2, h2, min_div_hpix=100.):
        """
        min_div_hpix : minimum division height (grid line distance) in pixels
        """
        assert w > 0.
        ch = self.channels[0]
        if abs(w2) < 0.000001:
            return

        sn1 = x2 # sample num
        sn2 = x2 + w2
        st1 = ch.sample_to_time(sn1) # sv - sample time
        st2 = ch.sample_to_time(sn2)
        # swap begin/end if necessary to make following calculations much more convenient
        if st2 < st1:
            st1, st2 = st2, st1
            sn1, sn2 = sn2, sn1

        #volts_per_min_div = (v2 - v1) / (h - 1.) * min_div_hpix
        seconds_per_min_div = (st2 - st1) / w * min_div_hpix
        #pixels_per_volt = (h - 1.) / (v2 - v1)
        pixels_per_second = float(w) / w2 * ch.freq
        st_step  = math.pow(2, math.ceil(math.log(seconds_per_min_div, 2)))
        st_begin = math.floor(st1 / st_step) * st_step + st_step

        px_begin = self._samplenum_to_pixel(ch.time_to_sample(st_begin), x2, w2, w)
        px_end   = self._samplenum_to_pixel(sn2, x2, w2, w) # overshooting is intentional
        sign = 1 if px_end > px_begin else -1
        px_step  = pixels_per_second * st_step * sign

        gl.glBegin(gl.GL_LINES)

        px = px_begin
        while px * sign < px_end:
            gl.glVertex3f( px, 0., 0. )
            gl.glVertex3f( px,  h, 0. )
            px += px_step

        gl.glEnd()

        min_div_hpix : minimum division height (grid line distance) in pixels
        
min_div_hpix : minimum division height (grid line distance) in pixels
min_div_hpix : minimum division height ( grid line distance ) in pixels
def _render_grid_verlines(self, w, h, x2, y2, w2, h2, min_div_hpix=100.):
        assert w > 0.
        ch = self.channels[0]
        if abs(w2) < 0.000001:
            return
        sn1 = x2 
        sn2 = x2 + w2
        st1 = ch.sample_to_time(sn1) 
        st2 = ch.sample_to_time(sn2)
        if st2 < st1:
            st1, st2 = st2, st1
            sn1, sn2 = sn2, sn1
        seconds_per_min_div = (st2 - st1) / w * min_div_hpix
        pixels_per_second = float(w) / w2 * ch.freq
        st_step  = math.pow(2, math.ceil(math.log(seconds_per_min_div, 2)))
        st_begin = math.floor(st1 / st_step) * st_step + st_step
        px_begin = self._samplenum_to_pixel(ch.time_to_sample(st_begin), x2, w2, w)
        px_end   = self._samplenum_to_pixel(sn2, x2, w2, w) 
        sign = 1 if px_end > px_begin else -1
        px_step  = pixels_per_second * st_step * sign
        gl.glBegin(gl.GL_LINES)
        px = px_begin
        while px * sign < px_end:
            gl.glVertex3f( px, 0., 0. )
            gl.glVertex3f( px,  h, 0. )
            px += px_step
        gl.glEnd()
def _render_grid_verlines ( self , w , h , x2 , y2 , w2 , h2 , min_div_hpix = 100. ) : assert w > 0. ch = self . channels [ 0 ] if abs ( w2 ) < 0.000001 : return sn1 = x2 sn2 = x2 + w2 st1 = ch . sample_to_time ( sn1 ) st2 = ch . sample_to_time ( sn2 ) if st2 < st1 : st1 , st2 = st2 , st1 sn1 , sn2 = sn2 , sn1 seconds_per_min_div = ( st2 - st1 ) / w * min_div_hpix pixels_per_second = float ( w ) / w2 * ch . freq st_step = math . pow ( 2 , math . ceil ( math . log ( seconds_per_min_div , 2 ) ) ) st_begin = math . floor ( st1 / st_step ) * st_step + st_step px_begin = self . _samplenum_to_pixel ( ch . time_to_sample ( st_begin ) , x2 , w2 , w ) px_end = self . _samplenum_to_pixel ( sn2 , x2 , w2 , w ) sign = 1 if px_end > px_begin else - 1 px_step = pixels_per_second * st_step * sign gl . glBegin ( gl . GL_LINES ) px = px_begin while px * sign < px_end : gl . glVertex3f ( px , 0. , 0. ) gl . glVertex3f ( px , h , 0. ) px += px_step gl . glEnd ( )
min_div_hpix : minimum division height (grid line distance) in pixels
min_div_hpix : minimum division height ( grid line distance ) in pixels
"""
        min_div_hpix : minimum division height (grid line distance) in pixels
        """ # sample num # sv - sample time # swap begin/end if necessary to make following calculations much more convenient #volts_per_min_div = (v2 - v1) / (h - 1.) * min_div_hpix #pixels_per_volt = (h - 1.) / (v2 - v1) # overshooting is intentional
self
w
h
x2
y2
w2
h2
min_div_hpix