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);
188 TGLClipPlane*
c =
new TGLClipPlane();
189 c->Setup(TGLVector3(1e10, 0, 0), TGLVector3(-1, 0, 0));
210 viewerGL()->RefCamera(TGLViewer::ECameraType(
x)).IncTimeStamp();
211 viewerGL()->SetCurrentCamera(TGLViewer::ECameraType(
x));
228 m_glClip->SetMode(TGLClip::kOutside);
232 for (TEveElement::List_i it = gEve->GetScenes()->BeginChildren(); it != gEve->GetScenes()->EndChildren(); ++it) {
233 if (strncmp((*it)->GetElementName(),
"TopGeoNodeScene", 15) == 0)
234 ((TEveScene*)(*it))->GetGLScene()->SetClip(
x ?
m_glClip :
nullptr);
255 float getBBoxLineLength(TEveScene* scene, TEveVector
in) {
256 if (!scene->NumChildren())
260 scene->GetGLScene()->CalcBoundingBox();
261 const TGLBoundingBox& bb = scene->GetGLScene()->BoundingBox();
270 TGLLine3
line(TGLVertex3(), TGLVertex3(inn.fX, inn.fY, inn.fZ));
271 std::vector<float>
res;
272 for (TGLPlaneSet_i
i = ps.begin();
i != ps.end(); ++
i) {
273 std::pair<Bool_t, TGLVertex3>
r = Intersection(*
i,
line,
false);
275 TGLVector3 vr(
r.second.X(),
r.second.Y(),
r.second.Z());
276 res.push_back(vr.Mag());
283 void setBBoxClipped(TGLBoundingBox& bbox, TEveVector
dir, TEveVector
b0, TEveVector
b1,
float fac) {
298 for (
int i = 4;
i < 8; ++
i)
311 for (
int i = 0;
i < 8; ++
i) {
312 bbv[
i].Set(bb[
i].fX, bb[
i].fY, bb[
i].fZ);
324 using namespace TMath;
328 TEveVector normXY(0., 1., 0);
329 TEveVector
b0 =
in.Cross(normXY);
330 TEveVector
b1 =
in.Cross(
b0);
348 for (
int i = 0;
i < 4; ++
i)
351 TEveVector aOff =
in;
355 ((Clipsi*)
m_glClip)->SetAppexOffset(aOff);
357 ((Clipsi*)
m_glClip)->SetPlaneInfo(&
c[0]);
377 TGLCamera& cam =
viewerGL()->CurrentCamera();
378 cam.SetExternalCenter(
true);
379 cam.SetCenterVec(bbox.Center().X(), bbox.Center().Y(), bbox.Center().Z());
380 cam.Setup(bbox,
true);
402 for (
const auto& it : HGCalEE->RefChildren()) {
405 it->SetRnrState(
layer >= r_lmin &&
layer <= r_lmax);
411 for (
const auto& it : HGCalHSi->RefChildren()) {
414 it->SetRnrState(
layer >= r_lmin &&
layer <= r_lmax);
420 for (
const auto& it : HGCalHSc->RefChildren()) {
423 it->SetRnrState(
layer >= r_lmin &&
layer <= r_lmax);
434 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(
viewerGL()->CurrentCamera()));
444 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(
viewerGL()->CurrentCamera()));
462 printf(
"ERROR!!!! FW3DViewBase::setCurrentDMTVertex \n");
503 Form(
"TEveGedEditor::SpawnNewEditor((TGLViewer*)0x%lx)", (
unsigned long)
viewerGL())));
507 new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
513 std::vector<unsigned int> ids =
515 m_ecalBarrel->Reset(TEveBoxSet::kBT_FreeBox,
true, ids.size());
516 for (std::vector<unsigned int>::iterator it = ids.begin(); it != ids.end(); ++it) {
532 TEveCalo3D* c3d = dynamic_cast<TEveCalo3D*>(
calo);
533 c3d->SetRnrFrame(!
x, !
x);
534 c3d->ElementChanged();