コード例 #1
0
    def draw_line(self, unit, zl, points, color, width, draw_distance=False):
        gc = self.style.black_gc
        gc.line_width = width
        gc.set_rgb_fg_color(gtk.gdk.color_parse(color))
        dist_str = None
        total_distance = 0

        def do_draw(ini, end):
            self.window.draw_line(gc, ini[0], ini[1], end[0], end[1])
            if dist_str:
                self.write_text(gc, end[0], end[1], dist_str, 10)

        for j in range(len(points) - 1):
            if draw_distance:
                distance = mapUtils.countDistanceFromLatLon(points[j].getLatLon(), points[j + 1].getLatLon())
                if unit != UNIT_TYPE_KM:
                    distance = mapUtils.convertUnits(UNIT_TYPE_KM, unit, distance)
                total_distance += distance
                dist_str = '%.3f %s \n%.3f %s' % (distance, DISTANCE_UNITS[unit], total_distance, DISTANCE_UNITS[unit])
            ini = self.coord_to_screen(points[j].latitude, points[j].longitude, zl)
            end = self.coord_to_screen(points[j + 1].latitude, points[j + 1].longitude, zl)
            if ini and end:
                do_draw(ini, end)
            elif ini or end:
                if ini:
                    end = self.coord_to_screen(points[j + 1].latitude, points[j + 1].longitude, zl, True)
                if end:
                    ini = self.coord_to_screen(points[j].latitude, points[j].longitude, zl, True)
                do_draw(ini, end)
        return gc
コード例 #2
0
ファイル: gpsWindow.py プロジェクト: yuviip/GMapCatcher
 def update_widgets(self):
     ## Check if gps exists by checking that fix exists and fix-time exists
     # NMEA should include some kind of time always,
     # although it might be seconds from GPS start, if now satellites is found.
     # -> If time is found, GPS is operational.
     if self.mapsObj.gps and self.mapsObj.gps.gpsfix and self.mapsObj.gps.gpsfix.time:
         if self.mapsObj.gps.gpsfix.mode > MODE_NO_FIX:
             if self.mapsObj.gps.gpsfix.mode == MODE_2D:
                 text = 'FIX'
             else:
                 text = '3D FIX'
             self.fix_label.set_text(
                 '<b><span foreground=\"green\">%s</span></b>' % text)
         else:
             self.fix_label.set_text(
                 '<b><span foreground=\"red\">NO FIX</span></b>')
         if self.mapsObj.gps.gpsfix.time:
             d = makeGPSTime(self.mapsObj.gps.gpsfix.time,
                             self.mapsObj.conf.gps_type,
                             use_offset=True)
             if d:
                 gps_time = '%02d:%02d:%02d' % (d.hour, d.minute, d.second)
                 self.gps_values[0].set_text(gps_time)
         if self.mapsObj.gps.gpsfix.latitude:
             self.gps_values[1].set_text('%.6f' %
                                         self.mapsObj.gps.gpsfix.latitude)
         if self.mapsObj.gps.gpsfix.longitude:
             self.gps_values[2].set_text('%.6f' %
                                         self.mapsObj.gps.gpsfix.longitude)
         speed_unit = self.mapsObj.conf.units
         speed = self.mapsObj.gps.gpsfix.speed
         if speed:
             if speed_unit != UNIT_TYPE_NM:
                 speed = mapUtils.convertUnits(UNIT_TYPE_NM, speed_unit,
                                               speed)
             self.gps_values[3].set_text('%.1f %s' %
                                         (speed, SPEED_UNITS[speed_unit]))
         if self.mapsObj.gps.gpsfix.track:
             self.gps_values[4].set_text('%.1f°' %
                                         self.mapsObj.gps.gpsfix.track)
         if self.mapsObj.gps.gpsfix.altitude:
             self.gps_values[5].set_text('%.1fm' %
                                         self.mapsObj.gps.gpsfix.altitude)
         if self.mapsObj.conf.gps_type == TYPE_SERIAL:
             self.gps_values[6].set_text('%i' %
                                         self.mapsObj.gps.gpsfix.satellites)
     else:
         self.fix_label.set_text(
             '<span foreground=\"red\">No GPS detected</span>')
         for gps_value in self.gps_values:
             gps_value.set_text('---')
     self.fix_label.set_use_markup(True)
     if self.__stop:
         return False
     else:
         return True
