EditColormap Widget Class


Overview

The EditColormap widget displays two panels that offer alternative methods for changing one or more colors in the application's colormap. The colors can be edited individually or in groups using an interpolation algorithm. An individual color is edited by using an EditColor widget instantiated by the EditColormap widget or by graphically defining a new value for the red, green and/or blue components of a color. In addition, provided functions can store a colormap file on disk, retrieve a colormap file from disk and generate a colormap to be used during editing.

Inherited Behavior and Resources

The EditColormap widget inherits behavior and resources from Core, Composite, Constraint, Manager, and BulletinBoard classes.
The following resources are defined by the EditColormap widget class:
NameTypeDefaultAccess
XmNannotationFontListXmFontList"fixed"CSG
XmNbiasint0CSG
XmNcancelCallbackXtCallbackListNULLC
XmNcolormapFilechar *NULLCSG
XmNcolorNumberFontListXmFontList"fixed"CSG
XmNcontrastint0CSG
XmNdoubleClickIntervalint250CSG
XmNhelpCallbackXtCallbackListNULLC
XmNnumberOfColorsint0CSG
XmNokCallbackXtCallbackListNULLC
XmNpixelArrayPixel *NULLC
XmNshowHelpButtonBooleanFalseCSG
XmNshowBiasScaleBooleanTrueCSG
XmNshowContrastScaleBooleanTrueCSG
XmNshowRotateScaleBooleanTrueCSG
XmNtitleFontListXmFontList"*helvetica-bold-r-*-180-*"CSG
XmNtitleStringXmStringNULLCSG


XmNannotationFontList

Specifies the font used for the scale annotation in the Color Diagram Panel.

XmNbias

Specifies the value for the bias. Valid values for the bias are between 1-ncolors and ncolors-1. where ncolors is the number of colors in the colormap.

XmNcancelCallback

Specifies the list of callback procedures called when the user clicks on the Cancel pushbutton on the EditColormap panels.

XmNcolormapFile

Specifies the name of the colormap file that will be provided as default to the user when the Save Colormap Panel appears. The user can edit this file specification as desired on the Save Colormap Panel.

XmNcolorNumberFontList

Specifies the font list that is used to display the color numbers inside the color squares on the Color Square Panel.

XmNcontrast

Specifies the value for the contrast. Valid values are between -ncolors/2 and ncolors/2, where ncolors is the number of colors in the colormap.

XmNdoubleClickInterval

Specifies the maximum time (in milliseconds) between the clicks that make up a double-click for selecting a color square to be edited.

XmNhelpCallback

Specifies the list of callback procedures called when the user clicks on the Help pushbutton on the Color Square Panel or Color Diagram Panel.

XmNnumberOfColors

In the case where a pixel array is passed to the EditColormap widget, this resource specifies the number of elements in the array of pixels passed to the EditColormap widget. If something other than a positive integer is specified, then an error message is generated and the widget will not be created.

When a colormap file is used by the EditColormap widget to generate the colors to be edited, this resource should not be specified by you because the widget will set it to the number of colors defined in the colormap file.


XmNokCallback

Specifies the list of callback procedures called when the user clicks on the OK pushbutton on the EditColormap panel.

XmNpixelArray

Specifies the array of pixels to be edited. This array must be at least as large as the value specified by the resource, XmNnumberOfColors.

XmNshowHelpButton

Specifies whether or not a Help pushbutton will appear on the Color Square Panel. The default is False, indicating that the Help pushbutton will not be visible.

XmNshowBiasScale

Specifies whether or not a bias scale will appear on the Color Square Panel. The default is True, indicating that the bias scale will be visible.

XmNshowContrastScale

Specifies whether or not a contrast scale will appear on the Color Square Panel. The default is True, indicating that the contrast scale will be visible.

XmNshowRotateScale

Specifies whether or not a colormap rotate scale will appear on the Color Square Panel. The default is True, indicating that the colormap rotate scale will be visible.

XmNtitleFontList

Specifies the font used for the title at the top of the Color Square Panel and Color Diagram Panel.

XmNtitleString

Specifies the compound string containing the title to be placed at the top of the Color Square Panel and Color Diagram Panel. If this resource value is NULL (the default), then no title will appear.

Internal Widgets

The following table lists the named widgets contained within an EditColormap widget that are accessible to the application programmer. The appearance of the internal widgets can be specified in a resource file using the listed widget names.

NameClassDescription
title_labelXmLabelGadgetContains the optional title.
frameXmFrameThe frame widget surrounding the colormap drawing area.
cmap_displayXmDrawingAreaDrawing area where the continuous spectrum of colors in the colormap is drawn.
cmap_squareXmDrawingAreaWhere the color squares in the colormap are drawn.
interpo_radio_boxXmRowColumnThe radio box containing the interpolation radio buttons.
linear_toggleXmToggleButtonGadgetThe linear interpolation radio button.
tanh_toggleXmToggleButtonGadgetThe tanh interpolation radio button.
spline_toggleXmToggleButtonGadgetThe spline interpolation radio button.
rotate_scaleXmScaleThe scale for rotating the colormap.
bias_scaleXmScaleThe scale for the bias.
contrast_scaleXmScaleThe scale for the contrast.
color_number_toggleXmToggleButtonGadgetThe check box controlling the display of the color numbers.
diagramXmDrawingAreaDrawing area where the color intensity diagram is drawn.
toggle_boxXmRowColumnThe box containing the color component check boxes on the Color Diagram Panel.
redXmToggleButtonGadgetThe red component check box.
greenXmToggleButtonGadgetThe green component check box.
blueXmToggleButtonGadgetThe blue component check box.


