source: trunk/MagicSoft/Mars/mbase/MEnv.cc@ 7700

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