def draw_rectangle_list(self, dc, rectangles, wx_colours): """Draw a list of rectangles all at once. @param dc: a wx.DC that will be used for drawing. @type dc: wx.DC @param coords: a list containing (lat, lon, lat, lon) sequences representing top left and bottom right corner of each rectangle. @param wx_colours: a list of at least as many colours as there are rectangles. @type wx_colours: iterable containing wx colours, e. g. wx.RED @param filled: if this is True, all rectangles will be drawn with an (not completely opaque) filling. """ rects = [] pens = [] brushes = [] for colour, line in enumerate(rectangles): x_left, y_top = calc.latlon_to_xy(line[0], line[1], self.zoom, self) x_right, y_bottom = calc.latlon_to_xy(line[2], line[3], self.zoom, self) width = abs(x_right - x_left) height = abs(y_bottom - y_top) rects.append([x_left - self.rel_pos_x, y_top - self.rel_pos_y, width, height]) pen = wx.Pen(wx_colours[colour], RECTANGLE_LINE_WIDTH) pens.append(pen) if RECTANGLE_FILL: colour = pen.GetColour().Get(True)[:-1] + (RECTANGLE_FILL_ALPHA,) # take colour from pen, but replace alpha value brush = wx.Brush(colour) else: brush = wx.Brush(wx_colours[colour], wx.TRANSPARENT) brushes.append(brush) dc.DrawRectangleList(rects, pens, brushes)
def draw_point(self, dc, lat, lon, wx_colour): """Draw a single point. @param dc: a wx.DC that will be used for drawing. @type dc: wx.DC @param lat: latitude of the point to be drawn on the map @param lon: longitude of the point to be drawn on the map @param wx_colour: the colour of the point @type wx_colour: wx colour, e. g. wx.RED """ x, y = calc.latlon_to_xy(lat, lon, self.zoom, self) dc.SetPen(wx.Pen(wx_colour, 2)) dc.DrawRectangle(x - POINT_SIZE / 2 + 1 - self.rel_pos_x, y - POINT_SIZE / 2 + 1 - self.rel_pos_y, POINT_SIZE, POINT_SIZE)
def draw_point_list(self, dc, coords, wx_colours): """Draw a list of points all at once. @param dc: a wx.DC that will be used for drawing. @type dc: wx.DC @param coords: a list containing (lat, lon) tuples. @param wx_colours: a list of at least as many colours as there are coord-pairs. @type wx_colours: iterable containing wx colours, e. g. wx.RED """ draw_list = [] pen_list = [] for colour, coord in enumerate(coords): #self.draw_point(dc, coord[0], coord[1], wx_colours[colour]) x, y = calc.latlon_to_xy(coord[0], coord[1], self.zoom, self) draw_list.append([x - POINT_SIZE / 2 + 1 - self.rel_pos_x, y - POINT_SIZE / 2 + 1 - self.rel_pos_y, POINT_SIZE, POINT_SIZE]) pen_list.append(wx.Pen(wx_colours[colour], 2)) dc.DrawRectangleList(draw_list, pen_list)