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

Last change on this file since 7450 was 7450, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 23.7 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 (unsigned)-1920099718/*2374867578*/: return 0;// hollow
127 case 764279305: return 1001;// solid
128 case 1854683492: 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 764279305: return kSolid;
151 case 241979881: return kDashed;
152 case (unsigned)-1903324694: return kDotted;
153 case 1124931659: 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 (unsigned)-1926423925/*2368543371*/: return kWhite+offset;
258 case 1814927399: return kBlack+offset;
259 case 7496964: return kRed+offset;
260 case (unsigned)-1397860222/*2897107074*/: return kGreen+offset;
261 case 1702194402: return kBlue+offset;
262 case (unsigned)-1920149414/* 2374817882*/: return kYellow+offset;
263 case (unsigned)-1400748595/*2894218701*/: return kMagenta+offset;
264 case 1851881955: return kCyan+offset;
265 case 749623518: return 18; // grey1
266 case 749623517: return 17; // grey2
267 case 749623516: return 16; // grey3
268 case 749623515: return 15; // grey4
269 case 749623514: return 14; // grey5
270 case 741234910: return 18; // gray1
271 case 741234909: return 17; // gray2
272 case 741234908: return 16; // gray3
273 case 741234907: return 15; // gray4
274 case 741234906: return 14; // gray5
275 }
276 return str.Atoi();
277}
278
279//---------------------------------------------------------------------------
280//
281// As possible convert the color col into a text string which can be
282// interpreted by GetColor before setting the resource value
283//
284void MEnv::SetColor(const char *name, Int_t col)
285{
286 TString val;
287
288 if (col>99 && col<101+kCyan)
289 {
290 val = "Dark ";
291 col -= 100;
292 }
293 if (col>150 && col<151+kCyan)
294 {
295 val = "Light ";
296 col -= 150;
297 }
298
299 switch (col)
300 {
301 case kWhite: val += "White"; break;
302 case kBlack: val += "Black"; break;
303 case kRed: val += "Red"; break;
304 case kGreen: val += "Green"; break;
305 case kBlue: val += "Blue"; break;
306 case kYellow: val += "Yellow"; break;
307 case kMagenta: val += "Magenta"; break;
308 case kCyan: val += "Cyan"; break;
309 case 18: val += "White"; break;
310 case 17: val += "White"; break;
311 case 16: val += "White"; break;
312 case 15: val += "White"; break;
313 case 14: val += "White"; break;
314 }
315
316 if (val.IsNull())
317 val += col;
318
319 SetValue(name, val);
320}
321
322//---------------------------------------------------------------------------
323//
324// As possible convert the alignment align into a text string which can be
325// interpreted by GetAlign before setting the resource value
326//
327void MEnv::SetAlign(const char *name, Int_t align)
328{
329 TString val;
330 if (align==22)
331 {
332 SetValue(name, "Center");
333 return;
334 }
335
336 switch (align%10)
337 {
338 case 1: val += "Left"; break;
339 case 2: val += "Center"; break;
340 case 3: val += "Right"; break;
341 }
342
343 switch (align/10)
344 {
345 case 1: val += "Bottom"; break;
346 case 2: val += "Center"; break;
347 case 3: val += "Top"; break;
348 }
349
350 SetValue(name, val);
351}
352
353//---------------------------------------------------------------------------
354//
355// As possible convert the fill style style into a text string which can be
356// interpreted by GetFillStyle before setting the resource value
357//
358void MEnv::SetFillStyle(const char *name, Int_t style)
359{
360 TString val;
361
362 if (style>3999 && style<4101)
363 val = Form("%d%%", style-4000);
364
365 switch (style)
366 {
367 case 0: val = "Hollow"; break;
368 case 1001: val = "Solid"; break;
369 case 2001: val = "Hatch"; break;
370 }
371
372 if (val.IsNull())
373 val += style;
374
375 SetValue(name, val);
376}
377
378//---------------------------------------------------------------------------
379//
380// As possible convert the line style style into a text string which can be
381// interpreted by GetLineStyle before setting the resource value
382//
383void MEnv::SetLineStyle(const char *name, Int_t style)
384{
385 TString val;
386 switch (style)
387 {
388 case kSolid: val = "Solid"; break;
389 case kDashed: val = "Dashed"; break;
390 case kDotted: val = "Dotted"; break;
391 case kDashDotted: val = "DashDotted"; break;
392 }
393
394 if (val.IsNull())
395 val += style;
396
397 SetValue(name, val);
398}
399
400//---------------------------------------------------------------------------
401//
402// As possible convert the marker style style into a text string which can be
403// interpreted by GetLineStyle before setting the resource value
404//
405void MEnv::SetMarkerStyle(const char *name, Int_t style)
406{
407 TString val;
408 switch (style)
409 {
410 case kDot: val = "dot";
411 case kPlus: val = "plus";
412 case kCircle: val = "circle";
413 case kMultiply: val = "multiply";
414 case kFullDotSmall: val = "fulldotsmall";
415 case kFullDotMedium: val = "fulldotmedium";
416 case kFullDotLarge: val = "fulldotlarge";
417 case kOpenTriangleDown: val = "opentriangledown";
418 case kFullCross: val = "fullcross";
419 case kFullCircle: val = "fullcircle";
420 case kFullSquare: val = "fullsquare";
421 case kFullTriangleDown: val = "fulltriangledown";
422 case kOpenCircle: val = "opencircle";
423 case kOpenSquare: val = "opensquare";
424 case kOpenTriangleUp: val = "opentriangleup";
425 case kOpenDiamond: val = "opendiamond";
426 case kOpenCross: val = "opencross";
427 case kFullStar: val = "fullstar";
428 case kOpenStar: val = "openstar";
429 }
430
431 if (val.IsNull())
432 val += style;
433
434 SetValue(name, val);
435}
436
437//---------------------------------------------------------------------------
438//
439// Get the attributed from a TAttLine (if dftl is given use it as default)
440// name.LineColor <see also GetColor>
441// name.LineStyle
442// name.LineWidth
443// For more details on the meaning see TAttLine
444//
445void MEnv::GetAttLine(const char *name, TAttLine &line, TAttLine *dftl)
446{
447 const TString color = Compile(name, "LineColor");
448 const TString style = Compile(name, "LineStyle");
449 const TString width = Compile(name, "LineWidth");
450
451 if (!dftl)
452 dftl = &line;
453
454 const Color_t col = GetColor(color, dftl->GetLineColor());
455 const Style_t sty = GetLineStyle(style, dftl->GetLineStyle());
456 const Style_t wid = GetValue(width, dftl->GetLineWidth());
457
458 line.SetLineColor(col);
459 line.SetLineStyle(sty);
460 line.SetLineWidth(wid);
461}
462
463//---------------------------------------------------------------------------
464//
465// Get the attributed from a TAttText (if dftl is given use it as default)
466// name.TextColor <see also GetColor>
467// name.TextAlign <see also GetAlign>
468// name.TextAngle
469// name.TextFont
470// name.TextSize
471// For more details on the meaning see TAttText
472//
473void MEnv::GetAttText(const char *name, TAttText &text, TAttText *dftl)
474{
475 const TString color = Compile(name, "TextColor");
476 const TString align = Compile(name, "TextAlign");
477 const TString angle = Compile(name, "TextAngle");
478 const TString font = Compile(name, "TextFont");
479 const TString size = Compile(name, "TextSize");
480
481 if (!dftl)
482 dftl = &text;
483
484 const Color_t col = GetColor(color, dftl->GetTextColor());
485 const Short_t ali = GetAlign(align, dftl->GetTextAlign());
486 const Float_t ang = GetValue(angle, dftl->GetTextAngle());
487 const Font_t fon = GetValue(font, dftl->GetTextFont());
488 const Float_t siz = GetValue(size, dftl->GetTextSize());
489
490 text.SetTextColor(col);
491 text.SetTextAlign(ali);
492 text.SetTextAngle(ang);
493 text.SetTextFont(fon);
494 text.SetTextSize(siz);
495}
496
497//---------------------------------------------------------------------------
498//
499// Get the attributed from a TAttFill (if dftl is given use it as default)
500// name.FillColor <see also GetColor>
501// name.FillStyle <see also GetFillStyle>
502// For more details on the meaning see TAttFill
503//
504void MEnv::GetAttFill(const char *name, TAttFill &fill, TAttFill *dftl)
505{
506 const TString color = Compile(name, "FillColor");
507 const TString style = Compile(name, "FillStyle");
508
509 if (!dftl)
510 dftl = &fill;
511
512 const Color_t col = GetColor(color, dftl->GetFillColor());
513 const Style_t sty = GetFillStyle(style, dftl->GetFillStyle());
514
515 fill.SetFillColor(col);
516 fill.SetFillStyle(sty);
517}
518
519//---------------------------------------------------------------------------
520//
521// Get the attributed from a TAttMarker (if dftl is given use it as default)
522// name.MarkerColor <see also GetColor>
523// name.MarkerStyle
524// name.MarkerSize
525// For more details on the meaning see TAttMarker
526//
527void MEnv::GetAttMarker(const char *name, TAttMarker &marker, TAttMarker *dftl)
528{
529 const TString color = Compile(name, "MarkerColor");
530 const TString style = Compile(name, "MarkerStyle");
531 const TString size = Compile(name, "MarkerSize");
532
533 if (!dftl)
534 dftl = &marker;
535
536 const Color_t col = GetColor(color, dftl->GetMarkerColor());
537 const Style_t sty = GetValue(style, dftl->GetMarkerStyle());
538 const Size_t siz = GetValue(size, dftl->GetMarkerSize());
539
540 marker.SetMarkerColor(col);
541 marker.SetMarkerStyle(sty);
542 marker.SetMarkerSize(siz);
543}
544
545//---------------------------------------------------------------------------
546//
547// Get the attributed from a TPave (if dftl is given use it as default)
548// name.CornerRadius
549// name.BorderSize
550// name.Option
551// Also all resources from TAttLine and TAttFill are supported.
552//
553// For your conveinience: If the CornerRadius is greater than 0 "arc" is
554// added to the options. If it is equal or less than 0 "arc" is removed
555// from the options.
556//
557// For more details on the meaning see TPave
558//
559void MEnv::GetAttPave(const char *str, TPave &pave, TPave *dftl)
560{
561 const TString post(str);
562
563 TString name(pave.GetName());
564 if (!name.IsNull() && name!=pave.ClassName())
565 name = Compile(name, post);
566
567 GetAttLine(name, pave, dftl);
568 GetAttFill(name, pave, dftl);
569
570 const TString corner = Compile(name, "CornerRadius");
571 const TString border = Compile(name, "BorderSize");
572 const TString option = Compile(name, "Option");
573
574 if (!dftl)
575 dftl = &pave;
576
577 const Double_t cor = GetValue(corner, dftl->GetCornerRadius());
578 const Int_t bor = GetValue(border, dftl->GetBorderSize());
579
580 pave.SetCornerRadius(cor);
581 pave.SetBorderSize(bor);
582
583 TString opt = GetValue(option, dftl->GetOption());
584 opt.ToLower();
585
586 const Bool_t has = pave.GetCornerRadius()>0;
587
588 if (has && !opt.Contains("arc"))
589 opt += "arc";
590
591 if (!has && opt.Contains("arc"))
592 opt.ReplaceAll("arc", "");
593
594 pave.SetOption(opt);
595
596}
597
598//---------------------------------------------------------------------------
599//
600// Get the attributed for the TObject obj. Use dftl for default attributes
601// if given.
602//
603// There is support for:
604// TPave <see GetAttPave>
605// TAttLine <see GetAttLine>
606// TAttText <see GetAttText>
607// TAttFill <see GetAttFill>
608// TAttMarker <see GetAttMarker>
609//
610void MEnv::GetAttributes(const char *name, TObject *obj, TObject *dftl)
611{
612 //TAttAxis *line = dynamic_cast<TAttAxis*>(obj);
613 //TAtt3D *line = dynamic_cast<TAtt3D*>(obj);
614 //TAttCanvas *line = dynamic_cast<TAttCanvas*>(obj);
615 //TAttFillCanvas *line = dynamic_cast<TAttFillEitor*>(obj);
616 //TAttLineCanvas *line = dynamic_cast<TAttLineCanvas*>(obj);
617 //TAttLineEditor *line = dynamic_cast<TAttLineEditor*>(obj);
618 //TAttMarkerCanvas *line = dynamic_cast<TAttMarkerCanvas*>(obj);
619 //TAttMarkerEditor *line = dynamic_cast<TAttMarkerEditor*>(obj);
620 //TAttPad *line = dynamic_cast<TAttPad*>(obj);
621 //TAttParticle *line = dynamic_cast<TAttParticle*>(obj);
622 //TAttTextCanvas *line = dynamic_cast<TAttTextCanvas*>(obj);
623 //TAttTextEditor *line = dynamic_cast<TAttTextEditor*>(obj);
624
625 TPave *pave = dynamic_cast<TPave*>(obj);
626 TAttLine *line = dynamic_cast<TAttLine*>(obj);
627 TAttText *text = dynamic_cast<TAttText*>(obj);
628 TAttFill *fill = dynamic_cast<TAttFill*>(obj);
629 TAttMarker *mark = dynamic_cast<TAttMarker*>(obj);
630
631 if (pave)
632 {
633 GetAttPave(name, *pave, dynamic_cast<TPave*>(dftl));
634 return;
635 }
636
637 if (line)
638 GetAttLine(name, *line, dynamic_cast<TAttLine*>(dftl));
639 if (text)
640 GetAttText(name, *text, dynamic_cast<TAttText*>(dftl));
641 if (fill)
642 GetAttFill(name, *fill, dynamic_cast<TAttFill*>(dftl));
643 if (mark)
644 GetAttMarker(name, *mark, dynamic_cast<TAttMarker*>(dftl));
645}
646
647//---------------------------------------------------------------------------
648//
649// Set the resources from a TAttLine:
650// name.LineColor <see also SetColor>
651// name.LineStyle
652// name.LineWidth
653//
654void MEnv::SetAttLine(const char *name, const TAttLine &line)
655{
656 const TString color = Compile(name, "LineColor");
657 const TString style = Compile(name, "LineStyle");
658 const TString width = Compile(name, "LineWidth");
659
660 SetColor(color, line.GetLineColor());
661 SetLineStyle(style, line.GetLineStyle());
662 SetValue(width, line.GetLineWidth());
663}
664
665//---------------------------------------------------------------------------
666//
667// Set the resources from a TAttText:
668// name.TextColor <see also SetColor>
669// name.TextAlign <see also SetAlign>
670// name.TextAngle
671// name.TextFont
672// name.TextSize
673//
674void MEnv::SetAttText(const char *name, const TAttText &text)
675{
676 const TString color = Compile(name, "TextColor");
677 const TString align = Compile(name, "TextAlign");
678 const TString angle = Compile(name, "TextAngle");
679 const TString font = Compile(name, "TextFont");
680 const TString size = Compile(name, "TextSize");
681
682 SetColor(color, text.GetTextColor());
683 SetAlign(align, text.GetTextAlign());
684 SetValue(angle, text.GetTextAngle());
685 SetValue(font, text.GetTextFont());
686 SetValue(size, text.GetTextSize());
687}
688
689//---------------------------------------------------------------------------
690//
691// Set the resources from a TAttFill:
692// name.FillColor <see also SetColor>
693// name.FillStyle <see also SetFillStyle>
694//
695void MEnv::SetAttFill(const char *name, const TAttFill &fill)
696{
697 const TString color = Compile(name, "FillColor");
698 const TString style = Compile(name, "FillStyle");
699
700 SetColor(color, fill.GetFillColor());
701 SetFillStyle(style, fill.GetFillStyle());
702}
703
704//---------------------------------------------------------------------------
705//
706// Set the resources from a TAttMarker:
707// name.MarkerColor <see also SetColor>
708// name.MarkerStyle
709// name.MarkerSize
710//
711void MEnv::SetAttMarker(const char *name, const TAttMarker &marker)
712{
713 const TString color = Compile(name, "MarkerColor");
714 const TString style = Compile(name, "MarkerStyle");
715 const TString size = Compile(name, "MarkerSize");
716
717 SetColor(color, marker.GetMarkerColor());
718 SetMarkerStyle(style, marker.GetMarkerStyle());
719 SetValue(size, marker.GetMarkerSize());
720}
721
722//---------------------------------------------------------------------------
723//
724// Set the resources from a TPave:
725// name.CornerRadius
726// name.BorderSize
727// name.Option
728// Also all resources from TAttLine and TAttFill are supported.
729//
730void MEnv::SetAttPave(const char *str, const TPave &pave)
731{
732 const TString name(str);
733
734 SetAttLine(name, pave);
735 SetAttFill(name, pave);
736
737 const TString corner = Compile(name, "CornerRadius");
738 const TString border = Compile(name, "BorderSize");
739 const TString option = Compile(name, "Option");
740
741 SetValue(corner, const_cast<TPave&>(pave).GetCornerRadius());
742 SetValue(border, const_cast<TPave&>(pave).GetBorderSize());
743 SetValue(option, pave.GetOption());
744}
745
746//---------------------------------------------------------------------------
747//
748// Set the attributed for the TObject obj.
749//
750// There is support for:
751// TPave <see SetAttPave>
752// TAttLine <see SetAttLine>
753// TAttText <see SetAttText>
754// TAttFill <see SetAttFill>
755// TAttMarker <see SetAttMarker>
756//
757void MEnv::SetAttributes(const char *name, const TObject *obj)
758{
759 const TPave *pave = dynamic_cast<const TPave*>(obj);
760 const TAttLine *line = dynamic_cast<const TAttLine*>(obj);
761 const TAttText *text = dynamic_cast<const TAttText*>(obj);
762 const TAttFill *fill = dynamic_cast<const TAttFill*>(obj);
763 const TAttMarker *mark = dynamic_cast<const TAttMarker*>(obj);
764
765 if (pave)
766 {
767 SetAttPave(name, *pave);
768 return;
769 }
770
771 if (line)
772 SetAttLine(name, *line);
773 if (text)
774 SetAttText(name, *text);
775 if (fill)
776 SetAttFill(name, *fill);
777 if (mark)
778 SetAttMarker(name, *mark);
779}
780
781//---------------------------------------------------------------------------
782//
783// Add all values from TEnv env the this MEnv. To not overwrite existing
784// values set overwrite to kFALSE
785//
786void MEnv::AddEnv(const TEnv &env, Bool_t overwrite)
787{
788 if (!GetTable() || !env.GetTable())
789 return;
790
791 TIter Next(env.GetTable());
792
793 TEnvRec *er;
794 while ((er = (TEnvRec*)Next()))
795 {
796 if (overwrite || !Defined(er->GetName()))
797 SetValue(er->GetName(), er->GetValue(), er->GetLevel(), er->GetType());
798 }
799}
800
801//---------------------------------------------------------------------------
802//
803// Print resources which have never been touched (for debugging)
804//
805void MEnv::PrintUntouched() const
806{
807 int i=0;
808 gLog << inf << flush;
809 gLog.Separator("Untouched Resources");
810 TIter Next(GetTable());
811 TObject *o=0;
812
813 while ((o=Next()))
814 if (!fChecked.FindObject(o->GetName()))
815 {
816 gLog << warn << " - Resource " << o->GetName() << " not touched" << endl;
817 i++;
818 }
819 if (i==0)
820 gLog << inf << "None." << endl;
821 else
822 gLog << inf << i << " resources have not been touched." << endl;
823}
Note: See TracBrowser for help on using the repository browser.