Customized mouse handler for viewer3d

3 次查看(过去 30 天)
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...

采纳的回答

Gebhard Stopper
Gebhard Stopper 2025-2-14
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...

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by