Using WindowButtonMotionFcn with getrect / getline

조회 수: 1 (최근 30일)
Dan
Dan 2012년 4월 6일
Hi,
I'm using a 'WindowButtonMotionFcn' callback on a figure to continually display the current position (in pixel and map coords) as the mouse moves over an image. This works just fine.
The problem I'm having, however, is that my GUI allows the user to specify a region of interest either as a rectangle (via getrect) or as a polygon (via getline). While the user is performing either of these operations my WindowButtonMotionFcn callback is no longer being triggered so the current position is no longer updated.
What steps are required to ensure that my callback continues to be triggered while using getrect / getline?
Thanks in advance for any replies.
-- Dan

답변 (3개)

Image Analyst
Image Analyst 2012년 4월 6일
I don't use the WindowButtonMotionFcn at all. I just set up impixelinfo(). However even that won't work when you're calling getrect() so I think you're out of luck as far as getting "live" coordinates while drawing the box.
  댓글 수: 2
Dan
Dan 2012년 4월 6일
Thanks for your reply, which basically confirmed that I'm probably SOL!
Image Analyst
Image Analyst 2012년 4월 6일
It might help somewhat if you call "axis on" right after you display your image.

댓글을 달려면 로그인하십시오.


Dan
Dan 2012년 4월 6일
This might not be the most elegant workaround, but I was able to call my original WindowButtonMotionFcn from within getrect/getline by making a local copy of getrect.m / getline.m and then making a few slight modifications as needed.
I'm still interested to find out if there is a less invasive solution, though!

Walter Roberson
Walter Roberson 2012년 4월 6일
Please see http://www.mathworks.com/matlabcentral/answers/2005-windowkeypressfcn-and-datacursormode-on as I suspect the mechanism is the same: zap a listener temporarily.
  댓글 수: 1
Dan
Dan 2012년 4월 6일
I'll take a look. Thanks for taking the time to respond.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Build Interactive Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by