LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in CwGraph 7.1.0 under LW/CVI 7?

Hi,
 
I'm using CwGraph 7.1.0 (306) (602) with LW/CVI 7.0 under Windows XP.
I have a CwGraph object with 4 plots on it, each of them being associated with its own Y-axis.
 
The bug I'm experiencing is that the coordinates used to place the cwCaption object always scale to the first plot even though I associate the cwAnnotation
object with another plot.
 
Here is a code snippet: 
 
/* cwAnnotation and cwCaption object handles */
ret = CWUIControlsLib_CWAnnotationsAdd (annotationsHandle, NULL, &annotationHandle);
ret = CWUIControlsLib_CWAnnotationGetCaption (annotationHandle, NULL, &captionHandle);
/* Set caption text */
ret = CWUIControlsLib_CWCaptionSetText (captionHandle, NULL, "test");
/* Annotation coordinate type */
ret = CWUIControlsLib_CWAnnotationSetCoordinateType (annotationHandle, NULL, CWUIControlsLibConst_cwAxesCoordinates);
/* Associate annotation with a valid plot - That's the point that doesn't seem to work... */
ret = CWUIControlsLib_CWAnnotationSetPlot (annotationHandle, NULL, plot[activePlot]);
/* Snap mode */
ret = CWUIControlsLib_CWAnnotationSetSnapMode (annotationHandle, NULL, CWUIControlsLibConst_cwCSnapPointsOnPlot);  
/* Position the caption - the Y coordinate scales to the 1st plot even when cwAnnotation has been associated with a different plot!!! */
ret = CWUIControlsLib_CWCaptionSetCoordinates (captionHandle, NULL, xPos, yPos);
 
All the return values equal 0. plot is a valid array of CAObjHandle. It is used elsewhere and it points on right plots. xPos and yPos are the right coordinates.
The code actually "works" because I can see the annotation appear on the cwGraph. The X coordinate is right since I have only 1 X axis.
The problem is that its Y coordinate is wrong (when I associate plot 2, 3 or 4) since it *ALWAYS* scales to the 1st plot.
 
I've looked at the VB examples for annotations but there is always only 1 plot used.
Is there a hotfix for this problem? I've been looking through the forum and KB, but nothing useful came up.
 
Any help would be greatly appreciated.
 
Regards,
 
svk
0 Kudos
Message 1 of 5
(3,346 Views)

Try using CWUIControlsLib_CWAnnotationSetByRefPlot() instead of CWUIControlsLib_CWAnnotationSetPlot()

Bilal Durrani
NI
Message 2 of 5
(3,334 Views)

Hi bilalD,

Thanks a lot! Your solution does work! Although I don't see why it works with this function and not with the one I used originally. In general, what's the difference between "normal" functions and those which have "SetByRef" in them?

Thanks again. Your help is very much appreciated.

Regards,

svk

 

0 Kudos
Message 3 of 5
(3,323 Views)


In your case, you wanted to assign the annotation to the plot object . In VB 6.0 for example, you would do this as follows

Set annotation.Plot = myPlot

What is happening is that the Plot property of the annotation object is being assigned a reference of the myPlot object. In CVI, using the Set methods for something that expects an object will end up assigning some copy of the object instead of the actual object itself. Now usually this is ok if you are setting properties that require booleans or other intrinsic types because you usually want just that value. But in this case, we want to use the actual plot object itself, not some copy.

So as a guideline, when setting properties that require types like variants, bools and intrinsic types, its ok to use the Set methods. But if you want to link a couple of living objects together, use the SetByRef methods.

I hope this clarifies things.

Bilal Durrani
NI
0 Kudos
Message 4 of 5
(3,315 Views)

Hi bilalD,

Right. Things are crystal clear now.

Thanks again.

Regards,

svk

0 Kudos
Message 5 of 5
(3,309 Views)