コード例 #3
0
ファイル: gpsWindow.py プロジェクト: 119-org/gmapcatcher
 def update_widgets(self):
     ## Check if gps exists by checking that fix exists and fix-time exists
     # NMEA should include some kind of time always,
     # although it might be seconds from GPS start, if now satellites is found.
     # -> If time is found, GPS is operational.
     if self.mapsObj.gps and self.mapsObj.gps.gpsfix and self.mapsObj.gps.gpsfix.time:
         if self.mapsObj.gps.gpsfix.mode > MODE_NO_FIX:
             if self.mapsObj.gps.gpsfix.mode == MODE_2D:
                 text = 'FIX'
             else:
                 text = '3D FIX'
             self.fix_label.set_text('<b><span foreground=\"green\">%s</span></b>' % text)
         else:
             self.fix_label.set_text('<b><span foreground=\"red\">NO FIX</span></b>')
         if self.mapsObj.gps.gpsfix.time:
             d = makeGPSTime(self.mapsObj.gps.gpsfix.time, self.mapsObj.conf.gps_type, use_offset=True)
             if d:
                 gps_time = '%02d:%02d:%02d' % (d.hour, d.minute, d.second)
                 self.gps_values[0].set_text(gps_time)
         if self.mapsObj.gps.gpsfix.latitude:
             self.gps_values[1].set_text('%.6f' % self.mapsObj.gps.gpsfix.latitude)
         if self.mapsObj.gps.gpsfix.longitude:
             self.gps_values[2].set_text('%.6f' % self.mapsObj.gps.gpsfix.longitude)
         speed_unit = self.mapsObj.conf.units
         speed = self.mapsObj.gps.gpsfix.speed
         if speed:
             if speed_unit != UNIT_TYPE_NM:
                 speed = mapUtils.convertUnits(UNIT_TYPE_NM, speed_unit, speed)
             self.gps_values[3].set_text('%.1f %s' % (speed, SPEED_UNITS[speed_unit]))
         if self.mapsObj.gps.gpsfix.track:
             self.gps_values[4].set_text('%.1f°' % self.mapsObj.gps.gpsfix.track)
         if self.mapsObj.gps.gpsfix.altitude:
             self.gps_values[5].set_text('%.1fm' % self.mapsObj.gps.gpsfix.altitude)
         if self.mapsObj.conf.gps_type == TYPE_SERIAL:
             self.gps_values[6].set_text('%i' % self.mapsObj.gps.gpsfix.satellites)
     else:
         self.fix_label.set_text('<span foreground=\"red\">No GPS detected</span>')
         for gps_value in self.gps_values:
             gps_value.set_text('---')
     self.fix_label.set_use_markup(True)
     if self.__stop:
         return False
     else:
         return True
