Create a parameterNode for a toolbar?

Hi devs.

I’m creating a toolbar that will have several actions. Some of them are zoom, rotate, brightness&contrast and flipView. These are special because when the corresponding toolbar button is checked, a popup widget per view will appear to let the user change the corresponding settings.

See the pictures below:




Some of the correponding states can be saved on a particular node (e.g. brightness and contrast on the displaynode of the current background scalar volume) so changes can be recognized if the observed node changes (by changeBrightness&Contrast mouseMode). Another one like this would be zoom, the zoomFactor can be recovered from the fieldOfView of the sliceNode. But other states (e.g. flipView) need to be saved on a parameterNode (or elsewhere) compulsorily because other logic functions need to access this info. And since I will need a parameterNode to control which of these (zoom, rotate, brightness&contrast and flipView) toolbuttons is checked because they are exclusive (this is not easy to code on Qt). I was thinking on doing it this way.

Is this the correct way of implementing this functionality? Should I try to do more on Qt? Should I save all the states on the toolbar parameterNode?

Thanks

You can put the various buttons into a QButtonGroup and set the state as exclusive so only one is selected at one time. Have you tried this already? We’re you having trouble using this?

https://doc.qt.io/qt-5/qbuttongroup.html#exclusive-prop

The problem is that setting the exclusive option of the QButtonGroup: you have to obligatorily check one of the buttons and I want the possibility of not having any button checked.
They are ways hackish ways (that I found online) to side-step this problem but I remember they were not-possible to implement on Slicer’s python

You don’t need custom attributes for slice view properties, such as flips or zoom. Each slice view has a default SliceToRas and a current SliceToRas transform. If you detect that the angle between default and current slice X is more than 90 degrees then it means that that view is horizontally flipped. It would be redundant to specify a parameter node for this. The same apply for all slip directions, zoom, etc - just compare various defaults to current values.

If your add some additional properties that you want to control using an application toolbar then it makes sense to adjust properties or attribute of a singleton node. If you specify some custom slice view properties that users can adjust with a per-slice toolbar then you can store them as attributes in each slice node.

I don’t remember ever having an issue with this. After you uncheck the only checked button in an exclusive button group and then all the buttons should be unchecked.

1 Like

Try just using the autoExclusive property and put the buttons in their own layout.

1 Like