DMelt:Plots/VisAd

From jWork.ORG
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member
Contents

VisAd

DMelt includes VisAd, which was destined by programmers at the University of Wisconsin Space Science and Engineering Center (SSEC). We reproduce its guide in VisAd guide section

The Java API is given by visad package.

VisAd tutorial

Here is a short tutorial how to visualize numerical information using interactive canvas called jhplot.HVisAd. We will show step-by step example, starting from elementary operation, such as opening the canvas and creating a 3D scene.

from jhplot import *
from java.awt import *
c1 = HVisAd("VisAd",600,600)  # make 600x600 canvas
display = c1.getDisplay()     # get display
ren=c1.getRender()            # get display render
ren.setBoxOn(True)            # draw a box
ren.setBackgroundColor(Color.white)  # make it white
c1.visible()                  # show it

Next, we will try to manipulate with the box. For example, we can zooming (or zoom out), move it and rotate:

from jhplot import *
c1 = HVisAd("VisAd",600,600)
ren=c1.getRender()
ren.setBoxOn(True)
c1.setScaling(0.8)
c1.setRotation(0,20,0)         # rotation around Y in 20 deg 
c1.setTranslation(0.1,0.0,0.0) # shift in X by 10%  
c1.visible()                   # show it

You can use full Java API of VisAd to archive scaling and rotations using the "ProjectionControl" method:

So far we had just a box. Now we can draw axises. Here is an example how to set axis, define their ranges

from jhplot import *
c1 = HVisAd("VisAd")
display=c1.getDisplay()
cont=display.getGraphicsModeControl()
cont.setSceneAntialiasingEnable(True)
cont.setLineWidth(1)
ren=c1.getRender(); ren.setBoxOn(True) # draw a box 
c1.setAxes("X",0,10,"Y",0,10,"Z",0,10)
c1.visible() # show canvas

The method setAxes() takes the name of the axis, min and max value for X,Y,Z axis. Here is a more refined example that shows how to make custom frame with axis:


VisAd code examples

Using full VisAd Java api

Here is a Jython macro which shows ho to visualize 2D data calling Java classes directly:


More information on this topic is in DMelt books