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:
Using ginput on an axes in a GUI?

Subject: Using ginput on an axes in a GUI?

From: Clive

Date: 14 Sep, 2010 16:24:08

Message: 1 of 6

Hi,
I have a GUI that contains a set of axes. I need to use ginput so a user can click on any point on the axes and obtain data from that point using the inpolygon function.

However, when the ginput function is called in the GUI script, the ginput crosshair isnt confined to the axes but the entire GUI figure. I have tried several methods to set the handles to the axes, for example:
[xp yp] = ginput(handles.axes, 1)
but nothing has worked.

Is there a way to confine ginput to the axes on the GUI only?

Thanks,
Clive

Subject: Using ginput on an axes in a GUI?

From: Sean

Date: 14 Sep, 2010 16:45:22

Message: 2 of 6

"Clive " <cgro8106@uni.sydney.edu.au> wrote in message <i6o7j8$qnn$1@fred.mathworks.com>...
> Hi,
> I have a GUI that contains a set of axes. I need to use ginput so a user can click on any point on the axes and obtain data from that point using the inpolygon function.
>
> However, when the ginput function is called in the GUI script, the ginput crosshair isnt confined to the axes but the entire GUI figure. I have tried several methods to set the handles to the axes, for example:
> [xp yp] = ginput(handles.axes, 1)
> but nothing has worked.
>
> Is there a way to confine ginput to the axes on the GUI only?
>
> Thanks,
> Clive

There is not to my knowledge. What you can do is find the bounds of your axes and, if the user selects outside these bounds, make them select again.

Subject: Using ginput on an axes in a GUI?

From: someone

Date: 14 Sep, 2010 17:17:07

Message: 3 of 6

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i6o8r2$jto$1@fred.mathworks.com>...
> "Clive " <cgro8106@uni.sydney.edu.au> wrote in message <i6o7j8$qnn$1@fred.mathworks.com>...
> > Hi,
> > I have a GUI that contains a set of axes. I need to use ginput so a user can click on any point on the axes and obtain data from that point using the inpolygon function.
> >
> > However, when the ginput function is called in the GUI script, the ginput crosshair isnt confined to the axes but the entire GUI figure. I have tried several methods to set the handles to the axes, for example:
> > [xp yp] = ginput(handles.axes, 1)
> > but nothing has worked.
> >
> > Is there a way to confine ginput to the axes on the GUI only?
> >
> > Thanks,
> > Clive
>
> There is not to my knowledge. What you can do is find the bounds of your axes and, if the user selects outside these bounds, make them select again.

Or perhaps in your script, instead of calling ginput directly, you can call the ginput function using the axes ButtonDownFcn property. Since:

ButtonDownFcn is a callback that executes whenever you press a mouse button while the pointer is within the axes, but not over another graphics object parented to the axes.

Subject: Using ginput on an axes in a GUI?

From: Naresh Pai

Date: 14 Sep, 2010 17:30:25

Message: 4 of 6

"Clive " <cgro8106@uni.sydney.edu.au> wrote in message <i6o7j8$qnn$1@fred.mathworks.com>...
> Hi,
> I have a GUI that contains a set of axes. I need to use ginput so a user can click on any point on the axes and obtain data from that point using the inpolygon function.
>
> However, when the ginput function is called in the GUI script, the ginput crosshair isnt confined to the axes but the entire GUI figure. I have tried several methods to set the handles to the axes, for example:
> [xp yp] = ginput(handles.axes, 1)
> but nothing has worked.
>
> Is there a way to confine ginput to the axes on the GUI only?
>
> Thanks,
> Clive

Clive,

Try exploring the impixel function to do this instead of ginput.

Naresh

Subject: Using ginput on an axes in a GUI?

From: Divakar Roy

Date: 13 Nov, 2012 04:53:17

Message: 5 of 6

I have just uploaded to file-exchange, codes that are supposed to solve the original problem. Here's the link - http://www.mathworks.com/matlabcentral/fileexchange/38997 . Basically it uses BUTTONDOWNFCN, alongwith uipanel. Would appreciate to know if the codes are any help to people still interested in the problem.

"Clive" wrote in message <i6o7j8$qnn$1@fred.mathworks.com>...
> Hi,
> I have a GUI that contains a set of axes. I need to use ginput so a user can click on any point on the axes and obtain data from that point using the inpolygon function.
>
> However, when the ginput function is called in the GUI script, the ginput crosshair isnt confined to the axes but the entire GUI figure. I have tried several methods to set the handles to the axes, for example:
> [xp yp] = ginput(handles.axes, 1)
> but nothing has worked.
>
> Is there a way to confine ginput to the axes on the GUI only?
>
> Thanks,
> Clive

Subject: Using ginput on an axes in a GUI?

From: Pedro Teodoro

Date: 12 Jan, 2013 10:37:08

Message: 6 of 6

Try this.

It does exactly what you want. This function works as ginput but it is adapted to be used in GUIs.

http://www.mathworks.com/matlabcentral/fileexchange/39799

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