From b43957afd8122a7bcf8c5b0820c10e8bdfff16b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Gy=C3=B6ngy=C3=B6si?= Date: Tue, 31 Oct 2017 22:42:56 +0100 Subject: [PATCH] Modify Plotter to multiple instance capable with multiple canvas --- include/Plotter.hh | 3 +++ src/Plotter.cc | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/Plotter.hh b/include/Plotter.hh index 4522691..2541f5a 100644 --- a/include/Plotter.hh +++ b/include/Plotter.hh @@ -27,11 +27,14 @@ public: void Plot(Int_t numRuns, Int_t nSteps, std::vector t, std::vector x); TMultiGraph * GetTmultiGraph(); + static unsigned int IDCounter; + private: bool draw; TMultiGraph *mg; TGraph* g1; TCanvas* canv; Double_t tl,xl; + unsigned int ID; }; #endif diff --git a/src/Plotter.cc b/src/Plotter.cc index 0e91212..8426dcf 100644 --- a/src/Plotter.cc +++ b/src/Plotter.cc @@ -1,13 +1,17 @@ #include "Plotter.hh" +unsigned int Plotter::IDCounter = 0; + Plotter::Plotter(bool draw_par = false) { draw = draw_par; +ID = IDCounter++; if(draw) { - canv = new TCanvas("canc","display",800,400); + char str[30]; + snprintf(str, 30, "Plotter_canvas%d", ID); + canv = new TCanvas(str, "display",800,400); } -//g1 = new TGraph(); mg = new TMultiGraph(); } @@ -24,17 +28,15 @@ TMultiGraph * Plotter::GetTmultiGraph() void Plotter::Plot(Int_t numRuns, Int_t nSteps, std::vector t, std::vector x) { - mg->SetTitle("BM1D"); + char str[30]; + snprintf(str, 30, "BM1D Plotter canvas%d", ID); + mg->SetTitle(str); for(int i= 0; i < numRuns; i++) { g1 = new TGraph(nSteps,&t[i*nSteps],&x[i*nSteps]); g1->SetLineColor(i%30+1); - //g1->SetTitle("Brownian Movement"); - //g1->GetYaxis()->SetTitle("X"); - //g1->GetXaxis()->SetTitle("Time"); g1->SetLineWidth(2); - //g1->SetMarkerColor(1); g1->SetMarkerStyle(1); mg -> Add(g1);