#include #include #include #include #include #include #include #include #include #include #include #include #include /* Parse input string */ vector splitString(const std::string& str, const char* separator) { vector result; string::size_type prev_pos=0; string::size_type pos=0; while ((pos = str.find_first_of(separator, prev_pos)) != string::npos) { if (prev_pos < pos) { result.push_back(str.substr(prev_pos, pos-prev_pos)); } prev_pos = pos + 1; } if (prev_pos < str.size()) { result.push_back(str.substr(prev_pos)); } return result; } /* Create and Draw a TGraph2D with 2 points to define the axes Then add TPolyMarker3D points */ void demo1(string infile){ TGraph2D *graph = new TGraph2D(); graph->SetPoint(0, -1,-1,-1); graph->SetPoint(1, 4, 4, 4); graph->SetMarkerStyle(20); TCanvas *c1 = new TCanvas("demo1", "Draw Markers", 0, 0, 500, 500); c1->cd(); graph->SetTitle("Draw Markers"); graph->Draw("p"); vector markers; ifstream in(infile.c_str()); if(!in.is_open()){ cerr<<"couldn't open "< splits = splitString(str, " "); float x = atof(splits[0].c_str()); float y = atof(splits[1].c_str()); float z = atof(splits[2].c_str()); cout<SetMarkerStyle(20); markers.back()->SetMarkerColor(2); markers.back()->Draw(); delete vals; vals=NULL; } gPad->Modified(); gPad->Update(); in.close(); } /* Create a TGraph2D using the TGraph2D constructor */ void demo2(string infile){ TCanvas *c1 = new TCanvas("demo2", "Draw From Constructor", 500, 0, 500, 500); c1->cd(); ifstream in(infile.c_str()); if(!in.is_open()){ cerr<<"couldn't open "< splits = splitString(str, " "); float x = atof(splits[0].c_str()); float y = atof(splits[1].c_str()); float z = atof(splits[2].c_str()); cout<SetTitle("Draw From Constructor"); graph->SetMarkerStyle(20); graph->SetMarkerColor(2); graph->Draw("p"); in.close(); delete [] X; delete [] Y; delete [] Z; } void runDemos(string infile){ demo1(infile); demo2(infile); }