Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Are there ways to speed up cwgraph3d plotting?

Hi,

I have a loop that updates the plot every time with new line data. If say for example, I am plotting an array of size 128 x 128, then initially the array is empty(0's) then the first line gets data and I plot the array, then the next loop I have a new line of data (2 total lines of data) which I plot, then 3 and so on. When I do this loop using an array of 1024 x 1024 I notice a considerable slowdown which I need to get rid of in my application. Is there some way to display one line of the array, and then just update the graph with the new line for each line so that the cwgraph3d doesn't have to plot the whole giant array each time. I'm assuming that this would speed things up.

Or is there some way (maybe with dll'
s) to speed up the plotting process.

Thanks in advance.

Kevin
0 Kudos
Message 1 of 6
(6,844 Views)
Kevin,

Ploting 1Meg of points can take some time, the first thing to try is to set the 3D acceleration option. In the general properties of the graph there is checkbox to enable this; this will make the 3D graph use the HW 3D capabilities of you video card. In my couputer make a noticable difference. Besides from this there are a couple of advices that I can suggest:

1.-Insted of using zeros for the points that are not drawn, you can use a "Not a Number" (NaN) value. that way the 3D graph will not plot anything for the empty points. Here is some C code yo generate a NaN constant, you can replicate this in VB and have the graph plot just what is needed.

double xTemp=0.0;
xTemp/=xTemp;
z[10][10] = xTemp;

2.- diide your data in mult
iple plots. Instead of having one single plot with all the data, you can create 8 plots of 128 lines each to hold the data. That way you only redraw 1 plot when adding a line.

There is also the option of decimating the array to get a lower number of points with a lower resolution, then you have some sort of zoom option that draws a smaller data set with full resolution.

I hope this helps.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 6
(6,844 Views)
I tried to do this NaN idea, however you cannot have a NaN in vb6 as far as I can figure out. I get a floating point exception error. Do you know how to do this in vb6?
0 Kudos
Message 3 of 6
(6,844 Views)
You can generate a NaN value in VB6 with the following code:

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pDest As Long, ByVal pSource As Long, ByVal Length As Long)
Private Const NanBase = &H7FF80000

Public Function GenerateNaN() As Double
Call CopyMemory(VarPtr(GenerateNaN) + 4, VarPtr(NanBase), 4)
End Function

- Elton
0 Kudos
Message 4 of 6
(6,844 Views)
What variable will be holding the NaN value, or how do I set my array elements to NaN. Also, is there a way to make the NaN a long value (I have an array of longs) or will it not matter.
0 Kudos
Message 5 of 6
(6,844 Views)
ok so I can get the NaN value but my question still stands about how to use it (if possible) in a long buff (i got it to work using a double buff).

Also, about the post regarding using multiple plots, when I try this, it seems to run even slower. Am I forgetting some setting that defaultly auto redraws the image? I simplpy added all the plots I needed, then I looped through and I called for each index.
0 Kudos
Message 6 of 6
(6,844 Views)