-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color legend in the layer-bar #693
base: master
Are you sure you want to change the base?
Conversation
CC-167 Color legend styling
CC-189 Styling for the color widget
CC-200 Work to fix the vertical alignment of the color widget symbols on the layer side bar
This is a nice idea! A few comments:
|
} | ||
|
||
get automaticLayerBarColor() { | ||
if (this.displayState.segmentDefaultColor.value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic isn't quite correct --- segmentDefaultColor is overridden by segmentStatedColors
. This should call getBaseObjectColor
.
Hey @jbms, thank you for the thoughts on this one!
We've been thinking about how to tackle primarily this bit. Removing the config sounds good, and that's good to know on the picking indication color as that was a concern we had when considering perhaps having a background color for this legend. Will update on this soon
This is a nice idea, we're having a look at it, hopefully we can land on something and will let you know
For non-annotation layers I think the default yellow color of the bounding box / default annotations is usually kept so I imagine it would go out of sync pretty easily with the actual color of the layer. If we can use a defaultColor style indicator in image layers it would then feed into this legend color - and if we're thinking of how to support the color legend on image layer shaders without a defaultColor we could potentially use some heuristics on the shader. I'd be inclined not to over complicate this PR for the color legend with also supporting image layer colors right now. But if it becomes a blocker to this PR then that is understandable and we will see what we can do, and of course open to suggestions Thanks again |
Thanks for your explanations. Leaving image layer support for a later time seems reasonable. |
Summary
This PR introduces a new color widget in the layer bar, which reflects the color status of a layer set by the user. It indicates three states for layer colors:
Unsupported: For layers that do not have a color.
Rainbow: For layers like segmentation with multiple colors, or when a color cannot be determined while the layer supports color (e.g: annotation with non-default color).
Single Color: For layers with only one color, or when a segmentation has only one visible segment.
This feature allows users to see the current color state directly in the layer bar.
The activation of this new widget is controlled by a new entry in the global settings menu. The following screenshot shows the new menu entry, as well as the state of the layer bar and the layer panel when the option is activated.
We can observe in this screenshot the 3 states:
FABFB.surf.vt.gz
synapses
segmentation
Currently annotation and segmentation layers are supported for automatic color detection, while image and mesh layers are not.
Motivation
Users often need to quickly identify the color status of layers, especially with segmentation layers that might have multiple colors. This widget provides an immediate visual indicator of the layer’s color configuration.
User Interaction
The color widget in the layer bar displays the current color state for each layer. Users can easily see if a layer uses multiple colors or a single color. The widget offers quick insight into the layer’s visual setup. The display of the color widgets is turned on and off via a "Enable layer color legend" setting in the settings panel, which is off by default.
Implementation
This update modifies the layer bar, and the layer panel to add the possibility to display the color widget. The two components register themselves on the layer they are targetting to get notified when a new color is computed.
Layers are modified to consider a new attribute that is stating if it can or not give a color (if it supports the feature). Two new methods defined on layers, and reified by layer type if necessary, are used to:
Extension
Currently only few layers are supported:
To support another layer type, e.g: img layer, the class variable
supportsLayerBarColorSyncOption
needs to be set totrue
, then theobserveLayerColor
function can be overriden in the reifed class of the layer to register all the signals or elements that needs to be watched. TheautomaticLayerBarColor
method can be then implemented in the layer to find the color depending on the various information that is available in the layer.In the case of the img layer, it would be possible to look for
emitGrayscale
oremitRGBA
to extract the color and display it, but we intentionally didn't implement it as it requires a complex implementation if we want to have a perfect idea of what's the color used reading the code. Indeed, parsing properly the content ofemitRGBA(...)
calls requires to possibly track variables in case the color is encoded somewhere in a variable and used later in theemitRGBA(...)
call. The same symbol resolution/variable tracking applies if we need to determine the shade of a color defined asvec4(x, 0.0, 0.0, 1.0)
wherex
would be defined in another place in the code.In addition to parsing the shader code, as a future possibility, the default image layer shader could be modified to add a
defaultColor
which would create a color widget in the image layer. This could then be used to inform the color in theautomaticLayerBarColor
ifdefaultColor
is used in the shader. This would then function similarly to the setup for annotation layers in this PR.