Mouse Handling in Matlab - matlab

Is there any way in matlab to do mouse event handling like click handling?
I need it to develop an application where I'm displaying an image in matlab's imshow.
Once user clicks at a particular point on image, I need to know co-ordinates of that point and use them for later processing.

To capture clicks, you have to define the ButtonDownFcn property of your IMAGE. The callback can then read the CurrentPoint property of the AXES and thus determine the coordinates.
Alternatively, you may want to have a look at GINPUT if you want the user to select a fixed number of points.

Related

Adding a slider to ILNumerics Plot

I'd like to make use of an ILNumerics 3D plot but I would like to add a slider control. The slider would be responsible for filtering values on the backing data set so I can visualize my data under certain conditions. Basically, user moves slider and plot automatically updates based on criteria set by slider.
The functionality that I am looking for is very similar to Mathematica's manipulate feature. Is this type of functionality possible?
Thanks!
Yes. Interactivity is one specialty of ILNumerics. All objects can be modified dynamically. Simply place your code into the event handler of the slider and change everyting you need there.
Afterwards, call Configure() on the affected part of the scene in order to lock your changes in. ILPanel.Refresh() causes an immediate refresh of the display.

Mouse as interrupt

I am using MATLAB Psychtoolbox for understanding behaviour of human under critical condition.
I want to use mouse as an interrupt. To be more precise, a program is running and a mouse action is needed when an abnormality happens.Since presence of abnormality is not well defined so does the operator action. So I need to be always of action taken by human. How to keep track of human action with mouse??
Please help!!!
Do you want just mouse clicks or all mouse movement? For the former, you can just use the function waitforbuttonpress. Otherwise, if you need coordinates for example, you would use the ginput function.
I think you need to set the 'ButtonDownFcn' to your figure.
Have a look at this.

Matlab: How can I use the a center mouse button click to record/log the data shown by a datacursor?

I am new to using Matlab and I have just made my first custom datacursor for a scatter graph I have plotted. This datacursor shows me the x position, y position and the location of that point within the original matrix (row). I want to be able to call the datacursormode and then have a callback within the datacursor, so that pressing the center mouse button on the point it will log the point data shown by the datatip/cursor into a matrix or array.
The idea is to be able to click on a point of interest,see the data tip info and then if the user wants they can click on the point with the middle mouse button to log the data tip information displayed, then move straight to the next point, without re-calling the datacursormode. This should then result in a cell array/matrix of all the point information selected.
I have tried disp(pos) but this displays every point clicked and I want to be able to click on the point and see the info before deciding whether to log it or not. I have tried ginput but calling it disables datacursormode. I think a callback within the custom datacursor function is needed, but I can never get them to work.
Please help.
Thanks for any help you can give.

How to find mouse position on click in GTK window using Perl?

In my GTK+ application, I want to show an image and let the user click on it to draw lines. I'm doing this by generating a new image, with lines, with ImageMagick. This is my problem: How can I find out where the user clicked?
There is no way to find coordinates of click, because that signal does not have them. You have to use the button-press-event and button-release-event signals. Than the second argument to the callback is GdkEventButton object and that has coordinates.
You may want to see the example for the GtkDrawingArea widget, it does just that.

Core Plot: Data point labels shown, or when data points touched?

Is there a way using Core Plot to have periodic labels assigned to data plots? Such as 10-20 labels listed across my plot points.
Here is an example (mockup) of what I am hoping to do:
Is it possible to do this when the graph loads, or maybe when you swipe across the graph you see the data points showing their call out?
You'll have to draw the callout bubbles yourself, but it is possible to label data points. To make a callout, you could subclass CPTextLayer and have it draw the bubble around the text. Use this new class to make your labels.
You can implement a datasource method to inform Core Plot which data points should be labeled and provide your own labels if you wish (this is how you'd do the callouts). You can also respond to touch events (click events on the Mac) and show a label for the point that was touched. You have to touch each point individually--you won't get the delegate notification if you drag from one point to the next.
The examples included with Core Plot demonstrate how both techniques work.