Ejemplo n.º 1
0
  private void doUpdate() {
    if (restorePending) {
      return; // we will get called again
      // after the restore is
      // complete
    }
    canvas.stopRenderer();
    canvas.setDoubleBufferEnable(doubleBufferAttr.getValue());
    if (coordSysAttr.getValue()) {
      coordSwitch.setWhichChild(Switch.CHILD_ALL);
    } else {
      coordSwitch.setWhichChild(Switch.CHILD_NONE);
    }
    if (getAnnotationsAttr().getValue()) {
      staticBackAnnotationSwitch.setWhichChild(Switch.CHILD_ALL);
      dynamicBackAnnotationSwitch.setWhichChild(Switch.CHILD_ALL);
      staticFrontAnnotationSwitch.setWhichChild(Switch.CHILD_ALL);
      dynamicFrontAnnotationSwitch.setWhichChild(Switch.CHILD_ALL);
    } else {
      staticBackAnnotationSwitch.setWhichChild(Switch.CHILD_NONE);
      dynamicBackAnnotationSwitch.setWhichChild(Switch.CHILD_NONE);
      staticFrontAnnotationSwitch.setWhichChild(Switch.CHILD_NONE);
      dynamicFrontAnnotationSwitch.setWhichChild(Switch.CHILD_NONE);
    }
    if (perspectiveAttr.getValue()) {
      view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
    } else {
      view.setProjectionPolicy(View.PARALLEL_PROJECTION);
    }
    if (renderer != renderers[rendererAttr.getValue()]) {
      // TODO: renderer.clear();
      // TODO: handle gui
      try {
        System.out.println("Clearing Attached : VolRend-doUpdate()");
        clearAttach();

      } catch (Exception e) {
        e.printStackTrace();
      }
      renderer = renderers[rendererAttr.getValue()];
      renderer.attach(dynamicAttachGroup, staticAttachGroup);
    }
    try {
      renderer.update();
      annotations.update();
    } catch (Exception e) {

      e.printStackTrace();
    } catch (OutOfMemoryError e) {
      JOptionPane.showMessageDialog(
          null, "Ran out of memory!", "Render Error", JOptionPane.ERROR_MESSAGE);
    }
    int newVolEditId;
    if ((newVolEditId = volume.update()) != volEditId) {
      updateCenter(volume.minCoord, volume.maxCoord);
      newVolEditId = volEditId;
    }
    eyePtChanged();
    canvas.startRenderer();
  }
Ejemplo n.º 2
0
  void setupScene() {

    // Setup the graphics
    // Create a simple scene and attach it to
    // the virtual universe
    BranchGroup scene = createSceneGraph();
    universe = new SimpleUniverse(canvas);

    // This will move the ViewPlatform back a
    // bit so the
    // objects in the scene can be viewed.
    universe.getViewingPlatform().setNominalViewingTransform();

    // get the primary view
    view = universe.getViewer().getView();

    // switch to a parallel projection, which
    // is faster for texture mapping
    view.setProjectionPolicy(View.PARALLEL_PROJECTION);
    view.setBackClipDistance(10000);

    universe.addBranchGraph(scene);

    canvas.setDoubleBufferEnable(true);

    // setup the renderers
    renderers = new Renderer[1];
    renderers[0] = new Axis2DRenderer(view, context, volume);
    // renderers[1] = new Axis3DRenderer(view,
    // context, volume);
    // renderers[2] = new
    // SlicePlane3DRenderer(view, context,
    // volume);
    // renderers[3] = new
    // SlicePlane2DRenderer(view, context,
    // volume);

    renderer = renderers[rendererAttr.getValue()];

    // Add the volume to the scene
    clearAttach();
    renderer.attach(dynamicAttachGroup, staticAttachGroup);

    // Set up the annotations
    annotations = new Annotations(view, context, volume);
    annotations.attach(dynamicFrontAnnotationSwitch, staticFrontAnnotationSwitch);
    annotations.attachBack(dynamicBackAnnotationSwitch, staticBackAnnotationSwitch);
  }