#include #include "TFile.h" #include "TTree.h" #include "TCanvas.h" #include "TImage.h" #include "TMath.h" #include "TH1F.h" #include "TH2F.h" #include "TObject.h" #include "TPad.h" #include "TStyle.h" #include "TSystem.h" #include "TGeoManager.h" #include "TGeoMatrix.h" #include "TVector3.h" #include "TColor.h" #include "TGeoCompositeShape.h" #include "TGeoBBox.h" #include "TGLViewer.h" #include "TVirtualGL.h" #include "TGLPerspectiveCamera.h" #include "TGraph.h" #include #include #include #include #include #include #include #include #include #include "TGLAnnotation.h" using namespace std; void neuro_graphical() { char OutputFile[200]="C:\Users\nvashkev\My_Projects\CAA_Model_Project\neuro\data\root_files"; //all it does is save the histogram char imfolder[200]="C:\Users\nvashkev\My_Projects\CAA_Model_Project\neuro\data\run_images"; //must end in "/" //////////////////////////////////// ROOT PREP ///////////////////////////////////////////////// gROOT->SetStyle("Plain"); gStyle->SetOptStat(kFALSE); TFile * DATAFILE = (TFile *) gROOT->FindObject(OutputFile); if(DATAFILE) DATAFILE->Close(); DATAFILE = new TFile(OutputFile,"RECREATE"); TH1F * structure_sizes=new TH1F("structure_sizes","Histogram of Bleed Sizes;Number of Pixels (natural log);Counts",24,0,12); TCanvas * c2 = new TCanvas ("c2","c2"); structure_sizes->Draw(); ////////////////////////////////// OPENGL PREP //////////////////////////////////////////////// // Setup environment and box objects cout << "\nSetting up OpenGL"<Load("libGeom"); TGeoManager * geom = new TGeoManager("boxtest", "Test of building boxes for neurons!"); TGeoMaterial *matEmptySpace = new TGeoMaterial("EmptySpace", 0, 0, 0); TGeoMaterial *matBox = new TGeoMaterial("Box" , 0, 0, 0); TGeoMaterial *transBox = new TGeoMaterial("Box" , 0, 0, 0); transBox->SetTransparency(100); TGeoMedium *EmptySpace = new TGeoMedium("Empty", 1, matEmptySpace); TGeoMedium *medBox = new TGeoMedium("medBox", 1, matBox); TGeoMedium *transMedBox= new TGeoMedium("transMedBox",1, transBox); TGeoVolume *top = geom->MakeBox("WORLD", EmptySpace, brainsize, brainsize, brainsize); geom->SetTopVolume(top); TGeoVolume * redBox = geom->MakeBox("redBox",medBox,0.5,0.5,0.5); redBox->SetLineColor(kRed); TGeoVolume * blueBox = geom->MakeBox("blueBox",medBox,0.5,0.5,0.5); blueBox->SetLineColor(kBlue); TGeoBBox *bigBox = new TGeoBBox("bigBox",viewsize,viewsize,viewsize); TGeoVolume * comp = new TGeoVolume("COMP",bigBox); comp->SetMedium(transMedBox); top->AddNode(comp,0); geom->SetVisLevel(0); top->Draw("ogl"); int num_boxes=0; // Setup colors for the boxes gStyle->SetPalette(1); TGeoVolume * coloredBox[ncolors]; char boxName[200]; TVector3 col1(260,260,260); //change if you want to alter box colors TVector3 col2(0,0,200); double temp_xyz[3]; string opti; int nimg=0; for (int i=0;iMakeBox(boxName,medBox,0.5,0.5,0.5); col.SetMag(col.Mag()/double(ncolors)*double(i+1)); col.GetXYZ(temp_xyz); for (int j=0;j<3;j++) temp_xyz[j]+=col2[j]; sprintf(boxName,"boxcolor_%i",i); coloredBox[i]=geom->MakeBox(boxName,medBox,0.5,0.5,0.5); coloredBox[i]->SetLineColor(TColor::GetColor(int(temp_xyz[0]),int(temp_xyz[1]),int(temp_xyz[2]))); } // Final setup, including annotation TGLViewer * view = (TGLViewer*)gPad->GetViewer3D();; char annName[200]; sprintf(annName,"Bleed #%i, Size %i",1,1); TGLAnnotation * ann = new TGLAnnotation(view,annName,0.05,0.95); ann->SetTextSize(0.05); view->SetViewport(0,0,600,600); //may need to change if view problems cout<<"End Test"<