Beispiel #1
0
    def pre_compute(self, painter):
        w = self.width()
        h = self.height()

        s = scale(
            self.config["min"], self.config["max"],
            float(self.config["max"] - self.config["min"]) /
            (self.config["w"] / 4))

        self.angles = map_scale(s, 0, self.config["w"])
        self.str_scale, self.multiplier = str_scale(s,
                                                    self.config["scale_mult"])
        self.red_angle = self.config["w"]
        if self.config["redline"] is not None:
            self.red_angle = map_value(self.config["redline"],
                                       self.config["min"], self.config["max"],
                                       0, self.config["w"])

        # recompute new values
        self.l = 2  # left X value
        self.r = w - self.l  # right X value
        self.t_height = self.config["font_size"] + 8
        self.bar_height = max(0, h - self.t_height) - self.l
        self.value_offset = map_value(self.value, self.config["min"],
                                      self.config["max"], self.l, self.r)
        self.red_offset = w
        if self.config["redline"] is not None:
            self.red_offset = map_value(self.config["redline"],
                                        self.config["min"], self.config["max"],
                                        self.l, self.r)
Beispiel #2
0
    def __init__(self, parent, config):
        super(Gauge, self).__init__(parent)

        self.config = config
        self.value = config["min"]

        self.font      = QFont()
        self.note_font = QFont()
        self.color     = QColor(config["color"])
        self.red_color = QColor(config["redline_color"])
        self.brush     = QBrush(self.color)
        self.pen       = QPen(self.color)
        self.red_pen   = QPen(self.red_color)

        self.font.setPixelSize(self.config["font_size"])
        self.note_font.setPixelSize(self.config["note_font_size"])
        self.pen.setWidth(3)
        self.red_pen.setWidth(3)

        s = scale(config["min"], config["max"], config["scale_step"])

        self.angles = map_scale(s, 0, 270)
        self.str_scale, self.multiplier = str_scale(s, config["scale_mult"])

        self.red_angle = 270
        if config["redline"] is not None:
            self.red_angle  = map_value(config["redline"], config["min"], config["max"], 0, 270)
Beispiel #3
0
    def __init__(self, parent, config):
        super(Gauge2, self).__init__(parent)

        self.config = config
        self.value = config["min"]

        self.font      = QFont()
        self.note_font = QFont()
        self.color     = QColor(config["color"])
        self.red_color = QColor(config["redline_color"])
        self.brush     = QBrush(self.color)
        self.pen       = QPen(self.color)
        self.red_pen   = QPen(self.red_color)

        self.font.setPixelSize(self.config["font_size"])
        self.note_font.setPixelSize(self.config["note_font_size"])
        self.pen.setWidth(4)
        self.red_pen.setWidth(4)

        s = scale(config["min"], config["max"], config["scale_step"])
        ss = scale(config["min"] + config["scale_step"], config["max"] - config["scale_step"], config["scale_step"])

        self.angles = map_scale(s, 0, 180)
        self.str_scale, self.multiplier = str_scale(s, config["scale_mult"])
        self.sub_angles = map_scale(ss, 22.5, 157.5)

        self.red_angle = 180
        if config["redline"] is not None:
            self.red_angle  = map_value(config["redline"], config["min"], config["max"], 0, 180)
