-
Notifications
You must be signed in to change notification settings - Fork 0
/
TCmdDraw.cc
84 lines (71 loc) · 2.35 KB
/
TCmdDraw.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* @file TCmdDraw.cc
* @brief
* @author Kodai Okawa<okawa@cns.s.u-tokyo.ac.jp>
* @date 2024-06-13 18:57:52
* @note
*/
#include "TCmdDraw.h"
#include <TCatHistManager.h>
#include <TCatPadManager.h>
#include <TF1.h>
#include <TLine.h>
#include <TPad.h>
#include <TROOT.h>
#include <TView3D.h>
#include <TH1.h>
#include <TH2.h>
using art::TCmdDraw;
ClassImp(TCmdDraw);
const char *TCmdDraw::kFuncNameBase = "f";
const char *TCmdDraw::kLabelNameBase = "l";
TCmdDraw::TCmdDraw() {
SetName("draw");
SetTitle("drawing object");
}
TCmdDraw::~TCmdDraw() {}
Long_t TCmdDraw::Cmd(vector<TString> tokens) {
Int_t n = tokens.size();
Int_t id;
if (n == 1) {
id = TCatHistManager::Instance()->GetId();
} else {
id = tokens[1].Atoi();
}
TObject *obj = TCatHistManager::Instance()->GetObject(id);
if (obj && (obj->InheritsFrom("TH1"))) {
TCatPadManager::Instance()->GetCanvas();
TCatHistManager::Instance()->DrawObject(id, tokens.size() > 2 ? tokens[2] : "");
return 1;
} else if (obj->InheritsFrom("TGraph")) {
TCatPadManager::Instance()->GetCanvas();
TCatHistManager::Instance()->DrawObject(id, tokens.size() > 2 ? tokens[2] : "ap");
return 1;
} else if (obj->InheritsFrom("TMultiGraph")) {
TCatPadManager::Instance()->GetCanvas();
TCatHistManager::Instance()->DrawObject(id, tokens.size() > 2 ? tokens[2] : "ap");
gPad->BuildLegend(0.78, 0.70, 0.95, 0.95, "", "p");
return 1;
//} else if (obj->InheritsFrom("TCanvas")) {
// TCatPadManager::Instance()->GetCanvas();
// TCatHistManager::Instance()->DrawObject(id, tokens.size() > 2 ? tokens[2] : "ap");
// return 1;
} else if (obj && obj->InheritsFrom("TGeoVolume")) {
TCatPadManager::Instance()->GetCanvas();
TView3D *vw1 = (TView3D *)TView::CreateView(1);
vw1->SetRange(-500., -500., -500., 500., 500., 500.);
vw1->SetPerspective();
vw1->ShowAxis();
TCatHistManager::Instance()->DrawObject(id, tokens.size() > 2 ? tokens[2] : "same");
gPad->Update();
return 1;
} else {
std::cout << "Invalid object" << std::endl;
}
return 1;
}
void TCmdDraw::Help() {
std::cout << "almost same with ht command"
<< "(to draw not TH1 object)"
<< std::endl;
}