private Content makeTrackContent() {
    // Prepare tracks instant
    trackNode = new TrackDisplayNode(model);
    universe.addTimelapseListener(trackNode);

    // Pass tracks instant to all instants
    final TreeMap<Integer, ContentInstant> instants = new TreeMap<Integer, ContentInstant>();
    final ContentInstant trackCI = new ContentInstant("Tracks_all_frames");
    trackCI.display(trackNode);
    instants.put(0, trackCI);
    final Content tc = new Content(TRACK_CONTENT_NAME, instants);
    tc.setShowAllTimepoints(true);
    tc.showCoordinateSystem(false);
    return tc;
  }
示例#2
0
  void rotate(final int xNew, final int yNew) {
    if (content == null || content.isLocked()) return;

    final int dx = xNew - xLast;
    final int dy = yNew - yLast;

    aaX.set(axisPerDx, dx * anglePerPix);
    aaY.set(axisPerDy, dy * anglePerPix);

    transX.set(aaX);
    transY.set(aaY);

    rotateTG.getTransform(rotateOld);

    rotateNew.set(transl_inv);
    rotateNew.mul(transY);
    rotateNew.mul(transX);
    rotateNew.mul(transl);
    rotateNew.mul(rotateOld);

    rotateTG.setTransform(rotateNew);
    xLast = xNew;
    yLast = yNew;

    transformChanged(BehaviorCallback.ROTATE, rotateNew);
  }
  @Override
  public void render() {
    if (DEBUG) System.out.println("[SpotDisplayer3D] Call to render().");

    updateRadiuses();
    updateSpotColors();
    spotContent.setVisible((Boolean) displaySettings.get(KEY_SPOTS_VISIBLE));
    if (null != trackContent) {
      trackContent.setVisible((Boolean) displaySettings.get(KEY_TRACKS_VISIBLE));
      trackNode.setTrackDisplayMode((Integer) displaySettings.get(KEY_TRACK_DISPLAY_MODE));
      trackNode.setTrackDisplayDepth((Integer) displaySettings.get(KEY_TRACK_DISPLAY_DEPTH));
      updateTrackColors();
      trackNode.refresh();
      universe.updateStartAndEndTime(blobs.firstKey(), blobs.lastKey());
      universe.updateTimelineGUI();
    }
  }
 @Override
 public void setDisplaySettings(final String key, final Object value) {
   super.setDisplaySettings(key, value);
   // Treat change of radius
   if (key == KEY_SPOT_RADIUS_RATIO) {
     updateRadiuses();
   } else if (key == KEY_SPOT_COLORING) {
     updateSpotColors();
   } else if (key == KEY_TRACK_COLORING) {
     updateTrackColors();
   } else if (key == KEY_DISPLAY_SPOT_NAMES) {
     for (final int frame : blobs.keySet()) {
       blobs.get(frame).setShowLabels((Boolean) value);
     }
   } else if (key == KEY_SPOTS_VISIBLE) {
     spotContent.setVisible((Boolean) value);
   } else if (key == KEY_TRACKS_VISIBLE && null != trackContent) {
     trackContent.setVisible((Boolean) value);
   } else if (key == KEY_TRACK_DISPLAY_MODE && null != trackNode) {
     trackNode.setTrackDisplayMode((Integer) value);
   } else if (key == KEY_TRACK_DISPLAY_DEPTH && null != trackNode) {
     trackNode.setTrackDisplayDepth((Integer) value);
   }
 }
