LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CWGraph Cursor Behavior

I'm using a cursor in a multiplot graph. That cursor points on any plot. You can have up to 8 plots displayed at the same time, but not necessarly all of them. Each one of the plots has its own Y axis.

Problems occur when I want to set programmatically the plot of the cursor. That doesn't seem to work. So I have to "preset" in the UIR a plot for that cursor. But if that plot doesn't exist at one time, I still can use the cursor only if it happens that its Y coordinate is in the plot area, if not, I can only set the X coordinate. So the cursor is useless.

Another thing is that I want the user to be able to manually choose the current pointed plot. But like I said before, I'm not able to programmatically set the current pointed plot.

Does s
omebody have any hint about how to accomplish what I want to do? Or have I reached a limitation in the usage of a cursor that points on any plot?

Any answers or hints would be appreciated.

Francis Savaria
R&D tech
Vulcain Alarme Inc
0 Kudos
Message 1 of 4
(3,255 Views)
You can change the plot of a cursor programmatically very easily. I assume you are programming in CVI since you posted to the CVI forum. Using the CVI generated instrument driver for the CWGraph, you would change the plot of the cursor with this code:

/Set up the new cursor to snap to Plot 1
CWUIControlsLib__DCWGraphGetPlots (hCWGraph, NULL, &hPlots);
CWUIControlsLib_CWPlotsItem (hPlots, NULL, CA_VariantInt(1), &hCurrentPlot);
CWUIControlsLib_CWCursorSetByRefPlot (hCurrentCursor, NULL, &hCurrentPlot);

You could change to any plot index you want to use.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 4
(3,255 Views)
I already knew how to proceed, but the function you used in your example was not the one I was using. So I tried CWUIControlsLib_CWCursorSetByRefPlot instead of CWUIControlsLib_CWCursorSetPlot and now everything's working perfectly. Maybe this last one has a bug.

Thanks for helping,

Francis
0 Kudos
Message 3 of 4
(3,255 Views)
This actually isn't a bug. It is the necessary implementation for correct functioning of the ActiveX control in Visual Basic. Let me try to explain. In Visual Basic there are objects and references to those objects. If you have a statement like:

CWGraph1.Cursors(1).Plot = Plot1

Then, that syntax is supposed to create a duplicate object of Plot1 that is assigned to CWGraph1.Cursors(1).Plot. On the other hand, if you want CWGraph1.Cursors(1).Plot to be a reference to Plot1 (not a copy of the object), then you would use the statement:

Set CWGraph1.Cursors(1).Plot = Plot1

Notice the "Set" statement which denotes this is a reference to Plot1. It will increment the reference count to the Plot1 object and set the Plot property to re
fer to Plot1. Some ActiveX controls implement a behavior for both copy and set reference. In the CVI ActiveX wrapper those are represented by Set (copy) and SetByRef (set reference). In the case of this property it should be a reference to an existing Plot object not a separate copy, so we need the equivalent of the Set statement which is SetByRefPlot, not SetPlot which would copy it and be invalid.

Hopefully that makes sense,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 4
(3,255 Views)