05-14-2013 12:40 AM
I am looking into plotting Mouse coordinates on XY Graph continuously based on where i move. My computer's resolution is 1200x800 and i would like it to plot based on where i move.,
Attached is my progress so far.
05-14-2013 01:18 AM
The XY Graph has a method which converts coordinates to XY values. You can call it by right clicking the graph and selecting Create>>Invoke Node>>Map Coordinates to XY.
However, if you look at the help for it, you will see that the coordinates it expects are those of the pane the graph is in, and the coordinates you have are of the screen. You can convert your global coords to pane coords by getting the VI's Front Panel Window. Panel Bounds property, building two matching XY clusters from the data and subtracting them (assuming the VI only has one pane) or you can use another loop with an event structure and a Mouse Move event (which returns local data) on the graph and then transfer the position data to your loop (you could also use a single loop, but that might be more complicated because the event structure will process every move of the mouse as a new event).
You will also need to keep the data to place in the graph somewhere. If you open the context help window and hover over the graph's BD terminal, you will see the data types it expects and you will need to build one of those yourself. A shift register is something you might want to look into. There are also some examples showing working with graphs in the example finder (Help>>Find Examples).
05-14-2013 01:34 AM
Hi! Thanks for your reply. I'm not exactly very good at LabVIEW, don't really understand what you said, would you like to help me to do it. Attached is my VI.
05-14-2013 03:08 AM
You're going about it completely the wrong way. You have to understand what the method does, what it expects and what each thing means, so that you know how to put them together. If you don't understand them properly, you will just keep having problems. A good place to start in order to understand something about the function is the context help for it and the detailed help. If that doesn't help, writing a small VI which calls the function and seeing how it behaves can help as well.
In this specific case, this is one thing you can do:
The part that's before the loop is described in the previous post and is left as an exercise to you. So is the part of actually building the graph. You might also try looking at some of these tutorials.
05-14-2013 04:28 AM - edited 05-14-2013 04:28 AM
I tried out the Front Panel panel board method but i do not know how start because i don't know where to extract/get the bound.
05-14-2013 04:49 AM
The Application Control palette has a VI Server reference which defaults to the current VI, but you can also right click a property node to select a specific class from the class hierarchy. If you select the VI class, the property node will act on the VI it's in.
05-14-2013 08:10 PM - edited 05-14-2013 08:26 PM
Still don't really know what you trying to say about the pane bound property
But i've tried making it like this but my axis got very very big with autoscale and unable to stop.
05-14-2013 09:53 PM - edited 05-14-2013 10:06 PM
Anyway, I got up the FP.Panel Bound. But i don't understand your after statement which is to create two seperate XY Cluster than subtracting off.
and how do you connect the panel bounds to the invoke node 's coord
05-14-2013 10:41 PM
I think this is what you are referring to right?
05-15-2013 01:12 PM
Since I don't have the time, here's the full code:
If you still don't understand the substraction, play with it. Move the window around and see how that affects it (and now that I say that, I see that the code actually has a bug which I will leave to you to find).
Working with the event structure would help with all that, because you won't have to do that, but the way you're doing it is wrong, because you will get only one event before the loop executes and you need multiple events.
I would suggest again that you go over some more tutorials and examples, because you will have to learn how to do these things yourself.