#include #include #include #include #include #include #include #include #include #include #include #include #include #include "TGLPerspectiveCamera.h" #include "TGLOrthoCamera.h" #include "TTimer.h" #include "TVirtualPad.h" class MyMainFrame { RQ_OBJECT("MyMainFrame") private: TGMainFrame *fMain; public: MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h); virtual ~MyMainFrame(); }; MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { gStyle->SetCanvasPreferGL(1); TGeoManager * geom =new TGeoManager("world","test"); TGeoMaterial * mat = new TGeoMaterial("space",0,0,0); TGeoMaterial *Fe = new TGeoMaterial("Fe",55.84,26.7,7.87); TGeoMedium *med = new TGeoMedium("medium",0,mat); TGeoMedium *Iron = new TGeoMedium("Iron",1,Fe); TGeoVolume * top = geom->MakeBox("Top",med,10.,10.,10.); geom->SetTopVolume(top); TGeoTube *zhong=new TGeoTube("zhong",58,60,50); TGeoEltu *shang=new TGeoEltu("shang",60,60,2); TGeoEltu *xia=new TGeoEltu("xia",60,60,2); TGeoBBox *kong=new TGeoBBox("kong",50,50,50); TGeoRotation *r1 = new TGeoRotation("r1",0,90,0); r1->RegisterYourself(); TGeoTranslation *t1 = new TGeoTranslation("t1",0,0,52); t1->RegisterYourself(); TGeoTranslation *t2 = new TGeoTranslation("t2",0,0,-52); t2->RegisterYourself(); TGeoTranslation *t3 = new TGeoTranslation("t3",50,50,50); t3->RegisterYourself(); TGeoCompositeShape *detector=new TGeoCompositeShape("detector", "((zhong+shang:t1+xia:t2)-(kong:t3)):r1"); TGeoVolume *comp = new TGeoVolume("COMP",detector); top->AddNodeOverlap(comp,1); top->Draw("gl"); TGLViewer * v = (TGLViewer *)gPad->GetViewer3D(); v->SetCurrentCamera(TGLViewer::kCameraPerspXOY); TCanvas *fCanvas = gCanvas->GetCanvas(); fCanvas->cd(); gPad->Update(); } MyMainFrame::~MyMainFrame() { fMain->Cleanup(); delete fMain; } void test() { new MyMainFrame(gClient->GetRoot(),200,200); }