VB examples

VB examples

Thanks, you have to install fortran to get the licence to enable the array visualizer demos to run.

I've been havinga play and looking in the documentation and am quite frankly struggling to produce what I require. How do I produce an XYZ plot, where each point is plotted as a point (not a joined up line connecting all the points together) and the color of the points is relative to a 4th array dimension.

Can you give me a quick pointer to the VB code. The block of code I;ve been playing with from the samples is below.

'Create first XYZPlot
Set xyzPlot1 = graph.Plots.CreatePlot("xyzplot1", AV_XYZPLOT)
xyzPlot1.Transform.Inherit = True
xyzPlot1.XSource = "/dset1@X"
xyzPlot1.YSource = "/dset1@Y"
xyzPlot1.ZSource = "/dset1@Z"
xyzPlot1.Color.Front = m_root.Context.RGBA(255, 0, 0, 255)

Also, in the VB code samples,

Dim xyzPlot1, xyzplot2 As IAvXYZPlot

should strictly be

Dim xyzplot2 As IAvXYZPlot
Dim xyzPlot1 As IAvXYZPlot

Otherwise xyzPlot1 will become a Variant.



16 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I figured out what I require by trial and error ....

xyzPlot1.GraphState.LineStyle = AV_NO_LINE
xyzPlot1.Marker.Visible = True
xyzPlot1.Marker.MarkerType = AV_FILLED_CIRCLE_MARKER
xyzPlot1.Marker.Size = 2

Another question though, if I have outliers in my data, how can I zoom in on the area of the graph of interest?

I've figured out that to zoom in on areas of the graph, I'll have to change the viewpoint. I came up with the code below, where camerapos() is an aray that the user sets, but this code doesn't have any effect. What am I missing?

Also, when you right click on a 3d graph, you get a 'set viewpoint' option, but nothing happens. How does this work exactly?

Private Sub setViewPoint()

Dim graph As IAvGraph3D
Dim camera As IAvCamera

Set graph = m_root.Graphs(1)
Set camera = graph.camera

camera.Viewpoint(AV_XCOORD) = camerapos(0)
camera.Viewpoint(AV_YCOORD) = camerapos(1)
camera.Viewpoint(AV_ZCOORD) = camerapos(2)

'Refresh the control
Call AvGraphCtl1.update

End Sub

Hi Phil,

I'm almost afraid to break in, it seems like you're making great progress on your own! But I'll see if I can help...

Thanks for pointing out the correct syntax for the xyplot1, xyplot2 declarations. In AV we have examples in VBScript, VB6, and VB.Net which are all just different enough that I haven't become very proficient in any of these languages.

