12 #include <boost/bind.hpp> 17 #include "TGLScenePad.h" 18 #include "TGLViewer.h" 20 #include "TGLPerspectiveCamera.h" 21 #include "TEveManager.h" 22 #include "TEveElement.h" 24 #include "TEveBoxSet.h" 25 #include "TEveScene.h" 26 #include "TGLLogicalShape.h" 28 #include "TEveCaloData.h" 29 #include "TEveStraightLineSet.h" 41 class TGLClipsiLogical :
public TGLLogicalShape
44 virtual void DirectDraw(TGLRnrCtx & rnrCtx)
const override{}
47 TGLClipsiLogical() : TGLLogicalShape() {}
48 virtual ~TGLClipsiLogical() {}
49 void Resize(Double_t
ext){}
52 const float fgColor[4] = { 1.0, 0.6, 0.2, 0.5 };
54 class Clipsi :
public TGLClip
58 Clipsi(
const Clipsi&);
59 Clipsi& operator=(
const Clipsi&);
62 TGLVertex3 appexOffset;
65 Clipsi(TGLRnrCtx* ctx):TGLClip(* new TGLClipsiLogical, TGLMatrix(), fgColor), m_rnrCtx(ctx){}
68 virtual void Setup(
const TGLBoundingBox & bbox)
override {}
70 void SetPlaneInfo(TEveVector* vec)
72 for (
int i = 0;
i < 4; ++
i) {
74 vtx[
i].Set(vec[
i].fX + appexOffset.X(), vec[
i].fY + appexOffset.Y(), vec[
i].fZ + appexOffset.Z());
78 void SetAppexOffset(TEveVector& vec)
80 appexOffset.Set(vec.fX, vec.fY, vec.fZ);
84 using TGLClip::PlaneSet;
85 virtual void PlaneSet(TGLPlaneSet_t & planeSet)
const override 87 TGLVertex3
o = appexOffset;
89 planeSet.push_back(TGLPlane(o, vtx[0], vtx[1]));
90 planeSet.push_back(TGLPlane(o, vtx[1], vtx[2]));
91 planeSet.push_back(TGLPlane(o, vtx[2], vtx[3]));
92 planeSet.push_back(TGLPlane(o, vtx[3], vtx[0]));
109 m_showMuonBarrel(this,
"Show Muon Barrel", 0
l, 0
l, 2
l ),
110 m_showMuonEndcap(this,
"Show Muon Endcap",
false ),
111 m_showPixelBarrel(this,
"Show Pixel Barrel",
false ),
112 m_showPixelEndcap(this,
"Show Pixel Endcap",
false),
113 m_showTrackerBarrel(this,
"Show Tracker Barrel",
false ),
114 m_showTrackerEndcap(this,
"Show Tracker Endcap",
false),
116 m_showEcalBarrel(this,
"Show Ecal Barrel",
false),
117 m_rnrStyle(this,
"Render Style", 0
l, 0
l, 2
l),
118 m_selectable(this,
"Enable Tooltips",
false),
119 m_cameraType(this,
"Camera Type", 0
l, 0
l, 5
l),
120 m_clipEnable(this,
"Enable Clip",
false),
121 m_clipTheta(this,
"Clip Theta", 0.0, -5.0, 5.0),
122 m_clipPhi(this,
"Clip Phi", 0.0, -2.0, 2.0),
123 m_clipDelta1(this,
"Clip Delta1", 0.2, 0.01, 2),
124 m_clipDelta2(this,
"Clip Delta2", 0.2, 0.01, 2),
125 m_clipAppexOffset(this,
"Appex Offset", 10
l, 0
l, 50
l),
129 viewerGL()->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
189 TGLClipPlane*
c=
new TGLClipPlane();
190 c->Setup(TGLVector3(1e10,0,0), TGLVector3(-1,0,0));
215 viewerGL()->RefCamera(TGLViewer::ECameraType(x)).IncTimeStamp();
216 viewerGL()->SetCurrentCamera(TGLViewer::ECameraType(x));
225 geoScene()->GetGLScene()->SetStyle(x);
233 geoScene()->GetGLScene()->SetSelectable(x);
241 m_glClip->SetMode(TGLClip::kOutside);
245 for (TEveElement::List_i it =gEve->GetScenes()->BeginChildren(); it != gEve->GetScenes()->EndChildren(); ++it )
247 if (strncmp((*it)->GetElementName(),
"TopGeoNodeScene", 15) == 0)
248 ((TEveScene*)(*it))->GetGLScene()->SetClip(x ? m_glClip : 0);
250 eventScene()->GetGLScene()->SetClip(x ? m_glClip : 0);
262 int thetaInt = theta*
base;
263 int phiInt = phi*
base;
270 float getBBoxLineLength(TEveScene* scene, TEveVector
in)
272 if (!scene->NumChildren())
return 0;
275 scene->GetGLScene()->CalcBoundingBox();
276 const TGLBoundingBox& bb = scene->GetGLScene()->BoundingBox();
277 if (bb.IsEmpty())
return 0;
279 TGLPlaneSet_t ps; bb.PlaneSet(ps);
280 TEveVector inn =
in; inn.Normalize();
282 TGLLine3
line(TGLVertex3(), TGLVertex3(inn.fX, inn.fY, inn.fZ));
283 std::vector<float>
res;
284 for (TGLPlaneSet_i
i = ps.begin();
i!= ps.end(); ++
i)
286 std::pair<Bool_t, TGLVertex3>
r = Intersection(*
i, line,
false);
288 TGLVector3 vr(r.second.X(), r.second.Y(), r.second.Z());
289 res.push_back(vr.Mag());
292 std::sort(res.begin(), res.end());
296 void setBBoxClipped(TGLBoundingBox& bbox, TEveVector
dir, TEveVector b0, TEveVector b1,
float fac)
303 bb[0] += b0; bb[0] += b1;
304 bb[1] -= b0; bb[1] += b1;
305 bb[2] -= b0; bb[2] -= b1;
306 bb[3] += b0; bb[3] -= b1;
308 for (
int i = 4;
i < 8; ++
i)
311 bb[0+4] += b0; bb[0+4] += b1;
312 bb[1+4] -= b0; bb[1+4] += b1;
313 bb[2+4] -= b0; bb[2+4] -= b1;
314 bb[3+4] += b0; bb[3+4] -= b1;
317 for (
int i = 0;
i < 8; ++
i) {
318 bbv[
i].Set(bb[
i].fX, bb[
i].fY, bb[
i].fZ);
333 using namespace TMath;
334 TEveVector
in(Sin(theta)*Cos(phi), Sin(theta)*Sin(phi), Cos(theta));
337 TEveVector normXY(0., 1., 0);
338 TEveVector b0 = in.Cross(normXY);
339 TEveVector b1 = in.Cross(b0);
349 c[0] += b0; c[0] += b1;
350 c[1] -= b0; c[1] += b1;
351 c[2] -= b0; c[2] -= b1;
352 c[3] += b0; c[3] -= b1;
353 for (
int i = 0;
i < 4; ++
i)
356 TEveVector aOff =
in; aOff.NegateXYZ();
358 ((Clipsi*)
m_glClip)->SetAppexOffset(aOff);
361 ((Clipsi*)
m_glClip)->SetPlaneInfo(&c[0]);
365 float es = getBBoxLineLength(
eventScene(), in);
367 setBBoxClipped(bbox, in, b0, b1,
TMath::Max(es, gs));
382 TGLCamera& cam =
viewerGL()->CurrentCamera();
383 cam.SetExternalCenter(
true);
384 cam.SetCenterVec(bbox.Center().X(), bbox.Center().Y(), bbox.Center().Z());
385 cam.Setup(bbox,
true);
402 TGLPerspectiveCamera* camera =
dynamic_cast<TGLPerspectiveCamera*
>(&(
viewerGL()->CurrentCamera()));
414 TGLPerspectiveCamera* camera =
dynamic_cast<TGLPerspectiveCamera*
>(&(
viewerGL()->CurrentCamera()));
437 printf(
"ERROR!!!! FW3DViewBase::setCurrentDMTVertex \n");
475 Form(
"TEveGedEditor::SpawnNewEditor((TGLViewer*)0x%lx)", (
unsigned long)
viewerGL())));
485 m_ecalBarrel->Reset(TEveBoxSet::kBT_FreeBox,
true, ids.size() );
486 for (std::vector<unsigned int>::iterator it = ids.begin(); it != ids.end(); ++it) {
500 TEveElement* calo =
eventScene()->FindChild(
"calo barrel");
502 TEveCalo3D* c3d =
dynamic_cast<TEveCalo3D*
>(calo);
503 c3d->SetRnrFrame(!x, !x);
504 c3d->ElementChanged();
FWDoubleParameter m_clipTheta
virtual bool requestGLHandlerPick() const
void showEcalBarrel(bool)
void showMuonBarrel(long)
virtual void setFrom(const FWConfiguration &)
FWBoolParameter m_showMuonEndcap
void showMuonBarrel(bool)
void setClip(float eta, float phi)
virtual void populateController(ViewerParameterGUI &) const
const FWGeometry * getGeom() const
FWColorManager * colorManager() const
ViewerParameterGUI & requestTab(const char *)
void showTrackerEndcap(bool)
virtual void setFrom(const FWConfiguration &)
ViewerParameterGUI & separator()
Geom::Theta< T > theta() const
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)
virtual void addTo(FWConfiguration &) const
virtual void populateController(ViewerParameterGUI &) const
void showMuonEndcap(bool)
FWEnumParameter m_rnrStyle
void updateClipPlanes(bool resetCamera)
FWBoolParameter m_clipEnable
FWBoolParameter m_showPixelEndcap
FWDoubleParameter m_clipDelta1
bool addEntry(Long_t id, const std::string &txt)
virtual void setContext(const fireworks::Context &)
virtual void resetCamera()
base
Make Sure CMSSW is Setup ##.
const std::string & value(unsigned int iIndex=0) const
const fireworks::Context & context()
const float * getCorners(unsigned int id) const
void setFromPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, const FWConfiguration &)
void showPixelBarrel(bool)
FWBoolParameter m_showEcalBarrel
ViewerParameterGUI & addParam(const FWParameterBase *)
TGCompositeFrame * getTabContainer()
void showPixelEndcap(bool)
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
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
FWEnumParameter m_cameraType
FWLongParameter m_clipAppexOffset
virtual void addTo(FWConfiguration &) const
virtual void setContext(const fireworks::Context &x)
FWBoolParameter m_showTrackerEndcap
FWDoubleParameter m_clipDelta2
FWBoolParameter m_showPixelBarrel
FWViewType::EType typeId() const
void addToPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, FWConfiguration &) const