When I change FolderA visibility, it triggers only Segmentation display node’s ModifiedEvent. I would expect it to trigger the FolderB display ModifiedEvent as well. Could you please point me to how I can fix this issue?
My problem was actually more associated with folderDisplayNode, which is a vtkMRMLDisplayNode, not a vtkMRMLDisplayabableNode. I just added this line (test.addObserver(segmentationNode.GetDisplayNode(), vtk.vtkCommand.ModifiedEvent, test_callback) to demonstrate that changing the parent folder visibility seems to call segmentationNode.DisplayNode()'s ModifiedEvent, but not folderDisplayNode’s ModifiedEvent.
I would appreciate any pointers as to why this might be happening / how I can solve the issue.
Toggling visibility of the folder actually calls folderDisplayNode’s ModifiedEvent. To test, you can create a new folder, click the eye icon so that a display node gets created for it automatically, run the code snippet below, and toggle the eye icon of the folder to see the message printed:
shNode = slicer.mrmlScene.GetSubjectHierarchyNode()
folderDisplayNode = shNode.GetItemDataNode(shNode.GetItemByName('NewFolder'))
if not folderDisplayNode or not folderDisplayNode.IsA('vtkMRMLFolderDisplayNode'):
raise RuntimeError("This folder has no display node")
def test_callback(caller, event):
print('in here!', caller.GetName())
test = slicer.util.VTKObservationMixin()
test.addObserver(folderDisplayNode, vtk.vtkCommand.ModifiedEvent, test_callback)
It looks like the folder display node explicitly invokes a Modified event on all display nodes of all its displayable node children:
The folder display node is not a displayable node, so it does not get a Modified event invokation. The code could be reorganized so that each folder display node just notifies its immediate children and then let the children folders notify their children. Do you want to give it a try to implement it?
Displaying branches that are under a “closed eye” branch in a different style (e.g., dark gray text, maybe a different icon) would be great. We’ve been thinking about implementing something like this just did not have the time. Do you plan to contribute this feature to Slicer core? Let us know how we can help.