Beispiel #1
0
    def Draw(self):
        log.debug("Draw()")
        dc = wx.BufferedPaintDC(self, self._Buffer)
        dc.Clear()

        if not self.image:
            return

        png_dc = wx.MemoryDC()
        png_dc.SelectObject(self.image)
        dc.Blit(0, 0, self.image.GetWidth(), self.image.GetHeight(),
                png_dc, 0, 0)


        dc.SetPen(wx.Pen('black'))
        for item in self.sprites:
            item.Draw(dc)

        if self.current_map:
            dc.SetPen(wx.Pen('yellow'))
            self.current_map.Draw(dc)

        ms = MapService()
        ds = DistanceService(ms)

        if wx.GetApp().GetNavTo():
            dc.SetPen(wx.Pen('red'))
            DrawElLocation(dc, wx.GetApp().GetNavTo())

            dc.SetPen(wx.Pen('yellow'))
            for item in ms.doors(wx.GetApp().GetNavTo().map_name):
                DrawElLocation(dc, item)
            dc.SetPen(wx.Pen('green'))
            DrawElLocation(dc, ds.nearest_door(wx.GetApp().GetNavTo()))

        if wx.GetApp().GetNavFrom():
            dc.SetPen(wx.Pen('blue'))
            DrawElLocation(dc, wx.GetApp().GetNavFrom())

            dc.SetPen(wx.Pen('yellow'))
            for item in ms.doors(wx.GetApp().GetNavFrom().map_name):
                DrawElLocation(dc, item)
            dc.SetPen(wx.Pen('green'))
            DrawElLocation(dc, ds.nearest_door(wx.GetApp().GetNavFrom()))


        if wx.GetApp().GetNavTo() and wx.GetApp().GetNavFrom():
            route = wx.GetApp().GetRoute()
            #~ for item in route:
                #~ log.debug(item)

            dc.SetPen(wx.Pen('blue'))
            last_pos = el_to_dc(route[0].payload)
            for item in route[1:]:
                pos = el_to_dc(item.payload)
                dc.DrawLine(last_pos[0], last_pos[1],
                            pos[0], pos[1])
                last_pos = pos