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