LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

New cursor position is outside plot area, why?

hSpecPlot = PlotXY (specpanel, SPECPANEL_GRAPH, pDsplFrqArray, pDsplSpecData,
       nXNumber*nCurveNumber, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE,
       VAL_SIMPLE_DOT, VAL_SOLID, 1, VAL_BLACK);
SetGraphCursorIndex (specpanel, SPECPANEL_GRAPH, 1, hSpecPlot, nCursorIdx); ----------line 718
where: 0 < nCursorIdx < nXNumber*nCurveNumber
 
NON-FATAL RUN-TIME ERROR:   "SpecChart.c", line 718, col 5, thread id 0x00000804:   Library function error (return value == -83 [0xffffffad]). New cursor position is outside plot area
 
Thanks.
 
ZSW
0 Kudos
Message 1 of 7
(4,308 Views)
The most probable cause it that  your graph is not in autoscale mode and part of the plotted curve goes outside x- or y-axis range: when you try to set the cursor to a point outside the plot area (i.e. the rectangle [xmin; ymin] - [xmax; ymax]) you get this error. Compare the value of pDsplFrqArray[nCursorIdx] and pDsplSpecData[nCursorIdx] when the program breaks on error to x- and y-axis range.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 7
(4,306 Views)
Thanks a lot,Roberto!
I followed your instruction and found the point the cursor set to is within the rang of x- and y-axis. Furthor more, I found that this error occurs only once when the application first time runs this code line, hereafter this code line runs OK. When the error occurs, it seems that the cursor snap to nothing because when I use arrow keys, the cursor can move free. At this time, If I press the  mouse key in the GRAPH plot area, the cursor snaps to the plot.
0 Kudos
Message 3 of 7
(4,299 Views)

Just a try...

What happens if you start without cursors, plot your data and then attach a cursor to the plot?

SetCtrlAttribute (panel, control, ATTR_NUM_CURSORS, 1);

SetGraphCursor (panel, control, 1, pDsplFrqArray[0], pDsplSpecData[0]);

 
Also, I would check that you are using the same x- and y-axis for the plot and the cursor.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 7
(4,287 Views)

Yes! I changed the code to attach cursor after plot the data as you told me. There is no error any more. But I am still bewildered by it. Any way, thank you very much! Roberto.

Further more, could you tell me how to check if the cursor and plot use the same coordinates ?
 

0 Kudos
Message 5 of 7
(4,282 Views)

Well, as you know, the plot is plotted against ATTR_ACTIVE_XAXIS and ATTR_ACTIVE_YAXIS of the graph, which are by default the bottom and left one unless otherwise set in code. The cursor itself has two reference axes, which you can set either in the UIR editor (Graph properties, Cursor popup, Use right Y axis and Use Top X axis check boxes) or programmatically by using

GetCursorAttribute (panel, control, 1, ATTR_CURSOR_XAXIS, VAL_BOTTOM_XAXIS);

GetCursorAttribute (panel, control, 1, ATTR_CURSOR_YAXIS, VAL_LEFT_YAXIS);

Again, default is to use bottom and left axis.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 7
(4,277 Views)

Yes ! I am completely clear. I checked the setting of cursor in UIR and found that I set the cursor to use right y-axis. It must be the cause of the error.

Thank you !

0 Kudos
Message 7 of 7
(4,274 Views)