Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

CmdColor.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2008 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: CmdColor.C,v $
00013  *      $Author: johns $        $Locker:  $                $State: Exp $
00014  *      $Revision: 1.42 $      $Date: 2008/03/27 19:36:36 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * 
00019  * Command objects for affecting molecules.
00020  *
00021  ***************************************************************************/
00022 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 #include <ctype.h>
00026 #include "CmdColor.h"
00027 #include "utilities.h"
00028 
00029 // the following defines commands for the Cmdtypes:
00030 // COLOR_NAME, COLOR_CHANGE, COLOR_SCALE_METHOD, COLOR_SCALE_MIDPOINT,
00031 // COLOR_SCALE_MIN, COLOR_SCALE_MAX
00032 
00033 void CmdColorName::create_text(void) { 
00034   *cmdText << "color " << cCatStr << " " << cNameStr;
00035   *cmdText << " " << cColStr;
00036   *cmdText << ends;
00037 }
00038 
00039 // constructor: category name, item name, new color
00040 CmdColorName::CmdColorName(const char *cCat, const char *cName, const char *cCol)
00041 : Command(Command::COLOR_NAME) {
00042   cCatStr = stringdup(cCat);
00043   cNameStr = stringdup(cName);
00044   cColStr = stringdup(cCol);
00045 }
00046 CmdColorName::~CmdColorName() {
00047   delete [] cCatStr;  
00048   delete [] cNameStr;  
00049   delete [] cColStr;  
00050 }
00051 
00053 
00054 void CmdColorChange::create_text() { 
00055   *cmdText << "color change rgb " << color << " ";
00056   *cmdText << newR << " " << newG << " " << newB;
00057   *cmdText << ends;
00058 }
00059 
00060 CmdColorChange::CmdColorChange(const char *cCol, float r, float g, float b) 
00061 : Command(Command::COLOR_CHANGE) {
00062   
00063   newR = r;
00064   newG = g;
00065   newB = b;
00066   color = stringdup(cCol);
00067 }
00068 CmdColorChange::~CmdColorChange() {
00069   delete [] color;
00070 }
00071 
00072 void CmdColorScaleMethod::create_text() {
00073   *cmdText << "color scale method " << method << ends;
00074 }
00075 
00076 // constructor: new method
00077 CmdColorScaleMethod::CmdColorScaleMethod(const char *nm)
00078         : Command(Command::COLOR_SCALE_METHOD) {
00079   method = stringdup(nm);
00080 }
00081 CmdColorScaleMethod::~CmdColorScaleMethod() {
00082   delete [] method;
00083 }
00084 
00085 void CmdColorScaleSettings::create_text() {
00086   *cmdText << "color scale midpoint " << mid << "\n";
00087   *cmdText << "color scale min " << min << "\n";
00088   *cmdText << "color scale max " << max << "\n";
00089   *cmdText << ends;
00090 }
00091 
00092 CmdColorScaleSettings::CmdColorScaleSettings(float newmid, float newmin, 
00093                                              float newmax)
00094 : Command(Command::COLOR_SCALE_SETTINGS), mid(newmid), min(newmin), max(newmax)
00095 {}
00096 
00097 
00098 CmdColorItem::CmdColorItem(const char *cat, const char *nm, const char *def)
00099 : Command(Command::COLOR_ADD_ITEM) {
00100   category = stringdup(cat);
00101   name     = stringdup(nm);
00102   defcolor = stringdup(def);
00103 }
00104 CmdColorItem::~CmdColorItem() {
00105   delete [] category;
00106   delete [] name;
00107   delete [] defcolor;
00108 }
00109 void CmdColorItem::create_text() {
00110   *cmdText << "color add item {" << category << "} {" << name << "} {"
00111     << defcolor << "}" << ends;
00112 }
00113 
00114 CmdColorScaleColors::CmdColorScaleColors(const char *nm, 
00115     const float themin[3], const float themid[3], const float themax[3])
00116 : Command(COLOR_SCALE_COLORS) {
00117   method = nm;
00118   memcpy(colors[0], themin, 3*sizeof(float));
00119   memcpy(colors[1], themid, 3*sizeof(float));
00120   memcpy(colors[2], themax, 3*sizeof(float));
00121 }
00122 
00123 void CmdColorScaleColors::create_text() {
00124   *cmdText << "color scale colors " << method;
00125   for (int i=0; i<3; i++)
00126     *cmdText << "{" << colors[i][0] << " " << colors[i][1] << " " 
00127       << colors[i][2] << "}" << " ";
00128   *cmdText << ends;
00129 }
00130 

Generated on Fri Aug 29 01:26:49 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002