I see you figured out how to set up a plot using markers. One nice thing about VB (which unfortunately IVF doesn't have) is statement completion (where the IDE will let you choose between aset of properties, methods, or arguments that are valid for where you are in the statement). This is really handy for figuring out how to do things in an unfamiliar object model.

Regarding setting the viewpoint, you need to understand that there are actually two cameras. One is a sub-object of AvGraph3D, the other is part of the AvGraphCtl. When the control is first pointed to a graph (AvGraphCtl1.GraphPath = "graph:xyzgraph"), the camera properties from xyzgraph are copied to AvGraphCtl1's camera. When the user changes the viewpoint with the mouse, it's the AvGraphCtl1's camera that is updated. This allows you to have a form with two (or more) AvGrapCtl's both using the same graph, but with different viewpoints. What the "Set Viewpoint" option does is copy the current view properties back to the graph's camera. If you open up a file with a 3d graph in Array Viewer and change the viewpoint using the mouse, you'll notice that the view changes aren't persistent. E.g. if you click refresh you'll go back to the original view settings. But if you select "Set Viewpoint" the changes do persist. If you then save the file you'll see your saved view settings when you view the graph.

What you want to do in your VB code is use:

Set camera = AvGraphCtl1.camera

Instead of:

Set camera = graph.camera

Sorry for the lengthy discourse; I hope this has been helpful!

Thanks - that now works, I would never have figured that out by myself.

I'm afraid there are probably going to be alot more questions though before I fully grasp everything. Hope this is OK.

1. Right clicking on the control pops up a 'set viewpoint' tip window. Nothing seems to be able to be done with this though. What is it for?

2. I work with data where there is always a couple of very extreme values that cause the data of interest to be bunched up ina corner of the plot. Is there a way of using the mouse to exclude this data. The only way I can think of zooming into the area of interest at the moment is to have 3 x y & z zoom controls on the form that go away and re-populate the source arrays, then replot the graph. Is there a simpler way?

In other software I've used (eg SAS Insight) you just highlight the points with your mouse and select 'hide data from plot'. Everything the gets rescaled and replotted nicely. Is there such a way with Array Visualizer.

3. CanI copy the plot as an image and paste it into a report. What pointers can you give me here?

Thanks in advance,


re: saving an image. I found something in the help talking about 'IAvImageSave Interface' but it doesn't elaborate much. Can you post some VB code on how to get it to work.

I also noticed in the array viewer that when you save an image it then automatically loads up that image in the default application. I would suggest that this should be optional as it can be annoying. Is it also possible to save the image to the clipboard so you can essentially copy and paste into a report?

You can take a look at the VBScript sample at: ArrayVisualizer/Samples/Script/CreateImage.vbs, I imagine it should be a fairly simple matter totranslate this to VB6. See the readme.txt in the script folder for instructions on running the script.

For the next release we plan to make the IAvImageSave interface available from VB as well asprovide some examples of using this interface.

Your suggestions are good. I'll look intoimplementing themfor the next release.

Regarding dealing with outlier values:

Isn't there a problem with selecting the points in a 3d graph with the mouse? What about points that are actually extreme values, but happen to be in the line of sight as some other nearer points?

Anyway, I've come up with a example that might be helpful. In this case I'm using the AvPolyList plot to plot the points rather than the XYZ plot. In the PolyList plot there is one dataset "/vlist" that gives indices to another dataset "/vertex" that contains the actual coordinates.

In the sample I sort the elements of /vlist by their distance to the origin. There's a section that can be adjusted via a slider that controls how many elements are in the section. If the slider is all the way to the left only the first element (closest to the origin) is displayed. If the slider is all the way to right, all the elements are displayed.

Would some method like this work for your program?

Thanks - I've taken the approach (for the moment)to recreate the raw arrays but only containing the values within the range specified by the user. I have set up some arrays that contain the max and min values for the X,Y and Z values.

The user sets these values, the raw arrays are re-calculated and then the graph re-plotted.

Being guided by the code in the samples, I thought it would be simple to then plot the points in a cube of equal length sides. What seems to happen though is that rather than the data adjust to fit in the border cube, the border cube just changes shape with the points not actually changing. Thus although the intention is to zoom in, I can't seem to make it happen.

How do I force the plot to fit the points into a cube of equal length sides, in the middle of the screen?

The code I've used is below, but it just seems to adjust the border rather than keep the border as it was and adjust the points.

graph.Transform.Origin(AV_XCOORD) = Mminn(0) 'm_dMinX
graph.Transform.size(AV_XCOORD) = Mmaxx(0) - Mminn(0) 'm_dMaxX - m_dMinX
graph.Transform.Origin(AV_YCOORD) = Mminn(1) 'm_dMinY
graph.Transform.size(AV_YCOORD) = Mmaxx(1) - Mminn(1) 'm_dMaxY - m_dMinY
graph.Transform.Origin(AV_ZCOORD) = Mminn(2) 'm_dMinZ
graph.Transform.size(AV_ZCOORD) = Mmaxx(2) - Mminn(2) 'm_dMaxZ - m_dMinZ

I tried you example code but all it did was plot the border. No points were plotted. It looks as though it could be a solution but I can't seem to get it to do anything.

You can leave the Transform of the graph as it is and instead adjust the Transform properties of the plot ( i.e. xyzplot.Transform). You'll need to set the Inherit property to False (otherwise the graph Transform settings will override the plot's). The values of graph.Transform will then effect the relative width, depth, height of the border cube, while the values of plot.Transform will effect were points get positioned within the cube.

