Customized mouse handler for viewer3d

5 visualizzazioni (ultimi 30 giorni)
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...

Risposta accettata

Gebhard Stopper
Gebhard Stopper il 14 Feb 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...

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by