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&);
64 Clipsi(TGLRnrCtx* ctx):TGLClip(* new TGLClipsiLogical, TGLMatrix(), fgColor), m_rnrCtx(ctx){}
67 virtual void Setup(
const TGLBoundingBox & bbox)
override {}
69 void SetPlaneInfo(TEveVector* vec)
71 for (
int i = 0;
i < 4; ++
i) {
73 vtx[
i].Set(vec[
i].fX, vec[
i].fY, vec[
i].fZ);
77 using TGLClip::PlaneSet;
78 virtual void PlaneSet(TGLPlaneSet_t & planeSet)
const override
81 planeSet.push_back(TGLPlane(o, vtx[0], vtx[1]));
82 planeSet.push_back(TGLPlane(o, vtx[1], vtx[2]));
83 planeSet.push_back(TGLPlane(o, vtx[2], vtx[3]));
84 planeSet.push_back(TGLPlane(o, vtx[3], vtx[0]));
101 m_showMuonBarrel(this,
"Show Muon Barrel", 0
l, 0
l, 2
l ),
102 m_showMuonEndcap(this,
"Show Muon Endcap",
false ),
103 m_showPixelBarrel(this,
"Show Pixel Barrel",
false ),
104 m_showPixelEndcap(this,
"Show Pixel Endcap",
false),
105 m_showTrackerBarrel(this,
"Show Tracker Barrel",
false ),
106 m_showTrackerEndcap(this,
"Show Tracker Endcap",
false),
109 m_rnrStyle(this,
"Render Style", 0
l, 0
l, 2
l),
110 m_selectable(this,
"Enable Tooltips",
false),
111 m_cameraType(this,
"Camera Type", 0
l, 0
l, 5
l),
112 m_clipEnable(this,
"Enable Clip",
false),
113 m_clipTheta(this,
"Clip Theta", 0.0, -5.0, 5.0),
114 m_clipPhi(this,
"Clip Phi", 0.0, -2.0, 2.0),
115 m_clipDelta1(this,
"Clip Delta1", 0.2, 0.01, 2),
116 m_clipDelta2(this,
"Clip Delta2", 0.2, 0.01, 2),
120 viewerGL()->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
179 TGLClipPlane*
c=
new TGLClipPlane();
180 c->Setup(TGLVector3(1e10,0,0), TGLVector3(-1,0,0));
205 viewerGL()->RefCamera(TGLViewer::ECameraType(x)).IncTimeStamp();
206 viewerGL()->SetCurrentCamera(TGLViewer::ECameraType(x));
215 geoScene()->GetGLScene()->SetStyle(x);
223 geoScene()->GetGLScene()->SetSelectable(x);
231 m_glClip->SetMode(TGLClip::kOutside);
235 for (TEveElement::List_i it =gEve->GetScenes()->BeginChildren(); it != gEve->GetScenes()->EndChildren(); ++it )
237 if (strncmp((*it)->GetElementName(),
"TopGeoNodeScene", 15) == 0)
238 ((TEveScene*)(*it))->GetGLScene()->SetClip(x ? m_glClip : 0);
240 eventScene()->GetGLScene()->SetClip(x ? m_glClip : 0);
252 int thetaInt = theta*
base;
253 int phiInt = phi*
base;
260 float getBBoxLineLength(TEveScene* scene, TEveVector
in)
262 if (!scene->NumChildren())
return 0;
265 scene->GetGLScene()->CalcBoundingBox();
266 const TGLBoundingBox& bb = scene->GetGLScene()->BoundingBox();
267 if (bb.IsEmpty())
return 0;
269 TGLPlaneSet_t ps; bb.PlaneSet(ps);
270 TEveVector inn =
in; inn.Normalize();
272 TGLLine3
line(TGLVertex3(), TGLVertex3(inn.fX, inn.fY, inn.fZ));
273 std::vector<float> res;
274 for (TGLPlaneSet_i
i = ps.begin();
i!= ps.end(); ++
i)
276 std::pair<Bool_t, TGLVertex3>
r = Intersection(*
i,
line,
false);
278 TGLVector3 vr(r.second.X(), r.second.Y(), r.second.Z());
279 res.push_back(vr.Mag());
286 void setBBoxClipped(TGLBoundingBox& bbox, TEveVector
dir, TEveVector b0, TEveVector b1,
float fac)
293 bb[0] += b0; bb[0] += b1;
294 bb[1] -= b0; bb[1] += b1;
295 bb[2] -= b0; bb[2] -= b1;
296 bb[3] += b0; bb[3] -= b1;
298 for (
int i = 4;
i < 8; ++
i)
301 bb[0+4] += b0; bb[0+4] += b1;
302 bb[1+4] -= b0; bb[1+4] += b1;
303 bb[2+4] -= b0; bb[2+4] -= b1;
304 bb[3+4] += b0; bb[3+4] -= b1;
307 for (
int i = 0;
i < 8; ++
i) {
308 bbv[
i].Set(bb[
i].fX, bb[
i].fY, bb[
i].fZ);
323 using namespace TMath;
324 TEveVector
in(Sin(theta)*Cos(phi), Sin(theta)*Sin(phi), Cos(theta));
327 TEveVector normXY(0., 1., 0);
328 TEveVector b0 = in.Cross(normXY);
329 TEveVector b1 = in.Cross(b0);
339 c[0] += b0;
c[0] += b1;
340 c[1] -= b0;
c[1] += b1;
341 c[2] -= b0;
c[2] -= b1;
342 c[3] += b0;
c[3] -= b1;
343 for (
int i = 0;
i < 4; ++
i)
346 ((Clipsi*)
m_glClip)->SetPlaneInfo(&
c[0]);
351 float es = getBBoxLineLength(
eventScene(), in);
353 setBBoxClipped(bbox, in, b0, b1,
TMath::Max(es, gs));
368 TGLCamera& cam =
viewerGL()->CurrentCamera();
369 cam.SetExternalCenter(
true);
370 cam.SetCenterVec(bbox.Center().X(), bbox.Center().Y(), bbox.Center().Z());
371 cam.Setup(bbox,
true);
388 TGLPerspectiveCamera* camera =
dynamic_cast<TGLPerspectiveCamera*
>(&(
viewerGL()->CurrentCamera()));
400 TGLPerspectiveCamera* camera =
dynamic_cast<TGLPerspectiveCamera*
>(&(
viewerGL()->CurrentCamera()));
423 printf(
"ERROR!!!! FW3DViewBase::setCurrentDMTVertex \n");
458 Form(
"TEveGedEditor::SpawnNewEditor((TGLViewer*)0x%lx)", (
unsigned long)
viewerGL())));
468 m_ecalBarrel->Reset(TEveBoxSet::kBT_FreeBox,
true, ids.size() );
469 for (std::vector<unsigned int>::iterator it = ids.begin(); it != ids.end(); ++it) {
483 TEveElement* calo =
eventScene()->FindChild(
"calo barrel");
485 TEveCalo3D* c3d =
dynamic_cast<TEveCalo3D*
>(calo);
486 c3d->SetRnrFrame(!x, !x);
487 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
T x() const
Cartesian x coordinate.
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 &)
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 *)
Geom::Phi< T > phi() const
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
volatile std::atomic< bool > shutdown_flag false
FWBoolParameter m_selectable
FWEnumParameter m_cameraType
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