Zooming (Rescaling the Image)

The zoom functionality is implemented almost entirely in TCL. Functions are found in the file mouse.tcl It consists of the following functions which are bound to the mouse events their names imply.

Ipl_Button1Down

This function simply records the coordinates of the mouse in the global variables ipl_ZP1x and ipl_ZP1y (Zoom Point 1 x,y). It checks to see if the user has requested to Create a 1D Cross Section and if not, sets the global flag ipl_buttonhold to true, indicating that the first mouse button is being held down. Finally it begins to draw a rectangle to indicate the zoom area.

Ipl_Button1Drag

First this function checks to see if the user is actually defining a cross section in which case the function simply returns. Otherwise it sets the global variables ipl_ZP2x and ipl_ZP2y (Zoom Point 2 x,y) to the coordinates of the mouse and it redraws the rectangle in the plot window to indicate the zoom area.

Ipl_Button1Up

Again, we first check to see if the user is actually defining a cross section in which case the function simply returns. Otherwise the entry is accepted as a zoom. The global variables ipl_ZP2x and ipl_ZP2y (Zoom Point 2 x,y) are updated a final time to hold the mouse coordinates but this time the y coordinates are flipped so that the box is not defined upside down in terms of the data coordinates.

Next the minimum and maximum coordinates of the rectangle are found and are used for all future calculations. This ensures that the user can sweepsweep out the zoom area in any manner he chooses - ie. Left to right, top to bottom, and any combination thereof.

If the zoom area is found to be too small, nothing is done. This removes the problem of the user just tapping the left mouse button and being zoomed in when he probably didn't want to be.

Finally the global variables minimum and maximum variables are set and the new maximum and minimum values of what appears in the screen are translated into the coordinates of the data system. Then the screen is erased and the new plot is presented.

Keep in mind that each data set has its own maximum and minimum values which represent the extent of the data in 2D space. These values are unaffected by this process. It is only the global variables which hold the values of the current maximum and minimum extent of screen plotting which are affected.

Ipl_Button2Down

This function sets the global variable ipl_fullzoomout to true and then erases and replots the screen. When the plot function is called it calls PlotSetUp which recognizes the fullzoomout flag and resets the maximum and minimum values to those stored for the data set.

Keep in mind that each data set has its own maximum and minimum values which represent the extent of the data in 2D space. These values are unaffected by the process of zooming in and out. It is only the global variables which hold the values of the current maximum and minimum extent of screen plotting which are affected by zooming. Therefore returning to the values held for each data set is relatively easy.


IPlot Home Page Technical Doc's User's Guide
IPlot and its accompanying WWW pages were written by Gene McKenna
a member of Stanford University's famous TCAD Group