Intuitive volume presets

Following Make volume presets more accessible · Issue #5951 · Slicer/Slicer · GitHub

I implemented the following solution using the right click menu of the slice views:

image

Is this something you consider useful? If yes I would need to implement the logic and have some questions.

That does look very handy. Perhaps it should be a pull-aside submenu to save space, which is pretty easy to do with a context menu.

2 Likes

I second that request. In fact would be an expansion of the Adjust Window/Level, perhaps?

1 Like

Very nice, thanks for working on this.

Fully agree that would have been my first suggestion, too.

It could make sense to add it there, but unfortunately Qt does not allow making checkable an action that has a submenu (that’s why we have “Interaction” checkable action and “Interaction options” submenu in two separate items).

One more thing that would be really cool would be to grab the current foreground/background image from the slice view, and create small icons with the window/level value applied. Rendering the images could take maybe a tenth of a second, so you could do it when the user clicked on the submenu (on aboutToShow signal). You could also make these icons bigger than the default menu icons (maybe 2x larger) so that details can be seen better.

1 Like

Thank you all for the feedback.
I´ll try to implement a pull-aside submenu and maybe Icons (a really cool idea) later.
What would be the best practice to involve the actual setPreset() action?
There is a

void qSlicerScalarVolumeDisplayWidget::setPreset(const QString& presetName)

in the Volumes module, should I use that and how could I call it from

qSlicerSubjectHierarchyViewContextMenuPlugin

?
Thank you.

This is the prototype for a pull-aside submenu:

image

1 Like

Nice :+1:

Maybe the menu text could be “Window/level presets” to better match the wording above.

Ok will do that, but would need a hint on how to actually set the levels from the SLOT function. Should this be done via the Volumes module? I found out how to get a pointer to the “Volumes” module in C++, but did not find suitable “Volumes” methods to invoke.

Unfortunately that feature is hard-coded in the GUI currently. Best would be to re-factor this feature so it can be re-used, ideally with the option for modules/extensions to register presets like we do for color tables and volume rendering. Simplest would be to move the guts of the method linked above into vtkSlicerVolumesLogic but there could be other options too (e.g. put it into mrml volume display nodes).

2 Likes

Thanks Steve, will try that.

Agreed. Maintaining the list in the Volumes module logic would be a great. For now, the presets can be hardcoded in the logic and we can add API to register new presets later.

1 Like

I am slowly getting there.
My main problems are today: How to get a reference to the ScalarVolumeNode loaded in one of the slices and how to detect they are grayscale, because I would not want to offer the color presets in this case.

Since you know which sliceView the menu is on you can use the sliceWidget's sliceLogic() method and then you can get the vtkMRMLSlicerCompositeNode from the sliceLogic and that has the IDs of the nodes for the layers. You can then use the IDs to get the nodes from the scene and use their IsA methods to check what class they are and only put up the menu items if they are in valid classes.

1 Like