The Gaudi Framework  v32r2 (46d42edc)
readMetaData.C
Go to the documentation of this file.
1 #include "TFile.h"
2 #include "TTree.h"
3 #include <map>
4 #include <stdio.h>
5 #include <string>
6 
7 #include "TApplication.h"
8 #include "TColor.h"
9 #include "TDatime.h"
10 #include "TGColorSelect.h"
11 #include "TGComboBox.h"
12 #include "TGHtml.h"
13 #include "TGLabel.h"
14 #include "TGNumberEntry.h"
15 #include "TROOT.h"
16 #include "TTimeStamp.h"
17 
18 using namespace std;
19 
20 class Widget {
21 private:
22  TString fHeader; // HTML header
23  TString fFooter; // HTML footer
24  TString fHtml_text; // output HTML string
25 
26  TGMainFrame* fMain; // main frame
27  TGHtml* fHtml; // html widget to display HTML calendar
28 public:
29  void MakeHeader();
30  void MakeFooter();
32  virtual ~Widget();
33  TString Html() const { return fHtml_text; }
34  ClassDef( Widget, 0 );
35 };
37  fHeader = "<html><head><title>Meta Data Viewer</title></head>";
38  fHeader += "<body>\n";
39  fHeader += "<center><H2>Meta Data Viewer</H2></center>";
40 }
41 void Widget::MakeFooter() { fFooter = "</body></html>"; }
42 
44  MakeHeader();
45  MakeFooter();
46 
48 
49  fHtml_text = fHeader;
50  fHtml_text += "<table border='1' style='width:100%'>";
51 
52  for ( iter = md.begin(); iter != md.end(); iter++ ) {
53  fHtml_text += "<tr><td><font color='black'><b>";
54  fHtml_text += iter->first;
55  fHtml_text += "</b></font></td><td><font color='blue'><b>";
56  fHtml_text += iter->second;
57  fHtml_text += "</b></font></td></tr>";
58  }
59  fHtml_text += "</table>";
60  fHtml_text += fFooter;
61 
62  // Main window.
63  fMain = new TGMainFrame( gClient->GetRoot(), 10, 10, kVerticalFrame );
64  fMain->SetCleanup( kDeepCleanup ); // delete all subframes on exit
65  // create HTML widget
66  fHtml = new TGHtml( fMain, 1, 1 );
67  fMain->AddFrame( fHtml, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 5, 2, 2 ) );
68  fHtml->ParseText( (char*)fHtml_text.Data() );
69  // terminate ROOT session when window is closed
70  fMain->Connect( "CloseWindow()", "TApplication", gApplication, "Terminate()" );
71  fMain->DontCallClose();
72 
73  fMain->MapSubwindows();
74  fMain->Resize( 700, 700 );
75 
76  // set minimum size of main window
77  fMain->SetWMSizeHints( fMain->GetDefaultWidth(), fMain->GetDefaultHeight(), 1000, 1000, 0, 0 );
78  fMain->MapRaised();
79 }
80 Widget::~Widget() { delete fMain; }
81 void readMetaData() {
82  TFile mFile( "TupleEx.root" ); // TODO update name of the file
83  map<string, string>* mdMap = (map<string, string>*)mFile.Get( "info" );
84  map<string, string> newMap = *mdMap;
85  new Widget( newMap );
86 }
void readMetaData()
Definition: readMetaData.C:81
void MakeHeader()
Definition: readMetaData.C:36
TString Html() const
Definition: readMetaData.C:33
STL namespace.
T end(T... args)
TGHtml * fHtml
Definition: readMetaData.C:27
virtual ~Widget()
Definition: readMetaData.C:80
STL class.
TString fHeader
Definition: readMetaData.C:22
TGMainFrame * fMain
Definition: readMetaData.C:26
TString fFooter
Definition: readMetaData.C:23
void MakeFooter()
Definition: readMetaData.C:41
Widget(map< string, string > md)
Definition: readMetaData.C:43
T begin(T... args)
TString fHtml_text
Definition: readMetaData.C:24