00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00030
00031
00032
00033 void CmdColorName::create_text(void) {
00034 *cmdText << "color " << cCatStr << " " << cNameStr;
00035 *cmdText << " " << cColStr;
00036 *cmdText << ends;
00037 }
00038
00039
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
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