Re: Display questions

"From: Bill Hibbard " wrote:
> 
> Hi Doug,
> 
> > I have a 3D display with terrain, satellite, lightning,...
> >
> > 1) My satellite data looks like (lon,lat) --> val, and I'd like it to
> > sit near the "bottom" of the box (low on the Z axis). I tried various
> > combinations of constant maps to Display.ZAxis and Display.ZAxisOffset
> > as arguments to Display.addReference with no luck, it just sits in the
> > middle of the box. I don't really want to complicate the data type. I
> > would settle for (lon,lat,lev) --> val but I can't get that to render
> > the data in any way other than points. Is (lon,lat) --> (val,z) my only
> > option?
> 
> ConstantMap(-1.0, Display.ZAxis) should work.  

Well, that works in point mode, but not in whatever "default" mode I am
in. (See sample code below.) Is there some other GraphicsModeControl
method I could take advantage of?  I did find another kludgy solution:
map val to Display.ZAxisOffset and set the range from 0 to some
sufficiently large value (>> val). 

> 
> > 2) Speaking of points..., the terrain looks pretty cool in point mode,
> > but I'd like the satellite as a surface.
> > GraphicsModeControl.setPointMode() applies to the entire display. Is
> > there a way to display one field in point mode and another not?
> 
> The way to do this is to destroy the topology of the terrain
> domain Set by changing its MathType from ((lon, lat) -> alt)
> to (index -> (lon, lat, alt)).  Something like:
> 
>   FlatField terrain = ...
>   float[][] vals = terrain.getDomainSet().getSamples();
>   float[][] alts = terrain.getValues();
>   float[][] new_vals = {vals[0], vals[1], alts[0]};
>   FunctionType func = (functionType)
>     MathType.stringToType("(index -> (lon, lat, alt))");
>   Integer1DSet set = new Integer1DSet(vals[0].length);
>   FlatField new_terrain = new FlatField(func, set);
>   new_terrain.setSamples(new_vals)
> 

I'm actually hoping to be able to switch between point/surface/contour
modes via the GUI. I suppose having the same data represented in
different ways and swapping out references will do.

Thanks,
Doug

-- 
*----------------------------------------------------------------------*
| Doug Lindholm, Software Engineer          |  E-mail: lind@xxxxxxxx   |
| Research Applications Program             |   Phone: 303-497-8374    |
| National Center for Atmospheric Research  |                          |
| P.O. Box 3000                             |     There's no place     |
| Boulder, Colorado 80307-3000              |        like $HOME        |
*----------------------------------------------------------------------*

------
import visad.*;
import visad.java3d.DisplayImplJ3D;
import java.awt.*;
import javax.swing.*;

public class VerySimple {

  public static void main(String args[])
         throws Exception {

    double[][] data = {{100.0,200.0,300.0,400.0}};

    Set set = new Linear2DSet(RealTupleType.SpatialEarth2DTuple,
                              -114.0, -112.0, 2,
                                39.0,   41.0, 2);

    RealType type = new RealType("sat",null,null);
    FunctionType ftype = new
FunctionType(RealTupleType.SpatialEarth2DTuple
                                             ,type);
    FieldImpl field = new FlatField(ftype, set);
    field.setSamples(data);
    DataReference ref = new DataReferenceImpl("sat");
    ref.setData(field);

    DisplayImpl display = new DisplayImplJ3D("display");
    GraphicsModeControl mode = display.getGraphicsModeControl();
    //mode.setPointMode(true); // ConstantMap works
    mode.setPointMode(false);// ConstantMap does not work

    display.addMap(new ScalarMap(RealType.Longitude, Display.XAxis));
    display.addMap(new ScalarMap(RealType.Latitude, Display.YAxis));
    display.addMap(new ScalarMap(type, Display.Cyan));
    ConstantMap[] cm = new ConstantMap[1];
    cm[0] = new ConstantMap(-1.0,Display.ZAxis);
    display.addMap(new ConstantMap(5.0,Display.PointSize));
    display.addReference(ref, cm);

    JFrame frame = new JFrame("VerySimple VisAD Application");
    frame.getContentPane().add(display.getComponent());
    frame.setSize(400, 400);
    frame.setVisible(true);
  }
}