| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz 2/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2007
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MEnv
|
|---|
| 28 | //
|
|---|
| 29 | // It is a slightly changed version of TEnv. It logs all resources which are
|
|---|
| 30 | // touched, so that you can print all untouched resources by
|
|---|
| 31 | // PrintUntouched()
|
|---|
| 32 | //
|
|---|
| 33 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 34 | #include "MEnv.h"
|
|---|
| 35 |
|
|---|
| 36 | #include <Gtypes.h>
|
|---|
| 37 | #include <TObjString.h>
|
|---|
| 38 |
|
|---|
| 39 | #include <TPave.h>
|
|---|
| 40 | #include <TAttText.h>
|
|---|
| 41 | #include <TAttMarker.h>
|
|---|
| 42 | #include <THashList.h> // needed since root v5.10/00 (TEnv::GetTable)
|
|---|
| 43 |
|
|---|
| 44 | #include "MLog.h"
|
|---|
| 45 | #include "MLogManip.h"
|
|---|
| 46 |
|
|---|
| 47 | ClassImp(MEnv);
|
|---|
| 48 |
|
|---|
| 49 | using namespace std;
|
|---|
| 50 |
|
|---|
| 51 | //---------------------------------------------------------------------------
|
|---|
| 52 | //
|
|---|
| 53 | // (Default) constructor. If the given file cannot be accessed SetRcName("")
|
|---|
| 54 | // is called which can then be checked by IsValid()
|
|---|
| 55 | //
|
|---|
| 56 | MEnv::MEnv(const char *name) : TEnv(name)
|
|---|
| 57 | {
|
|---|
| 58 | fChecked.SetOwner();
|
|---|
| 59 |
|
|---|
| 60 | if (!IsValid())
|
|---|
| 61 | return;
|
|---|
| 62 |
|
|---|
| 63 | TString fname(name);
|
|---|
| 64 | gSystem->ExpandPathName(fname);
|
|---|
| 65 |
|
|---|
| 66 | if (gSystem->AccessPathName(fname, kFileExists))
|
|---|
| 67 | fname = "";
|
|---|
| 68 |
|
|---|
| 69 | SetRcName(fname);
|
|---|
| 70 |
|
|---|
| 71 | if (GetEntries()<=0 && !fname.IsNull() && fname!=name)
|
|---|
| 72 | ReadFile(fname, kEnvLocal);;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | //---------------------------------------------------------------------------
|
|---|
| 76 | //
|
|---|
| 77 | // Return the total number of entries in the table
|
|---|
| 78 | //
|
|---|
| 79 | Int_t MEnv::GetEntries() const
|
|---|
| 80 | {
|
|---|
| 81 | if (!GetTable())
|
|---|
| 82 | return -1;
|
|---|
| 83 |
|
|---|
| 84 | return GetTable()->GetEntries();
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | //---------------------------------------------------------------------------
|
|---|
| 88 | //
|
|---|
| 89 | // Compile str+post and make sure that in between there is a unique dot.
|
|---|
| 90 | //
|
|---|
| 91 | TString MEnv::Compile(TString str, const char *post) const
|
|---|
| 92 | {
|
|---|
| 93 | if (!str.IsNull() && !str.EndsWith("."))
|
|---|
| 94 | str += ".";
|
|---|
| 95 |
|
|---|
| 96 | str += post;
|
|---|
| 97 |
|
|---|
| 98 | return str;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | //---------------------------------------------------------------------------
|
|---|
| 102 | //
|
|---|
| 103 | // Get the value from the table and remember the value as checked
|
|---|
| 104 | //
|
|---|
| 105 | Int_t MEnv::GetValue(const char *name, Int_t dflt)
|
|---|
| 106 | {
|
|---|
| 107 | if (!fChecked.FindObject(name))
|
|---|
| 108 | fChecked.Add(new TObjString(name));
|
|---|
| 109 | return TEnv::GetValue(name, dflt);
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | //---------------------------------------------------------------------------
|
|---|
| 113 | //
|
|---|
| 114 | // Get the value from the table and remember the value as checked
|
|---|
| 115 | //
|
|---|
| 116 | Double_t MEnv::GetValue(const char *name, Double_t dflt)
|
|---|
| 117 | {
|
|---|
| 118 | if (!fChecked.FindObject(name))
|
|---|
| 119 | fChecked.Add(new TObjString(name));
|
|---|
| 120 | return TEnv::GetValue(name, dflt);
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | //---------------------------------------------------------------------------
|
|---|
| 124 | //
|
|---|
| 125 | // Get the value from the table and remember the value as checked
|
|---|
| 126 | //
|
|---|
| 127 | const char *MEnv::GetValue(const char *name, const char *dflt)
|
|---|
| 128 | {
|
|---|
| 129 | if (!fChecked.FindObject(name))
|
|---|
| 130 | fChecked.Add(new TObjString(name));
|
|---|
| 131 | return TEnv::GetValue(name, dflt);
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | //---------------------------------------------------------------------------
|
|---|
| 135 | //
|
|---|
| 136 | // TEnv doen't have a streamer --> cannot be cloned
|
|---|
| 137 | // --> we have to clone it ourself
|
|---|
| 138 | //
|
|---|
| 139 | TObject *MEnv::Clone(const char *) const
|
|---|
| 140 | {
|
|---|
| 141 | MEnv *env = new MEnv("/dev/null");
|
|---|
| 142 | env->SetRcName(GetRcName());
|
|---|
| 143 | env->AddEnv(*this);
|
|---|
| 144 | return env;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | //---------------------------------------------------------------------------
|
|---|
| 148 | //
|
|---|
| 149 | // Interprete fill style: Hollow, Solid, Hatch, 0%-100%
|
|---|
| 150 | // If no text style is detected the value is converted to an integer.
|
|---|
| 151 | //
|
|---|
| 152 | Int_t MEnv::GetFillStyle(const char *name, Int_t dftl)
|
|---|
| 153 | {
|
|---|
| 154 | TString str = GetValue(name, "");
|
|---|
| 155 | str = str.Strip(TString::kBoth);
|
|---|
| 156 | if (str.IsNull())
|
|---|
| 157 | return dftl;
|
|---|
| 158 |
|
|---|
| 159 | str.ToLower();
|
|---|
| 160 |
|
|---|
| 161 | switch (str.Hash())
|
|---|
| 162 | {
|
|---|
| 163 | case 2374867578U: return 0; // hollow
|
|---|
| 164 | case 764279305U: return 1001; // solid
|
|---|
| 165 | case 1854683492U: return 2001; // hatch
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | return str.EndsWith("%") ? 4000+str.Atoi() : str.Atoi();
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | //---------------------------------------------------------------------------
|
|---|
| 172 | //
|
|---|
| 173 | // Interprete line style: Solid, Dashed, Dotted, DashDotted
|
|---|
| 174 | // If no line style is detected the value is converted to an integer.
|
|---|
| 175 | //
|
|---|
| 176 | Int_t MEnv::GetLineStyle(const char *name, Int_t dftl)
|
|---|
| 177 | {
|
|---|
| 178 | TString str = GetValue(name, "");
|
|---|
| 179 | str = str.Strip(TString::kBoth);
|
|---|
| 180 | if (str.IsNull())
|
|---|
| 181 | return dftl;
|
|---|
| 182 |
|
|---|
| 183 | str.ToLower();
|
|---|
| 184 |
|
|---|
| 185 | switch (str.Hash())
|
|---|
| 186 | {
|
|---|
| 187 | case 764279305U: return kSolid;
|
|---|
| 188 | case 241979881U: return kDashed;
|
|---|
| 189 | case 2391642602U: return kDotted;
|
|---|
| 190 | case 1124931659U: return kDashDotted;
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | return str.Atoi();
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | //---------------------------------------------------------------------------
|
|---|
| 197 | //
|
|---|
| 198 | // Interprete alignment: Top, Right, Left, Bottom, Center, tr, cc, bl, ...
|
|---|
| 199 | // If no text align is detected the value is converted to an integer.
|
|---|
| 200 | //
|
|---|
| 201 | // eg.
|
|---|
| 202 | // Top Right
|
|---|
| 203 | // Bottom Center
|
|---|
| 204 | // Center
|
|---|
| 205 | // tr
|
|---|
| 206 | // br
|
|---|
| 207 | // cr
|
|---|
| 208 | //
|
|---|
| 209 | Int_t MEnv::GetAlign(const char *name, Int_t dftl)
|
|---|
| 210 | {
|
|---|
| 211 | TString str = GetValue(name, "");
|
|---|
| 212 | str = str.Strip(TString::kBoth);
|
|---|
| 213 | if (str.IsNull())
|
|---|
| 214 | return dftl;
|
|---|
| 215 |
|
|---|
| 216 | str.ToLower();
|
|---|
| 217 |
|
|---|
| 218 | switch (str.Hash())
|
|---|
| 219 | {
|
|---|
| 220 | case 29746: return 33; // tr
|
|---|
| 221 | case 25379: return 22; // cc
|
|---|
| 222 | case 25132: return 11; // bl
|
|---|
| 223 |
|
|---|
| 224 | case 25388: return 12; // cl
|
|---|
| 225 | case 25394: return 32; // cr
|
|---|
| 226 |
|
|---|
| 227 | case 29731: return 23; // tc
|
|---|
| 228 | case 25123: return 32; // bc
|
|---|
| 229 |
|
|---|
| 230 | case 29740: return 13; // tl
|
|---|
| 231 | case 25138: return 13; // br
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | Int_t align = 0;
|
|---|
| 235 | if (str.Contains("right", TString::kIgnoreCase))
|
|---|
| 236 | align += 3;
|
|---|
| 237 | if (str.Contains("left", TString::kIgnoreCase))
|
|---|
| 238 | align += 1;
|
|---|
| 239 | if (str.Contains("bottom", TString::kIgnoreCase))
|
|---|
| 240 | align += 10;
|
|---|
| 241 | if (str.Contains("top", TString::kIgnoreCase))
|
|---|
| 242 | align += 30;
|
|---|
| 243 |
|
|---|
| 244 | if (str.Contains("center", TString::kIgnoreCase))
|
|---|
| 245 | {
|
|---|
| 246 | if (align==0)
|
|---|
| 247 | return 22;
|
|---|
| 248 | if (align/10==0)
|
|---|
| 249 | return align+20;
|
|---|
| 250 | if (align%10==0)
|
|---|
| 251 | return align+2;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | return align>0 ? align : str.Atoi();
|
|---|
| 255 | }
|
|---|
| 256 |
|
|---|
| 257 | //---------------------------------------------------------------------------
|
|---|
| 258 | //
|
|---|
| 259 | // Interprete color: Black, White, Red, Green, Blue, Yellow, Magenta,
|
|---|
| 260 | // Cyan, Gray1-5, Grey1-5.
|
|---|
| 261 | // If no text color is detected the value is converted to an integer.
|
|---|
| 262 | //
|
|---|
| 263 | // eg.
|
|---|
| 264 | // Red
|
|---|
| 265 | // Light Red
|
|---|
| 266 | // Dark Red
|
|---|
| 267 | //
|
|---|
| 268 | Int_t MEnv::GetColor(const char *name, Int_t dftl)
|
|---|
| 269 | {
|
|---|
| 270 | TString str = GetValue(name, "");
|
|---|
| 271 |
|
|---|
| 272 | str = str.Strip(TString::kBoth);
|
|---|
| 273 | if (str.IsNull())
|
|---|
| 274 | return dftl;
|
|---|
| 275 |
|
|---|
| 276 | str.ToLower();
|
|---|
| 277 |
|
|---|
| 278 | Int_t offset=0;
|
|---|
| 279 | if (str.Contains("dark"))
|
|---|
| 280 | {
|
|---|
| 281 | str.ReplaceAll("dark", "");
|
|---|
| 282 | str = str.Strip(TString::kBoth);
|
|---|
| 283 | offset = 100;
|
|---|
| 284 | }
|
|---|
| 285 | if (str.Contains("light"))
|
|---|
| 286 | {
|
|---|
| 287 | str.ReplaceAll("light", "");
|
|---|
| 288 | str = str.Strip(TString::kBoth);
|
|---|
| 289 | offset = 150;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | switch (str.Hash())
|
|---|
| 293 | {
|
|---|
| 294 | case 2368543371U: return kWhite+offset;
|
|---|
| 295 | case 1814927399U: return kBlack+offset;
|
|---|
| 296 | case 7496964U: return kRed+offset;
|
|---|
| 297 | case 2897107074U: return kGreen+offset;
|
|---|
| 298 | case 1702194402U: return kBlue+offset;
|
|---|
| 299 | case 2374817882U: return kYellow+offset;
|
|---|
| 300 | case 2894218701U: return kMagenta+offset;
|
|---|
| 301 | case 1851881955U: return kCyan+offset;
|
|---|
| 302 | case 749623518U: return 19; // grey1
|
|---|
| 303 | case 749623517U: return 18; // grey2
|
|---|
| 304 | case 749623516U: return 17; // grey3
|
|---|
| 305 | case 749623515U: return 16; // grey4
|
|---|
| 306 | case 749623514U: return 15; // grey5
|
|---|
| 307 | case 749623513U: return 14; // grey6
|
|---|
| 308 | case 749623512U: return 13; // grey7
|
|---|
| 309 | case 749623511U: return 12; // grey8
|
|---|
| 310 | case 741234910U: return 19; // gray1
|
|---|
| 311 | case 741234909U: return 18; // gray2
|
|---|
| 312 | case 741234908U: return 17; // gray3
|
|---|
| 313 | case 741234907U: return 16; // gray4
|
|---|
| 314 | case 741234906U: return 15; // gray5
|
|---|
| 315 | case 741234905U: return 14; // gray6
|
|---|
| 316 | case 741234904U: return 13; // gray7
|
|---|
| 317 | case 741234903U: return 12; // gray8
|
|---|
| 318 | }
|
|---|
| 319 | return str.Atoi();
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | //---------------------------------------------------------------------------
|
|---|
| 323 | //
|
|---|
| 324 | // As possible convert the color col into a text string which can be
|
|---|
| 325 | // interpreted by GetColor before setting the resource value
|
|---|
| 326 | //
|
|---|
| 327 | void MEnv::SetColor(const char *name, Int_t col)
|
|---|
| 328 | {
|
|---|
| 329 | TString val;
|
|---|
| 330 |
|
|---|
| 331 | if (col>99 && col<101+kCyan)
|
|---|
| 332 | {
|
|---|
| 333 | val = "Dark ";
|
|---|
| 334 | col -= 100;
|
|---|
| 335 | }
|
|---|
| 336 | if (col>150 && col<151+kCyan)
|
|---|
| 337 | {
|
|---|
| 338 | val = "Light ";
|
|---|
| 339 | col -= 150;
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | switch (col)
|
|---|
| 343 | {
|
|---|
| 344 | case kWhite: val += "White"; break;
|
|---|
| 345 | case kBlack: val += "Black"; break;
|
|---|
| 346 | case kRed: val += "Red"; break;
|
|---|
| 347 | case kGreen: val += "Green"; break;
|
|---|
| 348 | case kBlue: val += "Blue"; break;
|
|---|
| 349 | case kYellow: val += "Yellow"; break;
|
|---|
| 350 | case kMagenta: val += "Magenta"; break;
|
|---|
| 351 | case kCyan: val += "Cyan"; break;
|
|---|
| 352 | case 19: val += "Grey1"; break;
|
|---|
| 353 | case 18: val += "Grey2"; break;
|
|---|
| 354 | case 17: val += "Grey3"; break;
|
|---|
| 355 | case 16: val += "Grey4"; break;
|
|---|
| 356 | case 15: val += "Grey5"; break;
|
|---|
| 357 | case 14: val += "Grey6"; break;
|
|---|
| 358 | case 13: val += "Grey7"; break;
|
|---|
| 359 | case 12: val += "Grey8"; break;
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | if (val.IsNull())
|
|---|
| 363 | val += col;
|
|---|
| 364 |
|
|---|
| 365 | SetValue(name, val);
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | //---------------------------------------------------------------------------
|
|---|
| 369 | //
|
|---|
| 370 | // As possible convert the alignment align into a text string which can be
|
|---|
| 371 | // interpreted by GetAlign before setting the resource value
|
|---|
| 372 | //
|
|---|
| 373 | void MEnv::SetAlign(const char *name, Int_t align)
|
|---|
| 374 | {
|
|---|
| 375 | TString val;
|
|---|
| 376 | if (align==22)
|
|---|
| 377 | {
|
|---|
| 378 | SetValue(name, "Center");
|
|---|
| 379 | return;
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | switch (align%10)
|
|---|
| 383 | {
|
|---|
| 384 | case 1: val += "Left"; break;
|
|---|
| 385 | case 2: val += "Center"; break;
|
|---|
| 386 | case 3: val += "Right"; break;
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | switch (align/10)
|
|---|
| 390 | {
|
|---|
| 391 | case 1: val += "Bottom"; break;
|
|---|
| 392 | case 2: val += "Center"; break;
|
|---|
| 393 | case 3: val += "Top"; break;
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | SetValue(name, val);
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | //---------------------------------------------------------------------------
|
|---|
| 400 | //
|
|---|
| 401 | // As possible convert the fill style style into a text string which can be
|
|---|
| 402 | // interpreted by GetFillStyle before setting the resource value
|
|---|
| 403 | //
|
|---|
| 404 | void MEnv::SetFillStyle(const char *name, Int_t style)
|
|---|
| 405 | {
|
|---|
| 406 | TString val;
|
|---|
| 407 |
|
|---|
| 408 | if (style>3999 && style<4101)
|
|---|
| 409 | val = Form("%d%%", style-4000);
|
|---|
| 410 |
|
|---|
| 411 | switch (style)
|
|---|
| 412 | {
|
|---|
| 413 | case 0: val = "Hollow"; break;
|
|---|
| 414 | case 1001: val = "Solid"; break;
|
|---|
| 415 | case 2001: val = "Hatch"; break;
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | if (val.IsNull())
|
|---|
| 419 | val += style;
|
|---|
| 420 |
|
|---|
| 421 | SetValue(name, val);
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | //---------------------------------------------------------------------------
|
|---|
| 425 | //
|
|---|
| 426 | // As possible convert the line style style into a text string which can be
|
|---|
| 427 | // interpreted by GetLineStyle before setting the resource value
|
|---|
| 428 | //
|
|---|
| 429 | void MEnv::SetLineStyle(const char *name, Int_t style)
|
|---|
| 430 | {
|
|---|
| 431 | TString val;
|
|---|
| 432 | switch (style)
|
|---|
| 433 | {
|
|---|
| 434 | case kSolid: val = "Solid"; break;
|
|---|
| 435 | case kDashed: val = "Dashed"; break;
|
|---|
| 436 | case kDotted: val = "Dotted"; break;
|
|---|
| 437 | case kDashDotted: val = "DashDotted"; break;
|
|---|
| 438 | }
|
|---|
| 439 |
|
|---|
| 440 | if (val.IsNull())
|
|---|
| 441 | val += style;
|
|---|
| 442 |
|
|---|
| 443 | SetValue(name, val);
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | //---------------------------------------------------------------------------
|
|---|
| 447 | //
|
|---|
| 448 | // As possible convert the marker style style into a text string which can be
|
|---|
| 449 | // interpreted by GetLineStyle before setting the resource value
|
|---|
| 450 | //
|
|---|
| 451 | void MEnv::SetMarkerStyle(const char *name, Int_t style)
|
|---|
| 452 | {
|
|---|
| 453 | TString val;
|
|---|
| 454 | switch (style)
|
|---|
| 455 | {
|
|---|
| 456 | case kDot: val = "dot";
|
|---|
| 457 | case kPlus: val = "plus";
|
|---|
| 458 | case kCircle: val = "circle";
|
|---|
| 459 | case kMultiply: val = "multiply";
|
|---|
| 460 | case kFullDotSmall: val = "fulldotsmall";
|
|---|
| 461 | case kFullDotMedium: val = "fulldotmedium";
|
|---|
| 462 | case kFullDotLarge: val = "fulldotlarge";
|
|---|
| 463 | case kOpenTriangleDown: val = "opentriangledown";
|
|---|
| 464 | case kFullCross: val = "fullcross";
|
|---|
| 465 | case kFullCircle: val = "fullcircle";
|
|---|
| 466 | case kFullSquare: val = "fullsquare";
|
|---|
| 467 | case kFullTriangleDown: val = "fulltriangledown";
|
|---|
| 468 | case kOpenCircle: val = "opencircle";
|
|---|
| 469 | case kOpenSquare: val = "opensquare";
|
|---|
| 470 | case kOpenTriangleUp: val = "opentriangleup";
|
|---|
| 471 | case kOpenDiamond: val = "opendiamond";
|
|---|
| 472 | case kOpenCross: val = "opencross";
|
|---|
| 473 | case kFullStar: val = "fullstar";
|
|---|
| 474 | case kOpenStar: val = "openstar";
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | if (val.IsNull())
|
|---|
| 478 | val += style;
|
|---|
| 479 |
|
|---|
| 480 | SetValue(name, val);
|
|---|
| 481 | }
|
|---|
| 482 |
|
|---|
| 483 | //---------------------------------------------------------------------------
|
|---|
| 484 | //
|
|---|
| 485 | // Get the attributed from a TAttLine (if dftl is given use it as default)
|
|---|
| 486 | // name.LineColor <see also GetColor>
|
|---|
| 487 | // name.LineStyle
|
|---|
| 488 | // name.LineWidth
|
|---|
| 489 | // For more details on the meaning see TAttLine
|
|---|
| 490 | //
|
|---|
| 491 | void MEnv::GetAttLine(const char *name, TAttLine &line, TAttLine *dftl)
|
|---|
| 492 | {
|
|---|
| 493 | const TString color = Compile(name, "LineColor");
|
|---|
| 494 | const TString style = Compile(name, "LineStyle");
|
|---|
| 495 | const TString width = Compile(name, "LineWidth");
|
|---|
| 496 |
|
|---|
| 497 | if (!dftl)
|
|---|
| 498 | dftl = &line;
|
|---|
| 499 |
|
|---|
| 500 | const Color_t col = GetColor(color, dftl->GetLineColor());
|
|---|
| 501 | const Style_t sty = GetLineStyle(style, dftl->GetLineStyle());
|
|---|
| 502 | const Style_t wid = GetValue(width, dftl->GetLineWidth());
|
|---|
| 503 |
|
|---|
| 504 | line.SetLineColor(col);
|
|---|
| 505 | line.SetLineStyle(sty);
|
|---|
| 506 | line.SetLineWidth(wid);
|
|---|
| 507 | }
|
|---|
| 508 |
|
|---|
| 509 | //---------------------------------------------------------------------------
|
|---|
| 510 | //
|
|---|
| 511 | // Get the attributed from a TAttText (if dftl is given use it as default)
|
|---|
| 512 | // name.TextColor <see also GetColor>
|
|---|
| 513 | // name.TextAlign <see also GetAlign>
|
|---|
| 514 | // name.TextAngle
|
|---|
| 515 | // name.TextFont
|
|---|
| 516 | // name.TextSize
|
|---|
| 517 | // For more details on the meaning see TAttText
|
|---|
| 518 | //
|
|---|
| 519 | void MEnv::GetAttText(const char *name, TAttText &text, TAttText *dftl)
|
|---|
| 520 | {
|
|---|
| 521 | const TString color = Compile(name, "TextColor");
|
|---|
| 522 | const TString align = Compile(name, "TextAlign");
|
|---|
| 523 | const TString angle = Compile(name, "TextAngle");
|
|---|
| 524 | const TString font = Compile(name, "TextFont");
|
|---|
| 525 | const TString size = Compile(name, "TextSize");
|
|---|
| 526 |
|
|---|
| 527 | if (!dftl)
|
|---|
| 528 | dftl = &text;
|
|---|
| 529 |
|
|---|
| 530 | const Color_t col = GetColor(color, dftl->GetTextColor());
|
|---|
| 531 | const Short_t ali = GetAlign(align, dftl->GetTextAlign());
|
|---|
| 532 | const Float_t ang = GetValue(angle, dftl->GetTextAngle());
|
|---|
| 533 | const Font_t fon = GetValue(font, dftl->GetTextFont());
|
|---|
| 534 | const Float_t siz = GetValue(size, dftl->GetTextSize());
|
|---|
| 535 |
|
|---|
| 536 | text.SetTextColor(col);
|
|---|
| 537 | text.SetTextAlign(ali);
|
|---|
| 538 | text.SetTextAngle(ang);
|
|---|
| 539 | text.SetTextFont(fon);
|
|---|
| 540 | text.SetTextSize(siz);
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | //---------------------------------------------------------------------------
|
|---|
| 544 | //
|
|---|
| 545 | // Get the attributed from a TAttFill (if dftl is given use it as default)
|
|---|
| 546 | // name.FillColor <see also GetColor>
|
|---|
| 547 | // name.FillStyle <see also GetFillStyle>
|
|---|
| 548 | // For more details on the meaning see TAttFill
|
|---|
| 549 | //
|
|---|
| 550 | void MEnv::GetAttFill(const char *name, TAttFill &fill, TAttFill *dftl)
|
|---|
| 551 | {
|
|---|
| 552 | const TString color = Compile(name, "FillColor");
|
|---|
| 553 | const TString style = Compile(name, "FillStyle");
|
|---|
| 554 |
|
|---|
| 555 | if (!dftl)
|
|---|
| 556 | dftl = &fill;
|
|---|
| 557 |
|
|---|
| 558 | const Color_t col = GetColor(color, dftl->GetFillColor());
|
|---|
| 559 | const Style_t sty = GetFillStyle(style, dftl->GetFillStyle());
|
|---|
| 560 |
|
|---|
| 561 | fill.SetFillColor(col);
|
|---|
| 562 | fill.SetFillStyle(sty);
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| 565 | //---------------------------------------------------------------------------
|
|---|
| 566 | //
|
|---|
| 567 | // Get the attributed from a TAttMarker (if dftl is given use it as default)
|
|---|
| 568 | // name.MarkerColor <see also GetColor>
|
|---|
| 569 | // name.MarkerStyle
|
|---|
| 570 | // name.MarkerSize
|
|---|
| 571 | // For more details on the meaning see TAttMarker
|
|---|
| 572 | //
|
|---|
| 573 | void MEnv::GetAttMarker(const char *name, TAttMarker &marker, TAttMarker *dftl)
|
|---|
| 574 | {
|
|---|
| 575 | const TString color = Compile(name, "MarkerColor");
|
|---|
| 576 | const TString style = Compile(name, "MarkerStyle");
|
|---|
| 577 | const TString size = Compile(name, "MarkerSize");
|
|---|
| 578 |
|
|---|
| 579 | if (!dftl)
|
|---|
| 580 | dftl = ▮
|
|---|
| 581 |
|
|---|
| 582 | const Color_t col = GetColor(color, dftl->GetMarkerColor());
|
|---|
| 583 | const Style_t sty = GetValue(style, dftl->GetMarkerStyle());
|
|---|
| 584 | const Size_t siz = GetValue(size, dftl->GetMarkerSize());
|
|---|
| 585 |
|
|---|
| 586 | marker.SetMarkerColor(col);
|
|---|
| 587 | marker.SetMarkerStyle(sty);
|
|---|
| 588 | marker.SetMarkerSize(siz);
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | //---------------------------------------------------------------------------
|
|---|
| 592 | //
|
|---|
| 593 | // Get the attributed from a TPave (if dftl is given use it as default)
|
|---|
| 594 | // name.CornerRadius
|
|---|
| 595 | // name.BorderSize
|
|---|
| 596 | // name.Option
|
|---|
| 597 | // Also all resources from TAttLine and TAttFill are supported.
|
|---|
| 598 | //
|
|---|
| 599 | // For your conveinience: If the CornerRadius is greater than 0 "arc" is
|
|---|
| 600 | // added to the options. If it is equal or less than 0 "arc" is removed
|
|---|
| 601 | // from the options.
|
|---|
| 602 | //
|
|---|
| 603 | // For more details on the meaning see TPave
|
|---|
| 604 | //
|
|---|
| 605 | void MEnv::GetAttPave(const char *str, TPave &pave, TPave *dftl)
|
|---|
| 606 | {
|
|---|
| 607 | const TString post(str);
|
|---|
| 608 |
|
|---|
| 609 | TString name(pave.GetName());
|
|---|
| 610 | if (!name.IsNull() && name!=pave.ClassName())
|
|---|
| 611 | name = Compile(name, post);
|
|---|
| 612 |
|
|---|
| 613 | GetAttLine(name, pave, dftl);
|
|---|
| 614 | GetAttFill(name, pave, dftl);
|
|---|
| 615 |
|
|---|
| 616 | const TString corner = Compile(name, "CornerRadius");
|
|---|
| 617 | const TString border = Compile(name, "BorderSize");
|
|---|
| 618 | const TString option = Compile(name, "Option");
|
|---|
| 619 |
|
|---|
| 620 | if (!dftl)
|
|---|
| 621 | dftl = &pave;
|
|---|
| 622 |
|
|---|
| 623 | const Double_t cor = GetValue(corner, dftl->GetCornerRadius());
|
|---|
| 624 | const Int_t bor = GetValue(border, dftl->GetBorderSize());
|
|---|
| 625 |
|
|---|
| 626 | pave.SetCornerRadius(cor);
|
|---|
| 627 | pave.SetBorderSize(bor);
|
|---|
| 628 |
|
|---|
| 629 | TString opt = GetValue(option, dftl->GetOption());
|
|---|
| 630 | opt.ToLower();
|
|---|
| 631 |
|
|---|
| 632 | const Bool_t has = pave.GetCornerRadius()>0;
|
|---|
| 633 |
|
|---|
| 634 | if (has && !opt.Contains("arc"))
|
|---|
| 635 | opt += "arc";
|
|---|
| 636 |
|
|---|
| 637 | if (!has && opt.Contains("arc"))
|
|---|
| 638 | opt.ReplaceAll("arc", "");
|
|---|
| 639 |
|
|---|
| 640 | pave.SetOption(opt);
|
|---|
| 641 |
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 | //---------------------------------------------------------------------------
|
|---|
| 645 | //
|
|---|
| 646 | // Get the attributed for the TObject obj. Use dftl for default attributes
|
|---|
| 647 | // if given.
|
|---|
| 648 | //
|
|---|
| 649 | // There is support for:
|
|---|
| 650 | // TPave <see GetAttPave>
|
|---|
| 651 | // TAttLine <see GetAttLine>
|
|---|
| 652 | // TAttText <see GetAttText>
|
|---|
| 653 | // TAttFill <see GetAttFill>
|
|---|
| 654 | // TAttMarker <see GetAttMarker>
|
|---|
| 655 | //
|
|---|
| 656 | void MEnv::GetAttributes(const char *name, TObject *obj, TObject *dftl)
|
|---|
| 657 | {
|
|---|
| 658 | //TAttAxis *line = dynamic_cast<TAttAxis*>(obj);
|
|---|
| 659 | //TAtt3D *line = dynamic_cast<TAtt3D*>(obj);
|
|---|
| 660 | //TAttCanvas *line = dynamic_cast<TAttCanvas*>(obj);
|
|---|
| 661 | //TAttFillCanvas *line = dynamic_cast<TAttFillEitor*>(obj);
|
|---|
| 662 | //TAttLineCanvas *line = dynamic_cast<TAttLineCanvas*>(obj);
|
|---|
| 663 | //TAttLineEditor *line = dynamic_cast<TAttLineEditor*>(obj);
|
|---|
| 664 | //TAttMarkerCanvas *line = dynamic_cast<TAttMarkerCanvas*>(obj);
|
|---|
| 665 | //TAttMarkerEditor *line = dynamic_cast<TAttMarkerEditor*>(obj);
|
|---|
| 666 | //TAttPad *line = dynamic_cast<TAttPad*>(obj);
|
|---|
| 667 | //TAttParticle *line = dynamic_cast<TAttParticle*>(obj);
|
|---|
| 668 | //TAttTextCanvas *line = dynamic_cast<TAttTextCanvas*>(obj);
|
|---|
| 669 | //TAttTextEditor *line = dynamic_cast<TAttTextEditor*>(obj);
|
|---|
| 670 |
|
|---|
| 671 | TPave *pave = dynamic_cast<TPave*>(obj);
|
|---|
| 672 | TAttLine *line = dynamic_cast<TAttLine*>(obj);
|
|---|
| 673 | TAttText *text = dynamic_cast<TAttText*>(obj);
|
|---|
| 674 | TAttFill *fill = dynamic_cast<TAttFill*>(obj);
|
|---|
| 675 | TAttMarker *mark = dynamic_cast<TAttMarker*>(obj);
|
|---|
| 676 |
|
|---|
| 677 | if (pave)
|
|---|
| 678 | {
|
|---|
| 679 | GetAttPave(name, *pave, dynamic_cast<TPave*>(dftl));
|
|---|
| 680 | return;
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 | if (line)
|
|---|
| 684 | GetAttLine(name, *line, dynamic_cast<TAttLine*>(dftl));
|
|---|
| 685 | if (text)
|
|---|
| 686 | GetAttText(name, *text, dynamic_cast<TAttText*>(dftl));
|
|---|
| 687 | if (fill)
|
|---|
| 688 | GetAttFill(name, *fill, dynamic_cast<TAttFill*>(dftl));
|
|---|
| 689 | if (mark)
|
|---|
| 690 | GetAttMarker(name, *mark, dynamic_cast<TAttMarker*>(dftl));
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 | //---------------------------------------------------------------------------
|
|---|
| 694 | //
|
|---|
| 695 | // Set the resources from a TAttLine:
|
|---|
| 696 | // name.LineColor <see also SetColor>
|
|---|
| 697 | // name.LineStyle
|
|---|
| 698 | // name.LineWidth
|
|---|
| 699 | //
|
|---|
| 700 | void MEnv::SetAttLine(const char *name, const TAttLine &line)
|
|---|
| 701 | {
|
|---|
| 702 | const TString color = Compile(name, "LineColor");
|
|---|
| 703 | const TString style = Compile(name, "LineStyle");
|
|---|
| 704 | const TString width = Compile(name, "LineWidth");
|
|---|
| 705 |
|
|---|
| 706 | SetColor(color, line.GetLineColor());
|
|---|
| 707 | SetLineStyle(style, line.GetLineStyle());
|
|---|
| 708 | SetValue(width, line.GetLineWidth());
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 | //---------------------------------------------------------------------------
|
|---|
| 712 | //
|
|---|
| 713 | // Set the resources from a TAttText:
|
|---|
| 714 | // name.TextColor <see also SetColor>
|
|---|
| 715 | // name.TextAlign <see also SetAlign>
|
|---|
| 716 | // name.TextAngle
|
|---|
| 717 | // name.TextFont
|
|---|
| 718 | // name.TextSize
|
|---|
| 719 | //
|
|---|
| 720 | void MEnv::SetAttText(const char *name, const TAttText &text)
|
|---|
| 721 | {
|
|---|
| 722 | const TString color = Compile(name, "TextColor");
|
|---|
| 723 | const TString align = Compile(name, "TextAlign");
|
|---|
| 724 | const TString angle = Compile(name, "TextAngle");
|
|---|
| 725 | const TString font = Compile(name, "TextFont");
|
|---|
| 726 | const TString size = Compile(name, "TextSize");
|
|---|
| 727 |
|
|---|
| 728 | SetColor(color, text.GetTextColor());
|
|---|
| 729 | SetAlign(align, text.GetTextAlign());
|
|---|
| 730 | SetValue(angle, text.GetTextAngle());
|
|---|
| 731 | SetValue(font, text.GetTextFont());
|
|---|
| 732 | SetValue(size, text.GetTextSize());
|
|---|
| 733 | }
|
|---|
| 734 |
|
|---|
| 735 | //---------------------------------------------------------------------------
|
|---|
| 736 | //
|
|---|
| 737 | // Set the resources from a TAttFill:
|
|---|
| 738 | // name.FillColor <see also SetColor>
|
|---|
| 739 | // name.FillStyle <see also SetFillStyle>
|
|---|
| 740 | //
|
|---|
| 741 | void MEnv::SetAttFill(const char *name, const TAttFill &fill)
|
|---|
| 742 | {
|
|---|
| 743 | const TString color = Compile(name, "FillColor");
|
|---|
| 744 | const TString style = Compile(name, "FillStyle");
|
|---|
| 745 |
|
|---|
| 746 | SetColor(color, fill.GetFillColor());
|
|---|
| 747 | SetFillStyle(style, fill.GetFillStyle());
|
|---|
| 748 | }
|
|---|
| 749 |
|
|---|
| 750 | //---------------------------------------------------------------------------
|
|---|
| 751 | //
|
|---|
| 752 | // Set the resources from a TAttMarker:
|
|---|
| 753 | // name.MarkerColor <see also SetColor>
|
|---|
| 754 | // name.MarkerStyle
|
|---|
| 755 | // name.MarkerSize
|
|---|
| 756 | //
|
|---|
| 757 | void MEnv::SetAttMarker(const char *name, const TAttMarker &marker)
|
|---|
| 758 | {
|
|---|
| 759 | const TString color = Compile(name, "MarkerColor");
|
|---|
| 760 | const TString style = Compile(name, "MarkerStyle");
|
|---|
| 761 | const TString size = Compile(name, "MarkerSize");
|
|---|
| 762 |
|
|---|
| 763 | SetColor(color, marker.GetMarkerColor());
|
|---|
| 764 | SetMarkerStyle(style, marker.GetMarkerStyle());
|
|---|
| 765 | SetValue(size, marker.GetMarkerSize());
|
|---|
| 766 | }
|
|---|
| 767 |
|
|---|
| 768 | //---------------------------------------------------------------------------
|
|---|
| 769 | //
|
|---|
| 770 | // Set the resources from a TPave:
|
|---|
| 771 | // name.CornerRadius
|
|---|
| 772 | // name.BorderSize
|
|---|
| 773 | // name.Option
|
|---|
| 774 | // Also all resources from TAttLine and TAttFill are supported.
|
|---|
| 775 | //
|
|---|
| 776 | void MEnv::SetAttPave(const char *str, const TPave &pave)
|
|---|
| 777 | {
|
|---|
| 778 | const TString name(str);
|
|---|
| 779 |
|
|---|
| 780 | SetAttLine(name, pave);
|
|---|
| 781 | SetAttFill(name, pave);
|
|---|
| 782 |
|
|---|
| 783 | const TString corner = Compile(name, "CornerRadius");
|
|---|
| 784 | const TString border = Compile(name, "BorderSize");
|
|---|
| 785 | const TString option = Compile(name, "Option");
|
|---|
| 786 |
|
|---|
| 787 | SetValue(corner, const_cast<TPave&>(pave).GetCornerRadius());
|
|---|
| 788 | SetValue(border, const_cast<TPave&>(pave).GetBorderSize());
|
|---|
| 789 | SetValue(option, pave.GetOption());
|
|---|
| 790 | }
|
|---|
| 791 |
|
|---|
| 792 | //---------------------------------------------------------------------------
|
|---|
| 793 | //
|
|---|
| 794 | // Set the attributed for the TObject obj.
|
|---|
| 795 | //
|
|---|
| 796 | // There is support for:
|
|---|
| 797 | // TPave <see SetAttPave>
|
|---|
| 798 | // TAttLine <see SetAttLine>
|
|---|
| 799 | // TAttText <see SetAttText>
|
|---|
| 800 | // TAttFill <see SetAttFill>
|
|---|
| 801 | // TAttMarker <see SetAttMarker>
|
|---|
| 802 | //
|
|---|
| 803 | void MEnv::SetAttributes(const char *name, const TObject *obj)
|
|---|
| 804 | {
|
|---|
| 805 | const TPave *pave = dynamic_cast<const TPave*>(obj);
|
|---|
| 806 | const TAttLine *line = dynamic_cast<const TAttLine*>(obj);
|
|---|
| 807 | const TAttText *text = dynamic_cast<const TAttText*>(obj);
|
|---|
| 808 | const TAttFill *fill = dynamic_cast<const TAttFill*>(obj);
|
|---|
| 809 | const TAttMarker *mark = dynamic_cast<const TAttMarker*>(obj);
|
|---|
| 810 |
|
|---|
| 811 | if (pave)
|
|---|
| 812 | {
|
|---|
| 813 | SetAttPave(name, *pave);
|
|---|
| 814 | return;
|
|---|
| 815 | }
|
|---|
| 816 |
|
|---|
| 817 | if (line)
|
|---|
| 818 | SetAttLine(name, *line);
|
|---|
| 819 | if (text)
|
|---|
| 820 | SetAttText(name, *text);
|
|---|
| 821 | if (fill)
|
|---|
| 822 | SetAttFill(name, *fill);
|
|---|
| 823 | if (mark)
|
|---|
| 824 | SetAttMarker(name, *mark);
|
|---|
| 825 | }
|
|---|
| 826 |
|
|---|
| 827 | //---------------------------------------------------------------------------
|
|---|
| 828 | //
|
|---|
| 829 | // Add all values from TEnv env the this MEnv. To not overwrite existing
|
|---|
| 830 | // values set overwrite to kFALSE
|
|---|
| 831 | //
|
|---|
| 832 | void MEnv::AddEnv(const TEnv &env, Bool_t overwrite)
|
|---|
| 833 | {
|
|---|
| 834 | if (!GetTable() || !env.GetTable())
|
|---|
| 835 | return;
|
|---|
| 836 |
|
|---|
| 837 | TIter Next(env.GetTable());
|
|---|
| 838 |
|
|---|
| 839 | TEnvRec *er;
|
|---|
| 840 | while ((er = (TEnvRec*)Next()))
|
|---|
| 841 | {
|
|---|
| 842 | if (overwrite || !Defined(er->GetName()))
|
|---|
| 843 | SetValue(er->GetName(), er->GetValue(), er->GetLevel(), er->GetType());
|
|---|
| 844 | }
|
|---|
| 845 | }
|
|---|
| 846 |
|
|---|
| 847 | //---------------------------------------------------------------------------
|
|---|
| 848 | //
|
|---|
| 849 | // Print resources which have never been touched (for debugging)
|
|---|
| 850 | //
|
|---|
| 851 | void MEnv::PrintUntouched() const
|
|---|
| 852 | {
|
|---|
| 853 | int i=0;
|
|---|
| 854 | gLog << inf << flush;
|
|---|
| 855 |
|
|---|
| 856 | TString sep = "Untouched Resources - ";
|
|---|
| 857 | sep += GetRcName();
|
|---|
| 858 | gLog.Separator(sep);
|
|---|
| 859 | TIter Next(GetTable());
|
|---|
| 860 | TObject *o=0;
|
|---|
| 861 |
|
|---|
| 862 | while ((o=Next()))
|
|---|
| 863 | if (!fChecked.FindObject(o->GetName()))
|
|---|
| 864 | {
|
|---|
| 865 | gLog << warn << " - Resource " << o->GetName() << " not touched" << endl;
|
|---|
| 866 | i++;
|
|---|
| 867 | }
|
|---|
| 868 | if (i==0)
|
|---|
| 869 | gLog << inf << "None." << endl;
|
|---|
| 870 | else
|
|---|
| 871 | gLog << inf << i << " resources have not been touched." << endl;
|
|---|
| 872 | }
|
|---|
| 873 |
|
|---|
| 874 | //---------------------------------------------------------------------------
|
|---|
| 875 | //
|
|---|
| 876 | // Return number of resources which have not been touched.
|
|---|
| 877 | //
|
|---|
| 878 | Int_t MEnv::GetNumUntouched() const
|
|---|
| 879 | {
|
|---|
| 880 | int i=0;
|
|---|
| 881 | TIter Next(GetTable());
|
|---|
| 882 | TObject *o=0;
|
|---|
| 883 | while ((o=Next()))
|
|---|
| 884 | if (!fChecked.FindObject(o->GetName()))
|
|---|
| 885 | i++;
|
|---|
| 886 | return i;
|
|---|
| 887 | }
|
|---|