Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Use PlotXvsY

Hi, I am new to AxCWGraph for measurement studios. I am using Measurement Studios 7.0 for VC++.
 
I want to use the method PlotXvsY. I currently have a 1D array of floats which contains all the x/y values respectively. I want to plot them in a graph. I checked the prototype for the method, and it wants type objects__gc*. Therefore just typing
mygraph.plotXvsY(array[x], array[x+1]) just doesn't work.
 
I looked at all the examples online, and it seems people are using CNiVectors to be passed into the method. I am even more confused because I never used CNiVector class before. Can someone help me point to the right direction on what I should pass in?
 
Thank you very much for your time!
-Mike
0 Kudos
Message 1 of 9
(5,025 Views)

Hello

Looks like you are using a managed C++ .NET project. Was that your original intention? The CNi classes are all MFC based libraries, so you will need to use an (unmanaged) MFC C++ project to use those classes. The shipping examples that use the CNi classes are all MFC projects.

If you are trying to use a managed C++ .NET application, Measurement Studio 7.0 and higher does provide native .NET user interface components, so you will not have to deal with COM interop in .NET.

Let me know what you are trying to do and I'll try to provide more suggestions.

Bilal Durrani
NI
0 Kudos
Message 2 of 9
(5,018 Views)

Hi,

I am just trying to plot an array of points onto an AxCwGraph component. Yes,  I am using a .Net project. The method I want to use to plot my points is PlotXvsY(System::Object __gc, System::Object__gc);

I am assuming the parameters that are passed in are x and y values. So you are mentioning that I do not even need to use the Interop interface? All the examples I am seeing are using MFC classes. So you are saying that I need to use unmanaged MFC classes? I apologize, but I do not understand the terminology.

Let me know if you want anymore input. Thanks!

0 Kudos
Message 3 of 9
(5,012 Views)
Another question,
Because all the examples I am seeing are using CNiVector as parameters to plot the points, you are saying I do not need to? Or I have to use an unmanaged MFC project to have access to the CNi classes?
 
Thanks!
0 Kudos
Message 4 of 9
(5,011 Views)

The examples that you are looking at are for the Measurement Studio C++ interfaces, which are MFC-based classes that are intended to be used from unmanaged C++ applications.  The Measurement Studio C++ UI classes are custom C++ interfaces to ActiveX controls and use native Measurement Studio C++ data types, such as CNiVector.  If you are creating a .NET Windows Forms project, you must use .NET Windows Forms controls on the form.  You cannot use the Measurement Studio C++ UI classes on a .NET Windows Forms form.  The AxCWGraph class that you are using is a .NET interop wrapper around the CWGraph ActiveX control.  There are no C++ examples that demonstrate using the ActiveX control in this manner.

The interop wrapper approach will work, but I suggest using the controls that are native to the type of application that you are writing.  This means that if you're writing an unmanaged C++ application with MFC, use the CNiGraph class, and if you are writing a .NET Windows Forms application, use the native Measurement Studio .NET Windows Forms graphs, which are called WaveformGraph and ScatterGraph.  These graphs accept .NET data types and will be much easier to use from a .NET application.

- Elton

0 Kudos
Message 5 of 9
(5,004 Views)

The CNi classes are MFC-based C++ classes, so yes, you need to use an unmanaged MFC project to access these types.  Another option is that you can create a Managed C++ project and use both .NET and C++ data types (including the CNi classes) in the application.  However, a .NET Windows Forms form works with .NET controls only, so you will not be able to use the CNi UI classes in this type of application.

- Elton

0 Kudos
Message 6 of 9
(5,001 Views)
Hi Elton,
 
Thanks for the input. I prefer using Windows Form application because I am creating a UI program which makes use of all the window forms interface. So in other words, I probably can not have use CNi class. Is there any other way I can use PlotXvsY, since all the examples that came with teh software uses the CNi class to plot the points. Thanks!
0 Kudos
Message 7 of 9
(4,998 Views)

Ok,

I just played around with measurement studios, and it seems I have to remake a brand new MFC project. I am foreign to this format. I assume this is the conventional way on using graph plotting functions. This is a big problem for me because I am writing a larger program all based on the windows form project template. Because the graph controls are going to be in MFC, I have to rewrite the whole program using the MFC template.

Is there some way of incorporating the plot functions under the window forms template? I guess this is my main question throughout this thread. If I use the plot functions in windows form, it complains because I am not passing CNiVector into its parameters. I hope this makes my problem clearer. Thank you very much for your time!

0 Kudos
Message 8 of 9
(4,999 Views)

Please see my response on this thread. Thanks.

- Elton

0 Kudos
Message 9 of 9
(4,993 Views)