#include "MyDialog.h" ClassImp(MyDialog) MyDialog::MyDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) { // 1st: to create an window with respect to its parent (main) window fMain = new TGTransientFrame(p, main, w, h, options); fMain->Connect("CloseWindow()", "MyDialog", this, "CloseWindow()"); fHor1 = new TGHorizontalFrame(fMain, 80, 20, kFixedWidth); fDraw = new TGTextButton(fHor1, " &Draw ", 1); fDraw->Connect("Clicked()", "MyDialog", this, "DoDraw()"); fHor1->AddFrame(fDraw, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 4, 4, 4, 4)); fHor1->Resize(150, fDraw->GetDefaultHeight()); fMain->AddFrame(fHor1,new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1)); // 2nd: create widgets in the dialog fText = new TGTextEntry(fMain, new TGTextBuffer(100)); fText->SetToolTipText("Enter the label and hit Enter key"); fText->Connect("ReturnPressed()", "MyDialog", this, "DoSetlabel()"); fMain->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); fGframe = new TGGroupFrame(fMain, "Chain Name"); fLabel = new TGLabel(fGframe, "Plot name"); fGframe->AddFrame(fLabel, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); fMain->AddFrame(fGframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 1, 1)); fText->Resize(150, fText->GetDefaultHeight()); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); // position of the dialog relative to the parent's window Window_t wdum; int ax, ay; gVirtualX->TranslateCoordinates(main->GetId(), fMain->GetParent()->GetId(), (Int_t)(((TGFrame *) main)->GetWidth() - fMain->GetWidth()) >> 1, (Int_t)(((TGFrame *) main)->GetHeight() - fMain->GetHeight()) >> 1, ax, ay, wdum); fMain->Move(ax, ay); fMain->SetWindowName("My Dialog"); fMain->MapWindow(); } MyDialog::MyDialog(H1Analysis* analysis) { fAnalysis = analysis; } MyDialog::~MyDialog() { delete fText; delete fLabel; delete fDraw; delete fHor1; delete fGframe; delete fMain; } void MyDialog::CloseWindow() { // Called when the window is closed via the window manager. delete this; } void MyDialog::DoSetlabel() { printf("\nThe Enter key is pressed\n"); fLabel->SetText(fText->GetBuffer()->GetString()); fGframe->Layout(); } void MyDialog::DoDraw() { fPlotter->Draw(); // TCanvas *fCanvas = fEcanvas->GetCanvas(); // fCanvas->cd(); // fCanvas->Update(); TQObject::Disconnect(fText, "ReturnPressed()", this, "DoSetlabel()"); printf("\nThe Draw button is pressed\n"); fMain->SendCloseMessage(); } void MyDialog::AddHistArray(const char* chainname, const char* arrayname, const char* plotname) { H1AnalysisChain* Chain = fAnalysis->GetChain(chainname); H1AnalysisHistManager* HistManager = Chain->GetHistManager(); // Get HistArray TObjArray* HistArray = HistManager->GetHistArray(arrayname); // Add histogram arrays to plotter fPlotter->AddHistArray(HistArray, plotname); }