|
10 | 10 | "VerticalScalarBar", |
11 | 11 | ] |
12 | 12 |
|
| 13 | +NAN_COLOR_OPTIONS = [ |
| 14 | + # Default |
| 15 | + {"color": [0.0, 0.0, 0.0, 0.0], "situation_preset_type": "transparent"}, |
| 16 | + {"color": [0.75, 0.75, 0.75, 1.0], "situation_preset_type": "general"}, |
| 17 | + # Colormap types |
| 18 | + {"color": [0.85, 0.85, 0.85, 1.0], "situation_preset_type": "sequential maps"}, |
| 19 | + {"color": [0.60, 0.60, 0.60, 1.0], "situation_preset_type": "diverging maps"}, |
| 20 | + {"color": [0.80, 0.80, 0.80, 1.0], "situation_preset_type": "categorical maps"}, |
| 21 | + {"color": [0.22, 0.49, 0.72, 1.0], "situation_preset_type": "grayscale maps"}, |
| 22 | + {"color": [0.0, 0.0, 0.0, 1.0], "situation_preset_type": "bright maps"}, |
| 23 | + {"color": [1.0, 1.0, 1.0, 1.0], "situation_preset_type": "dark maps"}, |
| 24 | + {"color": [0.0, 1.0, 1.0, 1.0], "situation_preset_type": "hot maps"}, |
| 25 | + {"color": [0.74, 0.74, 0.74, 1.0], "situation_preset_type": "terrain final"}, |
| 26 | + # Data quality |
| 27 | + {"color": [0.89, 0.10, 0.11, 1.0], "situation_preset_type": "error"}, |
| 28 | + {"color": [1.0, 1.0, 0.20, 1.0], "situation_preset_type": "warning"}, |
| 29 | + {"color": [1.0, 0.50, 0.0, 1.0], "situation_preset_type": "suspect data"}, |
| 30 | + {"color": [0.30, 0.69, 0.29, 1.0], "situation_preset_type": "masked data"}, |
| 31 | + {"color": [1.0, 0.0, 1.0, 1.0], "situation_preset_type": "debugging"}, |
| 32 | + # Background/context |
| 33 | + {"color": [0.55, 0.55, 0.55, 1.0], "situation_preset_type": "light background"}, |
| 34 | + {"color": [0.33, 0.33, 0.33, 1.0], "situation_preset_type": "dark background"}, |
| 35 | + {"color": [0.94, 0.94, 0.94, 1.0], "situation_preset_type": "publication light"}, |
| 36 | + {"color": [0.15, 0.15, 0.15, 1.0], "situation_preset_type": "publication dark"}, |
| 37 | +] |
| 38 | + |
13 | 39 |
|
14 | 40 | def buttons(name): |
15 | 41 | return [ |
@@ -80,6 +106,12 @@ def buttons(name): |
80 | 106 | "tip": (f"'Toggle to ' + ({name}.invert ? 'Normal Preset' : 'Invert Preset')"), |
81 | 107 | "active": f"{name}.invert", |
82 | 108 | }, |
| 109 | + { |
| 110 | + "icon": "mdi-crosshairs-question", |
| 111 | + "tip": "'NaN Color'", |
| 112 | + "active": "false", |
| 113 | + "nan_menu": True, |
| 114 | + }, |
83 | 115 | {"separator": True}, |
84 | 116 | { |
85 | 117 | "icon": "mdi-gradient-horizontal", |
@@ -176,6 +208,62 @@ def __init__(self, name): |
176 | 208 | activator="parent", |
177 | 209 | location="bottom", |
178 | 210 | ) |
| 211 | + elif b.get("nan_menu"): |
| 212 | + with html.Div(): |
| 213 | + with v3.VMenu( |
| 214 | + v_model=f"{name}.show_nan_menu", |
| 215 | + close_on_content_click=True, |
| 216 | + location="bottom", |
| 217 | + ): |
| 218 | + with html.Template(v_slot_activator="{ props: nanProps }"): |
| 219 | + btn_kwargs["v_bind"] = "nanProps" |
| 220 | + btn_kwargs["variant"] = "'text'" |
| 221 | + btn_kwargs["color"] = "undefined" |
| 222 | + v3.VBtn(**btn_kwargs) |
| 223 | + with v3.VList(density="compact", max_height="300"): |
| 224 | + for nc in NAN_COLOR_OPTIONS: |
| 225 | + rgba = nc["color"] |
| 226 | + label = nc["situation_preset_type"] |
| 227 | + r255 = int(rgba[0] * 255) |
| 228 | + g255 = int(rgba[1] * 255) |
| 229 | + b255 = int(rgba[2] * 255) |
| 230 | + a_val = rgba[3] |
| 231 | + if a_val == 0: |
| 232 | + swatch_style = ( |
| 233 | + "width:16px; height:16px; " |
| 234 | + "border-radius:50%; " |
| 235 | + "border: 1px solid #999; " |
| 236 | + "margin-right: 8px; " |
| 237 | + "background: repeating-conic-gradient(" |
| 238 | + "#ccc 0% 25%, #fff 0% 50%) " |
| 239 | + "50%/8px 8px;" |
| 240 | + ) |
| 241 | + else: |
| 242 | + swatch_style = ( |
| 243 | + f"width:16px; height:16px; " |
| 244 | + f"border-radius:50%; " |
| 245 | + f"border: 1px solid #999; " |
| 246 | + f"margin-right: 8px; " |
| 247 | + f"background: rgb({r255},{g255},{b255});" |
| 248 | + ) |
| 249 | + color_json = ( |
| 250 | + f"[{rgba[0]},{rgba[1]},{rgba[2]},{rgba[3]}]" |
| 251 | + ) |
| 252 | + with v3.VListItem( |
| 253 | + click=(f"{name}.nan_color = {color_json}"), |
| 254 | + ): |
| 255 | + with html.Template( |
| 256 | + v_slot_prepend=True, |
| 257 | + ): |
| 258 | + html.Span( |
| 259 | + style=swatch_style, |
| 260 | + ) |
| 261 | + v3.VListItemTitle(label) |
| 262 | + v3.VTooltip( |
| 263 | + text=(b["tip"],), |
| 264 | + activator="parent", |
| 265 | + location="bottom", |
| 266 | + ) |
179 | 267 | else: |
180 | 268 | btn_kwargs["click"] = b["click"] |
181 | 269 | with html.Div(): |
|
0 commit comments