SlicerRT icon indicating copy to clipboard operation
SlicerRT copied to clipboard

ENH: Use color legend instead of scalar bars

Open MichaelColonel opened this issue 2 years ago • 11 comments

This is a possible solution for #208.

  1. Dummy vtkMRMLDisplayableNode and vtkMRMLDisplayNode were added to vtkMRMLIsodoseNode to allow visualization of color legend with vtkMRMLColorLegendDisplayNode;
  2. Scalar bars are replaced with color legend;
  3. qMRMLColorLegendDisplayNodeWidget was added to control color legend parameters.

image

MichaelColonel avatar Mar 31 '22 08:03 MichaelColonel

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?

lassoan avatar Mar 31 '22 12:03 lassoan

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.

cpinter avatar Mar 31 '22 12:03 cpinter

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?

MichaelColonel avatar Mar 31 '22 13:03 MichaelColonel

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.

cpinter avatar Mar 31 '22 15:03 cpinter

I've redone it with a single vtkMRMLModelNode.

MichaelColonel avatar Apr 02 '22 18:04 MichaelColonel

I have updated an old PR, so it can be merged with current master. Everything should work out of the box.

MichaelColonel avatar Aug 04 '22 10:08 MichaelColonel

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.

MichaelColonel avatar Aug 09 '22 19:08 MichaelColonel

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?

lassoan avatar Aug 09 '22 21:08 lassoan

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).

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.

MichaelColonel avatar Aug 10 '22 05:08 MichaelColonel

Other requested changes will be corrected shortly.

MichaelColonel avatar Aug 10 '22 05:08 MichaelColonel

Doxygen description has been updated.

MichaelColonel avatar Aug 10 '22 08:08 MichaelColonel

Sorry I'm just back from vacation. Anyting to do before integrating this PR?

cpinter avatar Sep 05 '22 11:09 cpinter

I will check everything one more time and let you know.

MichaelColonel avatar Sep 06 '22 14:09 MichaelColonel

It's ready to be merged.

MichaelColonel avatar Sep 09 '22 06:09 MichaelColonel

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?

cpinter avatar Sep 09 '22 10:09 cpinter

No, lgtm!

Sunderlandkyl avatar Sep 09 '22 15:09 Sunderlandkyl

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.

lassoan avatar Sep 09 '22 15:09 lassoan

@cpinter could you try to merge it? I hope there are no more conflicts.

MichaelColonel avatar Sep 10 '22 06:09 MichaelColonel

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

lassoan avatar Sep 11 '22 13:09 lassoan

I've rebased it.

MichaelColonel avatar Sep 11 '22 14:09 MichaelColonel

It is good now, merged. Thanks a lot for your contribution!

lassoan avatar Sep 11 '22 16:09 lassoan