NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

20001113: 3D ProjectionControl matrix & point of view

Just wanted to follow up on Stu Wier's question about setting the
projection "view".

visad.ProjectionControl as been modified with the following
methods added:

public void saveProjection()  - Saves the current display projection matrix.

public void resetProjection() - Restores to projection matrix at time of last 
                                saveProjection() call -- if one was made -- 
                                or to initial projection otherwise.

public double getSavedProjectionMatrix() - Get the matrix that defines 
                                           the saved graphics projection

saveProjection is called upon initialization and when setAspect() is
called.  This means that if you want to implement a Reset button
on your UI to reset the display to the original view, you could
do something like:

    DisplayImpl display = new DisplayImplJ3D("display");
    ProjectionControl projControl = display.getProjectionControl();
    JButton reset = new JButton("Reset");
    reset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e)
        {
            projControl.resetProjection();
        }
    });

Instead of having to keep track of the projection matrix and
setting it manually.  This has been implemented in both ProjectionControlJ2D
and ProjectionControlJ3D.

Additionally, a setOrthoView method has been added to ProjectionControlJ3D
to allow one to easily switch the projection to one of the 6 sides of
the 3D cube.  The signature is:

/**
   * Set the projection so the requested view is displayed.
   * @param  view  one of the static view fields (X_PLUS, X_MINUS, etc).  This
   *               will set the view so the selected face is orthogonal to
   *               the display.
   * @throws VisADException   VisAD failure.
   * @throws RemoteException  Java RMI failure.
   */
  public void setOrthoView(int view)
    throws VisADException, RemoteException

with valid views being:

  /** View of the postive X face of the display cube */
  public static final int X_PLUS = 0;
  /** View of the negative X face of the display cube */
  public static final int X_MINUS = 1;
  /** View of the postive Y face of the display cube */
  public static final int Y_PLUS = 2;
  /** View of the negative Y face of the display cube */
  public static final int Y_MINUS = 3;
  /** View of the postive Z face of the display cube */
  public static final int Z_PLUS = 4;
  /** View of the negative Z face of the display cube */
  public static final int Z_MINUS = 5;


So to set the view so the cube face on the positive X side is orthogonal
to your view, you could call:

    projControl.setOrthoView(ProjectionControlJ3D.X_PLUS);

If you have any questions or find any bugs, let me know.

Don 
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
*************************************************************
Unidata WWW Server               http://www.unidata.ucar.edu/
McIDAS Demonstration Machine  http://mcdemo.unidata.ucar.edu/
*************************************************************


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