// gROOT->Reset(); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class MyMainFrame { RQ_OBJECT("MyMainFrame") private: TGMainFrame *fMain; TRootEmbeddedCanvas *fEcanvas; TGVerticalFrame *fF1; TGLayoutHints *fL1, *fL2; TGNumberEntry *fNumericEntries[3]; TGHorizontalFrame *fF[3]; TGLabel *fLabel[3]; public: MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h); virtual ~MyMainFrame(); void DoDraw(); }; const Double_t numinit[] = { 0.5, 0.1, -40 }; const char *numlabel[] = { "A", "K", "D" }; MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { // Create a main frame fMain = new TGMainFrame(p,w,h); // Create canvas widget fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,w,h); fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY, 10,10,10,1)); // Create a horizontal frame widget with buttons fF1 = new TGVerticalFrame(fMain, 200, 300); fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2); fMain->AddFrame(fF1, fL1); fL2 = new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 2, 2, 2); for (int i = 0; i < 3; i++) { fF[i] = new TGHorizontalFrame(fF1, 200, 30); fF1->AddFrame(fF[i], fL2); fNumericEntries[i] = new TGNumberEntry(fF[i], numinit[i], 12, i + 20,(TGNumberFormat::EStyle) 5); fNumericEntries[i]->Connect("ValueSet(Long_t)", "MyMainFrame", this, "DoDraw()"); fF[i]->AddFrame(fNumericEntries[i], fL2); fLabel[i] = new TGLabel(fF[i], numlabel[i]); fF[i]->AddFrame(fLabel[i], fL2); } //cout<< fNumericEntries[0]->GetNumStyle()<<" "<GetNumber()<<" "<GetNumber()<SetFormat((TGNumberFormat::EStyle)5); cout<< fNumericEntries[0]->GetNumStyle()<<" "<GetNumber()<<" "<GetNumber()<Connect("Clicked()","MyMainFrame",this,"DoDraw()"); hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); TGTextButton *exit = new TGTextButton(hframe,"&Exit", "gApplication->Terminate(0)"); hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2)); // Set a name to the main frame fMain->SetWindowName("Simple Example"); // Map all subwindows of main frame fMain->MapSubwindows(); // Initialize the layout algorithm fMain->Resize(fMain->GetDefaultSize()); // Map main frame fMain->MapWindow(); } void MyMainFrame::DoDraw() { // Draws function graphics in randomly choosen interval TCanvas *fCanvas = fEcanvas->GetCanvas(); fCanvas->Clear(); Int_t n = 50; Double_t x[50],y[50], v = -80; for(Int_t i=0; iGetNumber() * exp(fNumericEntries[1]->GetNumber() * (x[i] - fNumericEntries[2]->GetNumber())); //y[i] = 0.5 * exp(0.1 * (x[i] + 50 )); } TGraph *T1 = new TGraph(n, x,y); T1->Draw("AC"); fCanvas->cd(); fCanvas->Update(); } MyMainFrame::~MyMainFrame() { // Clean up used widgets: frames, buttons, layouthints fMain->Cleanup(); delete fMain; } //void plot() { // Popup the GUI... // new MyMainFrame(gClient->GetRoot(),500,500); //} void plot() { new MyMainFrame(0, 400, 220); } //---- Main program ------------------------------------------------------------ #ifdef STANDALONE int main(int argc, char **argv) { TApplication theApp("App", &argc, argv); if (gROOT->IsBatch()) { fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]); return 1; } guitest(); theApp.Run(); return 0; }