Customized mouse handler for viewer3d

3 vues (au cours des 30 derniers jours)
Gebhard Stopper
Gebhard Stopper le 13 Fév 2025
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...

Réponse acceptée

Gebhard Stopper
Gebhard Stopper le 14 Fév 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...

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by