Picking a point changes selected object and makes current Action disappear
About you
CamiTK developper
Overview
While creating a CEP, an action that uses multiple components was written and needs to get point coordinates from a click in a viewer. When clicking on the point, if the image in the viewer is not the selected imageComponent, the picking action changes the selection. The action is then hidden because the selection changed.
Steps to Reproduce
This is visible when using Meniscare CamiTK CEP and the ManualRegistration3D action. Load two volumes (e.g. brain.mha and sinus-displaced.mha). In the action, select one of the images, and Ctrl+Click on the image in a slice viewer. Click on the "pick" button in the action to get the coordinates.
Actual VS Expected Result
If the image shown in the viewer (the one "selected" in the Action widget) is not the selected component of CamiTK Application, the image is selected, and the action disappears because the component selection changed.
Interpretation & Possible fixes
This is due to the selectionChanged(comp) in InteractiveViewer. The same applies to other picking modes in the same InteractiveViewer::picked() function.
I think this is done to show in the PropertyExplorer the coordinates of the picked point when it is clicked (which needs the ImageComponent to be selected), and hiding the action is a side effect of that.
I see two ways to fix this problem:
- do not change the selected component when a point is picked, but that might break the behavior of displaying the picked coordinates in the "selection" tab of the PropertyExplorer
- A large change in CamiTK: separate completely the notion of selected components in the Application with the currently running Action. I mean that when an action is open on selected components, the fact that the selection changes in the application should not hide the action. The action should only be closed if the component disappears (closed) or the action is closed by the user. This means rethinking what an action can be, e.g. an action can be instantiated multiple times, and there should be an ActionExplorer that lists currently opened actions. In this way, we could run the same action twice with different parameters at the same time.
CamiTK Version
CamiTK 5.1.dev.develop.f3f104d8
please do not remove anything below this line