forked from google/neuroglancer
-
Notifications
You must be signed in to change notification settings - Fork 0
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 widget in the layer-bar #54
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
seankmartin
reviewed
Jan 8, 2025
seankmartin
reviewed
Jan 8, 2025
@seankmartin The modifications were easier than what I was expecting, an event was sent for the change that were already caught by the code in the |
seankmartin
approved these changes
Jan 8, 2025
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.
looks good, thanks so much!
PR open here google#693 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.