Modify Plotter to multiple instance capable with multiple canvas

This commit is contained in:
Balázs Gyöngyösi 2017-10-31 22:42:56 +01:00
parent 25167e2d62
commit b43957afd8
2 changed files with 12 additions and 7 deletions

View File

@ -27,11 +27,14 @@ public:
void Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x);
TMultiGraph * GetTmultiGraph();
static unsigned int IDCounter;
private:
bool draw;
TMultiGraph *mg;
TGraph* g1;
TCanvas* canv;
Double_t tl,xl;
unsigned int ID;
};
#endif

View File

@ -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<Double_t> t, std::vector<Double_t> 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);