コード例 #4
0
    def draw_line(self, unit, zl, points, color, width, draw_distance=False):
        gc = self.style.black_gc
        gc.line_width = width
        gc.set_rgb_fg_color(gtk.gdk.color_parse(color))
        dist_str = None
        total_distance = 0

        def do_draw(ini, end):
            self.window.draw_line(gc, ini[0], ini[1], end[0], end[1])
            if dist_str:
                self.write_text(gc, end[0], end[1], dist_str, 10)

        for j in range(len(points) - 1):
            if draw_distance:
                distance = mapUtils.countDistanceFromLatLon(
                    points[j].getLatLon(), points[j + 1].getLatLon())
                if unit != UNIT_TYPE_KM:
                    distance = mapUtils.convertUnits(UNIT_TYPE_KM, unit,
                                                     distance)
                total_distance += distance
                dist_str = '%.3f %s \n%.3f %s' % (
                    distance, DISTANCE_UNITS[unit], total_distance,
                    DISTANCE_UNITS[unit])
            ini = self.coord_to_screen(points[j].latitude, points[j].longitude,
                                       zl)
            end = self.coord_to_screen(points[j + 1].latitude,
                                       points[j + 1].longitude, zl)
            if ini and end:
                do_draw(ini, end)
            elif ini or end:
                if ini:
                    end = self.coord_to_screen(points[j + 1].latitude,
                                               points[j + 1].longitude, zl,
                                               True)
                if end:
                    ini = self.coord_to_screen(points[j].latitude,
                                               points[j].longitude, zl, True)
                do_draw(ini, end)
        return gc
コード例 #5
0
        def draw_line(self, track, track_color, zl, draw_start_end=True):
            coord_to_screen_f = self.da.coord_to_screen

            def do_draw(ini, end, dist_str=None):
                gtk.threads_enter()
                try:
                    self.da.window.draw_line(self.gc, ini[0], ini[1], end[0], end[1])
                    if dist_str:
                        self.da.write_text(self.gc, end[0], end[1], dist_str, 10)
                finally:
                    gtk.threads_leave()

            def coord_to_screen(c):
                temp = coord_to_screen_f(c.latitude, c.longitude, zl, True)
                cur_coord = coord_to_screen_f(self.base_point[0], self.base_point[1], zl, True)
                return (temp[0] - cur_coord[0], temp[1] - cur_coord[1])

            self.gc.line_width = self.track_width
            self.gc.set_rgb_fg_color(gtk.gdk.color_parse(track_color))
            cur_coord = coord_to_screen_f(self.base_point[0], self.base_point[1], zl, True)

            rect = self.da.get_allocation()
            center = (rect.width / 2, rect.height / 2)
            threshold = 1000  # in pixels
            threshold_x = threshold + center[0]
            threshold_y = threshold + center[1]
            mod_x = cur_coord[0] - center[0]
            mod_y = cur_coord[1] - center[1]

            dist_str = None

            # start = time.time()
            # See if track is already in screen_coords
            try:
                self.screen_coords[track]
            except:
                # If not, add it
                self.screen_coords[track] = []

            screen_coords = self.screen_coords[track]
            if len(self.screen_coords[track]) < len(track.points):
                # Calculate screen_coords for points which aren't in it already
                screen_coords.extend(map(coord_to_screen, track.points[len(screen_coords):]))

            for j in range(len(screen_coords) - 1):
                # If update or __stop was set while we're in the loop, break
                if self.update.is_set() or self.update_all.is_set() or self.__stop.is_set():
                    return
                if abs(screen_coords[j][0] + mod_x) < threshold_x \
                  and abs(screen_coords[j][1] + mod_y) < threshold_y:
                    if self.draw_distance:
                        distance = mapUtils.countDistanceFromLatLon(track.points[j].getLatLon(), track.points[j + 1].getLatLon())
                        if self.unit != UNIT_TYPE_KM:
                            distance = mapUtils.convertUnits(UNIT_TYPE_KM, self.unit, distance)
                        dist_str = '%.3f %s' % (distance, DISTANCE_UNITS[self.unit])
                    ini = (screen_coords[j][0] + cur_coord[0], screen_coords[j][1] + cur_coord[1])
                    end = (screen_coords[j + 1][0] + cur_coord[0], screen_coords[j + 1][1] + cur_coord[1])
                    if ini and end:
                        do_draw(ini, end, dist_str)

            if draw_start_end:
                if track.distance:
                    distance = mapUtils.convertUnits(UNIT_TYPE_KM, self.unit, track.distance)
                    text = '%s - %.2f %s' % (track.name, distance, DISTANCE_UNITS[self.unit])
                else:
                    text = track.name
                gtk.threads_enter()     # Precautions to tell GTK that we're drawing from a thread now
                try:
                    self.da.write_text(self.gc, screen_coords[0][0] + cur_coord[0],
                        screen_coords[0][1] + cur_coord[1], '%s (start)' % text)
                    self.da.write_text(self.gc, screen_coords[-1][0] + cur_coord[0],
                        screen_coords[-1][1] + cur_coord[1], '%s (end)' % text)
                finally:
                    gtk.threads_leave()  # And once we are finished, tell that as well...
