![]() |
TerraLib 4.1
|
00001 /************************************************************************************ 00002 TerraLib - a library for developing GIS applications. 00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio. 00004 00005 This code is part of the TerraLib library. 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 You should have received a copy of the GNU Lesser General Public 00012 License along with this library. 00013 00014 The authors reassure the license terms regarding the warranties. 00015 They specifically disclaim any warranties, including, but not limited to, 00016 the implied warranties of merchantability and fitness for a particular purpose. 00017 The library provided hereunder is on an "as is" basis, and the authors have no 00018 obligation to provide maintenance, support, updates, enhancements, or modifications. 00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct, 00020 indirect, special, incidental, or consequential damages arising out of the use 00021 of this library and its documentation. 00022 *************************************************************************************/ 00026 #ifndef __TERRALIB_INTERNAL_COLORUTILS_H 00027 #define __TERRALIB_INTERNAL_COLORUTILS_H 00028 00029 00030 #include "../kernel/TeVisual.h" 00031 #include "../kernel/TeUtils.h" 00032 00033 #include "TeUtilsDefines.h" 00034 00035 TLUTILS_DLL void rgb2Hsv(const TeColor& c, int& h, int& s, int& v); 00036 TLUTILS_DLL void RGBtoHSV(const double& r, const double& g, const double& b, double& h, double& s, double& v ); 00037 TLUTILS_DLL void hsv2Rgb(TeColor& c, const int& h, const int& s, const int& v); 00038 TLUTILS_DLL void HSVtoRGB( double& r, double& g, double& b, const double& h, const double& s, const double& v ); 00039 00040 struct TLUTILS_DLL ColorBar { 00041 TeColor cor_; 00042 int h_; 00043 int s_; 00044 int v_; 00045 double distance_; 00046 00047 void color(const TeColor& c){cor_ = c; rgb2Hsv(cor_, h_, s_, v_);} 00048 00049 ColorBar& operator= (const ColorBar& cb) 00050 { 00051 cor_ = cb.cor_; 00052 h_ = cb.h_; 00053 s_ = cb.s_; 00054 v_ = cb.v_; 00055 distance_ = cb.distance_; 00056 00057 return *this; 00058 } 00059 00060 bool operator<= (const ColorBar& cb) const 00061 { 00062 return (distance_ <= cb.distance_); 00063 } 00064 00065 bool operator< (const ColorBar& cb) const 00066 { 00067 return (distance_ < cb.distance_); 00068 } 00069 }; 00070 00071 #include <vector> 00072 #include <string> 00073 #include <map> 00074 00076 00083 TLUTILS_DLL bool getColors(std::vector<std::string>& ramps, int nc, std::vector<TeColor>& colors); 00084 TLUTILS_DLL vector<TeColor> getColors(TeColor cfrom, TeColor cto, int nc); 00085 TLUTILS_DLL vector<TeColor> getColors(vector<ColorBar>& iVec, int ncores); 00086 TLUTILS_DLL string getColors(vector<ColorBar>& aVec, vector<ColorBar>& bVec, int groupingMode); 00087 TLUTILS_DLL void generateColorBarMap(vector<ColorBar>& inputColorVec, int ncores, map<int, vector<TeColor> >& colorMap); 00088 TLUTILS_DLL vector<ColorBar> getColorBarVector(string& scores, const bool& first); 00089 TLUTILS_DLL unsigned int TeReadColorRampTextFile(const string& fileName, map<string,string>& colorRamps); 00090 00091 #endif 00092 00093 00094