Customized mouse handler for viewer3d

Is it possible to implement a custom mouse event handler for a viewer3d object?
For example, when the user clicks onto the viewer3d I want to programmatically get the coordinates of the clicked voxel, e.g. to select a segmented object. This is similar to what happens with the "Draw point" tool, but i don't need a popup showing me the coordinates, I want to use them...

 Respuesta aceptada

Gebhard Stopper
Gebhard Stopper el 14 de Feb. de 2025
UPDATE:
I found something. I'm not completely happy, since it feels a bit hacky, but it works.
I foud out that a viewer3d has a 'AnnotationAdded' event. The event argument passed to the event handler containes the annotation with its coordinates in world space. This can then be converted to voxel coordinates.
addlistener(app.Viewer3D, "AnnotationAdded", @OnNewAnnotation);
function OnNewAnnotation(s,e,a)
disp(e);
e.Annotation.Position % XYZ in world coordinates
end
However, I still feel, there should be an easier way to get the coordinates of the clicked voxel...

Más respuestas (0)

Preguntada:

el 13 de Feb. de 2025

Respondida:

el 14 de Feb. de 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by