コード例 #6
0
        def draw_line(self, track, track_color):
            self.gc.line_width = self.track_width
            self.gc.set_rgb_fg_color(gtk.gdk.color_parse(track_color))

            def do_draw(ini, end, dist_str=None):
                gtk.threads_enter()
                try:
                    self.da.window.draw_line(self.gc, ini[0], ini[1], end[0],
                                             end[1])
                    if dist_str:
                        self.da.write_text(self.gc, end[0], end[1], dist_str,
                                           10)
                finally:
                    gtk.threads_leave()

            cur_coord = self.da.coord_to_screen(self.base_point[0],
                                                self.base_point[1], self.zl,
                                                True)

            rect = self.da.get_allocation()
            center = (rect.width / 2, rect.height / 2)
            threshold = 1000  # in pixels
            threshold_x = threshold + center[0]
            threshold_y = threshold + center[1]
            mod_x = cur_coord[0] - center[0]
            mod_y = cur_coord[1] - center[1]

            start = time.time()
            dist_str = None

            # See if track is already in screen_coords
            try:
                self.screen_coords[track]
            except:
                # If not, add it
                self.screen_coords[track] = []
            try:  # Check if first point is in screen_coords
                self.screen_coords[track][0]
            except:  # If not, add it...
                temp = self.da.coord_to_screen(track.points[0].latitude,
                                               track.points[0].longitude,
                                               self.zl, True)
                cur_coord = self.da.coord_to_screen(self.base_point[0],
                                                    self.base_point[1],
                                                    self.zl, True)
                self.screen_coords[track].append(
                    (temp[0] - cur_coord[0], temp[1] - cur_coord[1]))

            for j in range(len(track.points) - 1):
                # If update or __stop was set while we're in the loop, break
                if self.update.is_set() or self.update_all.is_set(
                ) or self.__stop.is_set():
                    return
                try:  # Check if j + 1 in screen_coords
                    self.screen_coords[track][j + 1]
                except:  # If not, add it...
                    temp = self.da.coord_to_screen(
                        track.points[j + 1].latitude,
                        track.points[j + 1].longitude, self.zl, True)
                    cur_coord = self.da.coord_to_screen(
                        self.base_point[0], self.base_point[1], self.zl, True)
                    self.screen_coords[track].append(
                        (temp[0] - cur_coord[0], temp[1] - cur_coord[1]))
                if abs(self.screen_coords[track][j][0] + mod_x) < threshold_x \
                  and abs(self.screen_coords[track][j][1] + mod_y) < threshold_y:
                    if self.draw_distance:
                        distance = mapUtils.countDistanceFromLatLon(
                            track.points[j].getLatLon(),
                            track.points[j + 1].getLatLon())
                        if self.unit != UNIT_TYPE_KM:
                            distance = mapUtils.convertUnits(
                                UNIT_TYPE_KM, self.unit, distance)
                        dist_str = '%.3f %s' % (distance,
                                                DISTANCE_UNITS[self.unit])
                    ini = (self.screen_coords[track][j][0] + cur_coord[0],
                           self.screen_coords[track][j][1] + cur_coord[1])
                    end = (self.screen_coords[track][j + 1][0] + cur_coord[0],
                           self.screen_coords[track][j + 1][1] + cur_coord[1])
                    if ini and end:
                        do_draw(ini, end, dist_str)
            print 'drawing: %.3fs' % (time.time() - start)

            if self.draw_start_end:
                if track.distance:
                    distance = mapUtils.convertUnits(UNIT_TYPE_KM, self.unit,
                                                     track.distance)
                    text = '%s - %.2f %s' % (track.name, distance,
                                             DISTANCE_UNITS[self.unit])
                else:
                    text = track.name
                gtk.threads_enter(
                )  # Precautions to tell GTK that we're drawing from a thread now
                try:
                    self.da.write_text(
                        self.gc,
                        self.screen_coords[track][0][0] + cur_coord[0],
                        self.screen_coords[track][0][1] + cur_coord[1],
                        '%s (start)' % text)
                    self.da.write_text(
                        self.gc,
                        self.screen_coords[track][-1][0] + cur_coord[0],
                        self.screen_coords[track][-1][1] + cur_coord[1],
                        '%s (end)' % text)
                finally:
                    gtk.threads_leave(
                    )  # And once we are finished, tell that as well...
