Skip to content

feat: add categorical brush canvas (Qt) #43

Description

@otto-link

Add a Qt widget providing a canvas for painting quantized/categorical values into an underlying Array.

Concept

The canvas behaves like a standard brush-based painting widget, but instead of painting continuous values, it paints values associated with a predefined set of labels.

The label mapping is provided as an input, for example:

0 → Sea
1 → Mountain
2 → Forest
...

Each label has:

  • a base value (v)
  • a display label
  • a color

UI

In addition to the standard brush canvas, the widget provides a set of exclusive toggle buttons, one for each defined label:

[ Sea ] [ Mountain ] [ Forest ]

Selecting a label activates it as the current brush value and updates the brush color to the label's color.

Only one label can be selected at a time.

Painting behavior

When a label with base value v is selected, painting with the brush writes values in the range:

[v, v + 1[

This ensures that each painted pixel belongs to the selected category while still allowing the underlying array to store floating-point values.

For example:

Sea      → [0, 1[
Mountain → [1, 2[
Forest   → [2, 3[

Colors

Each label defines a color used to visually represent that category on the canvas.

The active brush should use the selected label's color, providing immediate visual feedback about which category will be painted.

Input

The widget should take a label/value mapping as input, conceptually:

value → {
    label,
    color
}

The exact API can be designed to integrate with the existing Array and Qt widget infrastructure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: attributes-widgetsMeta widgets, sliders, brush/array editors, theming/palette

    Type

    No type

    Fields

    Priority

    P4 - Opportunistic

    Effort

    M

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions