#include #include #include #include #include #include #include #include #include #include "Riostream.h" void histo(); class MyMainFrame : public TGMainFrame { private: TGLabel *fLabel515; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); void DoLabel(Int_t nlines) ; ClassDef(MyMainFrame, 0) }; MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h): TGMainFrame(p, w, h) { TGFont *ufont; // will reflect user font changes ufont = gClient->GetFont("-*-Arial-bold-r-*-*-24-*-*-*-*-*-*-*"); TGGC *uGC; // will reflect user GC changes // graphics context changes GCValues_t vall515; vall515.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures; gClient->GetColorByName("#000000",vall515.fForeground); gClient->GetColorByName("#c0c0c0",vall515.fBackground); vall515.fFillStyle = kFillSolid; vall515.fFont = ufont->GetFontHandle(); vall515.fGraphicsExposures = kFALSE; uGC = gClient->GetGC(&vall515, kTRUE); ULong_t ucolor; // will reflect user color changes gClient->GetColorByName("#3399ff",ucolor); fLabel515 = new TGLabel( this,"1000",uGC->GetGC(),ufont->GetFontStruct(),kChildFrame,ucolor); fLabel515->SetTextJustify(36); fLabel515->SetMargins(0,0,0,0); fLabel515->SetWrapLength(-1); this->AddFrame(fLabel515, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); fLabel515->MoveResize(16,8,192,72); this->SetMWMHints(kMWMDecorAll, kMWMFuncAll, kMWMInputModeless); this->MapSubwindows(); this->Resize(this->GetDefaultSize()); this->MapWindow(); this->Resize(256,101); histo(); } void MyMainFrame::DoLabel(Int_t nlines) { cout<<"val ="<SetText(nlines); Layout(); } void histo( ) { ifstream in; in.open("essai.dat"); Float_t x; Int_t nlines = 0; TH1F *h1 = new TH1F("h1","x distribution",100,19000,21000); while (1) { in >> x ; if (!in.good()) break; h1->Fill(x); nlines++; } in.close(); //TCanvas *C1 = new TCanvas("1X ","1X",1); h1 -> Draw(); nlines = 2345; printf("In histo() nlines=%d\n",nlines); MyMainFrame::DoLabel(nlines); //above, the programme refuses to allow me to use "nlines" as argument. Why ? } void test1() { new MyMainFrame(0,100,100); }