It looks like that functionality wasn't enabled with the eval kit version. It should work fine with the most recent update.

I'm having no luck with this. I tried what you suggested but the result was the same sized border cube but all the points then disappear into 1 point right at the centre of the cube - you just cant see them.

I suspected it was something to do with the values I was setting for the origin and size, so I just reproduced the values of the graph object, assuming that re-setting them would have the same effect as having inherit=true. But this did the same, a nice big border but all the points right at the centre of the cube. Whatever values I try for for the origin and sixe gives the same result.

Any clues?

'Create a graph
Set graph = m_root.Graphs.CreateGraph3D("xyzgraph")
With graph
'Show the graph border
.Border.Visible = True

'Set the Origin and Size of the graph transform
.Transform.Origin(AV_XCOORD) = m_dMinX
.Transform.size(AV_XCOORD) = m_dMaxX - m_dMinX
.Transform.Origin(AV_YCOORD) = m_dMinY
.Transform.size(AV_YCOORD) = m_dMaxY - m_dMinY
.Transform.Origin(AV_ZCOORD) = m_dMinZ
.Transform.size(AV_ZCOORD) = m_dMaxZ - m_dMinZ
End With

'Create first XYZPlot
Set xyzPlot1 = graph.Plots.CreatePlot("xyzplot1", AV_XYZPLOT)
With xyzPlot1
.Transform.Inherit = False
.Transform.Origin(AV_XCOORD) = m_dMinX
.Transform.size(AV_XCOORD) = m_dMaxX - m_dMinX
.Transform.Origin(AV_YCOORD) = m_dMinY
.Transform.size(AV_YCOORD) = m_dMaxY - m_dMinY
.Transform.Origin(AV_ZCOORD) = m_dMinZ
.Transform.size(AV_ZCOORD) = m_dMaxZ - m_dMinZ

.XSource = "/dset1@X"
.YSource = "/dset1@Y"
.ZSource = "/dset1@Z"
.GraphState.LineStyle = AV_NO_LINE
.Marker.Visible = True
.Marker.size = markerSize
.Marker.Color = m_root.Context.RGBA(255, 0, 0, 255)
End With

You're code looks correct... If you could, post a zip file of the project. I'll take a look at it.

Here is the project - it is just a re-work of one of the sample projects to demonstrate the problem.



You need to define the Position values when Transform.Inherit is false. Try out your project with the following code:


xyzPlot1.Transform.Inherit = True
If Me.Check4.Value = 1 Then
xyzPlot1.Transform.Inherit = False
xyzPlot1.Position.Origin(AV_XCOORD) = m_dMinX
xyzPlot1.Position.Size(AV_XCOORD) = m_dMaxX - m_dMinX
xyzPlot1.Position.Origin(AV_YCOORD) = m_dMinY
xyzPlot1.Position.Size(AV_YCOORD) = m_dMaxY - m_dMinY
xyzPlot1.Position.Origin(AV_ZCOORD) = m_dMinZ
xyzPlot1.Position.Size(AV_ZCOORD) = m_dMaxZ - m_dMinZ
xyzPlot1.Transform.Origin(AV_XCOORD) = m_dMinX
xyzPlot1.Transform.Size(AV_XCOORD) = m_dMaxX - m_dMinX
xyzPlot1.Transform.Origin(AV_YCOORD) = m_dMinY
xyzPlot1.Transform.Size(AV_YCOORD) = m_dMaxY - m_dMinY
xyzPlot1.Transform.Origin(AV_ZCOORD) = m_dMinZ
xyzPlot1.Transform.Size(AV_ZCOORD) = m_dMaxZ - m_dMinZ
End If

Leave a Comment

Please sign in to add a comment. Not a member? Join today