コード例 #7
0
    def do_scale(self, zoom, current_zoom_level, doForce, dPointer):
        if (zoom == current_zoom_level) and not doForce:
            return

        rect = self.get_allocation()
        da_center = (rect.width // 2, rect.height // 2)
        if dPointer:
            fix_tile, fix_offset = mapUtils.pointer_to_tile(
                rect, dPointer, self.center, current_zoom_level
            )
        else:
            fix_tile, fix_offset = self.center

        scala = 2 ** (current_zoom_level - zoom)
        x = int((fix_tile[0] * TILES_WIDTH + fix_offset[0]) * scala)
        y = int((fix_tile[1] * TILES_HEIGHT + fix_offset[1]) * scala)
        if dPointer and not doForce:
            x = x - (dPointer[0] - da_center[0])
            y = y - (dPointer[1] - da_center[1])

        self.center = (x / TILES_WIDTH, y / TILES_HEIGHT), \
                      (x % TILES_WIDTH, y % TILEraw_image(self, screen_coord, img, width, height):
        self.window.draw_pixbuf(
            self.style.black_gc, img, 0, 0,
            screen_coord[0] - width / 2, screen_coord[1] - height / 2,
            width, height
        )

    def w_draw_line(self, gc, x1, y1, x2, y2):
        self.window.draw_line(gc, int(x1), int(y1), int(x2), int(y2))

    def draw_arrow(self, screen_coord, direction):
        arrow_length = 50
        self.set_arrow_gc()
        rad = math.radians(direction)
        sin = math.sin(rad)
        cos = math.cos(rad)

        arrowtop = (screen_coord[0] + arrow_length * sin, screen_coord[1] - arrow_length * cos)

        self.w_draw_line(self.arrow_gc,
                screen_coord[0],
                screen_coord[1],
                arrowtop[0],
                arrowtop[1])
        # TODO: Arrow pointers
        # self.w_draw_line(self.arrow_gc,
        #         arrowtop[0], arrowtop[1],
        #         arrowtop[0] + 7 * math.cos(direction + 3 * math.pi / 4.0),
        #         arrowtop[1] + 7 * math.sin(direction + 3 * math.pi / 4.0))
        # self.w_draw_line(self.arrow_gc,
        #         arrowtop[0], arrowtop[1],
        #         arrowtop[0] + 7 * math.cos(direction - 3 * math.pi / 4.0),
        #         arrowtop[1] + 7 * math.sin(direction - 3 * math.pi / 4.0))

    ## Draws the marker
    def draw_marker(self, conf, mcoord, zl, img, pixDim, marker_name):
        screen_coord = self.coord_to_screen(mcoord[0], mcoord[1], zl)
        if screen_coord:
            gc = self.scale_gc
            cPos = marker_name.find('#')
            if (cPos > -1):
                try:
                    my_gc = self.window.new_gc()
                    color = gtk.gdk.color_parse(marker_name[cPos:cPos + 7])
                    my_gc.set_rgb_fg_color(color)
                    gc = my_gc
                except:
                    pass
            if marker_name.startswith('point'):
                self.draw_point(screen_coord, gc)
            elif marker_name.startswith('circle'):
                self.draw_circle(screen_coord, gc)
            else:
                self.draw_image(screen_coord, img, pixDim, pixDim)
                if conf.show_marker_name:
                    # Display the Marker Name
                    gco = self.window.new_gc()
                    gco.set_rgb_fg_color(gtk.gdk.color_parse(conf.marker_font_color))

                    pangolayout = self.create_pango_layout(marker_name)
                    pangolayout.set_font_description(
                            pango.FontDescription(conf.marker_font_desc))
                    self.wr_pltxt(gco, screen_coord[0], screen_coord[1], pangolayout)

    ## Show the text
    def wr_pltxt(self, gc, x, y, pl):
        gc1 = self.window.new_gc()
        gc1.line_width = 2
        gc1.set_rgb_fg_color(gtk.gdk.color_parse("#000000"))
        self.window.draw_layout(gc1, x - 1, y - 1, pl)
        self.window.draw_layout(gc1, x, y - 1, pl)
        self.window.draw_layout(gc1, x + 1, y - 1, pl)
        self.window.draw_layout(gc1, x + 1, y, pl)
        self.window.draw_layout(gc1, x + 1, y + 1, pl)
        self.window.draw_layout(gc1, x, y + 1, pl)
        self.window.draw_layout(gc1, x - 1, y + 1, pl)
        self.window.draw_layout(gc1, x - 1, y, pl)
        self.window.draw_layout(gc, x, y, pl)

    ## Draw the second layer of elements
    def draw_overlay(self, zl, conf, crossPixbuf, dlpixbuf,
                    downloading=False, visual_dlconfig={},
                    marker=None, locations={}, entry_name="",
                    showMarkers=False, gps=None, gps_track=None,
                    r_coord=[],
                    tracks=None, draw_track_distance=False,
                    cur_coord=None):
        self.set_scale_gc()
        self.set_visualdl_gc()
        rect = self.get_allocation()
        middle = (rect.width / 2, rect.height / 2)
        full = (rect.width, rect.height)

        if (self.markerThread is not None):
           ad.cancel()

        if tracks:
            self.draw_tracks(conf.units, tracks, zl, conf.gps_track_width, draw_track_distance)

        if conf.gps_track and len(gps_track.points) > 1:
            self.draw_gps_line(conf.units, gps_track, zl, conf.gps_track_width)

        # Draw the Ruler lines
        if len(r_coord) >= 1:
            self.draw_ruler_lines(conf.units, r_coord, zl, conf.gps_track_width)

        if showMarkers:
            pixDim = .get_pixDim(zl)
            # Draw the selected location
         rd_to_screen(coord[0], coord[1], zl)
                if screen_coord:
                    img = marker.get_marker_pixruler(zl, 'marker1.png')
                    self.draw_image(screen_coord, img, pixDim, pixDim)
            else:
                coord = (None, None, None)

            # Draw the markers
            if len(marker.positions) < 1000:
                self.draw_markers(zl, marker, coord, conf, pixDim)
            else:
                self.markerThread = Timer(0.5, self.draw_markers_thread, [zl, marker, coord, conf, pixDim])
                self.markerThread.start()

        # Draw the downloading notification
        if downloading:
            self.windoself.draw_markers(zl, marker, coord, conf, pixDimnf)

        # Draw cross in the center
        if conf.show_cross:
            self.draw_image(middle, crossPixbuf, 12, 12)

        # Draw GPS position
        if gps and gps.gpsfix:
            location = gps.get_location()
            if location is not None and zl <= conf.max_gps_zoom:
                img = gps.pixbuf
          and cur_coord       screen_coord = self.coord_to_screen(location[0], location[1], zl)
                if screen_coord:
                    self.draw_image(screen_coord, img,
                        GPS_IMG"make the damn thing not so bright" -overlay
        if conf.opacity != 0.0:
            self.cr.set_source_rgba(0, 0, 0, conf.opacity)
            self.cr.rectangle(0, 0, rect.width, rect.height)
            self.cr.fill(      GPS_IMG_SIZE[0], GPS_IMG_SIZE[1])
                    if gps.gpsfix.speed >= 0.5:  # draw arrow only, if speed is over 0.5 knots
                        self.draw_arrow(screen_coord, gps.gpsfix.track)
            if gps.mode != GPS_DISABLED and gps.gpsfix.mode == MODE_NO_FIX:
                gc = self.style.black_gc
             # # Draw the circle
                    # self.cr.set_source_rgba(1, 0, 0, 0.5)
                    # self.cr.set_line_width(4)
                    # self.cr.arc(screen_coord[0], screen_coord[1], 15, 0, 2 * math.pi)
                    # self.cr.stroke_preserve()

                    # # Draw "target lines"
                    # self.cr.set_line_width(2)
                    # self.cr.move_to(screen_coord[0], screen_coord[1] - 15)
                    # self.cr.rel_line_to(0, 30)
                    # self.cr.move_to(screen_coord[0] - 15, screen_coord[1])
                    # self.cr.rel_line_to(30, 0)
                    # self.cr.stroke()
                    self.draw_image(screen_coord, img,
                   
                self.write_text(gc, middle[0] - 160, 0, 'INVALID GPS DATtrack andALID GPS DATA', 28)

    def draw_markers(self, zl, marker, coord, conf, pixDim):
        img = marker.get_marker_pixbuf(zl)
        for string in marker.positions.keys():
            mpos = marker.positions[string]
            if (zl <=self.draw_message('INVALID GPS DATA', middle[0] - 150, 0, 'red')

    def draw_message(self, strMessage, x=0, y=0, colorStr='black'):
        color = gtk.gdk.color_parse(colorStr)
        gc = self.window.new_gc(
            color, color, None, gtk.gdk.COPY,
            gtk.gdk.SOLID, None, None, None,
            gtk.gdk.INCLUDE_INFERIORS,
            0, 0, 0, 0, True, 3, gtk.gdk.LINE_DOUBLE_DASH,
            gtk.gdk.CAP_NOT_LAST, gtk.gdk.JOIN_ROUND)
        gc.set_rgb_fg_color(color)
        self.write_text(gc, x, y, strMessage, 28)
      try:
   DISTANCE_UNITS[conf.units])
        self.scale_lo.set_text(scalestr)
        self.window.draw_line(self.scale_gc, 10, full[1] - 10, 10, full[1] - 15)
        self.window.draw_line(self.scale_gc, 10, full[1] - 10, scaledata[0] + 10, full[1] - 10)
        self.window.draw_line(self.scale_gc, scaledata[0] + 10, full[1] - 10, scaledata[0] + 10, full[1] - 15)
        self.window.draw_layout(self.scale_gc, 15, full[1] - 25, self.scale_lo)

    def draw_visual_dlconfig(self, visual_dlconfig, middle, full, zl):
        sz = visual_dlconfig.get("sz", 4)
        # Draw a rectangle
        if visual_dlconfig.get("show_rectangle", False):
            width = visual_dlconfig.get("width_rect", 0)
            height = visual_dlconfig.get("height_rect", 0)
            if width > 0 and height > 0:
                self.window.draw_rectangle(
                    self.scale_gc, True,
                    visual_dlconfig.get("x_rect", 0),
                    visual_dlconfig.get("y_rect", 0),
                    width, height
                )
        # Draw the download utility
        elif visual_dlconfig.get("active", False):
            thezl = str(zl + visual_dlconfig.get("zl", -2))
            self.visualdl_lo.set_text(thezl)
            self.window.draw_rectangle(self.visualdl_gc, False,
                    middle[0] - full[0] / (sz * 2),
                    middle[1] - full[1] / (sz * 2), full[0] / sz, full[1] / sz)
            self.window.draw_layout(self.visualdl_gc,
                    middle[0] + full[0] / (sz * 2) - len(thezl) * 10,
                    middle[1] - full[1] / (sz * 2),
                    self.visualdl_lo)

        if visual_dlconfig.get('qd', 0) > 0:
            self.visualdl_lo.set_text(
                    str(visual_dlconfig.get('recd', 0)) + "/" +
                    str(visual_dlconfig.get('qd', 0)))
            if sz == 1:
                ypos = -15
            else:
                ypos = 0
            self.window.draw_layout(self.visualdl_gc,
                    middle[0],
                    middle[1] + full[1] / (sz * 2) + ypos,
                    self.visualdl_lo)

    ## Draw line with zoomlevel, [points], color, width and optional distance string
    # returns used gc (to be used in write_text for example)
    def draw_line(self, unit, zl, points, color, width, draw_distance=False):
        gc = self.style.black_gc
        gc.line_width = width
        gc.set_rgb_fg_color(gtk.gdk.color_parse(color))
        dist_str = None
        total_distance = 0

        def do_draw(ini, end):
            self.window.draw_line(gc, ini[0], ini[1], end[0], end[1])
            if dist_str:
                self.write_text(gc, end[0], end[1], dist_str, 10)

        for j in range(len(points) - 1):
            if draw_distance:
                distance = mapUtils.countDistanceFromLatLon(points[j].getLatLon(), points[j + 1].getLatLon())
                if unit != UNIT_TYPE_KM:
                    distance = mapUtils.convertUnits(UNIT_TYPE_KM, unit, distance)
                total_distance += distance
                dist_str = '%.3f %s \n%.3f %s' % (distance, DISTANCE_UNITS[unit], total_distance, DISTANCE_UNITS[unit])
            ini = self.coord_to_screen(points[j].latitude, points[j].longitude, zl)
            end = self.coord_to_screen(points[j + 1].latitude, points[j + 1].longitude, zl)
            if ini and end:
                do_draw(ini, end)
            elif ini or end:
                if ini:
                    end = self.coord_to_screen(points[j + 1].latitude, points[j + 1].longitude, zl, True)
                if end:
                    ini = self.coord_to_screen(points[j].latitude, points[j].longitude, zl, True)
                do_draw(ini, end)
        return gc

    ## Write text to point in screen coord -format
    def write_text(self, gc, x, y, text, fontsize=12):
        pangolayout = self.create_pango_layout("")
        pangolayout.set_font_description(pango.FontDescription("sans normal %s" % fontsize))
        pangolayout.set_text(text)
        self.wr_pltxt(gc, x, y, pangolayout)

    ## Write text to point in (lat, lon) -format
    def write_text_lat_lon(self, gc, zl, point, text):
        screen_coord = self.coord_to_screen(point.latitude, point.longitude, zl)
        if screen_coord:
            self.write_text(gc, screen_coord[0], screen_coord[1], text)

    def draw_ruler_lines(self, unit, points, zl, track_width):
        color = 'green'
        self.draw_line(unit, zl, points, color, track_width, True)

    def draw_gps_line(self, unit, track, zl, track_width):
        if not self.gpsTrackInst:
            self.set_gps_track_gc('red')
            color = 'red'
            self.gpsTrackInst = self.TrackThread(self, self.gps_track_gc,
                color, unit, track, zl, track_width, False, False)
            self.gpsTrackInst.start()
        else:
            self.gpsTrackInst.unit =