-
Notifications
You must be signed in to change notification settings - Fork 1
/
pointTest.C
128 lines (101 loc) · 3.11 KB
/
pointTest.C
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/// \file
/// \ingroup tutorial_eve7
/// This example display only points in web browser
///
/// \macro_code
///
#include "TRandom.h"
#include <ROOT/REveElement.hxx>
#include <ROOT/REveScene.hxx>
#include <ROOT/REveManager.hxx>
#include <ROOT/REvePointSet.hxx>
using namespace ROOT::Experimental;
REvePointSet *createPointSet(int npoints = 100, float s = 200, int color = 28)
{
TRandom &r = *gRandom;
REvePointSet *ps = new REvePointSet("MyTestPoints", "list of eve points", npoints);
for (Int_t i = 0; i < npoints; ++i)
ps->SetNextPoint(r.Uniform(-s, s), r.Uniform(-s, s), r.Uniform(-s, s));
ps->SetMarkerColor(color);
ps->SetMarkerSize(3 + r.Uniform(1, 2));
ps->SetMarkerStyle(4);
const Double_t kR_min = 240;
const Double_t kR_max = 250;
const Double_t kZ_d = 300;
auto jet = new REveJetCone();
jet->SetCylinder(2 * kR_max, 2 * kZ_d);
jet->AddEllipticCone(r.Uniform(-0.5, 0.5), r.Uniform(0, TMath::TwoPi()),
0.1, 0.2);
jet->SetFillColor(kRed);
jet->SetLineColor(kRed);
ps->AddElement(jet);
return ps;
}
// -----------------------------------------------
class EventManager : public REveElement
{
private:
bool m_autoplay{false};
int run{100};
int lumi{200};
int event{300};
public:
void autoplay(bool x)
{
std::cout << "EventMaanger autoplay() ....... " << x << std::endl;
}
void playdelay(float x)
{
printf("EventManager playdelay() %f .... \n", x);
}
void goToRunEvent(int runId, int eventId, int lumiId)
{
printf("Got to event %d %d %d\n", runId, eventId, lumiId);
run = runId;
event = eventId;
lumi = lumiId;
StampObjProps();
}
void FileDialogSaveAs(char *path)
{
printf("dialog path %s \n", path);
}
void NextEvent()
{
auto es = gEve->GetEventScene();
es->DestroyElements();
es->AddElement(createPointSet());
event++;
printf("EventManager::NextEvent event = %d\n", event);
StampObjProps(); // stamp to stream changes
}
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
{
Int_t ret = REveElement::WriteCoreJson(j, rnr_offset);
j["UT_PostStream"] = "UT_refresh_event_info"; // this defines GUI callback on the client
j["run"] = run;
j["lumi"] = lumi;
j["event"] = event;
std::cout << "json dump " << j.dump(3) << "\n";
return ret;
}
};
//----------------------------------------------
void pointTest()
{
auto eveMng = REveManager::Create();
// disable unique auth key for dec purposes
eveMng->AllowMultipleRemoteConnections(false, false);
gEnv->SetValue("WebGui.HttpPort", 7799);
std::string locPath = "ui5";
eveMng->AddLocation("mydir/", locPath);
eveMng->SetDefaultHtmlPage("file:mydir/eventDisplay.html");
auto eventMng = new EventManager();
eventMng->SetNameTitle("EventManager", "Event Manager GUI");
REveElement *event = eveMng->GetEventScene();
auto ps = createPointSet(100);
event->AddElement(ps);
// Add EventManager as the last in the EveWorld
eveMng->GetWorld()->AddElement(eventMng);
eveMng->Show();
}