Changeset 568 for trunk/loci/visbio/view


Ignore:
Timestamp:
11/04/05 12:26:02 (15 years ago)
Author:
curtis
Message:

Fix Z axis bug with multiple data objects in a single 3D display,
where ConstantMaps to Z are not being set properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/visbio/view/StackLink.java

    r566 r568  
    276276      else { 
    277277        for (int i=0; i<len; i++) { 
    278           display.addReferences((DataRenderer) renderers.elementAt(i), 
    279             (DataReferenceImpl) references.elementAt(i)); 
     278          DataRenderer dataRend = (DataRenderer) renderers.elementAt(i); 
     279          DataReference dataRef = (DataReferenceImpl) references.elementAt(i); 
     280          display.addReferences(dataRend, dataRef); 
     281          setZLevel(dataRend, i, len); 
    280282        } 
    281283      } 
     
    432434 
    433435  /** 
    434    * Assigns the given data object to the given data reference, 
     436   * Assigns the given data object to the specified data reference, 
    435437   * switching to the proper types if the flag is set. 
    436438   */ 
     
    446448      FunctionType ftype = it.getType(); 
    447449      Unit[] imageUnits = it.getImageUnits(); 
    448       try { 
    449         d = DataUtil.switchType(ff, ftype, imageUnits); 
    450  
    451         // assign proper Z value 
    452         RealType zbox = it.getZType(); 
    453         Unit zunit = it.getZUnit(stackAxis); 
    454         //Set set = new SingletonSet(new RealTupleType(zbox), 
    455         //  new double[] {zval}, null, new Unit[] {zunit}, null); 
    456         //FieldImpl field = new FieldImpl(new FunctionType(zbox, ftype), set); 
    457         //field.setSample(0, d, false); 
    458         //d = field; 
    459  
    460         //Real zreal = new Real(zbox, zval, zunit, null); 
    461         int numSlices = getSliceCount(); 
    462         if (numSlices > 1) { 
    463           zval = 2 * zval / (getSliceCount() - 1) - 1; 
    464           ConstantMap zmap = new ConstantMap(zval, Display.ZAxis); 
    465           dataRend.getLinks()[0].setConstantMaps(new ConstantMap[] {zmap}); 
    466         } 
    467       } 
     450      try { d = DataUtil.switchType(ff, ftype, imageUnits); } 
    468451      catch (VisADException exc) { exc.printStackTrace(); } 
    469452      catch (RemoteException exc) { exc.printStackTrace(); } 
    470453    } 
    471454    try { dataRef.setData(d); } 
     455    catch (VisADException exc) { exc.printStackTrace(); } 
     456    catch (RemoteException exc) { exc.printStackTrace(); } 
     457  } 
     458 
     459  /** 
     460   * Assigns the given value to the specified 
     461   * data renderer's ConstantMap to the Z axis. 
     462   */ 
     463  protected void setZLevel(DataRenderer rend, double zval, int len) { 
     464    zval = 2 * zval / (len - 1) - 1; 
     465    try { 
     466      ConstantMap zmap = new ConstantMap(zval, Display.ZAxis); 
     467      rend.getLinks()[0].setConstantMaps(new ConstantMap[] {zmap}); 
     468    } 
    472469    catch (VisADException exc) { exc.printStackTrace(); } 
    473470    catch (RemoteException exc) { exc.printStackTrace(); } 
Note: See TracChangeset for help on using the changeset viewer.