![]() |
MechSys
1.0
Computing library for simulations in continuum and discrete mechanics
|
00001 /************************************************************************ 00002 * MechSys - Open Library for Mechanical Systems * 00003 * Copyright (C) 2005 Dorival M. Pedroso, Raúl D. D. Farfan * 00004 * * 00005 * This program is free software: you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation, either version 3 of the License, or * 00008 * any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00017 ************************************************************************/ 00018 00019 #ifndef MECHSYS_COLORS_H 00020 #define MECHSYS_COLORS_H 00021 00022 // Std Lib 00023 #include <map> 00024 #include <cstdlib> // for rand 00025 00026 // MechSys 00027 #include <mechsys/util/string.h> 00028 #include <mechsys/linalg/matvec.h> 00029 00030 namespace Colors 00031 { 00032 00033 typedef std::map<String, Vec3_t> CLR_t; 00034 00035 CLR_t CLR; 00036 00037 Vec3_t const & Get (String const & Name) 00038 { 00039 Colors::CLR_t::const_iterator p = Colors::CLR.find(Name); 00040 if (p==Colors::CLR.end()) throw new Fatal("Colors::Get: Could not find color named %s in Colors::CLR map",Name.CStr()); 00041 return p->second; 00042 } 00043 00044 Vec3_t const & Get (char const * Name) 00045 { 00046 Colors::CLR_t::const_iterator p = Colors::CLR.find(Name); 00047 if (p==Colors::CLR.end()) throw new Fatal("Colors::Get: Could not find color named %s in Colors::CLR map",Name); 00048 return p->second; 00049 } 00050 00051 void GetRandom (size_t Num, Array<String> & Clrs) 00052 { 00053 size_t num = (Num<CLR.size() ? Num : CLR.size()); 00054 size_t maxit = 10*CLR.size(); 00055 size_t iter = 0; 00056 while (iter<maxit) 00057 { 00058 int count = 0; 00059 int score = (rand()%(int)CLR.size()); 00060 for (CLR_t::const_iterator it=CLR.begin(); it!=CLR.end(); ++it) 00061 { 00062 if (count>=score) 00063 { 00064 Clrs.XPush (it->first); 00065 break; 00066 } 00067 count++; 00068 } 00069 if (Clrs.Size()==num) break; 00070 iter++; 00071 } 00072 if (Clrs.Size()!=num) throw new Fatal("Colors::GetRandom: failed with %d iterations",iter); 00073 size_t j = 0; 00074 for (size_t i=0; i<Num-num; ++i) 00075 { 00076 Clrs.Push (Clrs[j]); 00077 j++; 00078 } 00079 } 00080 00081 char const * GetNext (size_t Idx) 00082 { 00083 CLR_t::const_iterator p = CLR.begin(); 00084 size_t k = Idx % CLR.size(); 00085 for (size_t i=0; i<k; ++i) p++; 00086 return p->first.CStr(); 00087 } 00088 00089 char const * GetRandom () 00090 { 00091 size_t k = (rand()%(size_t)CLR.size()); 00092 return GetNext (k); 00093 } 00094 00095 int __init_colors__() 00096 { 00097 // 191 colors 00098 Vec3_t c; 00099 c = 0.0, 0.0, 0.0; 00100 00101 // Whites 00102 c = 0.9804, 0.9216, 0.8431; CLR["antique_white"] = c; 00103 c = 0.9412, 1.0000, 1.0000; CLR["azure"] = c; 00104 c = 1.0000, 0.8941, 0.7686; CLR["bisque"] = c; 00105 c = 1.0000, 0.9216, 0.8039; CLR["blanched_almond"] = c; 00106 c = 1.0000, 0.9725, 0.8627; CLR["cornsilk"] = c; 00107 c = 0.9900, 0.9000, 0.7900; CLR["eggshell"] = c; 00108 c = 1.0000, 0.9804, 0.9412; CLR["floral_white"] = c; 00109 c = 0.8627, 0.8627, 0.8627; CLR["gainsboro"] = c; 00110 c = 0.9725, 0.9725, 1.0000; CLR["ghost_white"] = c; 00111 c = 0.9412, 1.0000, 0.9412; CLR["honeydew"] = c; 00112 c = 1.0000, 1.0000, 0.9412; CLR["ivory"] = c; 00113 c = 0.9020, 0.9020, 0.9804; CLR["lavender"] = c; 00114 c = 1.0000, 0.9412, 0.9608; CLR["lavender_blush"] = c; 00115 c = 1.0000, 0.9804, 0.8039; CLR["lemon_chiffon"] = c; 00116 c = 0.9804, 0.9412, 0.9020; CLR["linen"] = c; 00117 c = 0.9608, 1.0000, 0.9804; CLR["mint_cream"] = c; 00118 c = 1.0000, 0.8941, 0.8824; CLR["misty_rose"] = c; 00119 c = 1.0000, 0.8941, 0.7098; CLR["moccasin"] = c; 00120 c = 1.0000, 0.8706, 0.6784; CLR["navajo_white"] = c; 00121 c = 0.9922, 0.9608, 0.9020; CLR["old_lace"] = c; 00122 c = 1.0000, 0.9373, 0.8353; CLR["papaya_whip"] = c; 00123 c = 1.0000, 0.8549, 0.7255; CLR["peach_puff"] = c; 00124 c = 1.0000, 0.9608, 0.9333; CLR["seashell"] = c; 00125 c = 1.0000, 0.9804, 0.9804; CLR["snow"] = c; 00126 c = 0.8471, 0.7490, 0.8471; CLR["thistle"] = c; 00127 c = 0.9900, 1.0000, 0.9400; CLR["titanium_white"] = c; 00128 c = 0.9608, 0.8706, 0.7020; CLR["wheat"] = c; 00129 c = 1.0000, 1.0000, 1.0000; CLR["white"] = c; 00130 c = 0.9608, 0.9608, 0.9608; CLR["white_smoke"] = c; 00131 c = 0.9900, 0.9700, 1.0000; CLR["zinc_white"] = c; 00132 00133 // Greys 00134 c = 0.5000, 0.5400, 0.5300; CLR["cold_grey"] = c; 00135 c = 0.4118, 0.4118, 0.4118; CLR["dim_grey"] = c; 00136 c = 0.7529, 0.7529, 0.7529; CLR["grey"] = c; 00137 c = 0.8275, 0.8275, 0.8275; CLR["light_grey"] = c; 00138 c = 0.4392, 0.5020, 0.5647; CLR["slate_grey"] = c; 00139 c = 0.1843, 0.3098, 0.3098; CLR["slate_grey_dark"] = c; 00140 c = 0.4667, 0.5333, 0.6000; CLR["slate_grey_light"] = c; 00141 c = 0.5000, 0.5000, 0.4100; CLR["warm_grey"] = c; 00142 00143 // Blacks 00144 c = 0.0000, 0.0000, 0.0000; CLR["black"] = c; 00145 c = 0.1600, 0.1400, 0.1300; CLR["ivory_black"] = c; 00146 c = 0.1800, 0.2800, 0.2300; CLR["lamp_black"] = c; 00147 00148 // Reds 00149 c = 0.8900, 0.1500, 0.2100; CLR["alizarin_crimson"] = c; 00150 c = 0.6100, 0.4000, 0.1200; CLR["brick"] = c; 00151 c = 0.8900, 0.0900, 0.0500; CLR["cadmium_red_deep"] = c; 00152 c = 1.0000, 0.4980, 0.3137; CLR["coral"] = c; 00153 c = 0.9412, 0.5020, 0.5020; CLR["coral_light"] = c; 00154 c = 1.0000, 0.0784, 0.5765; CLR["deep_pink"] = c; 00155 c = 0.8300, 0.2400, 0.1000; CLR["english_red"] = c; 00156 c = 0.6980, 0.1333, 0.1333; CLR["firebrick"] = c; 00157 c = 0.8900, 0.0700, 0.1900; CLR["geranium_lake"] = c; 00158 c = 1.0000, 0.4118, 0.7059; CLR["hot_pink"] = c; 00159 c = 0.6900, 0.0900, 0.1200; CLR["indian_red"] = c; 00160 c = 1.0000, 0.6275, 0.4784; CLR["light_salmon"] = c; 00161 c = 0.8900, 0.1800, 0.1900; CLR["madder_lake_deep"] = c; 00162 c = 0.6902, 0.1882, 0.3765; CLR["maroon"] = c; 00163 c = 1.0000, 0.7529, 0.7961; CLR["pink"] = c; 00164 c = 1.0000, 0.7137, 0.7569; CLR["pink_light"] = c; 00165 c = 0.5300, 0.1500, 0.3400; CLR["raspberry"] = c; 00166 c = 1.0000, 0.0000, 0.0000; CLR["red"] = c; 00167 c = 0.8900, 0.2100, 0.2200; CLR["rose_madder"] = c; 00168 c = 0.9804, 0.5020, 0.4471; CLR["salmon"] = c; 00169 c = 1.0000, 0.3882, 0.2784; CLR["tomato"] = c; 00170 c = 0.8300, 0.1000, 0.1200; CLR["venetian_red"] = c; 00171 00172 // Browns 00173 c = 0.6400, 0.5800, 0.5000; CLR["beige"] = c; 00174 c = 0.5000, 0.1647, 0.1647; CLR["brown"] = c; 00175 c = 0.8600, 0.1600, 0.1600; CLR["brown_madder"] = c; 00176 c = 0.5300, 0.2600, 0.1200; CLR["brown_ochre"] = c; 00177 c = 0.8706, 0.7216, 0.5294; CLR["burlywood"] = c; 00178 c = 0.5400, 0.2100, 0.0600; CLR["burnt_sienna"] = c; 00179 c = 0.5400, 0.2000, 0.1400; CLR["burnt_umber"] = c; 00180 c = 0.8235, 0.4118, 0.1176; CLR["chocolate"] = c; 00181 c = 0.4500, 0.2400, 0.1000; CLR["deep_ochre"] = c; 00182 c = 1.0000, 0.4900, 0.2500; CLR["flesh"] = c; 00183 c = 1.0000, 0.3400, 0.1300; CLR["flesh_ochre"] = c; 00184 c = 0.7800, 0.4700, 0.1500; CLR["gold_ochre"] = c; 00185 c = 1.0000, 0.2400, 0.0500; CLR["greenish_umber"] = c; 00186 c = 0.9412, 0.9020, 0.5490; CLR["khaki"] = c; 00187 c = 0.7412, 0.7176, 0.4196; CLR["khaki_dark"] = c; 00188 c = 0.9608, 0.9608, 0.8627; CLR["light_beige"] = c; 00189 c = 0.8039, 0.5216, 0.2471; CLR["peru"] = c; 00190 c = 0.7373, 0.5608, 0.5608; CLR["rosy_brown"] = c; 00191 c = 0.7800, 0.3800, 0.0800; CLR["raw_sienna"] = c; 00192 c = 0.4500, 0.2900, 0.0700; CLR["raw_umber"] = c; 00193 c = 0.3700, 0.1500, 0.0700; CLR["sepia"] = c; 00194 c = 0.6275, 0.3216, 0.1765; CLR["sienna"] = c; 00195 c = 0.5451, 0.2706, 0.0745; CLR["saddle_brown"] = c; 00196 c = 0.9569, 0.6431, 0.3765; CLR["sandy_brown"] = c; 00197 c = 0.8235, 0.7059, 0.5490; CLR["tan"] = c; 00198 c = 0.3700, 0.1500, 0.0200; CLR["van_dyke_brown"] = c; 00199 00200 // Oranges 00201 c = 1.0000, 0.3800, 0.0100; CLR["cadmium_orange"] = c; 00202 c = 1.0000, 0.0100, 0.0500; CLR["cadmium_red_light"] = c; 00203 c = 0.9300, 0.5700, 0.1300; CLR["carrot"] = c; 00204 c = 1.0000, 0.5490, 0.0000; CLR["dark_orange"] = c; 00205 c = 0.5900, 0.2700, 0.0800; CLR["mars_orange"] = c; 00206 c = 0.8900, 0.4400, 0.1000; CLR["mars_yellow"] = c; 00207 c = 1.0000, 0.5000, 0.0000; CLR["orange"] = c; 00208 c = 1.0000, 0.2706, 0.0000; CLR["orange_red"] = c; 00209 c = 0.8900, 0.5100, 0.0900; CLR["yellow_ochre"] = c; 00210 00211 // Yellows 00212 c = 1.0000, 0.6600, 0.1400; CLR["aureoline_yellow"] = c; 00213 c = 0.8900, 0.8100, 0.3400; CLR["banana"] = c; 00214 c = 1.0000, 0.8900, 0.0100; CLR["cadmium_lemon"] = c; 00215 c = 1.0000, 0.6000, 0.0700; CLR["cadmium_yellow"] = c; 00216 c = 1.0000, 0.6900, 0.0600; CLR["cadmium_yellow_light"] = c; 00217 c = 1.0000, 0.8431, 0.0000; CLR["gold"] = c; 00218 c = 0.8549, 0.6471, 0.1255; CLR["goldenrod"] = c; 00219 c = 0.7216, 0.5255, 0.0431; CLR["goldenrod_dark"] = c; 00220 c = 0.9804, 0.9804, 0.8235; CLR["goldenrod_light"] = c; 00221 c = 0.9333, 0.9098, 0.6667; CLR["goldenrod_pale"] = c; 00222 c = 0.9333, 0.8667, 0.5098; CLR["light_goldenrod"] = c; 00223 c = 0.8900, 0.6600, 0.4100; CLR["melon"] = c; 00224 c = 1.0000, 0.6600, 0.0700; CLR["naples_yellow_deep"] = c; 00225 c = 1.0000, 1.0000, 0.0000; CLR["yellow"] = c; 00226 c = 1.0000, 1.0000, 0.8784; CLR["yellow_light"] = c; 00227 00228 // Greens 00229 c = 0.4980, 1.0000, 0.0000; CLR["chartreuse"] = c; 00230 c = 0.4000, 0.5000, 0.0800; CLR["chromeoxidegreen"] = c; 00231 c = 0.3800, 0.7000, 0.1600; CLR["cinnabar_green"] = c; 00232 c = 0.2400, 0.5700, 0.2500; CLR["cobalt_green"] = c; 00233 c = 0.0000, 0.7900, 0.3400; CLR["emerald_green"] = c; 00234 c = 0.1333, 0.5451, 0.1333; CLR["forest_green"] = c; 00235 c = 0.0000, 1.0000, 0.0000; CLR["green"] = c; 00236 c = 0.0000, 0.3922, 0.0000; CLR["green_dark"] = c; 00237 c = 0.5961, 0.9843, 0.5961; CLR["green_pale"] = c; 00238 c = 0.6784, 1.0000, 0.1843; CLR["green_yellow"] = c; 00239 c = 0.4863, 0.9882, 0.0000; CLR["lawn_green"] = c; 00240 c = 0.1961, 0.8039, 0.1961; CLR["lime_green"] = c; 00241 c = 0.7400, 0.9900, 0.7900; CLR["mint"] = c; 00242 c = 0.2300, 0.3700, 0.1700; CLR["olive"] = c; 00243 c = 0.4196, 0.5569, 0.1373; CLR["olive_drab"] = c; 00244 c = 0.3333, 0.4196, 0.1843; CLR["olive_green_dark"] = c; 00245 c = 0.0400, 0.7900, 0.1700; CLR["permanent_green"] = c; 00246 c = 0.1900, 0.5000, 0.0800; CLR["sap_green"] = c; 00247 c = 0.1804, 0.5451, 0.3412; CLR["sea_green"] = c; 00248 c = 0.5608, 0.7373, 0.5608; CLR["sea_green_dark"] = c; 00249 c = 0.2353, 0.7020, 0.4431; CLR["sea_green_medium"] = c; 00250 c = 0.1255, 0.6980, 0.6667; CLR["sea_green_light"] = c; 00251 c = 0.0000, 1.0000, 0.4980; CLR["spring_green"] = c; 00252 c = 0.0000, 0.9804, 0.6039; CLR["spring_green_medium"] = c; 00253 c = 0.2200, 0.3700, 0.0600; CLR["terre_verte"] = c; 00254 c = 0.4300, 1.0000, 0.4400; CLR["viridian_light"] = c; 00255 c = 0.6039, 0.8039, 0.1961; CLR["yellow_green"] = c; 00256 00257 // Cyans 00258 c = 0.4980, 1.0000, 0.8314; CLR["aquamarine"] = c; 00259 c = 0.4000, 0.8039, 0.6667; CLR["aquamarine_medium"] = c; 00260 c = 0.0000, 1.0000, 1.0000; CLR["cyan"] = c; 00261 c = 0.8784, 1.0000, 1.0000; CLR["cyan_white"] = c; 00262 c = 0.2510, 0.8784, 0.8157; CLR["turquoise"] = c; 00263 c = 0.0000, 0.8078, 0.8196; CLR["turquoise_dark"] = c; 00264 c = 0.2824, 0.8196, 0.8000; CLR["turquoise_medium"] = c; 00265 c = 0.6863, 0.9333, 0.9333; CLR["turquoise_pale"] = c; 00266 00267 // Blues 00268 c = 0.9412, 0.9725, 1.0000; CLR["alice_blue"] = c; 00269 c = 0.0000, 0.0000, 1.0000; CLR["blue"] = c; 00270 c = 0.6784, 0.8471, 0.9020; CLR["blue_light"] = c; 00271 c = 0.0000, 0.0000, 0.8039; CLR["blue_medium"] = c; 00272 c = 0.3725, 0.6196, 0.6275; CLR["cadet"] = c; 00273 c = 0.2400, 0.3500, 0.6700; CLR["cobalt"] = c; 00274 c = 0.3922, 0.5843, 0.9294; CLR["cornflower"] = c; 00275 c = 0.0200, 0.7200, 0.8000; CLR["cerulean"] = c; 00276 c = 0.1176, 0.5647, 1.0000; CLR["dodger_blue"] = c; 00277 c = 0.0300, 0.1800, 0.3300; CLR["indigo"] = c; 00278 c = 0.0100, 0.6600, 0.6200; CLR["manganese_blue"] = c; 00279 c = 0.0980, 0.0980, 0.4392; CLR["midnight_blue"] = c; 00280 c = 0.0000, 0.0000, 0.5020; CLR["navy"] = c; 00281 c = 0.2000, 0.6300, 0.7900; CLR["peacock"] = c; 00282 c = 0.6902, 0.8784, 0.9020; CLR["powder_blue"] = c; 00283 c = 0.2549, 0.4118, 0.8824; CLR["royal_blue"] = c; 00284 c = 0.4157, 0.3529, 0.8039; CLR["slate_blue"] = c; 00285 c = 0.2824, 0.2392, 0.5451; CLR["slate_blue_dark"] = c; 00286 c = 0.5176, 0.4392, 1.0000; CLR["slate_blue_light"] = c; 00287 c = 0.4824, 0.4078, 0.9333; CLR["slate_blue_medium"] = c; 00288 c = 0.5294, 0.8078, 0.9216; CLR["sky_blue"] = c; 00289 c = 0.0000, 0.7490, 1.0000; CLR["sky_blue_deep"] = c; 00290 c = 0.5294, 0.8078, 0.9804; CLR["sky_blue_light"] = c; 00291 c = 0.2745, 0.5098, 0.7059; CLR["steel_blue"] = c; 00292 c = 0.6902, 0.7686, 0.8706; CLR["steel_blue_light"] = c; 00293 c = 0.0000, 0.7800, 0.5500; CLR["turquoise_blue"] = c; 00294 c = 0.0700, 0.0400, 0.5600; CLR["ultramarine"] = c; 00295 00296 // Magenta 00297 c = 0.5412, 0.1686, 0.8863; CLR["blue_violet"] = c; 00298 c = 0.5700, 0.1300, 0.6200; CLR["cobalt_violet_deep"] = c; 00299 c = 1.0000, 0.0000, 1.0000; CLR["magenta"] = c; 00300 c = 0.8549, 0.4392, 0.8392; CLR["orchid"] = c; 00301 c = 0.6000, 0.1961, 0.8000; CLR["orchid_dark"] = c; 00302 c = 0.7294, 0.3333, 0.8275; CLR["orchid_medium"] = c; 00303 c = 0.8600, 0.1500, 0.2700; CLR["permanent_red_violet"] = c; 00304 c = 0.8667, 0.6275, 0.8667; CLR["plum"] = c; 00305 c = 0.6275, 0.1255, 0.9412; CLR["purple"] = c; 00306 c = 0.5765, 0.4392, 0.8588; CLR["purple_medium"] = c; 00307 c = 0.3600, 0.1400, 0.4300; CLR["ultramarine_violet"] = c; 00308 c = 0.5600, 0.3700, 0.6000; CLR["violet"] = c; 00309 c = 0.5804, 0.0000, 0.8275; CLR["violet_dark"] = c; 00310 c = 0.8157, 0.1255, 0.5647; CLR["violet_red"] = c; 00311 c = 0.7804, 0.0824, 0.5216; CLR["violet_red_medium"] = c; 00312 c = 0.8588, 0.4392, 0.5765; CLR["violet_red_pale"] = c; 00313 00314 return 0; 00315 } 00316 00317 int __colors_dummy__ = __init_colors__(); 00318 00319 }; // namespace Colors 00320 00321 #endif // MECHSYS_COLORS_H