Re: DataReference

Hi Doug,

> I have data of the type (x,y) -> (t,u,v)
> 
> I display t as contours (IsoContour) and u,v as a vector field
> (Flow1X,Flow1Y). No problem so far, but I'd like to be able to turn each
> of them off and on via my GUI. I have done this sort of thing
> successfully by removing and adding DataReferences to the Display. But,
> for this case, there is one DataReference for the whole thing. I can't
> remove one (e.g. t countours) without removing the other (e.g. u,v
> vectors). Do I have to create 2 distinct Fields with types:
> 
> (x,y) -> (t)
> (x,y) -> (u,v)

This will work.

> If so, then I'd like to have my generic data reading code create
> something like:
> 
> (x,y) -> (t)
> (x,y) -> (u)
> (x,y) -> (v)
> 
> But then, as far as I can tell, the Flow vectors won't work unless u and
> v are part of the same Field. Is that the case?

Yes, they must be part of the same Field.

> Then what do I do if I
> want to have individual contours of u and v also? Do I have to have
> multiple copies of data all over the place? Is there a better way to
> add/remove data from the Display?

Given a FlatField with the MathType ((x, y) -> (u, v)) you can map:

  u -> Flow1X
  v -> Flow1Y
  u -> IsoContour
  v -> IsoContour

and get flow vectors plus contours of both u and v.  If you
want to turn flow, u contour and v contour all on and off
independently, then you'll need multiple FlatFields (or
another suggestion below).  No need for multiple copies of
the float u and v values though, just use copy = false in
calls to FlatField.setSamples() and FlatField.getFloats()
and repeat the same float[] arrays inside various float[][]
arrays passed to setSamples().

Another way to do this (JMet does it) is to create a complex
Tuple object with MathType:

  ((select1 -> ((x, y) -> (u, v))),
   (select2 -> ((x, y) -> u)),
   (select3 -> ((x, y) -> v)))

and to give each of the FieldImpl's (selectN -> ...) a domain
set Integer1DSet(2), where one range value is the FlatField
((x, y) -> ...) you want to display, and the other range value
is a FlatField with missing value (just don't call its
setSamples() method).  Then construct ScalarMaps of each selectN
to SelectValue.  The advantage of this approach is faster
toggling speed.

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html

  • 2000 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: