how to get pixel coordinates from iptSetPointerBehavior

1 Ansicht (letzte 30 Tage)
Andrew Diamond
Andrew Diamond am 25 Dez. 2017
Bearbeitet: Andrew Diamond am 25 Dez. 2017
EDIT I can get this to work by using set(handles.figure1,'WindowButtonMotionFcn',@(src,event)overMe(src,event,handles,himage));
vs all the PointerBehavior stuff below. I do call the axes 'currentpoint' to get axes mouse coordinate in the callback (the same one I used below) but now it actually returns good coordinates. I also have to filter out the axes coordinates for ones that are actually in the axes/image limits.
=== Matlab 2016b
Within the context of a GUIDE gui, I create an image object and then I want to create a callback that changes the cursor if it's within a specified region of the image. To accomplish this, after I create the image pointer,
himage=getappdata(handles.figure1,'himage');
set(himage,'ButtonDownFcn',@(src,event)axes1_ButtonDownFcn(src,event,handles));
set(himage,'cdata', FilteredFrame);
as you can see, above, I also have a callback associated with image handle's ButtonDownFnc. That works fine giving me the correct coordinates. For the mouse movement callback, as per the documentation, to set the appropriate callback, I then do this:
pointerBehavior.enterFcn = [];
pointerBehavior.exitFcn = [];
pointerBehavior.traverseFcn = @(src,event) overMe(src,event,handles,himage);
iptSetPointerBehavior(hImage, pointerBehavior);
iptPointerManager(handles.figure1);
The overMe call function, I thought, would get the coordinates in image space (in event) whenever I moved over it, but that doesn't happen. My callback gets called but I get coordinates nothing like the image coordinates.
Within overMe I tried the following to get mouse/axis coordinates as I thought that would be the same as the image pixel coordinates (note I use the axes handle as 'CurrentPoint' is not an image handle property) but no such luck. Note, I can see that axes limits are in fact correct, i.e. the same as the image coordinates. The coordinates I get back are typically not even in the axes/image limits.
currentPoint = get(handles.axes1, 'CurrentPoint');

Antworten (0)

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by