Beispiel #4
0
    def __init__(self, parent, config):
        super(DigitalBoost, self).__init__(parent)

        self.config = config
        config.update({'min' : -30, 
            'max' : 20, 
            'color' : '#2e3fcc', 
            'redline_color' : '#ff0000', 
            'scale_multi': 1, 
            'scale_step': 10, 
            'redline' : 14, 
            'font_size' : 18, 
            'title' : 'Highest Trip Boost',
            'x': 0,
            'y': 5,
            'w': 200,
            'h': 200,
            'numerals': 'false',
            'sensor': 'Boost'})
        self.value = config["min"]
        self.highest = config['min']

        self.font_db  = QFontDatabase()
        self.font_id  = self.font_db.addApplicationFont("fonts/DS-DIGI.TTF")
        self.families = self.font_db.applicationFontFamilies(self.font_id)
        #print [str(f) for f in self.families] #DS-Digital

        self.font         = QFont("DS-Digital")
        self.note_font    = QFont("DS-Digital")
        self.title_font   = QFont("DS-Digital")
        self.color        = QColor(config["color"])
        self.pen_color    = QColor(Qt.black)
        self.red_color    = QColor(config["redline_color"])
        self.brush        = QBrush(self.color)
        self.brush_bg     = QBrush(QColor("#555555"))
        self.brush_red    = QBrush(self.red_color)
        self.brush_red_bg = QBrush(self.red_color)
        self.pen          = QPen(self.pen_color)
        self.red_pen      = QPen(self.red_color)
        self.text_pen     = QPen(self.color)

        self.font.setPixelSize(self.config["font_size"])
        
        self.pen.setWidth(1)
        self.red_pen.setWidth(1)
        
        # TODO: make 80 configurable
        s = scale(config["min"], config["max"], float(config["max"] - config["min"])/80)

        self.angles = map_scale(s, 0, 270)
        self.str_scale, self.multiplier = str_scale(s, config["scale_multi"])

        self.red_angle = 270
        if config["redline"] is not None:
            self.red_angle  = map_value(config["redline"], config["min"], config["max"], 0, 270)
Beispiel #5
0
    def __init__(self, parent, config):
        super(GL_DigitalGauge, self).__init__(parent)

        self.config = config
        self.value = config["min"]

        self.font_db  = QFontDatabase()
        self.font_id  = self.font_db.addApplicationFont("fonts/DS-DIGI.TTF")
        self.families = self.font_db.applicationFontFamilies(self.font_id)
        #print [str(f) for f in self.families] #DS-Digital

        self.font         = QFont("DS-Digital")
        self.note_font    = QFont("DS-Digital")
        self.title_font   = QFont("DS-Digital")
        self.color        = QColor(config["color"])
        self.pen_color    = QColor(Qt.black)
        self.red_color    = QColor(config["redline_color"])
        self.brush        = QBrush(self.color)
        self.brush_bg     = QBrush(QColor("#555555"))
        self.brush_red    = QBrush(self.red_color)
        self.brush_red_bg = QBrush(self.red_color)
        self.pen          = QPen(self.pen_color)
        self.red_pen      = QPen(self.red_color)
        self.indicator_color = QColor(config["indicator_color"])
        self.text_pen     = QPen(self.color)
        self.indicator_pen     = QPen(self.indicator_color)



        self.font.setPixelSize(self.config["font_size"])
        
        self.pen.setWidth(1)
        self.red_pen.setWidth(1)
        
        # TODO: make 80 configurable
        s = scale(config["min"], config["max"], float(config["max"] - config["min"])/80)

        self.angles = map_scale(s, 0, 270)
        self.str_scale, self.multiplier = str_scale(s, config["scale_mult"])

        self.red_angle = 270
        if config["redline"] is not None:
            self.red_angle  = map_value(config["redline"], config["min"], config["max"], 0, 270)
Beispiel #6
0
    def __init__(self, parent, config):
        super(GL_Gauge, self).__init__(parent)

        self.config = config

        self.value = config["min"]

        self.font = QFont()
        self.note_font = QFont()
        self.color = QColor(config["color"])
        self.red_color = QColor(config["redline_color"])
        self.indicator_color = QColor(config["indicator_color"])

        self.brush = QBrush(self.color)
        self.indicator_brush = QBrush(self.indicator_color)

        self.pen = QPen(self.color)
        self.red_pen = QPen(self.red_color)
        self.indicator_pen = QPen(self.indicator_color)

        self.font.setPixelSize(self.config["font_size"])
        self.note_font.setPixelSize(self.config["note_font_size"])

        self.pen.setWidth(3)
        self.red_pen.setWidth(3)
        self.indicator_pen.setWidth(3)

        s = scale(config["min"], config["max"], config["scale_step"])

        self.angles = map_scale(s, 0, 270)
        self.str_scale, self.multiplier = str_scale(s, config["scale_mult"])

        self.red_angle = 270
        if config["redline"] is not None:
            self.red_angle = map_value(config["redline"], config["min"],
                                       config["max"], 0, 270)

        #self.initializeGL()
        self.resizeGL(config['w'], config['h'])