Reference Guide > W Routines > WgSliceTool Procedure
  

WgSliceTool Procedure
Creates a window with a built-in set of controls; these controls allow you to easily select and view “slices” from a three-dimensional block of data.
Usage
WgSliceTool, block_data[, last_slice]
Input Parameters
block_data — A 3D variable containing volumetric data. The dimensions of  block_data define the size of the cube that you see when the SliceTool window is first opened.
Output Parameters
Last_slice — The two-dimensional set of values describing the most recent slice that was displayed. The data type of last_slice is the same as the data type for block_data.
Keywords
Cmap — The index of the color table to load when the widget is created; a positive integer in the range (0–18).
Cube_color — The color in which the rotatable cube is drawn; a positive integer in the range (0–255). The number that is provided for cube_color is used as an index into the current color table.
Parent — The widget or shell ID of the parent widget (long). If parent is not specified, WgSliceTool runs on its own (i.e., in its own event loop).
Position — A two-element vector specifying the x- and y-coordinates of the upper-left corner of the SliceTool window (long integer). The elements of the vector are [x, y], where x (horizontal) and y (vertical) are specified in pixels. These coordinates are measured from the upper-left corner of the screen.
Slice_color — The color in which the slice is drawn; a positive integer in the range (0–255). The number that is provided for slice_color is used as an index into the current color table.
Slice_rot — A three-element vector specifying the XYZ slicing plane rotation, in degrees. If not supplied, the initial rotation is [0, 0, 0] — in other words, no rotation.
Slice_trans — A three-element vector specifying the initial slicing plane translation, in degrees. If not supplied, the initial translation is [0, 0, 0] — in other words, no translation.
Shell — The ID of the newly created widget. If the procedure fails, zero (0) is returned.
Title — A string containing the title that appears in the header of the SliceTool window. Default value is “Slicer Tool”.
View_persp — The initial perspective distance. If View_persp is zero, then the initial setting on the Perspective Distance slider is 0.5, but the Perspective pushbutton is initially deselected. If View_persp is nonzero, then the initial setting on the Perspective Distance slider is the value specified by View_persp and the Perspective pushbutton is selected.
 
note
Using no perspective to draw the cube is equivalent to having the eyepoint an infinite distance away from the cube, and will produce a cube with sides that all appear to be parallel to one another.
View_rot — A three-element vector specifying the initial view rotation, in degrees. If not supplied, the initial rotation of the cube is [30, 30, 0] — in other words, 30 degrees rotation around the x-axis, 30 degrees rotation around the y-axis, and 0 degrees rotation around the z-axis.
View_zoom — The initial zoom factor. (Default: 0.5)
Color/Font Keywords
For additional information on the color and font keywords, see Setting Colors and Fonts in the PV‑WAVE Application Developer’s Guide.
Background — Specifies the background color name.
Basecolor — Specifies the base color.
Font — Specifies the name of the font used for text.
Foreground — Specifies the foreground color name.
Discussion
WgSliceTool, shown in WgSliceTool Window, is an interactive window that lets you use the mouse to view and modify the location of a slice that bisects a volume of data; you can position the slice anywhere within the three-dimensional input dataset, surface_data.
If the zoom factor is large, or the perspective parameter is small, then the cube display in the View orientation area may be erroneous. To cure the problem, reduce the zoom or increase the perspective (or disable the perspective entirely).
To select a slice, adjust the sliders that control perspective, zoom, and orientation of the slice in relationship to the cube. When you are satisfied with your selections, click the Apply button.
Slices of data are displayed “head-on”. In other words, the data slice is not projected into 3D space — the data displayed is the actual 2D slice that you selected.
Event Handling
You can use the SliceTool widget in one of the following two ways:
*From the WAVE> prompt — Enter the procedure name at the WAVE> prompt to display the SliceTool widget. The SliceTool widget handles its own event loop by calling WwLoop.
*Stand-alone widget in its own window created by another application — The SliceTool widget has its own Main window, but the application (not the SliceTool widget) handles the event loop by calling WwLoop.
The output parameter shell can be returned only if you also supply the input parameter parent.
 
Figure 19-8: WgSliceTool Window
SliceTool Display Area
The display area is towards the right of the window; it is divided into an upper and lower region:
*View orientation area — The cube establishes a frame of reference for positioning the slice of data.
*Data slice area — This region contains an image displaying the actual slice of data that you have selected for viewing.
The orientation of the cube provides a frame of reference for selecting and understanding the slice of data that you have chosen to view.
SliceTool Control Area
Use the following controls to operate the SliceTool window:
*X, Y, and Z Rotation — These controls allow you to rotate the cube (counter-clockwise around the desired axis) a specified number of degrees. The current rotation is shown in the text field to the right of the slider. To modify the rotation, either enter a new value in one of the text fields, or use the left mouse button to drag one of the sliders. If you enter a new value into a text field, press <Return> to apply the new value to the slider and the surface. If you use the sliders, the change is applied immediately as the slider moves.
*Perspective — If enabled, the cube is drawn with perspective; if disabled, the cube is drawn without perspective.
*Perspective Distance — Controls the amount of perspective used when drawing the cube; in other words, how close the eyepoint is to the cube. The closer the eyepoint gets to the cube, the greater the amount of perspective exaggeration that is used to draw the cube.
*Zoom Factor — Controls the amount of magnification used to draw the cube.
*Slice — Redraw the cube and the data slice with the specified viewing parameters.
*Reset — Return to the default viewing parameters and the initial orientation and positioning of the slice.
*Dismiss — Destroy the SliceTool window and erase it from the screen.
Example
Enter the commands shown below into a file, and compile the procedure with the .RUN command. If the variable parent is defined, WgSliceTool is created as a child of parent; otherwise, WgSliceTool runs on its own (i.e., in its own event loop).
When you are finished interacting with the WgSliceTool window, close it by clicking on the Dismiss button.
PRO Sample_wgslicetool, parent, tool_shell
   ; Define a variable to hold the data.
   head = BYTARR(115, 75, 105)
   OPENR, u, !Data_Dir+'man_head.dat', /Get_lun
   ; Read the man_head.dat file that contains three-dimensional 
   ; volumetric data.
   READU, u, head
   ; Close the file and free the LUN.
   CLOSE, u
   FREE_LUN, u
   IF N_ELEMENTS(parent) NE 0 THEN BEGIN
      ; Create WgSliceTool as a child of "parent". The window of
      ; newly created widget is returned via the optional output
      ; parameter "tool_shell".
      WgSliceTool, head, slice, Parent=parent, Shell=tool_shell
   ENDIF ELSE BEGIN
      ; Create WgSliceTool and display it as its own Main window.
      ; In other words, the WgSliceTool window runs on its own 
      ; (i.e., in its own event loop).
      WgSliceTool, head, slice
   ENDELSE
END
See Also
SLICE_VOL, VIEWER
For information about other approaches to slicing volumes, see Chapter 7, Advanced Rendering Techniques, in the PV‑WAVE User’s Guide.This chapter includes an example showing how to render selected slices from a large amount of volume data.
For more information about how to write an application program based on PV‑WAVE Widgets or Widget Toolbox, refer to the PV‑WAVE Application Developer’s Guide.

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.