02-15-2009 03:01 PM
Hello,
I have a problem with the annotation shape coordinates.
I'm using Measurement Studio 8.6 for VC++ with Visual Studio 2008.
I have a cwGraph in an ActiveX container.
I create the graph and add the plots (voltage versus time). Than, after a processing, I have to add some annotations to the plots in correspondence of specific time instants.
I'm able to add the caption of the annotation at the desired point with the following code:
CNiAnnotation annot= m_ProbeSignalGraph.Annotations.Add();
annot.Caption.SetText(caption);
annot.SetCoordinateType(CNiAnnotation::AxesCoordinates);
annot.Plot = m_ProbeSignalGraph.Plots.Item(1);
annot.SnapMode = CNiAnnotation::SnapNearestPoint;
annot.Caption.SetCoordinates(index/sampling_frequency, 0.4); // index is the index of the sample, index/sampling_frequency is the corresponding time instant
The problem is that I have to associate to the caption a MinMax region or an arrow pointing to a specified point of the plot.
It seems that the CNiAnnotation::AxesCoordinates applies only to the caption and that the coordinates of the shape are not referred to the axes.
If, for example, I use the following code:
annot.CoordinateType = CNiAnnotation::AxesCoordinates;
CNiShape shape = annot.Shape;
shape.MinMaxRegion;
CNiReal64Vector *xC, *yC;
xC= new(CNiReal64Vector); yC= new(CNiReal64Vector);
xC->Append(index/2048); xC->Append((index+100)/2048); // // index is the index of the sample in the signal, index/sampling_frequency is the corresponding time instant
yC->Append(0); yC->Append(1);
shape.SetCoordinates(*xC,*yC);
The region is created in a wrong place.
I'm doing something wrong? Is there a way to specify the Shape coordinates as Axes coordinates?
Thank you, Marco
02-17-2009 01:10 PM
Hello Marco,
When I ran a small test program of my own, I did not see the issue that you are reporting. Looking at the code you posted, the only thing that looks fishy is the third line: shape.MinMaxRegion; I'm not sure if this is a typo, or if you perhaps meant to do this:
shape.Type = CNiShape::MinMaxRegion;
If this does not take care of it for you, please attach a small program that reproduces the issue you are referring to, and I would be happy to take a look at it.
Thanks!
NickB
National Instruments