`GetSelectionNode().GetActiveVolumeID()` always returns None

Hi,

Probably I misunderstand what is selection node but here is the example:

import numpy as np
import math

def some_func(x, y, z):
  return 0.01*x*x + 0.01*y*y + 0.01*z*z

a = np.fromfunction(some_func,(128,128,128))

volumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode')

print(slicer.app.applicationLogic().GetSelectionNode().GetActiveVolumeID())    # returns `None`

What do I do wrong?
Is it possible to have multiple nodes displayed on the scene and get the latest node that I picked with Mouse_1 btn?

Active volume concept was introduced in very early Slicer versions. We have not actively removed it to reduce unnecessary breaking of backward compatibility, but bnow it is not used for anything. The main reason is that there can be any number of “active” volumes. Even in one view we can show 3 volumes (and any number of models, markups, transforms, etc).

It comes up quite often that some kind of selection feature would be useful, for example to make it easier to find an object in different views, reduce the chance of accidental modifications, etc. What is your use case? How do you envision the concept of selected volumes (and other nodes)?

1 Like

Thank you for reply,

For now I would like to write a module that displays vtkCubeAxesActor around chosen object on the scene.

I can see that in Slicer we usually chose the “active” volume by selecting in pop-up menu (maybe in volume module or volume rendering or in widget controller).

Nevertheless I’m a geoscientist and I’m working on custom app for geoscience and there we usually have numerous of objects: seismic data (usually displayed as vtkImageData), wells (displayed as curves and each well has its name), surfaces (also has its name) and other type of data (like points, polygons etc). When there are plenty of displayed objects on the screen it is very simple to forget what name has some object but chosing object from the scene (by clicking on that object) is very efficient way to chose the object needed.

Thus I see my module should have drop-down menu for chosing current object (usual for Slicer) but the user should be able to set current object in two ways:

  1. directly (from drop down menu);
  2. interactively from the scene (when he clicks on the object from the scene the active object should be changed in that drop-down menu).

Or make a pop-up menu when user clicks on scene’s object Mouse 2 and there add action “Set active”. That is even better I think and the possibility to add custom actions there would make Slicer more user frienly and more customizable (my opinion).

P.S. Slicer has module concept. That make allows for any who is familiar with python or C++ to easilly develop custom modules. I very like that. But for me there are two things that are unusual:

  1. you cannot invoke pop-up menu by clicking on scene and have some object properties;
  2. there is no QTreeView widgets where user could see his data on the disk (not loaded to RAM) but there is only Data module where all loaded data resides. In my SlicerCAT I add this and it looks like diplayed on the picture:
    image

The concept of this is when user checks-on data in tree view then the data gets load to the RAM (or that sets some module active and in that module user choses wich part of that big data he wants to load to the RAM). When data is loaded user can see it in Data module. Probably Slicer could display filesystem in treeview using QDirModel (also as I remember user can drag and drop files to load it, with this treeview would look nice)

These two features are standard in geoscience world.
Though I’m pretty sure you are familiar with some other 3D applications from other science field but have a look at short video of well known in geoscience world Petrel commercial app (video) (it is also based on VTK as I know). Perhaps you will find somethin useful

This is because for many years we tried to make VTK widgets work and they were just bad. A few years ago we started to rework the widget infrastructure and we have now a nice way to to pick objects by right-clicking on them and perform any action on them (edit properties, etc.). We have only implemented this for markups so far, but would be straightforward to implement it for any other node types. It would be great if you could work on this.

Slicer, similarly to most other applications, do not have an always-on local file browser. This need has only come up very few times over the years and it is getting less and less relevant. Nowadays you browse remote data stores, you get all the metadata live from there, and the local file system only serves as a cache for bulk data.

You can very easily add a local file browser module that shows a folder/file tree and allows partial loading (similarly to ImageStacks module in SlicerMorph extension), but this just feels very dated. I would recommend to not spend time with implementing a local file browser but instead implement a nice and convenient GUI for browsing and retrieving data from a storage service. Such a service is needed to meet expectations of users who want to access their data anywhere, share it, get updates in real-time, etc. The storage service can be hosted on the cloud, but could also run locally, so you would not be forced to use a remote server, if you don’t want.

You can have a look at the DICOMweb Browser or FlyWheel extensions for some simple examples.

1 Like