next up previous contents
Next: ColorUser Up: Display objects Previous: Display objects   Contents



Files: ColorList.h, ColorList.C
Derived from: \bf Displayable3D
Global instance (if any): colors
Used in optional component: Part of main VMD code


Contains a list of all the items which have an assigned color, and the list of all the different color categories which exist. VMD uses a colormap made of 16 base colors (plus black), and a colorscale made of 1024 colors in user-definable gradient (e.g., red-green-blue, or red-white-blue). Color categories are used to contain the names of items which are related and which may have their colors changed; an example of a color category is `Axes', which contains the colors for the `X', `Y', and `Z' axes. The categories contain just a list of names and the associated colors assigned to these names (an integer, from 0 ... 16). Other objects in VMD which are derived from ColorUser can add new color categories (or can query if one of a specific name already exists), and can add new names to an existing color category. The colors assigned to the named items in each category can be changed via the Color menu, or through the color text command. Once a category is created by some ColorUser object (or, if it already exists, has been obtained by the object from ColorList), the ColorUser can use the category to retrieve the proper color to use for whatever purpose it needs it (i.e., creating the object's display list if it is a Displayable).


Enumerations, lists or character name arrays

There are three different ways to set the colorscale: There are sixteen colors in the colormap, along with black, for seventeen total colors. They are: blue, red, grey, orange, yellow, tan, silver, green, white pink, cyan, purple, lime, mauve, ochre, iceblue, and black.

Internal data structures

Method of use

VMD contains one global instance of this class, colors. It is used by all objects derived from ColorUser, which includes all Displayable objects as well as DisplayDevice. An object which wishes to allow the user to be able to change its colors goes through these steps:
  1. call int ColorList::add_color_category(char *) ; this adds a new category with the given name and returns a unique index for that category, or else returns the index of the category if it already exists. This index should be saved for later use.
  2. once a category exists, names should be added to the category that correspond to all the components that can be configured, with default colors. This is done by doing the following:
    (colors->color_category(catIndex))->add_name("item name", defaultColor)
  3. When the colors have been added, they may be retrieved later when creating a display list by doing the following:
    (colors->color_category(catIndex))->data("item name")
    This will return the index of the color assigned to the given item name.

next up previous contents
Next: ColorUser Up: Display objects Previous: Display objects   Contents