Changeset 431 for trunk/loci/visbio/view


Ignore:
Timestamp:
06/07/05 14:03:01 (15 years ago)
Author:
curtis
Message:

Fix bug in cursor probe when micron units are used; improve aspect ratio
detection to use micron units if they are present; fix some minor aspect
ratio bugs.

Location:
trunk/loci/visbio/view
Files:
3 edited

Legend:

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

    r428 r431  
    592592    double[] domain = VisUtil.cursorToDomain(display, 
    593593      new RealType[] {xType, yType, zType}, cur); 
    594     // CTR START HERE - 
    595     // 1) This cursor probe is wrong when micron values are specified. 
    596     // 2) Then, make aspect ratio automatically match micron values if present.  
    597     // 3) Fix derivative data objects (arbitrary slice, etc.) to work properly. 
    598     // 4) Test state logic a bit more. 
    599     // 5) Release! 
    600594 
    601595    // determine which slice to probe 
    602596    int index = -1; 
    603597    int len = references.size(); 
    604     double zpos = Math.round(domain[2]); 
     598    double step = it.getMicronStep(); 
     599    if (step != step) step = 1; 
     600    double zpos = Math.round(domain[2] / step); 
    605601    if (zpos >= 0 && zpos < len) index = (int) zpos; 
    606602    if (index < 0) return; 
  • trunk/loci/visbio/view/ViewHandler.java

    r373 r431  
    201201  } 
    202202 
    203   /** Guesses aspect ratio based on linked data transforms. */ 
     203  /** Guesses aspect ratio based on first linked data transform. */ 
    204204  public void guessAspect() { 
    205205    TransformHandler transformHandler = window.getTransformHandler(); 
    206206    DataTransform[] trans = transformHandler.getTransforms(); 
    207     int x = 0, y = 0; 
     207    double x = 1, y = 1, z = 1; 
    208208    for (int i=0; i<trans.length; i++) { 
    209209      if (!(trans[i] instanceof ImageTransform)) continue; 
    210210      ImageTransform it = (ImageTransform) trans[i]; 
    211       x += it.getImageWidth(); 
    212       y += it.getImageHeight(); 
    213     } 
    214     if (x == 0) x = 1; 
    215     if (y == 0) y = 1; 
    216     double dx = x > y ? (double) x / y : 1.0; 
    217     double dy = y > x ? (double) y / x : 1.0; 
    218     panel.setAspect(dx, dy, 1.0); 
     211      int w = it.getImageWidth(); 
     212      int h = it.getImageHeight(); 
     213      TransformLink link = (TransformLink) transformHandler.getLink(it); 
     214      int axis = link instanceof StackLink ? 
     215        ((StackLink) link).getStackAxis() : -1; 
     216      int numSlices = axis < 0 ? 1 : it.getLengths()[axis]; 
     217      double mw = it.getMicronWidth(); 
     218      double mh = it.getMicronHeight(); 
     219      double ms = it.getMicronStep(); 
     220      x = mw == mw ? mw : w; 
     221      y = mh == mh ? mh : h; 
     222      z = ms == ms ? (ms * (numSlices - 1)) : (x < y ? x : y); 
     223      break; 
     224    } 
     225    panel.setAspect(x, y, z); 
    219226  } 
    220227 
  • trunk/loci/visbio/view/ViewPanel.java

    r198 r431  
    7373  /** Updates aspect ratio GUI controls. */ 
    7474  public void setAspect(double dx, double dy, double dz) { 
     75    aspectX.getDocument().removeDocumentListener(this); 
     76    aspectY.getDocument().removeDocumentListener(this); 
     77    if (aspectZ != null) aspectZ.getDocument().removeDocumentListener(this); 
    7578    aspectX.setText("" + dx); 
    7679    aspectY.setText("" + dy); 
    7780    if (aspectZ != null) aspectZ.setText("" + dz); 
     81    aspectX.getDocument().addDocumentListener(this); 
     82    aspectY.getDocument().addDocumentListener(this); 
     83    if (aspectZ != null) aspectZ.getDocument().addDocumentListener(this); 
     84    doAspect(); 
    7885  } 
    7986 
Note: See TracChangeset for help on using the changeset viewer.