Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Patch Callback by Face

Subject: Patch Callback by Face

From: Dave

Date: 2 Jun, 2010 21:48:04

Message: 1 of 3

I am using patch to generate many polygons with different colors, where each color represents a value.

I would like to be able to click on a polygon and print what that value is in the command window. I'm attempting to do this by writing a callback for ButtonDownFcn.

The patch command, however, generates a single object so it can have only a single callback for ButtonDownFcn. As far as I can tell, that callback does not provide any information about what face was clicked.

Is there any way to:
1. figure out which face was clicked;
2. provide a different callback for each face; or
3. provide a different callback argument for each face?

I know that I could generate a separate patch object for each polygon, however, I am generating tens of thousands of these so I'm concerned that there would be a performance issue. I'm about to try it anyway though with the profiler.

Any help will be appreciated, thanks

Subject: Patch Callback by Face

From: Walter Roberson

Date: 2 Jun, 2010 21:55:12

Message: 2 of 3

Dave wrote:
> I am using patch to generate many polygons with different colors, where
> each color represents a value.
>
> I would like to be able to click on a polygon and print what that value
> is in the command window. I'm attempting to do this by writing a
> callback for ButtonDownFcn.

Perhaps you should be using datacursormode() instead?

Subject: Patch Callback by Face

From: Richard Kennaway

Date: 14 Oct, 2010 11:28:04

Message: 3 of 3

"Dave " <dfick@umich.edu> wrote in message <hu6jik$7hi$1@fred.mathworks.com>...
> I am using patch to generate many polygons with different colors, where each color represents a value.
>
> I would like to be able to click on a polygon and print what that value is in the command window. I'm attempting to do this by writing a callback for ButtonDownFcn.

I'm trying to do the same sort of thing: I need to know which polygon in a patch was hit and where the hit point is. I looked at datacursormode, and it only tells me the hit point, not the polygon; besides which, it insists on displaying the hit point on the screen, which I don't want.

Matlab must have calculated this information to detect the hit. Is there any way to make it pass it on to me?

--
Richard Kennaway
http://www.cmp.uea.ac.uk/~jrk/
School of Computing Sciences,
University of East Anglia, Norwich NR4 7TJ, U.K.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us