00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <iostream>
00013 #include <TApplication.h>
00014 #include <TGClient.h>
00015 #include <TGButton.h>
00016 #include <TGFrame.h>
00017 #include <TGWindow.h>
00018 #include <TString.h>
00019 #include <TGTreeTable.h>
00020 #include <TFile.h>
00021 #include <TNtuple.h>
00022 #include <TTree.h>
00023
00024
00025
00026 class IDList {
00027 private:
00028 Int_t nID;
00029 public:
00030 IDList() : nID(0) {}
00031 ~IDList() {}
00032 Int_t GetUnID(void) { return ++nID ; }
00033 };
00034
00035 class TableTest : public TGMainFrame {
00036
00037 private:
00038 IDList fIDs;
00039 UInt_t fNTableRows;
00040 UInt_t fNTableColumns;
00041 TGTreeTable *fTreeTable;
00042 TFile *fFile;
00043
00044 public:
00045 TableTest(const TGWindow *p, UInt_t ntrows, UInt_t ntcols,
00046 UInt_t w = 100, UInt_t h = 100);
00047 virtual ~TableTest() ;
00048
00049 void DoExit() ;
00050
00051 TGTreeTable *GetTable() { return fTreeTable; }
00052
00053 ClassDef(TableTest, 0)
00054 };
00055
00056 TableTest::TableTest(const TGWindow *p, UInt_t ntrows, UInt_t ntcols,
00057 UInt_t w, UInt_t h)
00058 : TGMainFrame(p, w, h), fNTableRows(ntrows), fNTableColumns(ntcols),
00059 fTreeTable(0)
00060 {
00061 SetCleanup(kDeepCleanup) ;
00062 Connect("CloseWindow()", "TableTest", this, "DoExit()") ;
00063 DontCallClose() ;
00064
00065
00066 fFile = new TFile("$ROOTSYS/tutorials/tree/cernstaff.root");
00067
00068 if (!fFile || fFile->IsZombie()) {
00069 printf("Please run <ROOT location>/tutorials/tree/cernbuild.C first.");
00070 return;
00071 }
00072
00073
00074 TTree *tree = (TTree *)fFile->Get("T");
00075
00076
00077
00078 TString varexp = "px:py:pz:random:sin(px):log(px/py):log(pz)";
00079 TString select = "px>0 && py>0 && pz>0";
00080 TString options = "";
00081
00082
00083 fTreeTable = new TGTreeTable(this, fIDs.GetUnID(), tree);
00084 AddFrame(fTreeTable, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00085
00086
00087 SetWindowName("TGTreeTable Test") ;
00088 MapSubwindows() ;
00089 Layout();
00090 Resize(GetDefaultWidth()+20, 600) ;
00091 MapWindow() ;
00092
00093 } ;
00094
00095 TableTest::~TableTest()
00096 {
00097
00098 fFile->Close();
00099 Cleanup() ;
00100 }
00101
00102 void TableTest::DoExit()
00103 {
00104
00105
00106
00107
00108
00109 DeleteWindow();
00110
00111 }
00112
00113 TGTreeTable *gtreeTableTest(UInt_t ntrows = 50, UInt_t ntcols = 10) {
00114 TableTest *test = new TableTest(0, ntrows, ntcols, 500, 200);
00115 return test->GetTable();
00116 }