def db_query_finished(self, heatmap_dict: dict, status_type: str):
        """
        Method that handles the calculation of node colors for heatmap display
        :param heatmap_dict: An array with node IDs as keys and percentages (i.e. how much of the total
        running/failure/waiting/success statuses the node is responsible for) as values
        :param status_type: Which status we're interested in (running, waiting, success, or failure)
        """
        heatmap_color_dict = {}

        # Determine base color based on the chosen status
        if status_type == "Success":
            start_color = Qt.green
        elif status_type == "Waiting":
            start_color = Qt.yellow
        elif status_type == "Running":
            start_color = QColor(255, 153, 0)   # Orange
        else:
            start_color = Qt.red

        # Calculate the color intensity for each node based on the dictionary values
        for node_id, percentage in heatmap_dict.items():
            color = QColor(start_color)
            # skip the lower (dark) part of the spectrum and keep the lightness between 0.5 and 0.9
            lightness = 1 - (percentage * 0.3 + 0.2)
            color.setHslF(color.hslHue() / 360, color.hslSaturation() / 255, lightness)
            heatmap_color_dict[node_id] = color
        self.gui.tree_view_widget.graphics_scene.change_colors(heatmap_color_dict)
Exemple #2
0
    def rgb_changed(self, *_args):
        if self.changing:
            return

        r, g, b = self.spin_r.value(), self.spin_g.value(), self.spin_b.value()
        rgb = QColor(r, g, b)
        h, s, l = rgb.hslHue(), rgb.hslSaturation(), rgb.lightness()

        self.changing = True

        if h != -1: # Qt returns -1 if the color is achromatic (i.e. grey).
            self.spin_h.setValue(h)
        self.spin_s.setValue(s)
        self.spin_l.setValue(l)
        self.changing = False

        self.rgb_led.set_rgb_value(r, g, b)
        self.label_color.setStyleSheet('QLabel {{ background: #{:02x}{:02x}{:02x} }}'.format(r, g, b))
Exemple #3
0
    def rgb_changed(self, *_args):
        if self.changing:
            return

        r, g, b = self.spin_r.value(), self.spin_g.value(), self.spin_b.value()
        rgb = QColor(r, g, b)
        h, s, l = rgb.hslHue(), rgb.hslSaturation(), rgb.lightness()

        self.changing = True

        if h != -1:  # Qt returns -1 if the color is achromatic (i.e. grey).
            self.spin_h.setValue(h)
        self.spin_s.setValue(s)
        self.spin_l.setValue(l)
        self.changing = False

        self.rgb_led.set_rgb_value(r, g, b)
        self.label_color.setStyleSheet(
            'QLabel {{ background: #{:02x}{:02x}{:02x} }}'.format(r, g, b))