From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use CWGraph3D for Visual C++,How the Variant operate?

I have a VC++ project that use CWGraph3D to show data.
How I use it's method Plot3DCurve(VARIANT& xVector,...)
what's the VARIANT type.
How do I use the VARIANT type to do this job?
0 Kudos
Message 1 of 4
(3,434 Views)
If you have Measurement Studio, you really should be using our native Visual C++ tools instead of the ActiveX controls directly. It will save you A LOT of time trying to deal with VB/ActiveX data types.

In case you don't have Measurement Studio for Visual C++ and just have the 3DGraph ActiveX control, not the MFC classes, then I attached a ZIP file with several examples of using the 3Dgraph ActiveX control in Visual C++.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 4
(3,434 Views)
Is there anyway that you can use the 3Dgraph that comes with Measurement Studio for VC++? It has the same functionality and the added benefit that you won't have to deal with Variants. Since you are in VC++, you can find the 3Dgraph control in the Visual C++ Controls palette. If you don't have it there, run the Measurement Studo Add/Remove Components Wizard to add it to your project.
With the native VC++ 3Dgraph, your Plot3DCurve will have the following prototype:

void Plot3DCurve(
const CNiVector& x,
const CNiVector& y,
const CNiVector& z);

Let me know if you have further questions.

Regards,
Azucena
NI
0 Kudos
Message 3 of 4
(3,434 Views)
Thank you for response this question so soon.
Because I do not have Measurement Studio for VC++,
I do not have CNiVector data type.
Now I have CCWSafeArray from Chris Matthews,
National Instruments.
I could use it's contructor and AccessData() method
to create an array like this:
double xArray[3]={0,1,2};
double yArray[3]={0,1,2};
double zArray[3]={7,8,9};
double wArray[3]={0,0,0};
CCWSafeArray xSafeArray(xArray,3);
CCWSafeArray ySafeArray(yArray,3);
CCWSafeArray zSafeArray(zArray,3);
CCWSafeArray wSafeArray(wArray,3);
m_Graph.Plot3DCurve(xSafeArray,ySafeArray,zSafeArray,wSafeArray);

It works very well.

But now I would like to use Plot3DSurface() method.
I write C++ code like this:
double xArray[3]={0,1,2};
double yArray[3]={0,1,2};
dou
ble zMatrix[3][3]={{1,2,3},{4,5,6}.{7,8,9}};
double wMatrix[3][3]={0};
CCWSafeArray xSafeArray(xArray,3);
CCWSafeArray ySafeArray(yArray,3);
CCWSafeArray zSafeArray2D(zArray,3,3);//error line
CCWSafeArray wSafeArray2D(wArray,3,3);//error line
m_Graph.Plot3DSurface(xSafeArray,ySafeArray,zSafeArray2D,wSafeArray2D);

It could not work.Complier tell me:
error C2664: '__thiscall CCWSafeArray::CCWSafeArray(unsigned short,long,long,long)' : cannot convert parameter 1 from 'double [3][3]' to 'unsigned short'

I don't know what's wrong.
0 Kudos
Message 4 of 4
(3,434 Views)