12 #include <boost/bind.hpp>
19 #include "TGLScenePad.h"
20 #include "TGLViewer.h"
22 #include "TGLPerspectiveCamera.h"
23 #include "TEveManager.h"
24 #include "TEveElement.h"
26 #include "TEveBoxSet.h"
27 #include "TEveScene.h"
28 #include "TGLLogicalShape.h"
30 #include "TEveCaloData.h"
31 #include "TEveStraightLineSet.h"
43 class TGLClipsiLogical :
public TGLLogicalShape {
45 void DirectDraw(TGLRnrCtx& rnrCtx)
const override {}
48 TGLClipsiLogical() : TGLLogicalShape() {}
49 ~TGLClipsiLogical()
override {}
50 void Resize(Double_t
ext) {}
53 const float fgColor[4] = {1.0, 0.6, 0.2, 0.5};
55 class Clipsi :
public TGLClip {
58 Clipsi(
const Clipsi&) =
delete;
59 Clipsi& operator=(
const Clipsi&) =
delete;
62 TGLVertex3 appexOffset;
65 Clipsi(TGLRnrCtx* ctx) : TGLClip(*new TGLClipsiLogical, TGLMatrix(), fgColor), m_rnrCtx(ctx) {}
68 void Setup(
const TGLBoundingBox& bbox)
override {}
70 void SetPlaneInfo(TEveVector* vec) {
71 for (
int i = 0;
i < 4; ++
i) {
73 vtx[
i].Set(vec[
i].fX + appexOffset.X(), vec[
i].fY + appexOffset.Y(), vec[
i].fZ + appexOffset.Z());
77 void SetAppexOffset(TEveVector& vec) { appexOffset.Set(vec.fX, vec.fY, vec.fZ); }
79 using TGLClip::PlaneSet;
80 void PlaneSet(TGLPlaneSet_t& planeSet)
const override {
81 TGLVertex3
o = appexOffset;
83 planeSet.push_back(TGLPlane(
o,
vtx[0],
vtx[1]));
84 planeSet.push_back(TGLPlane(
o,
vtx[1],
vtx[2]));
85 planeSet.push_back(TGLPlane(
o,
vtx[2],
vtx[3]));
86 planeSet.push_back(TGLPlane(
o,
vtx[3],
vtx[0]));
103 m_showMuonBarrel(this,
"Show Muon Barrel", 0
l, 0
l, 2
l),
104 m_showMuonEndcap(this,
"Show Muon Endcap",
false),
105 m_showPixelBarrel(this,
"Show Pixel Barrel",
false),
106 m_showPixelEndcap(this,
"Show Pixel Endcap",
false),
107 m_showTrackerBarrel(this,
"Show Tracker Barrel",
false),
108 m_showTrackerEndcap(this,
"Show Tracker Endcap",
false),
109 m_showHGCalEE(this,
"Show HGCalEE",
false),
110 m_showHGCalHSi(this,
"Show HGCalHSi",
false),
111 m_showHGCalHSc(this,
"Show HGCalHSc",
false),
112 m_ecalBarrel(nullptr),
113 m_showEcalBarrel(this,
"Show Ecal Barrel",
false),
114 m_rnrStyle(this,
"Render Style", 0
l, 0
l, 2
l),
115 m_selectable(this,
"Enable Tooltips",
false),
116 m_cameraType(this,
"Camera Type", 0
l, 0
l, 5
l),
117 m_clipEnable(this,
"Enable Clip",
false),
118 m_clipTheta(this,
"Clip Theta", 0.0, -5.0, 5.0),
119 m_clipPhi(this,
"Clip Phi", 0.0, -2.0, 2.0),
120 m_clipDelta1(this,
"Clip Delta1", 0.2, 0.01, 2),
121 m_clipDelta2(this,
"Clip Delta2", 0.2, 0.01, 2),
122 m_clipAppexOffset(this,
"Appex Offset", 10
l, 0
l, 50
l),
123 m_clipHGCalLayerBegin(this,
"HGCal Lower Bound", 1
l, 1
l, 52
l),
124 m_clipHGCalLayerEnd(this,
"HGCal Upper Bound", 52
l, 1
l, 52
l),
127 viewerGL()->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
186 TGLClipPlane*
c =
new TGLClipPlane();
187 c->Setup(TGLVector3(1e10, 0, 0), TGLVector3(-1, 0, 0));
208 viewerGL()->RefCamera(TGLViewer::ECameraType(
x)).IncTimeStamp();
209 viewerGL()->SetCurrentCamera(TGLViewer::ECameraType(
x));
226 m_glClip->SetMode(TGLClip::kOutside);
230 for (TEveElement::List_i it = gEve->GetScenes()->BeginChildren(); it != gEve->GetScenes()->EndChildren(); ++it) {
231 if (strncmp((*it)->GetElementName(),
"TopGeoNodeScene", 15) == 0)
232 ((TEveScene*)(*it))->GetGLScene()->SetClip(
x ?
m_glClip :
nullptr);
253 float getBBoxLineLength(TEveScene* scene, TEveVector
in) {
254 if (!scene->NumChildren())
258 scene->GetGLScene()->CalcBoundingBox();
259 const TGLBoundingBox& bb = scene->GetGLScene()->BoundingBox();
268 TGLLine3
line(TGLVertex3(), TGLVertex3(inn.fX, inn.fY, inn.fZ));
269 std::vector<float>
res;
270 for (TGLPlaneSet_i
i = ps.begin();
i != ps.end(); ++
i) {
271 std::pair<Bool_t, TGLVertex3>
r = Intersection(*
i,
line,
false);
273 TGLVector3 vr(
r.second.X(),
r.second.Y(),
r.second.Z());
274 res.push_back(vr.Mag());
277 std::sort(
res.begin(),
res.end());
281 void setBBoxClipped(TGLBoundingBox& bbox, TEveVector
dir, TEveVector
b0, TEveVector
b1,
float fac) {
296 for (
int i = 4;
i < 8; ++
i)
309 for (
int i = 0;
i < 8; ++
i) {
310 bbv[
i].Set(bb[
i].fX, bb[
i].fY, bb[
i].fZ);
322 using namespace TMath;
326 TEveVector normXY(0., 1., 0);
327 TEveVector
b0 =
in.Cross(normXY);
328 TEveVector
b1 =
in.Cross(
b0);
346 for (
int i = 0;
i < 4; ++
i)
349 TEveVector aOff =
in;
353 ((Clipsi*)
m_glClip)->SetAppexOffset(aOff);
355 ((Clipsi*)
m_glClip)->SetPlaneInfo(&
c[0]);
375 TGLCamera& cam =
viewerGL()->CurrentCamera();
376 cam.SetExternalCenter(
true);
377 cam.SetCenterVec(bbox.Center().X(), bbox.Center().Y(), bbox.Center().Z());
378 cam.Setup(bbox,
true);
400 for (
const auto& it : HGCalEE->RefChildren()) {
402 int layer = stoi(
title.substr(
title.length() - 2));
403 it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
409 for (
const auto& it : HGCalHSi->RefChildren()) {
411 int layer = stoi(
title.substr(
title.length() - 2)) + 28;
412 it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
418 for (
const auto& it : HGCalHSc->RefChildren()) {
420 int layer = stoi(
title.substr(
title.length() - 2)) + 28;
421 it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
432 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(
viewerGL()->CurrentCamera()));
442 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(
viewerGL()->CurrentCamera()));
460 printf(
"ERROR!!!! FW3DViewBase::setCurrentDMTVertex \n");
501 Form(
"TEveGedEditor::SpawnNewEditor((TGLViewer*)0x%lx)", (
unsigned long)
viewerGL())));
505 new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
511 std::vector<unsigned int> ids =
513 m_ecalBarrel->Reset(TEveBoxSet::kBT_FreeBox,
true, ids.size());
514 for (std::vector<unsigned int>::iterator it = ids.begin(); it != ids.end(); ++it) {
530 TEveCalo3D* c3d = dynamic_cast<TEveCalo3D*>(
calo);
531 c3d->SetRnrFrame(!
x, !
x);
532 c3d->ElementChanged();