spacr.qt.widgets.channel_mapping

Three-field editor for png_channel_mapping: which source channel is red, which is green, which is blue.

Replaces a text box holding {'r': 2, 'g': 1, 'b': 0}. The dict form is still what the setting is – this only stops the user having to type a Python literal to say something as simple as “555 is my red”.

Why three labelled fields rather than one ordered list: the list form (png_dims) never said which colour it meant. Position 0 was blue because of how cv2 interprets an array it is handed, which is not something the settings panel could show and not something a user could infer. It got read backwards for eleven days and every crop written in that window has its nuclear stain in the red channel. A field labelled “R” cannot be read backwards.

Classes

ChannelMappingWidget

Editor for a {'r': int, 'g': int, 'b': int} channel mapping.

Module Contents

class spacr.qt.widgets.channel_mapping.ChannelMappingWidget(value: Any = None, parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: PySide6.QtWidgets.QWidget

Editor for a {'r': int, 'g': int, 'b': int} channel mapping.

Parameters:
  • value – the mapping already saved. None opens with nothing assigned, and a colour left empty STAYS empty – the run must not put a plane back into a slot the user cleared.

  • parent – parent widget.

Build the row of colour-slot spin boxes.

The whole help lives on each slot’s name rather than on the box beside it: hovering the field the user is about to type in used to cover it with a tooltip they had already read on the label.

The container paints nothing and registers no stylesheet of its own, so there is no new rule to forget to add to the theme’s module list – the children are styled by the existing spin-box and label rules. A theme that cannot be reached leaves the field working on the window colour, because decoration must never be load-bearing.

Parameters:
  • value – the mapping to start with.

  • parent – parent widget, or None.

get_value() → Dict[str, int | None][source]

Return the mapping, with None for any colour left empty.

set_value(value: Any) → None[source]

Load a mapping dict, a legacy png_dims list, or nothing.

The list form is accepted because a settings CSV written by an older build holds one, and the panel has to be able to show what that file actually asked for. It is translated the same way the pipeline translates it – entry 0 is blue – so the fields show the colours the run will produce, not a rearrangement of them.

Parameters:

value – None (the default mapping), a colour-slot mapping, a legacy png_dims list, or the string form of either; an unparseable string falls back to the default mapping.