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
46 void DirectDraw(TGLRnrCtx & rnrCtx)
const override{}
49 TGLClipsiLogical() : TGLLogicalShape() {}
50 ~TGLClipsiLogical()
override {}
51 void Resize(Double_t
ext){}
54 const float fgColor[4] = { 1.0, 0.6, 0.2, 0.5 };
56 class Clipsi :
public TGLClip
60 Clipsi(
const Clipsi&) =
delete;
61 Clipsi& operator=(
const Clipsi&) =
delete;
64 TGLVertex3 appexOffset;
67 Clipsi(TGLRnrCtx* ctx):TGLClip(* new TGLClipsiLogical, TGLMatrix(), fgColor), m_rnrCtx(ctx){}
70 void Setup(
const TGLBoundingBox & bbox)
override {}
72 void SetPlaneInfo(TEveVector* vec)
74 for (
int i = 0;
i < 4; ++
i) {
76 vtx[
i].Set(vec[
i].fX + appexOffset.X(), vec[
i].fY + appexOffset.Y(), vec[
i].fZ + appexOffset.Z());
80 void SetAppexOffset(TEveVector& vec)
82 appexOffset.Set(vec.fX, vec.fY, vec.fZ);
86 using TGLClip::PlaneSet;
87 void PlaneSet(TGLPlaneSet_t & planeSet)
const override 89 TGLVertex3
o = appexOffset;
91 planeSet.push_back(TGLPlane(o, vtx[0], vtx[1]));
92 planeSet.push_back(TGLPlane(o, vtx[1], vtx[2]));
93 planeSet.push_back(TGLPlane(o, vtx[2], vtx[3]));
94 planeSet.push_back(TGLPlane(o, vtx[3], vtx[0]));
111 m_showMuonBarrel(this,
"Show Muon Barrel", 0
l, 0
l, 2
l ),
112 m_showMuonEndcap(this,
"Show Muon Endcap",
false ),
113 m_showPixelBarrel(this,
"Show Pixel Barrel",
false ),
114 m_showPixelEndcap(this,
"Show Pixel Endcap",
false),
115 m_showTrackerBarrel(this,
"Show Tracker Barrel",
false ),
116 m_showTrackerEndcap(this,
"Show Tracker Endcap",
false),
117 m_showHGCalEE(this,
"Show HGCalEE",
false),
118 m_showHGCalHSi(this,
"Show HGCalHSi",
false),
119 m_showHGCalHSc(this,
"Show HGCalHSc",
false),
121 m_showEcalBarrel(this,
"Show Ecal Barrel",
false),
122 m_rnrStyle(this,
"Render Style", 0
l, 0
l, 2
l),
123 m_selectable(this,
"Enable Tooltips",
false),
124 m_cameraType(this,
"Camera Type", 0
l, 0
l, 5
l),
125 m_clipEnable(this,
"Enable Clip",
false),
126 m_clipTheta(this,
"Clip Theta", 0.0, -5.0, 5.0),
127 m_clipPhi(this,
"Clip Phi", 0.0, -2.0, 2.0),
128 m_clipDelta1(this,
"Clip Delta1", 0.2, 0.01, 2),
129 m_clipDelta2(this,
"Clip Delta2", 0.2, 0.01, 2),
130 m_clipAppexOffset(this,
"Appex Offset", 10
l, 0
l, 50
l),
131 m_clipHGCalLayerBegin(this,
"HGCal Lower Bound", 1
l, 1
l, 52
l),
132 m_clipHGCalLayerEnd(this,
"HGCal Upper Bound", 52
l, 1
l, 52
l),
136 viewerGL()->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
200 TGLClipPlane*
c=
new TGLClipPlane();
201 c->Setup(TGLVector3(1e10,0,0), TGLVector3(-1,0,0));
226 viewerGL()->RefCamera(TGLViewer::ECameraType(x)).IncTimeStamp();
227 viewerGL()->SetCurrentCamera(TGLViewer::ECameraType(x));
236 geoScene()->GetGLScene()->SetStyle(x);
244 geoScene()->GetGLScene()->SetSelectable(x);
252 m_glClip->SetMode(TGLClip::kOutside);
256 for (TEveElement::List_i it =gEve->GetScenes()->BeginChildren(); it != gEve->GetScenes()->EndChildren(); ++it )
258 if (strncmp((*it)->GetElementName(),
"TopGeoNodeScene", 15) == 0)
259 ((TEveScene*)(*it))->GetGLScene()->SetClip(x ? m_glClip :
nullptr);
261 eventScene()->GetGLScene()->SetClip(x ? m_glClip :
nullptr);
274 int thetaInt = theta*
base;
275 int phiInt = phi*
base;
282 float getBBoxLineLength(TEveScene* scene, TEveVector
in)
284 if (!scene->NumChildren())
return 0;
287 scene->GetGLScene()->CalcBoundingBox();
288 const TGLBoundingBox& bb = scene->GetGLScene()->BoundingBox();
289 if (bb.IsEmpty())
return 0;
291 TGLPlaneSet_t ps; bb.PlaneSet(ps);
292 TEveVector inn =
in; inn.Normalize();
294 TGLLine3
line(TGLVertex3(), TGLVertex3(inn.fX, inn.fY, inn.fZ));
295 std::vector<float>
res;
296 for (TGLPlaneSet_i
i = ps.begin();
i!= ps.end(); ++
i)
298 std::pair<Bool_t, TGLVertex3>
r = Intersection(*
i, line,
false);
300 TGLVector3 vr(r.second.X(), r.second.Y(), r.second.Z());
301 res.push_back(vr.Mag());
308 void setBBoxClipped(TGLBoundingBox& bbox, TEveVector
dir, TEveVector b0, TEveVector b1,
float fac)
315 bb[0] += b0; bb[0] += b1;
316 bb[1] -= b0; bb[1] += b1;
317 bb[2] -= b0; bb[2] -= b1;
318 bb[3] += b0; bb[3] -= b1;
320 for (
int i = 4;
i < 8; ++
i)
323 bb[0+4] += b0; bb[0+4] += b1;
324 bb[1+4] -= b0; bb[1+4] += b1;
325 bb[2+4] -= b0; bb[2+4] -= b1;
326 bb[3+4] += b0; bb[3+4] -= b1;
329 for (
int i = 0;
i < 8; ++
i) {
330 bbv[
i].Set(bb[
i].fX, bb[
i].fY, bb[
i].fZ);
345 using namespace TMath;
346 TEveVector
in(Sin(theta)*Cos(phi), Sin(theta)*Sin(phi), Cos(theta));
349 TEveVector normXY(0., 1., 0);
350 TEveVector b0 = in.Cross(normXY);
351 TEveVector b1 = in.Cross(b0);
361 c[0] += b0; c[0] += b1;
362 c[1] -= b0; c[1] += b1;
363 c[2] -= b0; c[2] -= b1;
364 c[3] += b0; c[3] -= b1;
365 for (
int i = 0;
i < 4; ++
i)
368 TEveVector aOff =
in; aOff.NegateXYZ();
370 ((Clipsi*)
m_glClip)->SetAppexOffset(aOff);
373 ((Clipsi*)
m_glClip)->SetPlaneInfo(&c[0]);
377 float es = getBBoxLineLength(
eventScene(), in);
379 setBBoxClipped(bbox, in, b0, b1,
TMath::Max(es, gs));
394 TGLCamera& cam =
viewerGL()->CurrentCamera();
395 cam.SetExternalCenter(
true);
396 cam.SetCenterVec(bbox.Center().X(), bbox.Center().Y(), bbox.Center().Z());
397 cam.Setup(bbox,
true);
422 for (
const auto & it : HGCalEE->RefChildren()){
424 int layer = stoi(
title.substr(
title.length() - 2));
425 it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
431 for (
const auto & it : HGCalHSi->RefChildren()){
433 int layer = stoi(
title.substr(
title.length() - 2)) + 28;
434 it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
440 for (
const auto & it : HGCalHSc->RefChildren()){
442 int layer = stoi(
title.substr(
title.length() - 2)) + 28;
443 it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
456 TGLPerspectiveCamera* camera =
dynamic_cast<TGLPerspectiveCamera*
>(&(
viewerGL()->CurrentCamera()));
468 TGLPerspectiveCamera* camera =
dynamic_cast<TGLPerspectiveCamera*
>(&(
viewerGL()->CurrentCamera()));
491 printf(
"ERROR!!!! FW3DViewBase::setCurrentDMTVertex \n");
534 Form(
"TEveGedEditor::SpawnNewEditor((TGLViewer*)0x%lx)", (
unsigned long)
viewerGL())));
544 m_ecalBarrel->Reset(TEveBoxSet::kBT_FreeBox,
true, ids.size() );
545 for (std::vector<unsigned int>::iterator it = ids.begin(); it != ids.end(); ++it) {
559 TEveElement* calo =
eventScene()->FindChild(
"calo barrel");
561 TEveCalo3D* c3d =
dynamic_cast<TEveCalo3D*
>(calo);
562 c3d->SetRnrFrame(!x, !x);
563 c3d->ElementChanged();
FWDoubleParameter m_clipTheta
void updateHGCalVisibility(bool)
void showEcalBarrel(bool)
void showMuonBarrel(long)
FWBoolParameter m_showMuonEndcap
void showMuonBarrel(bool)
void setClip(float eta, float phi)
TEveElementList const *const getHGCalHSc()
const FWGeometry * getGeom() const
FWBoolParameter m_showHGCalEE
FWColorManager * colorManager() const
ViewerParameterGUI & requestTab(const char *)
void showTrackerEndcap(bool)
ViewerParameterGUI & separator()
Geom::Theta< T > theta() const
bool requestGLHandlerPick() const override
unsigned int version() const
void setCurrentDMTVertex(double x, double y, double z)
FWBoolParameter m_showTrackerBarrel
TGLViewer * viewerGL() const
sigc::signal< void, T > changed_
FW3DViewDistanceMeasureTool * m_DMT
void showMuonBarrelFull(bool)
FWDoubleParameter m_clipPhi
void showTrackerBarrel(bool)
void enableSceneClip(bool)
void setGeomTransparency(Color_t idx, bool projectedType)
void showMuonEndcap(bool)
void addTo(FWConfiguration &) const override
FWEnumParameter m_rnrStyle
void updateClipPlanes(bool resetCamera)
FWBoolParameter m_clipEnable
TEveElementList const *const getHGCalHSi()
FWBoolParameter m_showPixelEndcap
FWDoubleParameter m_clipDelta1
bool addEntry(Long_t id, const std::string &txt)
virtual void resetCamera()
base
Make Sure CMSSW is Setup ##.
void setContext(const fireworks::Context &) override
FWLongParameter m_clipHGCalLayerBegin
const std::string & value(unsigned int iIndex=0) const
const fireworks::Context & context()
FWBoolParameter m_showHGCalHSi
const float * getCorners(unsigned int id) const
void setFrom(const FWConfiguration &) override
void setFromPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, const FWConfiguration &)
void showPixelBarrel(bool)
FWBoolParameter m_showHGCalHSc
FWBoolParameter m_showEcalBarrel
ViewerParameterGUI & addParam(const FWParameterBase *)
TGCompositeFrame * getTabContainer()
void showPixelEndcap(bool)
void populateController(ViewerParameterGUI &) const override
void addTo(FWConfiguration &) const override
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
TEveElementList const *const getHGCalEE()
TEveBoxSet * m_ecalBarrel
FWEnumParameter m_showMuonBarrel
FW3DViewBase(TEveWindowSlot *, FWViewType::EType, unsigned int version=8)
FW3DViewGeometry * m_geometry
const FWConfiguration * valueForKey(const std::string &iKey) const
FWBoolParameter m_selectable
FWLongParameter m_clipHGCalLayerEnd
FWEnumParameter m_cameraType
void setFrom(const FWConfiguration &) override
FWLongParameter m_clipAppexOffset
virtual void setContext(const fireworks::Context &x)
FWBoolParameter m_showTrackerEndcap
FWDoubleParameter m_clipDelta2
void populateController(ViewerParameterGUI &) const override
FWBoolParameter m_showPixelBarrel
FWViewType::EType typeId() const
void addToPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, FWConfiguration &) const