00001 #include "PixelProfile.h" 00002 00003 00004 PixelProfile::PixelProfile(int newx, int newy){ 00005 x = newx; 00006 y = newy; 00007 } 00008 00009 PixelProfile::~PixelProfile(){;} 00010 00011 void PixelProfile::add(int val){ 00012 values.push_back((double)val); 00013 } 00014 00015 void PixelProfile::add(double val){ 00016 values.push_back(val); 00017 } 00018 void PixelProfile::add(float val){ 00019 values.push_back((double)val); 00020 } 00021 void PixelProfile::add(char *val){ 00022 values.push_back(strtod(val, NULL)); 00023 } 00024 00025 int PixelProfile::getX(){ 00026 return x; 00027 } 00028 int PixelProfile::getY(){ 00029 return y; 00030 } 00031 00032 int PixelProfile::size(){ 00033 return values.size(); 00034 } 00035 00036 double PixelProfile::valueAt(int loc){ 00037 return values[loc]; 00038 } 00039 00040 std::string PixelProfile::getAsString(){ 00041 00042 std::string str = ""; 00043 00044 std::stringstream ss; 00045 00046 ss << "X:"<< x << " Y:" << y << "; "; 00047 for(unsigned int i=0; i<values.size(); i++){ 00048 ss << values[i] << "; "; 00049 } 00050 00051 str = ss.str(); 00052 00053 return str; 00054 00055 } 00056 00057 00058 std::string PixelProfile::getAsString(std::string delim){ 00059 00060 std::string str = ""; 00061 00062 std::stringstream ss; 00063 00064 ss << x << delim << " " << y << delim << " "; 00065 for(unsigned int i = 0 ; i < values.size() ; i++){ 00066 ss << values[i] << delim << " "; 00067 } 00068 00069 str = ss.str(); 00070 00071 return str; 00072 00073 } 00074 00075 std::string PixelProfile::runDriverTest(){ 00076 std::string str = "Created new PixelProfile\n"; 00077 00078 //add some values of different types 00079 this->add(3.0); 00080 this->add(4.555); 00081 this->add(-4.03); 00082 this->add(-9); 00083 this->add("40.9"); 00084 this->add("-40"); 00085 this->add(0.0000002); 00086 this->add(7.09808); 00087 str = str+"adds sucessfull\n"; 00088 00089 //get the getAsString() 00090 str.append(this->getAsString()); 00091 00092 str = str+"\n"; 00093 return str; 00094 } 00095
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |