Modify Plotter to multiple instance capable with multiple canvas
This commit is contained in:
parent
25167e2d62
commit
b43957afd8
|
@ -27,11 +27,14 @@ public:
|
||||||
void Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x);
|
void Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x);
|
||||||
TMultiGraph * GetTmultiGraph();
|
TMultiGraph * GetTmultiGraph();
|
||||||
|
|
||||||
|
static unsigned int IDCounter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool draw;
|
bool draw;
|
||||||
TMultiGraph *mg;
|
TMultiGraph *mg;
|
||||||
TGraph* g1;
|
TGraph* g1;
|
||||||
TCanvas* canv;
|
TCanvas* canv;
|
||||||
Double_t tl,xl;
|
Double_t tl,xl;
|
||||||
|
unsigned int ID;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
#include "Plotter.hh"
|
#include "Plotter.hh"
|
||||||
|
|
||||||
|
unsigned int Plotter::IDCounter = 0;
|
||||||
|
|
||||||
Plotter::Plotter(bool draw_par = false)
|
Plotter::Plotter(bool draw_par = false)
|
||||||
{
|
{
|
||||||
draw = draw_par;
|
draw = draw_par;
|
||||||
|
ID = IDCounter++;
|
||||||
if(draw)
|
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();
|
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)
|
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++)
|
for(int i= 0; i < numRuns; i++)
|
||||||
{
|
{
|
||||||
g1 = new TGraph(nSteps,&t[i*nSteps],&x[i*nSteps]);
|
g1 = new TGraph(nSteps,&t[i*nSteps],&x[i*nSteps]);
|
||||||
g1->SetLineColor(i%30+1);
|
g1->SetLineColor(i%30+1);
|
||||||
//g1->SetTitle("Brownian Movement");
|
|
||||||
//g1->GetYaxis()->SetTitle("X");
|
|
||||||
//g1->GetXaxis()->SetTitle("Time");
|
|
||||||
g1->SetLineWidth(2);
|
g1->SetLineWidth(2);
|
||||||
//g1->SetMarkerColor(1);
|
|
||||||
g1->SetMarkerStyle(1);
|
g1->SetMarkerStyle(1);
|
||||||
|
|
||||||
mg -> Add(g1);
|
mg -> Add(g1);
|
||||||
|
|
Loading…
Reference in New Issue