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

CmdColor.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 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.48 $      $Date: 2020/12/24 04:21:51 $
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, int newrev,
00094                                              int newposterize)
00095 : Command(Command::COLOR_SCALE_SETTINGS), mid(newmid), min(newmin), max(newmax), rev(newrev), posterize(newposterize)
00096 {}
00097 
00098 
00099 CmdColorItem::CmdColorItem(const char *cat, const char *nm, const char *def)
00100 : Command(Command::COLOR_ADD_ITEM) {
00101   category = stringdup(cat);
00102   name     = stringdup(nm);
00103   defcolor = stringdup(def);
00104 }
00105 CmdColorItem::~CmdColorItem() {
00106   delete [] category;
00107   delete [] name;
00108   delete [] defcolor;
00109 }
00110 void CmdColorItem::create_text() {
00111   *cmdText << "color add item {" << category << "} {" << name << "} {"
00112     << defcolor << "}" << ends;
00113 }
00114 
00115 CmdColorScaleColors::CmdColorScaleColors(const char *nm, 
00116     const float themin[3], const float themid[3], const float themax[3])
00117 : Command(COLOR_SCALE_COLORS) {
00118   method = nm;
00119   memcpy(colors[0], themin, 3*sizeof(float));
00120   memcpy(colors[1], themid, 3*sizeof(float));
00121   memcpy(colors[2], themax, 3*sizeof(float));
00122 }
00123 
00124 void CmdColorScaleColors::create_text() {
00125   *cmdText << "color scale colors " << method;
00126   for (int i=0; i<3; i++)
00127     *cmdText << "{" << colors[i][0] << " " << colors[i][1] << " " 
00128       << colors[i][2] << "}" << " ";
00129   *cmdText << ends;
00130 }
00131 

Generated on Fri Mar 29 02:44:39 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002