Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get/access the original data buffer that sent to a CNiGraph?

Hello, I have a CNiGraph Control. I make a free drawing on the graph by reading the cursor position into 2 vectors (discreet values) and then plotting them. I want to read the plot on the graph after I am done drawing it. By this I mean to get the coordinates of all the points on the plot. I was thinking that a way to access the points on the graph - their coordinates - is to read/access the data buffer that is sent to the CNiGraph. Does anybody know how to read this data buffer? Or how can I read the coordinates of the points on the plot? Thanks, Alexandra
0 Kudos
Message 1 of 5
(5,109 Views)

I'm sorry to say that this functionality is not built into the CNiGraph. It is built into the .NET graphs, but if you are using MFC, you probably don't want to change your application to use the .NET graphs.

You will have to keep your own copy of the data that you pass to the CNiGraph. I would create a member varible of type CNiReal64Vector in the same class (probably a CDialog-derived class) that contains your instance of CNiGraph. Then, whenever you plot a point to the CNiGraph, call CNiReal64Vector::Append to add the data point to the vector.

0 Kudos
Message 2 of 5
(5,103 Views)

I tried to do something like this:

m_Graph.GetCursors().Item("Cursor-1").SetPlot(m_Graph.GetPlots().Item("Plot-1"));
m_Graph.GetCursors().Item("Cursor-1").SetSnapMode(CNiCursor::SnapPointsOnPlot);

//inside a for loop - counter i

m_Graph.GetCursors().Item("Cursor-1").SetYPosition(CNiVariant(i));
x = m_Graph.GetCursors().Item("Cursor-1").GetXPosition();

but this option SnapPointsOnPlot doesn't do what I would like it to do.

I thought to set the Y Position for the Cursor - and increase it - and to read the X Position, while the cursor is somehow set to follow the plot - a snap option, but I couldn't find a proper snap mode

Do you know anything that can help?

Thanks,

Alexandra

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

Hey ale_m,

You need to read David's response above.  You cannot obtain the data from the graph once it is plotted.  You need to retain it while you are plotting.

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 5
(5,079 Views)
Dear all,
 
I've managed to read the plot from a CNiGraph control, using the following code:
 
   m_Graph.GetCursors().Item("Cursor-1").SetPlot(m_Graph.GetPlots().Item("Plot-1"));
   m_Graph.GetCursors().Item("Cursor-1").SetSnapMode(CNiCursor::SnapNearestYForFixedX);
   nMaxXaxis = m_Graph.GetAxes().Item(1).Maximum;
 
    nInc = nMaxXaxis/nValue;    //nValue is a sample rate
   
   for(nCounter = 0 ; nCounter <= nMaxXaxis ; nCounter=nCounter+nInc)
   {
    m_Graph.GetCursors().Item("Cursor-1").SetXPosition(CNiVariant(nCounter));
    nYvalue = m_Graph.GetCursors().Item("Cursor-1").GetYPosition();
   }
The x value is in nCounter, and the y value in nYvalue - and they can be used in whatever way needed....
This really works, I've tested it 🙂
 
All the best,
Alexandra
 
 
0 Kudos
Message 5 of 5
(5,053 Views)