-
Notifications
You must be signed in to change notification settings - Fork 668
BUG: Suppress unnecessary warning for hidden subject hierarchy items #8695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Suppress unnecessary warning for hidden subject hierarchy items #8695
Conversation
Modules/Loadable/SubjectHierarchy/Widgets/qMRMLSubjectHierarchyTreeView.cxx
Outdated
Show resolved
Hide resolved
Modules/Loadable/SubjectHierarchy/Widgets/qMRMLSubjectHierarchyTreeView.cxx
Outdated
Show resolved
Hide resolved
c8f1ad4 to
8ea8eac
Compare
|
There may be many reasons why a subject hierarchy item is not created for a node. We should not treat it as a special case when an item is not created because Also, So, I would just remove the warning message. |
|
I've pushed an additional commit that removes the qCritical warning based on the reasoning that @lassoan described. |
I think @lassoan meant we should also remove the early return ... this means of the relevant SH node are explicitly created. It should be possible to establish the association. |
Yes. The w = slicer.qMRMLNodeComboBox()
w.setMRMLScene(slicer.mrmlScene)
w.show()
w.setCurrentNodeID("vtkMRMLColorTableNodeFilePlasma.txt")To make the behavior consistent, calling |
|
If I had a current selection in the subject hierarchy tree view and I added a node to the scene that I predefined as hidden from editors, wouldn’t I want to keep my original subject hierarchy selection rather than selecting None? I would assume the hide from editors indication is saying to not get involved in that widget and therefore it shouldn’t change to a None state from an existing selection. |
|
So, we should change the behavior to:
|
slicer.util.selectModule("Markups")
line_node = slicer.vtkMRMLMarkupsLineNode()
line_node.SetHideFromEditors(True)
slicer.mrmlScene.AddNode(line_node)Ok so in the case of an angle node having been selected prior to the hidden line node added in the code above, the Markups module subject hierarchy tree view should still maintain the selection of the angle node with the collapsible sections below still enabled based on the angle node and the Markups Toolbar node combobox still reflecting that angle node is the selection? |
I agree, this is unusual behavior compared to other modules. It is a consequence of the unusual behavior that the markup node selection in Markups module shows the active place node. None of the other modules do this (there are "active" nodes for some other classes, but they are only used to propagate selection in viewers, and only on request). I believe this special behavior is useful because it makes easy to see which markup is where points will be added to when the user clicks in a view. We might be able to remove this unusual behavior if we implement focus display in views. Then it may be more clear what markup is being edited and the Markups module's node selection no longer has to show this. To avoid the side effect of losing selection in Markups module when a hidden markup node is added: we could probably find a way to prevent making a newly added markup node automatically the active place node. It is not a must to change this in Slicer core though, because if a module adds a hidden markup node, then that module can also save the previously selected active place node and restore it after it added the hidden markup node. |
There are many reasons why a subject hierarchy item is not created for a node so there is not a reason to throw a critical warning regarding the situation.
Nodes defined to be hidden from editors were being unnecessarily warned by the "Unable to find subject hierarchy item by data node" log message because it is expected for them to not be visible and available in the subject hierarchy as they are hidden.
Code that previously produced the unnecessary warning:
```python
slicer.util.selectModule("Markups")
line_node = slicer.vtkMRMLMarkupsLineNode()
line_node.SetHideFromEditors(True)
slicer.mrmlScene.AddNode(line_node)
```
Co-authored-by: Andras Lasso <lasso@queensu.ca>
a9e1a94 to
3dec023
Compare
|
@lassoan I have squashed down the various commits here to get to the simplified removal of the warning and the early return. This should address the log spam I was observing while creating some hidden nodes. For the future I'll consider whether or not changing the active place node state upon adding a hidden node, but for now this change is acceptable for my work. |
@jamesobutler Thanks for your patience with the whole review process. To capture this requirement, when you have a chance, would you be able to create a feature request ? |
lassoan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I've tested it and it behaved as expected - unselecting the item in the subject hierarchy tree in Markups module if the active place node was not visible in the tree.
It would be nice to mention the behavior change in the commit comment (selection is removed in Markups module if the active markup node is not visible in the tree).
@lassoan To account for this, I ended up selecting |
…rchy items (Slicer#8695) Nodes marked as hidden from editors were triggering an unnecessary critical warning: `Unable to find subject hierarchy item by data node`. This was misleading, since it is expected that hidden nodes do not have a subject hierarchy item. The warning has been removed to avoid confusion. Additionally, behavior has been updated so that if the active markup node is not visible in the subject hierarchy, its selection is cleared in the **Markups** module. This prevents inconsistencies between the active place node and the subject hierarchy tree view. Example of previously logged unnecessary warning: ```python slicer.util.selectModule("Markups") line_node = slicer.vtkMRMLMarkupsLineNode() line_node.SetHideFromEditors(True) slicer.mrmlScene.AddNode(line_node) ``` Cherry-picked commit Slicer@ca21ee4 Co-authored-by: Andras Lasso <lasso@queensu.ca>



Nodes defined to be hidden from editors were being unnecessarily warned by the "Unable to find subject hierarchy item by data node" log message because it is expected for them to not be visible and available in the subject hierarchy as they are hidden.
Code that previously produced the unnecessary warning:
main