Next: DispCmd
Up: Display objects
Previous: ColorList
  Contents
Subsections
ColorUser
Files: |
ColorUser.h,
ColorUser.C |
Derived from: |
none |
Global instance (if any): |
none |
Used in optional component: |
Part of main VMD code |
Simple base class for objects which will be needing to use a ColorList
for colors. This class provides routines for being given a ColorList
object, and for being informed of when colors are changed. The user
can create new categories of colors in the ColorList, and add specific
color objects to the category with an identifying name. The user can
edit these colors via commands.
- ColorList *colorList - a pointer to a ColorList object for this object to use. The ColorList is the object which keeps the global lists of color categories.
- virtual void use_colors(ColorList *) - this function is used to set up this object to use the specified ColorList to store and retrieve data. By default, it will save the pointer and then call do_use_colors.
- virtual void color_changed(ColorList *collist, int c) - after a color has been changed via the GUI or a text command, the ColorUser must be notified of the change so that it can update any internal state. This routine is called when color c in the specified ColorList is changed. By default, this just calls the virtual function do_color_changed.
- virtual void do_use_colors(void) - this is called after a new ColorList object is provided. It is a protected function, and by default does nothing. It should only be defined if the derived class needs to do something special when a new ColorList is given, such as create a new color category.
- virtual void do_color_changed(ColorList *collist, int c) - this is called after a color in the given category is changed. It is a protected function, and by default does nothing. It should only be defined if the derived class needs to do something special when a color is changed, such as rebuild a display list or recalculate some data.
ColorUser is a base class designed to be specified as a parent for some class which desires to use a ColorList to maintain categories of colors associated with names, and to make these names be customizeable to the user via the VMD user interfaces. All Displayable objects are derived from ColorUser, as are all DisplayDevice objects.
ColorList describes how to create new categories and how to access them. If a new class wishes to use these features, it should derive from ColorUser, and define versions of the protected virtual functions do_use_colors and do_color_changed. This first is designed to be only called once, right after the object is created - it should create new categories, and add the necessary names to these categories. The second is designed to be called every time a particular color changes. The do_color_changed should check to see which color was modified, and then update itself if necessary.
Next: DispCmd
Up: Display objects
Previous: ColorList
  Contents
vmd@ks.uiuc.edu