def load_course(self):

        if len(self.config.logger.course.distance) == 0 or len(
                self.config.logger.course.altitude) == 0:
            return

        t = datetime.datetime.utcnow()

        if not self.config.logger.sensor.sensor_gps.hasGPS():
            self.zoom = self.config.G_MAX_ZOOM

        self.plot.showGrid(x=True, y=True, alpha=1)
        self.plot.showAxis('left')
        self.plot.showAxis('bottom')
        font = QtGui.QFont()
        font.setPixelSize(16)
        font.setBold(True)
        self.plot.getAxis("bottom").tickFont = font
        #self.plot.getAxis("bottom").setStyle(tickTextOffset = 5)
        self.plot.getAxis("left").tickFont = font
        #self.plot.getAxis("left").setStyle(tickTextOffset = 5)
        #self.plot.setAutoPan()

        print("\tpyqt_graph : load course profile : ",
              (datetime.datetime.utcnow() - t).total_seconds(), "sec")
        t = datetime.datetime.utcnow()

        bg = pg.CourseProfileGraphItem(
            x=self.config.logger.course.distance,
            y=self.config.logger.course.altitude,
            brushes=self.config.logger.course.colored_altitude,
            pen=pg.mkPen(color=(255, 255, 255, 0),
                         width=0.01))  #transparent(alpha=0) and thin line
        self.plot.addItem(bg)

        print("\tpyqt_graph : plot course profile : ",
              (datetime.datetime.utcnow() - t).total_seconds(), "sec")
Beispiel #2
0
    def load_course(self):

        if len(self.config.logger.course.distance) == 0:
            return

        t = datetime.datetime.utcnow()

        if not self.config.logger.sensor.sensor_gps.hasGPS():
            self.zoom = self.config.G_MAX_ZOOM

        self.plot.showGrid(x=True, y=True, alpha=1)
        self.plot.showAxis('left')
        self.plot.showAxis('bottom')
        font = QtGui.QFont()
        font.setPixelSize(16)
        font.setBold(True)
        self.plot.getAxis("bottom").tickFont = font
        #self.plot.getAxis("bottom").setStyle(tickTextOffset = 5)
        self.plot.getAxis("left").tickFont = font
        #self.plot.getAxis("left").setStyle(tickTextOffset = 5)
        #self.plot.setAutoPan()

        print("\tpyqt_graph : load course profile : ",
              (datetime.datetime.utcnow() - t).total_seconds(), "sec")
        t = datetime.datetime.utcnow()

        bg = pg.CourseProfileGraphItem(
            x=self.config.logger.course.distance,
            y=self.config.logger.course.altitude,
            brushes=self.config.logger.course.colored_altitude,
            pen=pg.mkPen(color=(255, 255, 255, 0),
                         width=0.01))  #transparent(alpha=0) and thin line
        self.plot.addItem(bg)

        self.course_points_plot = pg.ScatterPlotItem(pxMode=True, symbol="t")
        self.course_points = []

        for i in reversed(range(len(
                self.config.logger.course.point_distance))):
            cp = {
                'pos': [
                    self.config.logger.course.point_distance[i],
                    self.config.logger.course.point_altitude[i]
                ],
                'size':
                10,
                'pen': {
                    'color': 'r',
                    'width': 1
                },
                'brush':
                pg.mkBrush(color=(255, 0, 0))
            }
            self.course_points.append(cp)
        self.course_points_plot.setData(self.course_points)
        self.plot.addItem(self.course_points_plot)

        self.course_points_label = []
        if self.config.G_FONT_NAME != "":
            self.font = QtGui.QFont(self.config.G_FONT_NAME)
        for i in reversed(range(len(
                self.config.logger.course.point_distance))):
            text = pg.TextItem(
                text=self.config.logger.course.point_name[i],
                anchor=(-0.1, 1.2),
                angle=0,
                border=(255, 0, 0),
                fill=(255, 255, 255),
                color=(0, 0, 0),
            )
            #text.setTextWidth(int(self.config.G_WIDTH/2.5))
            if self.config.G_FONT_NAME != "":
                text.setFont(self.font)
            self.plot.addItem(text)
            text.setPos(self.config.logger.course.point_distance[i],
                        self.config.logger.course.point_altitude[i])
            self.course_points_label.append(text)

        print("\tpyqt_graph : plot course profile : ",
              (datetime.datetime.utcnow() - t).total_seconds(), "sec")