Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

CWGraph, mulitiple plots using C++ .NET

I have a two fold question as I have been struggling with this issue for a while now. I am using Visual Studio .NET 2003 Visual C++ Windows Forms. I can't find any real examples or help anywhere.

I want to have a CWGraph that can have up to 11 different plots simutaneously. I can make the first plot using the PlotY command as shown below:

double dataY __gc[] = new double __gc[163];

for (int i = 0; i < 163; ++i)
dataY[i] = i * 24.5;

GraphDefault->PlotY(dataY,S"5.8",S"0.1",S"true");

This works great for a single plot, but not of multiple plots.

I have the data for every plot that I need to make at runtime and can easily assemble it to whatever format it needs to be in to get PlotY to work. I have changed all the colors for each plot from within the properties portion for the CWGraph. All the examples I tend to find have something like this:

DefaultGraph.Plots.Item(index).PlotY( System::object __gc*,System::object __gc*,System::object __gc*,System::object __gc*);

But, I can't seem to get anything like that to work for VC++ .NET using Windows Forms. The compiler will compile something similar (using -> instead of .), but the program crashes when it attempts to run that line of code. From what I can tell, Windows Forms for Visual C++ syntax is really:

DefaultGraph->PlotY( param1, param2, param3, param4);

So I see no way to tell it which plot I want it to use.


From my understanding, you send a matrix to the PlotY and it will display all the different graphs for you at once. That is fine, but I can't figure out the structure for the matrix. All the header files I have for National Instruments have some sort of compile error and I can't compile any of them into my source, so I am unable to use the NiScalarMatrix for my matrix.

Part 2 of my question is being able to hide on plot (or several plots) by turning some sort of visibility property to false.

What I would eventually like to do is upon loading up a particular form, I would like to load all 11 plots to the CWGraph and make them all invisible. When the user checks a check box, I will display that current graph by making it visible. This way if they click on all the checkboxes for the various graphs, all will be displayed in various colors distiguishing them from each other and coordinating them with the checkbox checked.

Does anyone have any idea's for this? Is there any C# sourse that does this? I think I could successfully take C# code and translate it to C++ code, although I would prefer any type of help in the C++ arena.
0 Kudos
Message 1 of 6
(4,645 Views)
I forgot to mention.. I am using Measurement Studio version 7.0 and I am also using Windows XP.
0 Kudos
Message 2 of 6
(4,645 Views)
Part 1: If you want to plot the data one plot at a time, you can access the plot via the Plots collection and call PlotY like this:

GraphDefault->Plots->Item(__box(index))->PlotY(dataY, Type::Missing, Type::Missing);

If you want to plot all of the data at once via a matrix, you can create the matrix and plot it like this:

double dataY __gc[,] = new double __gc[5, 50];
// Populate the matrix with data ...

GraphDefault->PlotY(dataY, Type::Missing, Type::Missing, Type::Missing);

Part 2: You can iterate through the plots via the Plots collection and set each plot's Visible property to false like this:

int plotCount = GraphDefault->Plots->Count;
for (int i = 1; i <= plotCount; ++i)
GraphDefault->Plots->Item(__box
(i))->Visible = !GraphDefault->Plots->Item(__box(i))->Visible;

Just out of curiosity, is there a reason that you're using the interop assembly to the ActiveX CWGraph instead of using the native Windows Forms .NET graph that ships with Measurement Studio 7.0? The Windows Forms .NET graph would feel much more natural in your Windows Forms application than using the CWGraph. For example, accessing the plot via the Plots collection and plotting data would look like this instead:

GraphDefault->Plots->get_Item(index)->PlotY(dataY);

Creating and plotting a matrix would look like this instead:

double dataY __gc[,] = new double __gc[5, 50];
// Populate the matrix with data ...

GraphDefault->PlotYMultiple(dataY);

And iterating through the plots and setting each plot to be invisible would look like this instead:

int plotCount = GraphDefault->Plots->Count;
for (int i = 0; i < plotCount; ++i)
GraphDefault->Plots->get_Item(i)->V
isible = false;

- Elton
Message 3 of 6
(4,645 Views)
Your curiosity has now raised my curiosity. I only see:

CWSlide Control
CWKnob Control
CWGraph Control
CWButton Control
CWNumEdit Control

when I hover on the tooblox, then click Measurement Studios C++ Tools. I was completely unaware that there was a native Windows Form .NET graph that I could use from Measurement Studio 7.0. Did I somehow miss that in the installation? Or, maybe I caused a problem because I had originally installed Visual C++ .NET, then installed Measurement Studio. Then, about one week later, I got a copy of Visual Studio .NET and installed it and it appeared to not effect Measurement Studio, so I never re-installed Measurement Studio after that point. I certainly like the straight forward implementation that is used wit
h the native Windows Forms .NET illustration you provided.

Where do I find this graph (not currently in my Measurement Studio C++ Tools)? Is there a switch I need to turn on, through some project options or settings, to supply me with that graphing tool, or do I need to reinstall Measurement Studio 7.0?


I would like to add that you have been extremely helpful and I can't thank you enough. After seeing what you have provided, it makes a lot of sense now, but would be interested in the native Windows Forms .NET Measurement Studio solution as well.

Again, thank you very much.
0 Kudos
Message 4 of 6
(4,645 Views)
No problem. I'm glad that my response was helpful.

Regarding the Measurement Studio .NET libraries in Measurement Studio 7.0, they did not get installed because you only had Visual C++ .NET installed at the time that you installed Measurement Studio 7.0. The Measurement Studio 7.0 installer will not install the .NET libraries unless Visual Basic .NET or Visual C# .NET are installed. Try reinstalling Measurement Studio now that you have Visual Studio .NET installed. Once you've reinstalled, you should see a Measurement Studio .NET Tools tab in the toolbox. This tab will have the Windows Forms .NET graph.

- Elton
0 Kudos
Message 5 of 6
(4,645 Views)
Thanks a lot. You have been most helpful. I will reinstall Measurement Studio 7.0 so that I can have all the available tools to work with.
0 Kudos
Message 6 of 6
(4,645 Views)