Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Color legend (formerly "color bar" or "scalar bar"), which can display scalar (or label) mapping to colors was completely reworked to conform with Slicer architecture. The new implementation is simpler (does not require manual adjustment of number of colors and scalar range, accessible in subject hierarchy and Colors, Volumes, and Markups modules) and safer (less chance for displayed and actual scalar range getting out of sync), and more capable (multiple color legends can be displayed). A new display node, vtkMRMLColorLegendDisplayNode was added, which is displayed by vtkMRMLColorLegendDisplayableManager. The old vtkMRMLScalarBarDisplayableManager remained unchanged (including the name, which is now not very accurate) for now, for backward compatibility. A subject hierarchy plugin is added, which adds the "Show color legend" checkbox to the visibility menu (right-click on eye icon in the data tree) to show-hide color legend with default options. Color legend properties can be edited for all nodes in Color module. A Color legend section was added to Volumes, Models, and Markups modules to allow editing of color legend properties without leaving those modules. qMRMLColorLegendDisplayNodeWidget was added to allow editing of color legend properties in custom GUIs. Additional improvements: - Unified design of handling of "additional" display nodes (such as volume rendering and color legend display nodes) that should not be automatically displayed when user request show of the displayable node (e.g., clicking on the eye icon). If the new ShowMode property of the display node is be set to ShowIgnore then show/hide requests of the displayable node will not affect visibility of the display node. This is useful because often color legend or volume rendering is disabled explicitly (using the subject hierarchy visibility menu) to prevent clutter in viewers and in these cases the user would not want to show these again when overall visibility is toggled. - Added Qt designer plugins for Volumes widgets. - Improved Color module widget layout: If Discrete and Continuous color lookup table are showed in the same collapsible section. This way if the section is collapsed then it remains collapsed regardless of what color node is selected (so the Color legend section position on screen remains the same). - Improved Volumes module widget layout: Display section used a QStackedWidget-based widget, which always filled the available space, pushing down the Color legend section. Switched to using a simple QWidget and switch between qSlicer*DisplayWidget widgets manually. Co-authored-by: Andras Lasso <lasso@queensu.ca>
- Loading branch information
Showing
98 changed files
with
6,398 additions
and
1,273 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Colors | ||
|
||
## Color table file format (.txt, .ctbl) | ||
|
||
The color file format can store a [color node](http://apidocs.slicer.org/master/classvtkMRMLColorNode.html) in a plain text file with the `.txt` or `.ctbl` extension. It is a text file with values separated by space, with a custom header to specify lookup table type. Header lines are prefixed with `#`. | ||
|
||
### Discrete scale color lookup table | ||
|
||
Header starts with `# Color table file`. Each data line contains `color index` (integer), `color name` (string, if the name contains spaces then the spaces must be replaced by underscore), `red` (0-255), `green` (0-255), `blue` (0-255), and `opacity` (0-255). | ||
|
||
Example: | ||
|
||
``` | ||
# Color table file C:/Users/andra/OneDrive/Projects/SlicerTesting2022/20220109-ColorLegend/Segmentation-label_ColorTable.ctbl | ||
# 4 values | ||
0 Background 0 0 0 0 | ||
1 artery 216 101 79 255 | ||
2 bone 241 214 145 255 | ||
3 connective_tissue 111 184 210 255 | ||
``` | ||
|
||
### Continuous scale color lookup table | ||
|
||
Header starts with `# Color procedural file`. Each data line contains `position` (mapped value, a floating-point number), `red` (0.0-1.0), `green` (0.0-1.0), `blue` (0.0-1.0). | ||
|
||
Example: | ||
|
||
``` | ||
# Color procedural file /path/to/file.txt | ||
# 5 points | ||
# position R G B | ||
0 0 0 0 | ||
63 0 0.501961 0.490196 | ||
128 0.501961 0 1 | ||
192 1 0.501961 0 | ||
255 1 1 1 | ||
``` | ||
|
||
## Debugging | ||
|
||
### Access scalar bar actor | ||
|
||
Access to the scalar bar VTK actor may can be useful for debugging and for experimenting with new features. This code snippet shows how to access the actor in the Red slice view using Python: | ||
|
||
```python | ||
displayableNode = getNode('Model') | ||
colorLegendDisplayNode = slicer.modules.colors.logic().GetColorLegendDisplayNode(displayableNode) | ||
sliceView = slicer.app.layoutManager().sliceWidget('Red').sliceView() | ||
displayableManager = sliceView.displayableManagerByClassName("vtkMRMLColorLegendDisplayableManager") | ||
colorLegendActor = displayableManager.GetColorLegendActor(colorLegendDisplayNode) | ||
|
||
# Experimental adjustment of a parameter that is not exposed via the colorLegendDisplayNode | ||
colorLegendActor.SetBarRatio(0.2) | ||
sliceView.forceRender() | ||
``` |
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
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
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
Oops, something went wrong.