WgCbarTool Procedure
Creates a simple color bar that can be used to view and interactively shift a color table.
Usage
WgCbarTool
Keywords
Cmap — The index of the color table to load when the widget is created; a positive integer in the range (0–18).
Horizontal — If present and nonzero, the color bar is oriented horizontally (see WgCbarTool Window). (Default: vertical orientation).
MovedCB — A string containing the name of the callback routine that is executed when the color bar is shifted to the left or right.
Parent — The widget or shell ID of the parent widget (long). If parent is not specified, WgCbarTool runs on its own (i.e., in its own event loop).
Popup — If present and nonzero, the color bar widget is displayed in its own Main window.
Position — A two-element vector specifying the x- and y-coordinates of the upper-left corner of the CbarTool window (long integer). The elements of the vector are [x, y], where x (horizontal) and y (vertical) are specified in pixels. These coordinates are either: 1) if parent is present and the Popup keyword is not specified or has a value of zero, measured from the upper-left corner of a layout (container) widget or 2) if the Popup keyword is present and nonzero (regardless of whether parent is present and/or nonzero), measured from the upper-left corner of the screen.
Range — (optional) The range of colors to be displayed in the color bar. The default is to display the entire range of colors, as defined in the system variable !D.Table_Size.
Size — A two-element vector specifying the width and height of the color bar (long integer). If not specified, the default size of the color bar is 30-by-256 pixels.
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 CbarTool window. Default value is “Color Bar”.
Tool_number — (Output) The instance of the WgCbarTool. Up to 10 tools can be displayed at any one time.
Vertical — If present and nonzero, the color bar is oriented vertically. This is the default orientation.
Win — The window ID of the graphics window. (For information on window IDs, see the description for the Window Procedure.)
Color/Font Keywords
For additional information on the color and font keywords, see Chapter 5, 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.
Attachment Keywords
For additional information on attachment keywords, see Form Layout: Attachments in the PV‑WAVE Application Developer’s Guide.
Bottom — If a widget ID is specified (for example, Bottom=wid), then the bottom of the color bar widget is attached to the top of the specified widget. If no widget ID is specified (for example, /Bottom), then the bottom of the color bar widget is attached to the bottom of the parent widget.
Left — If a widget ID is specified (for example, Left=wid), then the left side of the color bar widget is attached to the right side of the specified widget. If no widget ID is specified (for example, /Left), then the left side of the color bar widget is attached to the left side of the parent widget.
Right — If a widget ID is specified (for example, Right=wid), then the right side of the color bar widget is attached to the left side of the specified widget. If no widget ID is specified (for example, /Right), then the right side of the color bar widget is attached to the right side of the parent widget.
Top — If a widget ID is specified (for example, Top=wid), then the top of the color bar widget is attached to the bottom of the specified widget. If no widget ID is specified (for example, /Top), then the top of the color bar widget is attached to the top of the parent widget.
Discussion
The color bar displays the colors of the current color table and “rotates” them.
To rotate the color table using the color bar, press and drag the left mouse button inside the color bar. As you “slide” colors into different color table indices, the colors that “scroll off” the end of the color table are added to the opposite end.
Note: |
Use the window manager menu of the window frame to dismiss the CbarTool window from the screen. |
|
Event Handling
You can use the color bar widget in one of the following three ways:
From the WAVE> prompt — Enter the procedure name at the WAVE> prompt to display the color bar widget. The color bar widget handles its own event loop by calling WwLoop.
Stand-alone widget in its own window created by another application — If the Popup keyword is present and nonzero, the color bar widget has its own Main window. The application (not the color bar widget) handles the event loop by calling WwLoop.
Combined with other widgets in a layout widget — Another application combines the color bar widget with other widgets inside a layout widget. The application (not the color bar widget) handles the event loop by calling WwLoop.
When the input parameter parent is present and nonzero, the widget operates in either the second or third mode listed, depending on the value of the Popup keyword. The output parameter shell can be returned only if you also supply the input parameter parent.
You can use the output parameter windowid to keep track of the PV‑WAVE window ID that is assigned to the color bar. You can create multiple instances of the color bar; each one will be assigned a different PV‑WAVE window ID.
The Colors Common Block
This procedure modifies the PV‑WAVE internal color table, as well as the color table variables in the Colors common block.
Most color table procedures maintain the current color table in a common block called Colors, defined as follows:
COMMON Colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
The variables are integer vectors of length equal to the number of color indices. Your program can access these variables by declaring the common block. The modifications you make to the color table by interacting with the CbarTool widget are stored in r_curr, g_curr, and b_curr.
Example
Enter the commands shown below into a file, and compile the procedure with the .RUN command. If the variable parent is defined, WgCbarTool is created as a child of parent; otherwise, WgCbarTool runs on its own (i.e., in its own event loop). The window is shown in WgCbarTool Window.
When you are finished interacting with the WgCbarTool window, close it using the window manager menu.
PRO Sample_wgcbartool, parent, tool_shell
; Create WgCbarTool as a child of "parent". The window of the
; newly created widget is returned via the optional output
; parameter "tool_shell".
IF N_ELEMENTS(parent) NE 0 THEN BEGIN
WgCbarTool, Parent=parent, Shell=tool_shell, $
/Horizontal, /Popup
ENDIF ELSE BEGIN
; Create a horizontally oriented WgCbarTool and display it
; as its own Main window. In other words, the WgCbarTool
; window runs on its own (i.e., in its own event loop).
WgCbarTool, /Horizontal
ENDELSE
END
See Also
For more information about color table indices, refer to the PV‑WAVE User Guide.
For more information about how to write an application program based on PV‑WAVE Widgets, refer to the PV‑WAVE Application Developer’s Guide. For more information about how to write an application program based on the PV‑WAVE Widget Toolbox, refer to the PV‑WAVE Application Developer’s Guide.