Is there a plot mode allowing click-to-select a point, rather than dragging the selection box? I only want to select one point at a time. Thanks.
Currently, single point selection on click is not available in plot view. It would not be difficult to add a new interaction mode, in qMRMLPlotView that would map vtkChart::NOTIFY to LEFT_BUTTON event and then add an event handler for the notification that would select the clicked point. @Davide_Punzo or I would be happy to help/review if you decide to implement it.
What would you like to use this for? Note that you can define a custom label for each point that is displayed in the tooltip when you hover over a point with the mouse (labels are defined in the “Labels Column” table column that you set in Plots module / Series).
That’s a feature I’d also be interested in. I’d use it to allow a user to click on a point in a chart, which would then take them back to another workflow step where they set the value of that point.
Note that you can change the value of any point by directly dragging in the plot (if you switch interaction mode to “move points”). Of course this may not be optimal for all use cases, as you may want to use a different GUI or apply some constraints - I just wanted to make sure that you are aware of this feature.
We are porting a matlab GUI in which we plot a slice-wise quantity, and one of the interaction modes provides a vertical slider on the plot to control which slice is displayed. Plotting a point per slice with a callback on click-to-select seems like the simplest approximation for now.
Hi @ihnorton. Unfortunately it is not straightforward to implement, because there is no single selection click at VTK level. The Andras suggestion is good, but even better will be to implement it at VTK level and expose it in Slicer as a new interaction mode (such as the click and move).
Rethink about it, the click and drag can be constrained both on X and Y. The result will be that you select the point. However, at the moment it is not possible to select multiple points (one selection after another, let’s say) which had few bugs (and we have to force the selection to be on after the release of the click). In principle this can be implemented (at VTK level) and it should not be too difficult. At the moment, I haven’t the time to implement it, but I’ll be glad to review any PR. I may do it in future when I’ll have some free time (: .
Done!
here VTK PR: https://gitlab.kitware.com/vtk/vtk/merge_requests/4531
here Slicer PR: https://github.com/Slicer/Slicer/pull/994
this selects (left click) one point in the plot view if using the pan, selection points and free-hand select point interaction modes (so if you click a point, the left click will do the single point selection, otherwise it will do still the interaction chosen in the plotView controller). In addition pressing the key U removes the current selection. Still, there can be only one selection at time: a subsequent selection will delete the previous one.
Video: https://www.dropbox.com/s/vzue6tmchm3vltq/SinglePointSelection.webm?dl=0
Remember that there is an high level Slicer API method for connecting the VTK selection to your modules:
Thanks!
Is it possible to make this selection mode exclusive?
you are welcome.
Is it possible to make this selection mode exclusive?
do you mean to have a new interaction mode in the plot view controller combo box? If it is this it can be done, I didn’t want to add an another interaction mode, however for me it is fine. @lassoan what do you think about it?
I couldn’t tell for sure from the code/your comment: does click-to-select with this PR require also enabling one of the other selection modes – box/freehand? (I would like to allow only click-to-select)
does click-to-select with this PR require also enabling one of the other selection modes – box/freehand?
with the current PR, you will be able to use the click one point selection also with the pan interaction mode. Will that work for you?
in the video I show how does work both with the pan view and the select points interaction
Ok, I see. Eventually we may want to be able to select with pan disabled, but not critical for now – this is great and sufficient to port the GUI.
Ok, I see. Eventually we may want to be able to select with pan disabled, but not critical for now – this is great and sufficient to port the GUI.
In the case, for allowing only the clickSelectPoint interaction, it will be needed to change the following if condition in the VTK chartXY method:
and add the clickSelectPoint interaction in combobox in the GUI of the plot controller and set the (click)ActionToButton of the chart for the specific interaction mode here:
https://github.com/Punzo/Slicer/blob/SingleClickSelection/Libs/MRML/Widgets/qMRMLPlotView.cxx#L697-L720