Defined Callbacks

The following callbacks are defined by an EditColormap widget.

NameStructureReason
XmNcancelCallbackXmAnyCallbackStructXmCR_CANCEL
XmNhelpCallbackXmAnyCallbackStructXmCR_HELP
XmNokCallbackXmAnyCallbackStructXmCR_OK

The following ordered table lists the members of the callback structure, XmAnyCallbackStruct, used by the EditColormap widget for all of its callbacks.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent*eventPoints to the XEvent that triggered the callback.


Defined Functions

The following functions are defined for creating and using an EditColormap widget.

Function NameDescription
XintCreateEditColormapCreates an unmanaged EditColormap widget.
XintCreateEditColormapDialogCreates a dialog shell containing an unmanaged EditColormap widget.
XintGenerateColormapGenerates a colormap containing gray scale colors.
XintGetColormapBiasContrastReturns the bias and contrast values from a colormap file.
XintIsColormapFileDetermines whether a specified file is a colormap file.
XintReadColormapGenerates a colormap containing the colors defined in a colormap file.
XintParseColormapFileCreates an array of XColor structures based upon the colors defined in a colormap file.
XintEditColormapFreeColorsFrees the pixels in the pixel array allocated by the XintReadColormap and XintGenerateColormap functions.
XintEditColormapUpdateTo update the colormap display if the user has changed the mapping of the pixel values to RGB externally.


XintCreateEditColormap

XintCreateEditColormap creates an unmanaged EditColormap widget.

     Widget XintCreateEditColormap (...)

WidgetparentParent of new EditColormap widget.
char *nameName of new EditColormap widget.
ArgListarglistList of resource/value items.
CardinalargcountNumber of items in arglist.


XintCreateEditColormapDialog

XintCreateEditColormapDialog creates an unmanaged dialog shell containing an EditColormap widget.

     Widget XintCreateEditColormapDialog (...)

WidgetparentParent of new dialog shell.
char *nameName of new dialog shell.
ArgListarglistList of resource/value items.
CardinalargcountNumber of items in arglist.


XintGenerateColormap

This function allocates a gray scale colormap for use with a specified EditColormap widget.

     Pixel *XintGenerateColormap(...)

Widgetwidget A widget ID (It does not need to be and EditColormap Widget).
intnum_colorsSpecifies the number of colors to allocate in the new colormap.
int *err_codeError code returned in case of error.

In case of error, the function returns NULL and the argument err_code contains a pointer to an error code. Possible error codes include

Error CodeDescription
XintBAD_ALLOC_COLORIndicates that the colormap could not be generated.


XintGetColormapBiasContrast

This function returns the bias and contrast values saved into a colormap file. If the bias or contrast values are not specified in the colormap file, they are set to 0.

     void XintGetColormapBiasContrast (...)

Widgetwidget A widget ID (It does not need to be and EditColormap Widget).
char *filenameSpecifies the colormap file to be read.
int *biasReturns the bias value.
int *contrastReturns the contrast value.
int *err_codeReturns an error code in case of error.

If the specified filename cannot be open, err_code is set to XintOPEN_ERROR, otherwise it is set to 0.


XintIsColormapFile

This function returns True if a specified file contains an EditColormap colormap definition; otherwise, it returns False.

     Boolean XintIsColormapFile (char *filename)

where filename is the name of the file to be checked.


XintReadColormap

This function reads a specified colormap file and allocates read-write color cells based upon the colormap file. A pointer to the array of Pixels in the colormap is returned if the file was read successfully and if the colormap was allocated successfully.

     Pixel *XintReadColormap (...)

Widgetwidget A widget ID (It does not need to be and EditColormap Widget).
char *filenameSpecifies the colormap file to be read.
int *num_colorsReturns the number of colors in colormap.
int *err_codeReturns an error code in case of error.

In case of error, the function returns NULL and the argument err_code contains a pointer to an error code. Possible error codes include:

Error CodeDescription
XintBAD_ALLOC_COLORIndicates that the colormap could not be generated.
XintBAD_COLORMAPIndicates that an error occurred while reading the colormap file.
XintOPEN_ERRORIndicates that an error occurred while opening the colormap file.


XintParseColormapFile

This function reads a specified colormap file and allocates an array of XColor structures based upon the colormap file. A pointer to the XColor structures is returned, if the colormap file was read successfully. No color cells are allocated by this function.

     XColor *XintParseColormapFile (...)

char *filenameSpecifies the colormap file to be read.
int *num_colorsReturns the number of colors in the colormap.
int *err_codeReturns an error code in case of error.

In case of error, the function returns NULL and the argument err_code contains a pointer to an error code. Possible error codes include:

Error CodeDescription
XintBAD_COLORMAPIndicates that an error occurred while reading the colormap file.
XintOPEN_ERRORIndicates that an error occurred while opening the colormap file.


XintEditColormapFreeColors

This function frees the colormap allocated by the functions XintReadColormap or XintGenerateColormap. Call this function after the application has finished with the colormap generated by XintReadColormap or XintGenerateColormap to free the colormap cells allocated by those functions.

     void XintEditColormapFreeColors (...)

WidgetwidgetSpecifies a widget ID that is using the same colormap as the one that was used when allocating the pixels to be freed.
Pixel *pixelsSpecifies the colormap used by the EditColormap widget.
intnum_colorsSpecifies number of pixels in the pixels array to be freed.


XintEditColormapUpdate

This function is used to update the display of the EditColormap when the application has changed the mapping of the pixels to RGB externally.

     void XintEditColormapUpdate (Widget widget)

where widget specifies the ID of the EditColormap widget.