#include #include #include #include #include #include #include #include "ged.h" #include "eventDisplay.h" using namespace std; 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,200,200); fCanvas = fEcanvas->GetCanvas(); fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY, 10,10,10,1)); // Create a horizontal frame widget with buttons TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40); // next event TGTextButton *draw = new TGTextButton(hframe,"&Draw"); draw->Connect("Clicked()","MyMainFrame",this,"DoDraw()"); hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // zoom in TGTextButton *zoomIn = new TGTextButton(hframe,"&Zoom In"); zoomIn->Connect("Clicked()","MyMainFrame",this,"DoZoomIn()"); hframe->AddFrame(zoomIn, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // zoom out TGTextButton *zoomOut = new TGTextButton(hframe,"&Zoom Out"); zoomOut->Connect("Clicked()","MyMainFrame",this,"DoZoomOut()"); hframe->AddFrame(zoomOut, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // pan positive x TGTextButton *panXP = new TGTextButton(hframe,"&panXP"); panXP->Connect("Clicked()","MyMainFrame",this,"DoPanXP()"); hframe->AddFrame(panXP, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // pan negative x TGTextButton *panXM = new TGTextButton(hframe,"&panXM"); panXM->Connect("Clicked()","MyMainFrame",this,"DoPanXM()"); hframe->AddFrame(panXM, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // pan positive y TGTextButton *panYP = new TGTextButton(hframe,"&panYP"); panYP->Connect("Clicked()","MyMainFrame",this,"DoPanYP()"); hframe->AddFrame(panYP, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // pan negative y TGTextButton *panYM = new TGTextButton(hframe,"&panYM"); panYM->Connect("Clicked()","MyMainFrame",this,"DoPanYM()"); hframe->AddFrame(panYM, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // pan positive z TGTextButton *panZP = new TGTextButton(hframe,"&panZP"); panZP->Connect("Clicked()","MyMainFrame",this,"DoPanZP()"); hframe->AddFrame(panZP, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // pan negative z TGTextButton *panZM = new TGTextButton(hframe,"&panZM"); panZM->Connect("Clicked()","MyMainFrame",this,"DoPanZM()"); hframe->AddFrame(panZM, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // exit 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() { ed.readAndDraw(); fCanvas->Update(); } void MyMainFrame::DoZoomIn() { ed.doZoomIn(); } void MyMainFrame::DoZoomOut() { ed.doZoomOut(); } void MyMainFrame::DoPanXP() { ed.doPanXP(); } void MyMainFrame::DoPanXM() { ed.doPanXM(); } void MyMainFrame::DoPanYP() { ed.doPanYP(); } void MyMainFrame::DoPanYM() { ed.doPanYM(); } void MyMainFrame::DoPanZP() { ed.doPanZP(); } void MyMainFrame::DoPanZM() { ed.doPanZM(); } MyMainFrame::~MyMainFrame() { // Clean up used widgets: frames, buttons, layouthints fMain->Cleanup(); delete fMain; } void createTheMainFrame() { // Popup the GUI... new MyMainFrame(gClient->GetRoot(),200,200); } int main(int argc, char **argv) { TApplication theApp("App",&argc,argv); createTheMainFrame(); theApp.Run(); return 0; }