SlicerRT
SlicerRT copied to clipboard
ENH: Use color legend instead of scalar bars
This is a possible solution for #208.
- Dummy vtkMRMLDisplayableNode and vtkMRMLDisplayNode were added to vtkMRMLIsodoseNode to allow visualization of color legend with vtkMRMLColorLegendDisplayNode;
- Scalar bars are replaced with color legend;
- qMRMLColorLegendDisplayNodeWidget was added to control color legend parameters.
Adding dummy nodes is not very clean and makes it more difficult to synchronize the visibility of the isodose surfaces and the color legend.
Instead, a nicer solution would be to use the subject hierarchy folder's existing vtkMRMLFolderDisplayNode for this.
We could also consider creating a single model node for all the isodose surfaces and color them using point scalars. It would simplify many other things, too. The only thing that would be harder is to quickly toggle visibility of individual lines/surfaces in the data module, but it might not be that important (the levels can be edited in isodose module).
@cpinter what do you think about changing the design to keep all the isodose lines in a single model?
I think it would lead to simpler code in most places.
Yes the only thing indeed is individual handling of the levels. I'm not sure how often it is needed by actual users, but if @MichaelColonel and @gregsharp say that almost never, then it's probably clear and we don't have to worry about it. Otherwise we could add a feature that separates the surfaces by the scalars.
I have no objections, but what do you mean by coloring with point scalars? Something like: https://kitware.github.io/vtk-examples/site/Cxx/PolyData/ColoredPoints/, or am i wrong?
Yes, this is the mechanism. You have an array that assigns some value to each point (or cell - that is also possible) in a way that the point indices match the value indices in the array, then you set the array with GetPointData()->SetScalars
. In the models module you can color the polydata using scalars by wnabling it in the Display/Scalars section.
I've redone it with a single vtkMRMLModelNode.
I have updated an old PR, so it can be merged with current master. Everything should work out of the box.
The method int GetDoseUnitsFromString(const char *)
has already been added:
https://github.com/MichaelColonel/SlicerRT/blob/isodose-cl/Isodose/MRML/vtkMRMLIsodoseNode.h#L113
https://github.com/MichaelColonel/SlicerRT/blob/isodose-cl/Isodose/MRML/vtkMRMLIsodoseNode.cxx#L236-L256
So the scene with should be loaded, but if you recalculate isodose with color legend, the isolines will be too thin and barely visible.
The method
int GetDoseUnitsFromString(const char *)
has already been added:
That's good, but for backward compatibility GetDoseUnitsFromString
should recognize the old values (0
, 1
, and -1
) and not just the new strings (Gy
, Relative
, and Unknown
).
the isolines will be too thin and barely visible
Why the isolines thickness is related to the dose units?
That's good, but for backward compatibility
GetDoseUnitsFromString
should recognize the old values (0
,1
, and-1
) and not just the new strings (Gy
,Relative
, andUnknown
).
Method modified.
I check the process of loading scene, and the DoseUnits is preserved between an old isodose color bar and a new color legend.
Absolute Dose scene: https://disk.yandex.ru/d/iVwup0TxZoiGXw Relative Dose scene: https://disk.yandex.ru/d/G9q9TB6Z6uDyVA
Why the isolines thickness is related to the dose units? Correct. It isn't related, but the difference in visualization is noticeable.
Other requested changes will be corrected shortly.
Doxygen description has been updated.
Sorry I'm just back from vacation. Anyting to do before integrating this PR?
I will check everything one more time and let you know.
It's ready to be merged.
Thanks @MichaelColonel ! GitHub tells me the branch cannot be rebased due to conflicts, can you please manually rebase the branch?
@lassoan @Sunderlandkyl any requests before merging?
No, lgtm!
OK to merge for me, too. I would merge it, but, as @cpinter noted, there are conflicts that @MichaelColonel would need to resolve by rebasing on latest master.
@cpinter could you try to merge it? I hope there are no more conflicts.
We still have the error message: "This branch cannot be rebased due to conflicts"
- Pull from SlicerRt:master
- Rebase
- Force-push to MichaelColonel:isodose-cl
I've rebased it.
It is good now, merged. Thanks a lot for your contribution!