Permanently pin down view controls

I was wondering if there is a way to have the “pin button” above the view (where you can select Axial/Sagittal/Coronal and the volume) permanently set.

I find myself using this panel quite often and wish that panel would stay in view without having to hover the mouse over pin button first. I don’t need the rest of the controls though (the double arrow button).

I want to add a listener function to my .slicerrc file that checks whether the views changed, and if so, set some python command to “press” the pin button. Or is there some easier method?

Thank you.

Yes, probably a python script would be the best workaround for that.

But you might also look at the View Controllers module. You could make a hotkey to bring that up as an alternative to using the pins.

Which part do you find that you use often?

We have been adding most commonly needed features to Data module’s Subject hierarchy tab.

For selecting what image is displayed in which view, I’m thinking about enabling drag-and-drop, as it has become a quite common trend in medical image viewers. As a test, I’ve already implemented it for images and labelmap (and it would be easy to enable this for all node types):

2020-09-04-13-31-57

1 Like

Hi thank you both for replying.

I click the pin so that orientation/volume panel stays open. It sounds simple, but you have to hover over the pin which is quite small in screen area in order to bring the panel down. And if you move the mouse too far it’ll disappear quickly. It just interrupts my workflow so I wanted to add a listener to ensure no matter which layout is open, all the views have the pin button permanently pressed.

I could have the View Controller modules open, but I’m usually using other modules to segment/mask/register, etc.

I know how to add listener/observer functions, but I don’t know the object tree well enough to do this.

I’m wondering if the python console can interact with the view control buttons? My thinking would be to loop over all the views in the layout, check if the pin button is pressed, and if not, “click” it.

Thanks so much.

Sure, that’s very possible. You just need to search around in the code to find the widgets and look at what method activate the thing you need.

I agree the little pin button with the hover behavior can be annoying. If your goal is to easily move between layouts you might try the script below or some variant in .slicerrc.py.

if qt.QSysInfo().productType() == 'osx':
    controlKey = "Meta"
else:
    controlKey = "Ctrl"

shortcuts = [
    (controlKey+'+b', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)),
    (controlKey+'+n', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpYellowSliceView)),
    (controlKey+'+m', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpGreenSliceView)),
    (controlKey+'+,', lambda: slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView)),
    ]

for (shortcutKey, callback) in shortcuts:
    shortcut = qt.QShortcut(slicer.util.mainWindow())
    shortcut.setKey(qt.QKeySequence(shortcutKey))
    if not shortcut.connect( 'activated()', callback):
        print(f"Couldn't set up {shortcutKey}")

Can you tell about your workflow? Why do you need to keep adjusting view orientations?

We have modules designed for specific tasks, such as comparing volumes or register volumes. Maybe a more convenient solution would be to use these modules and improve them as needed.

You can also use “View controllers” module - it gives you access to all the view controls at one place, without taking away space from the viewers:

image

Note that you can also add more buttons to slice view controls, so for example you could add an Ax, Sag, Cor button right next to the slice offset slider and so you could switch between slice orientations without having to sacrifice any space in the viewers.

We could also add some slice view property adjustments (such as orientation) to right-click menu.

This interesting. Does it mean that slice viewers would stay empty until a node is dragged into them? Are you planning the same for the 3D viewer as well (otherwise I think it will be a bit weird).

Drag-and-drop to viewers could be just an additional way of making display nodes in selected views (or view groups). This is how most clinical image viewers allow specifying what is shown where.

This could be enabled for all views (slice, 3d, table, plot) and all node types.

1 Like