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

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