示例#5
0
  void translate(final int xNew, final int yNew) {
    if (content == null || content.isLocked()) return;
    final int dx = xNew - xLast;
    final int dy = yNew - yLast;
    translateTG.getTransform(translateOld);
    v1.scale(dx, translationPerDx);
    v2.scale(-dy, translationPerDy);
    translation.add(v1, v2);
    translateNew.set(translation);
    translateNew.mul(translateOld);

    translateTG.setTransform(translateNew);
    transformChanged(BehaviorCallback.TRANSLATE, translateNew);

    xLast = xNew;
    yLast = yNew;
  }
  private void makeSpotContent() {

    blobs = new TreeMap<Integer, SpotGroupNode<Spot>>();
    contentAllFrames = new TreeMap<Integer, ContentInstant>();
    final double radiusRatio = (Double) displaySettings.get(KEY_SPOT_RADIUS_RATIO);
    final SpotCollection spots = model.getSpots();
    @SuppressWarnings("unchecked")
    final FeatureColorGenerator<Spot> spotColorGenerator =
        (FeatureColorGenerator<Spot>) displaySettings.get(KEY_SPOT_COLORING);

    for (final int frame : spots.keySet()) {
      if (spots.getNSpots(frame, false) == 0) {
        continue; // Do not create content for empty frames
      }
      buildFrameContent(spots, frame, radiusRatio, spotColorGenerator);
    }

    spotContent = new Content(SPOT_CONTENT_NAME, contentAllFrames);
    spotContent.showCoordinateSystem(false);
    universe.removeContent(SPOT_CONTENT_NAME);
    universe.addContentLater(spotContent);
  }
示例#7
0
    private void init(final Content c, final int x, final int y) {
      xLast = x;
      yLast = y;

      content = c;

      // some transforms
      c.getLocalToVworld(localToVWorld);
      localToVWorldInverse.invert(localToVWorld);
      canvas.getImagePlateToVworld(ipToVWorld);
      ipToVWorldInverse.invert(ipToVWorld);

      // calculate the canvas position in world coords
      c.getContent().getCenter(centerInVWorld);
      localToVWorld.transform(centerInVWorld);
      ipToVWorldInverse.transform(centerInVWorld, centerInIp);

      // get the eye point in world coordinates
      canvas.getCenterEyeInImagePlate(eyePtInVWorld);
      ipToVWorld.transform(eyePtInVWorld);

      // use picking to infer the radius of the virtual sphere which is rotated
      final Point3d p = univ.getPicker().getPickPointGeometry(c, x, y);
      float r = 0, dD = 0;
      if (p != null) {
        pickPtInVWorld.set(p);
        localToVWorld.transform(pickPtInVWorld);
        r = (float) pickPtInVWorld.distance(centerInVWorld);
      } else {
        c.getContent().getMin(p1);
        localToVWorld.transform(p1);
        r = (float) p1.distance(centerInVWorld);
        vec.sub(centerInVWorld, eyePtInVWorld);
        vec.normalize();
        vec.scale(-r);
        pickPtInVWorld.add(centerInVWorld, vec);
      }
      dD = (float) pickPtInVWorld.distance(eyePtInVWorld);

      // calculate distance between eye and canvas point
      canvas.getPixelLocationInImagePlate(x, y, p1);
      ipToVWorld.transform(p1);
      final float dd = (float) p1.distance(eyePtInVWorld);

      // calculate the virtual distance between two neighboring pixels
      canvas.getPixelLocationInImagePlate(x + 1, y, p2);
      ipToVWorld.transform(p2);
      final float dx = (float) p1.distance(p2);

      // calculate the virtual distance between two neighboring pixels
      canvas.getPixelLocationInImagePlate(x, y + 1, p3);
      ipToVWorld.transform(p3);
      final float dy = (float) p1.distance(p3);

      final float dX = dD / dd * dx;
      final float dY = dD / dd * dy;

      anglePerPix = Math.atan2(dX, r);

      univ.getViewPlatformTransformer().getYDir(axisPerDx, ipToVWorld);
      univ.getViewPlatformTransformer().getXDir(axisPerDy, ipToVWorld);

      translationPerDx.set(axisPerDy);
      translationPerDx.scale(dX);

      translationPerDy.set(axisPerDx);
      translationPerDy.scale(dY);

      rotateTG = c.getLocalRotate();
      translateTG = c.getLocalTranslate();
      c.getContent().getCenter(vec);
      transl_inv.set(vec);
      vec.set(-vec.x, -vec.y, -vec.z);
      transl.set(vec);
    }