Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Annotations to a fixed point on a graph?

Hi,

I am using MeasurementStudio7 in C++ mode. I have to create a marker on a graph (this is just a cursor) and a text assigned to it. I am able to create the cursor. I have tried almost every possible way to add an Annotation, but it seems that for some reason the system disregards my efforts. I am trying with no curves displayed. The range of the axis is 0-10 both X and Y. I can add the annotation, but I cannot specify which coordinates I want it to point to and which coordinates the text should be displayed at. The idea would be to point to a point on the cursor. I also noticed that if I add an anotation and pan the graph it just stays at the same position no matter what the axes are displaying.

Also if I try to move the text it just clips to the top left of the graph.

So my question is this:
1. how can I create an annotation with arrow pointing to a specified graph coordinate?
2. how can I track this without having a bounding limit

Here is the code I used:

CNiAnnotation newAnnotation = m_Graph2D.Annotations.Add();


newAnnotation.SnapMode = CNiAnnotation::SnapFixed;
newAnnotation.CoordinateType = CNiAnnotation::AxesCoordinates;
CNiShape shape = newAnnotation.Shape;
shape.Type = CNiShape:: Point;

CNiReal64Vector xC,yC;

xC.Append(3);
yC.Append(5);

shape.SetCoordinates(xC,yC);

newAnnotation.Caption.Text = _T("Caption");
newAnnotation.Enabled = true;
newAnnotation.Visible = true;

This means I want it to point to (3,5). I am always clipped to an area of (0, 9.25, 5, 10). I have attahced a JPG, the left one shows where the annotation is placed based on the above code, the right one shows how it reacts when I pan.

Please help,

Thank You
Miklos
0 Kudos
Message 1 of 4
(3,409 Views)
Hello Miklos

Perhaps I missed something, but I was able to get the annotation to point to the correct point with the code you have. Even if I pan, the annotation stays on that point. I tried this using version 7.1.0 (306)(602) of the CWWGraph. You can update to the newer version from here.

Try this out and let me know if you still have problems.
Bilal Durrani
NI
0 Kudos
Message 2 of 4
(3,397 Views)
I am using NI Measurement Studio7 under Microsoft Visual Studio .NET developing in C++. The m_Graph2D is CNiGraph class. It behaves rather weird. On the example source I am able to place the point to the appropriate position. What could I be missing? I also have an OnResize function. The whole graph window is placed in a splitter window pane.

Here are the resizes:
void CGraph2DPaneView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
CRect rect;
GetClientRect(rect);

if (!m_bFirst)
m_Graph2D.SetWindowPos(NULL,gnBorder,gnBorder, rect.Width()-2*gnBorder,rect.Height()-2*gnBorder, 0);

}

Could this be causing the clipping? I am stumped completely on this matter. Any help would be welcome. Btw. the link you sent was for MeasurementStudio6 wasn't it? I am using 7 with Visual Studio .NET environment using C++.

Miklos
0 Kudos
Message 3 of 4
(3,390 Views)
The link will update versions of the CWGraph prior to 7.1 to the current version. I just wanted to make sure that the problem you are seeing is not because of some issues that were corrected in the 7.1 version of the control. You should be able to use this installer since you have a valid version of Measurement Studio installed already.

If you still have trouble after updating the control, could you post a sample project here that reproduces the problem?

Thanks
Bilal Durrani
NI
0 Kudos
Message 4 of 4
(3,384 Views)