How to display coordinates and use ginput

折月煮酒 提交于 2019-12-01 05:59:20

If you type edit ginput and scroll to line 238-ish, you'll see

% Adding this to enable automatic updating of currentpoint on the figure 
set(fig,'WindowButtonMotionFcn',@(o,e) dummy());

In other words, ginput sets a WindowButtonMotionFcn in the figure. My guess is that impixelinfo uses this function as well, so it gets disabled as soon as ginput is called.

Indeed, in impixelinfoval (a function used by impixelinfo) we find around line 83:

callbackID = iptaddcallback(hFig,'WindowButtonMotionFcn', @displayPixelInfo);

The odd thing is then: how does it get reset after you click 4 points?

This magic is accomplished by line 222-ish of ginput:

initialState.uisuspendState = uisuspend(fig);

Apparently, uisuspend is a little undocumented function that is used to suspend any pre-existing WindowButton* functions, in order to reset them later. So, if you comment out this line

%initialState.uisuspendState = uisuspend(fig);

and save ginput, and re-do the whole thing, you see the behavior you want.

You will also see why these functions get suspended in the first place -- For reasons I do not quite understand, everything gets unworkably slow when two such functions are enabled.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!