LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Making graph annotations visible based on mouse location

    Hi All
I have a graph, with several points throughout the graph.  I would like these points to have annotations, referencing the name of the particular item that is  being pointed to by the annotation.  However, I only want to show these annotations when the mouse is moved over that particular point by the user.  Does anyone know of a way to do this.  I know there is a function that allows you to make annotations visible/invisible, so I would need to know something that takes the position of the mouse, and if that position is on a particular point (with an annotation), the annotation becomes visible.
I hope this makes sense.
Cheers,
neemtt
0 Kudos
Message 1 of 9
(5,229 Views)
Hello Neemtt,
 
I wrote you a small example program that you can find attached to this post.
What I do is catch the EVENT_MOUSE_POINTER_MOVE event for the panel, containing the graph. If the callback function is launched with this event, you can get the mouse coordinates from eventData1 and eventData2. Then I use the GetGraphCoordsFromPoint function to transform this panel coordinates into graph coordinates. When this is done, you can simple adjust the visibility of each annotation by comparing these coordinates to the annotation coordinates.
 
Have fun Smiley Happy
 
 
Edit: sorry, I misspelled your name Smiley Tongue


Message Edited by Wim S on 06-11-2008 03:40 PM
0 Kudos
Message 2 of 9
(5,221 Views)
Is the case EVENT_MOUSE_POINTER_MOVE available in CVI version 8.0.1, because I cannot seem to locate it.  Thanks for your tips... once/if I fine this case, everything should work.
Cheers,
neemtt


Message Edited by neemtt on 06-11-2008 09:04 AM
0 Kudos
Message 3 of 9
(5,216 Views)

Hello Neemtt,

Sorry, the answer is no. I created the example with CVI8.5. But don't worry, I converted it to CVI80. You can find it in the attachment. The only change I needed to make was calling the EnableExtendedMouseEvents for the graph, and moving the code from the panel callback into the graph callback. After calling the EnableExtendedMouseEvents function, the graph's callback function will also be called with the EVENT_MOUSE_MOVE event.

 

Message 4 of 9
(5,211 Views)
Cheers!!!
Works like a charm.
0 Kudos
Message 5 of 9
(5,201 Views)
Wim or anyone

Here is an additional question I was wondering/struggling with.  Assume that in your example, you had a list made up of the three points in your graph(Point 1, Point 2, Point 3).  Could you think of a way to, when Point 1 is selected, Point 1 on the graph would be highlighted or altered somewhat from its initial appearance (--for example-- maybe its symbol changes from being a red cross to a blue x) and then when Point 2 is selected in the list, Point 1 goes back to normal and Point 2 changes appearance.
Thanks,
neemtt

0 Kudos
Message 6 of 9
(5,165 Views)

Hello Neemtt,

Sorry, but you cannot alter the point style of a single point of a plot. There are a few other things you might consider to do:

  • Put a cursr on the selected point. You can change the cursor's point style and cross hair style to your needs.
  • Plot a single point on top of the selected point. Make sure you put the return value of this PlotPoint function into a global variable, so you can remove it afterwards without having to clear the entire graph.

Personally I would go for the first solution.

0 Kudos
Message 7 of 9
(5,155 Views)
How can you determine which list item you've selected is "active"?  I want to GetIndexFromValue but I'm not sure how I can identify one element being selected as opposed to a different item in the list.  Ultimately, I will use the index that that function returns to determine position of a certain point on my graph, and then have the cursor go to that point.  But thats not related to my question.
I appreciate the help.
neemtt
0 Kudos
Message 8 of 9
(5,131 Views)

Hi Neemtt,

To obtain the index of the selected item, use GetCtrlIndex.

To obtain the value of the selected item, use GetCtrlVal.

 

0 Kudos
Message 9 of 9
(5,105 Views)