#include "testGUI.h" testGUI::testGUI(QApplication *parent_app) { app = parent_app; // layout QGridLayout *lay_grid = new QGridLayout(); // radiobuttons button[0] = new QRadioButton(tr("TH1F")); button[0]->setChecked(true); button[1] = new QRadioButton(tr("TH2F")); for (int r=0; r<2; r++) { QObject::connect( button[r], SIGNAL(clicked()), this, SLOT(updatePlot()) ); lay_grid->addWidget(button[r],0,r,1,1); } // canvas screen = new TQtWidget(this,"canvas"); lay_grid->addWidget(screen,1,0,1,2); // the gui this->setLayout(lay_grid); this->resize(640,480); this->show(); // histos h_1d = new TH1F("h_1d","One dimension",10,0,400); for (int b=0; b<100; b++) { h_1d->SetBinContent(b+1,b); } h_2d = new TH2F("h_2d","Two dimensions",10,0,400,10,0,400); h_2d->Fill(100,100); h_2d->Fill(100,200); h_2d->Fill(300,100); // plot the first histo h_1d->Draw(); screen->GetCanvas()->Update(); } testGUI::~testGUI() { } void testGUI::updatePlot() { if (button[0]->isChecked()) { screen->Erase(); screen->GetCanvas()->Clear(); screen->GetCanvas()->Update(); gVirtualX->SetFillColor(1); h_1d->Draw(); screen->GetCanvas()->Update(); sleep(3); h_1d->Add(h_1d,20); gVirtualX->SetFillColor(1); h_1d->Draw(); screen->GetCanvas()->Update(); } else { screen->Erase(); screen->GetCanvas()->Clear(); screen->GetCanvas()->Update(); gVirtualX->SetFillColor(1); h_2d->Draw(); screen->GetCanvas()->Update(); sleep(3); h_2d->Add(h_2d,2); gVirtualX->SetFillColor(1); h_2d->Draw(); screen->GetCanvas()->Update(); } }