How to find mouse position on click in GTK window using Perl? - 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.

Related

How to let the user to build a polygon on the open street map?

UPD: Done. Look at this beautiful polygon.
UPD: In Flutter / openstreetmap, I want to let users draw a polygon by tapping a map and/or clicking a button. The polygon should be not filled. I need a very simple example just to get an idea of how it works.
The final task is:
I am making a flutter application that should give the user the ability to get information about markers located within a certain area on the map. I use osm. By pressing the button, the user initiates the construction of an arbitrary polygon, each corner of which is formed at the place of the next pressing of the button. When the construction of the polygon is completed, the objects inside the polygon are shown, the rest are hidden or not built. After that, the cycle ends by clearing the map.
I haven't found any solution for osm. I would appreciate any help. I don't have any code yet)
You can use the flutter_map library, I'm sure you can understand the documentation and how to set it up.
Then use PolygonLayerOptions(polygons: [Polygon(points: polygonList)]) as a layer on top of the OSM layer. Then set up the list polygonList and use the FlutterMap()'s onTap callback to get the position at which the user tapped and add the LatLng to the polygonList list. There are multiple other configuration options within the Polygon() constructor, and those can be found through IntelliSense or similar. To have no fill, just set the color to transparent.
I use this method (or a very similar one) for my app which lets users download areas of map. The user taps the top left and bottom right of a rectangular area they want to download, by code calculates the top right and bottom left, and a polygon is drawn to show the user exactly where they tapped. Make sure to use setState() or similar.

Implanting mouse simulation need visual feed back that mouse is clicked

Implanting mouse simulation application using c# and winApi to control other windows application , need to blink the cursor when I simulates Mouse click event. so that I will get a visual feed back that mouse is clicked.
You could use ControlPaint.DrawReversibleFrame() or ControlPaint.DrawReversibleLine() to draw a quick series of disappearing concentric shapes to give feedback. When you draw the exact same frame/line twice with these methods they erase themselves and restore whatever was there before.

How to get image coordinates and color data per pixel clicking on a displayed image?

I loaded several PNG files into Matlab and displayed them with no problem but was wondering if there is a way to point (or click) on a pixel and immediately get its pixel coordinates and color (RGB), in real time, either as an output on-screen or stored in some variable.
For example, I have a 64 x 64 face photo to serve as a ground truth image for an eye detection algorithm. The algorithm will return the bounding box for an eye, but, to check it, I want to manually extract coordinates by clicking or mousing around the image as it is plotted, and also color information about the pixels on which I click or mouse.
Please feel free to suggest another language, software, or environment if Matlab does not support such interactivity.
Thank you for your help!
The Data Cursor does exactly what you want:
http://www.mathworks.co.uk/help/matlab/creating_plots/data-cursor-displaying-data-values-interactively.html
It is the icon to the right of the "rotate" icon in the image toolbar.
If you have the Image Processing Toolbox, there is a built in tool called impixel, which will allow you to click on an image and get pixel values and location automatically. There is no data cursor that pops up, but what the data cursor is returning, impixel is also, and you could easily display this with a uicontrol (text).

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.

Mouse Handling in 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.