def update_model_with_led_targets()

in src/open_vp_cal/widgets/colourspaces_widget.py [0:0]


    def update_model_with_led_targets(self, led_walls: List[LedWallSettings]) -> None:
        """ When the LED wall selection changes, we want to update the model so that the targets for each wall
            are displayed correctly based on if their target gamuts have changed or not

        Args:
            led_walls: The LED walls we want to update the model with
        """
        data = self._model.get_data()
        did_gamuts_change = False
        for led_wall in led_walls:
            target_gamut = led_wall.target_gamut
            if led_wall.name not in data:
                data[led_wall.name] = {}

            if constants.DisplayFilters.TARGET in data[led_wall.name]:
                if data[led_wall.name][constants.DisplayFilters.TARGET]["gamut_name"] == target_gamut:
                    break

            did_gamuts_change = True
            color_space = self.get_target_colourspace_for_led_wall(led_wall)
            target_macbeth = macbeth.get_rgb_references_for_color_checker(color_space, illuminant=None)
            target_macbeth_XYZ = np.apply_along_axis(
                lambda rgb: color_space.matrix_RGB_to_XYZ.dot(rgb), 1, target_macbeth
            )
            target_macbeth_xy = colour.XYZ_to_xy(target_macbeth_XYZ)

            if constants.DisplayFilters.MACBETH not in data[led_wall.name]:
                data[led_wall.name][constants.DisplayFilters.MACBETH] = {}

            data[led_wall.name][constants.DisplayFilters.MACBETH][constants.DisplayFilters.TARGET] = target_macbeth_xy

            data_x, data_y = [], []
            for primary in color_space.primaries:
                data_x.append(primary[0])
                data_y.append(primary[1])

            data_x.append(data_x[0])
            data_y.append(data_y[0])

            color = utils.generate_color(f"{led_wall.name}_{constants.DisplayFilters.TARGET}")
            data[led_wall.name][constants.DisplayFilters.TARGET] = {
                "gamut_name": target_gamut,
                "line_colour": color,
                "plot_data": (data_x, data_y),
                "white_point": color_space.whitepoint
            }

        if did_gamuts_change:
            self._model.set_data(data)