Пример #1
0
    def draw(self, parent, dc, obj, rect):
        # obj: (self,chart,time,val)
        # rect: (left,top,right,bottom,width,height)
        axe = parent.chart2axe(obj[1])

        a, b = axe.get_ylim()
        y = rect[3] - int((obj[3] - a) * (rect[5] / (b - a)))

        #print 'rect:',rect,'y range:',a,b,b-a,' val=',obj[3],(obj[3] - a),' y=',y
        if y <= rect[3] and y >= rect[1]:
            lc = wx.NamedColor("BLACK")
            bg = wx.NamedColor("RED")
            font = wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL)

            dc.SetPen(wx.Pen(lc, 1, wx.SOLID))
            dc.DrawLine(rect[0], y, rect[2], y)

            label = parent.GetYLabel(axe, obj[3])
            textExtent = self.m_parent.GetFullTextExtent(label, font)

            DrawRectLabel(dc,
                          label,
                          rect[0],
                          y,
                          textExtent[0],
                          textExtent[1],
                          lc,
                          bg,
                          font,
                          vert='top',
                          horz='right')
Пример #2
0
    def draw(self, parent, dc, obj, rect):
        # obj: (self,chart,time,val,offtime,periodtime)
        # rect: (left,top,right,bottom,width,height)
        axe = parent.chart2axe(obj[1])
        time = obj[2]

        #print 'time',time,' initial:',obj[4],' current:',parent.GetIndexTime(0),' new time:',obj[4] - parent.GetIndexTime(0) + time
        time = obj[4] - parent.GetIndexTime(0) + time

        # update time on the grid
        a, b = axe.get_xlim()
        period = b - a

        #print 'period:',period,' inital period:',obj[5],' delta:',obj[5]-period, ' new time:',time - (obj[5]-period) / 2

        time = time - int((obj[5] - period) / 2)

        if time >= a and time <= b:
            x = rect[0] + int((time - a) * (rect[4] / period))

            #print 'rect:',rect,'x range:',a,b,b-a,' val=',time,(time - a),' x=',x

            lc = wx.NamedColor("BLACK")
            bg = wx.NamedColor("BLUE")
            font = wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL)

            dc.SetPen(wx.Pen(lc, 1, wx.SOLID))
            dc.DrawLine(x, rect[1], x, rect[3])

            label = parent.GetXLabel(time)
            textExtent = self.m_parent.GetFullTextExtent(label, font)

            DrawRectLabel(dc,
                          label,
                          x,
                          rect[3],
                          textExtent[0],
                          textExtent[1],
                          lc,
                          bg,
                          font,
                          vert='bottom',
                          horz='center')