Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-02-07 02:57:47

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FW3DViewBase
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Thu Feb 21 11:22:41 EST 2008
0011 //
0012 #include <functional>
0013 #include <string>
0014 #include <algorithm>
0015 
0016 // user include files
0017 
0018 #include "TGButton.h"
0019 #include "TGLScenePad.h"
0020 #include "TGLViewer.h"
0021 #include "TGLClip.h"
0022 #include "TGLPerspectiveCamera.h"
0023 #include "TEveManager.h"
0024 #include "TEveElement.h"
0025 #include "TEveLine.h"
0026 #include "TEveBoxSet.h"
0027 #include "TEveScene.h"
0028 #include "TGLLogicalShape.h"
0029 #include "TEveCalo.h"
0030 #include "TEveCaloData.h"
0031 #include "TEveStraightLineSet.h"
0032 
0033 #include "Fireworks/Core/interface/FW3DViewBase.h"
0034 #include "Fireworks/Core/interface/FW3DViewGeometry.h"
0035 #include "Fireworks/Core/interface/Context.h"
0036 #include "Fireworks/Core/interface/FWViewContext.h"
0037 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
0038 #include "Fireworks/Core/interface/CmsShowViewPopup.h"
0039 #include "Fireworks/Core/src/FW3DViewDistanceMeasureTool.h"
0040 #include "Fireworks/Core/interface/FWGeometry.h"
0041 
0042 namespace {
0043   class TGLClipsiLogical : public TGLLogicalShape {
0044   protected:
0045     void DirectDraw(TGLRnrCtx& rnrCtx) const override {}
0046 
0047   public:
0048     TGLClipsiLogical() : TGLLogicalShape() {}
0049     ~TGLClipsiLogical() override {}
0050     void Resize(Double_t ext) {}
0051   };
0052 
0053   const float fgColor[4] = {1.0, 0.6, 0.2, 0.5};
0054 
0055   class Clipsi : public TGLClip {
0056   public:
0057     Clipsi(const Clipsi&) = delete;             // Not implemented
0058     Clipsi& operator=(const Clipsi&) = delete;  // Not implemented
0059 
0060   private:
0061     TGLRnrCtx* m_rnrCtx;
0062     TGLVertex3 vtx[4];
0063     TGLVertex3 appexOffset;
0064 
0065   public:
0066     Clipsi(TGLRnrCtx* ctx) : TGLClip(*new TGLClipsiLogical, TGLMatrix(), fgColor), m_rnrCtx(ctx) {}
0067     ~Clipsi() override {}
0068     using TGLClip::Setup;
0069     void Setup(const TGLBoundingBox& bbox) override {}
0070 
0071     void SetPlaneInfo(TEveVector* vec) {
0072       for (int i = 0; i < 4; ++i) {
0073         // vec[i].Dump();
0074         vtx[i].Set(vec[i].fX + appexOffset.X(), vec[i].fY + appexOffset.Y(), vec[i].fZ + appexOffset.Z());
0075       }
0076     }
0077 
0078     void SetAppexOffset(TEveVector& vec) { appexOffset.Set(vec.fX, vec.fY, vec.fZ); }
0079 
0080     using TGLClip::PlaneSet;
0081     void PlaneSet(TGLPlaneSet_t& planeSet) const override {
0082       TGLVertex3 o = appexOffset;
0083 
0084       planeSet.push_back(TGLPlane(o, vtx[0], vtx[1]));
0085       planeSet.push_back(TGLPlane(o, vtx[1], vtx[2]));
0086       planeSet.push_back(TGLPlane(o, vtx[2], vtx[3]));
0087       planeSet.push_back(TGLPlane(o, vtx[3], vtx[0]));
0088     }
0089   };
0090 }  // namespace
0091 
0092 ////////////////////////////////////////////////////////////////////////////////
0093 //
0094 //
0095 //                  FW3DViewBase
0096 //
0097 //
0098 //
0099 ////////////////////////////////////////////////////////////////////////////////
0100 FW3DViewBase::FW3DViewBase(TEveWindowSlot* iParent, FWViewType::EType typeId, unsigned int version)
0101     : FWEveView(iParent, typeId, version),
0102       m_geometry(nullptr),
0103       m_glClip(nullptr),
0104       m_showMuonBarrel(this, "Show Muon Barrel", 0l, 0l, 2l),
0105       m_showMuonEndcap(this, "Show Muon Endcap", false),
0106       m_showPixelBarrel(this, "Show Pixel Barrel", false),
0107       m_showPixelEndcap(this, "Show Pixel Endcap", false),
0108       m_showTrackerBarrel(this, "Show Tracker Barrel", false),
0109       m_showTrackerEndcap(this, "Show Tracker Endcap", false),
0110       m_showHGCalEE(this, "Show HGCalEE", false),
0111       m_showHGCalHSi(this, "Show HGCalHSi", false),
0112       m_showHGCalHSc(this, "Show HGCalHSc", false),
0113       m_showMtdBarrel(this, "Show MTD Barrel", false),
0114       m_showMtdEndcap(this, "Show MTD Endcap", false),
0115       m_ecalBarrel(nullptr),
0116       m_showEcalBarrel(this, "Show Ecal Barrel", false),
0117       m_rnrStyle(this, "Render Style", 0l, 0l, 2l),
0118       m_selectable(this, "Enable Tooltips", false),
0119       m_cameraType(this, "Camera Type", 0l, 0l, 5l),
0120       m_clipEnable(this, "Enable Clip", false),
0121       m_clipTheta(this, "Clip Theta", 0.0, -5.0, 5.0),
0122       m_clipPhi(this, "Clip Phi", 0.0, -2.0, 2.0),
0123       m_clipDelta1(this, "Clip Delta1", 0.2, 0.01, 2),
0124       m_clipDelta2(this, "Clip Delta2", 0.2, 0.01, 2),
0125       m_clipAppexOffset(this, "Appex Offset", 10l, 0l, 50l),
0126       m_clipHGCalLayerBegin(this, "HGCal Lower Bound", 1l, 1l, 52l),
0127       m_clipHGCalLayerEnd(this, "HGCal Upper Bound", 52l, 1l, 52l),
0128       m_DMT(nullptr),
0129       m_DMTline(nullptr) {
0130   viewerGL()->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
0131   m_DMT = new FW3DViewDistanceMeasureTool();
0132 
0133   m_showMuonBarrel.addEntry(0, "Hide");
0134   m_showMuonBarrel.addEntry(1, "Simplified");
0135   m_showMuonBarrel.addEntry(2, "Full");
0136   m_showMuonBarrel.changed_.connect(std::bind(&FW3DViewBase::showMuonBarrel, this, std::placeholders::_1));
0137 
0138   m_rnrStyle.addEntry(TGLRnrCtx::kFill, "Fill");
0139   m_rnrStyle.addEntry(TGLRnrCtx::kOutline, "Outline");
0140   m_rnrStyle.addEntry(TGLRnrCtx::kWireFrame, "WireFrame");
0141   m_rnrStyle.changed_.connect(std::bind(&FW3DViewBase::rnrStyle, this, std::placeholders::_1));
0142 
0143   m_selectable.changed_.connect(std::bind(&FW3DViewBase::selectable, this, std::placeholders::_1));
0144 
0145   m_cameraType.addEntry(TGLViewer::kCameraPerspXOZ, "PerspXOZ");
0146   m_cameraType.addEntry(TGLViewer::kCameraOrthoXOY, "OrthoXOY");
0147   m_cameraType.addEntry(TGLViewer::kCameraOrthoXOZ, "OrthoXOZ");
0148   m_cameraType.addEntry(TGLViewer::kCameraOrthoZOY, "OrthoZOY");
0149   m_cameraType.addEntry(TGLViewer::kCameraOrthoXnOY, "OrthoXnOY");
0150   m_cameraType.addEntry(TGLViewer::kCameraOrthoXnOZ, "OrthoXnOZ");
0151   m_cameraType.addEntry(TGLViewer::kCameraOrthoZnOY, "OrthoZnOY");
0152   m_cameraType.changed_.connect(std::bind(&FW3DViewBase::setCameraType, this, std::placeholders::_1));
0153 
0154   m_clipEnable.changed_.connect(std::bind(&FW3DViewBase::enableSceneClip, this, std::placeholders::_1));
0155   m_clipTheta.changed_.connect(std::bind(&FW3DViewBase::updateClipPlanes, this, false));
0156   m_clipPhi.changed_.connect(std::bind(&FW3DViewBase::updateClipPlanes, this, false));
0157   m_clipDelta1.changed_.connect(std::bind(&FW3DViewBase::updateClipPlanes, this, false));
0158   m_clipDelta2.changed_.connect(std::bind(&FW3DViewBase::updateClipPlanes, this, false));
0159   m_clipAppexOffset.changed_.connect(std::bind(&FW3DViewBase::updateClipPlanes, this, false));
0160   m_clipHGCalLayerBegin.changed_.connect(std::bind(&FW3DViewBase::updateHGCalVisibility, this, false));
0161   m_clipHGCalLayerEnd.changed_.connect(std::bind(&FW3DViewBase::updateHGCalVisibility, this, false));
0162 
0163   m_ecalBarrel = new TEveBoxSet("ecalBarrel");
0164   m_ecalBarrel->UseSingleColor();
0165   m_ecalBarrel->SetMainColor(kAzure + 10);
0166   m_ecalBarrel->SetMainTransparency(98);
0167   geoScene()->AddElement(m_ecalBarrel);
0168 }
0169 
0170 FW3DViewBase::~FW3DViewBase() { delete m_glClip; }
0171 
0172 void FW3DViewBase::setContext(const fireworks::Context& context) {
0173   FWEveView::setContext(context);
0174 
0175   m_geometry = new FW3DViewGeometry(context);
0176   geoScene()->AddElement(m_geometry);
0177 
0178   m_showPixelBarrel.changed_.connect(std::bind(&FW3DViewGeometry::showPixelBarrel, m_geometry, std::placeholders::_1));
0179   m_showPixelEndcap.changed_.connect(std::bind(&FW3DViewGeometry::showPixelEndcap, m_geometry, std::placeholders::_1));
0180   m_showTrackerBarrel.changed_.connect(
0181       std::bind(&FW3DViewGeometry::showTrackerBarrel, m_geometry, std::placeholders::_1));
0182   m_showTrackerEndcap.changed_.connect(
0183       std::bind(&FW3DViewGeometry::showTrackerEndcap, m_geometry, std::placeholders::_1));
0184   m_showHGCalEE.changed_.connect(std::bind(&FW3DViewGeometry::showHGCalEE, m_geometry, std::placeholders::_1));
0185   m_showHGCalHSi.changed_.connect(std::bind(&FW3DViewGeometry::showHGCalHSi, m_geometry, std::placeholders::_1));
0186   m_showHGCalHSc.changed_.connect(std::bind(&FW3DViewGeometry::showHGCalHSc, m_geometry, std::placeholders::_1));
0187   m_showMuonEndcap.changed_.connect(std::bind(&FW3DViewGeometry::showMuonEndcap, m_geometry, std::placeholders::_1));
0188   m_showMtdBarrel.changed_.connect(std::bind(&FW3DViewGeometry::showMtdBarrel, m_geometry, std::placeholders::_1));
0189   m_showMtdEndcap.changed_.connect(std::bind(&FW3DViewGeometry::showMtdEndcap, m_geometry, std::placeholders::_1));
0190   m_showEcalBarrel.changed_.connect(std::bind(&FW3DViewBase::showEcalBarrel, this, std::placeholders::_1));
0191 
0192   // don't clip event scene --  ideally, would have TGLClipNoClip in root
0193   TGLClipPlane* c = new TGLClipPlane();
0194   c->Setup(TGLVector3(1e10, 0, 0), TGLVector3(-1, 0, 0));
0195   eventScene()->GetGLScene()->SetClip(c);
0196 
0197   m_DMTline = new TEveLine();
0198   m_DMTline->SetLineColor(1016);
0199   m_DMTline->SetLineStyle(5);
0200 
0201   m_DMTline->SetPoint(0, 0, 0, 0);
0202   m_DMTline->SetPoint(1, 0, 0, 0);
0203   eventScene()->AddElement(m_DMTline);
0204   showEcalBarrel(m_showEcalBarrel.value());
0205 }
0206 
0207 void FW3DViewBase::showMuonBarrel(long x) {
0208   if (m_geometry) {
0209     m_geometry->showMuonBarrel(x == 1);
0210     m_geometry->showMuonBarrelFull(x == 2);
0211   }
0212 }
0213 
0214 void FW3DViewBase::setCameraType(long x) {
0215   viewerGL()->RefCamera(TGLViewer::ECameraType(x)).IncTimeStamp();
0216   viewerGL()->SetCurrentCamera(TGLViewer::ECameraType(x));
0217 
0218   //if (viewerGL()->CurrentCamera().IsOrthographic())
0219   //   ((TGLOrthoCamera*)(&viewerGL()->CurrentCamera()))->SetEnableRotate(1);
0220 }
0221 
0222 void FW3DViewBase::rnrStyle(long x) {
0223   geoScene()->GetGLScene()->SetStyle(x);
0224   viewerGL()->Changed();
0225   gEve->Redraw3D();
0226 }
0227 
0228 void FW3DViewBase::selectable(bool x) { geoScene()->GetGLScene()->SetSelectable(x); }
0229 void FW3DViewBase::enableSceneClip(bool x) {
0230   if (m_glClip == nullptr) {
0231     m_glClip = new Clipsi(viewerGL()->GetRnrCtx());
0232 
0233     m_glClip->SetMode(TGLClip::kOutside);
0234   }
0235 
0236   geoScene()->GetGLScene()->SetClip(x ? m_glClip : nullptr);
0237   for (TEveElement::List_i it = gEve->GetScenes()->BeginChildren(); it != gEve->GetScenes()->EndChildren(); ++it) {
0238     if (strncmp((*it)->GetElementName(), "TopGeoNodeScene", 15) == 0)
0239       ((TEveScene*)(*it))->GetGLScene()->SetClip(x ? m_glClip : nullptr);
0240   }
0241   eventScene()->GetGLScene()->SetClip(x ? m_glClip : nullptr);
0242   updateClipPlanes(true);
0243   updateHGCalVisibility(false);
0244   viewerGL()->RequestDraw();
0245 }
0246 
0247 void FW3DViewBase::setClip(float theta, float phi) {
0248   // called from popup menu via FWGUIManager
0249 
0250   // limit to 2 decimals, else TGNumber entry in the view controller shows only last 5 irrelevant digits
0251   double base = 100.0;
0252   int thetaInt = theta * base;
0253   int phiInt = phi * base;
0254   m_clipTheta.set(thetaInt / base);
0255   m_clipPhi.set(phiInt / base);
0256   m_clipEnable.set(true);
0257 }
0258 
0259 namespace {
0260   float getBBoxLineLength(TEveScene* scene, TEveVector in) {
0261     if (!scene->NumChildren())
0262       return 0;
0263 
0264     scene->Repaint();
0265     scene->GetGLScene()->CalcBoundingBox();
0266     const TGLBoundingBox& bb = scene->GetGLScene()->BoundingBox();
0267     if (bb.IsEmpty())
0268       return 0;
0269 
0270     TGLPlaneSet_t ps;
0271     bb.PlaneSet(ps);
0272     TEveVector inn = in;
0273     inn.Normalize();
0274     inn *= 10000;
0275     TGLLine3 line(TGLVertex3(), TGLVertex3(inn.fX, inn.fY, inn.fZ));
0276     std::vector<float> res;
0277     for (TGLPlaneSet_i i = ps.begin(); i != ps.end(); ++i) {
0278       std::pair<Bool_t, TGLVertex3> r = Intersection(*i, line, false);
0279       if (r.first) {
0280         TGLVector3 vr(r.second.X(), r.second.Y(), r.second.Z());
0281         res.push_back(vr.Mag());
0282       }
0283     }
0284     std::sort(res.begin(), res.end());
0285     return res.front();
0286   }
0287 
0288   void setBBoxClipped(TGLBoundingBox& bbox, TEveVector dir, TEveVector b0, TEveVector b1, float fac) {
0289     dir *= fac;
0290     b0 *= fac;
0291     b1 *= fac;
0292 
0293     TEveVectorD bb[8];
0294     bb[0] += b0;
0295     bb[0] += b1;
0296     bb[1] -= b0;
0297     bb[1] += b1;
0298     bb[2] -= b0;
0299     bb[2] -= b1;
0300     bb[3] += b0;
0301     bb[3] -= b1;
0302 
0303     for (int i = 4; i < 8; ++i)
0304       bb[i] = dir;
0305 
0306     bb[0 + 4] += b0;
0307     bb[0 + 4] += b1;
0308     bb[1 + 4] -= b0;
0309     bb[1 + 4] += b1;
0310     bb[2 + 4] -= b0;
0311     bb[2 + 4] -= b1;
0312     bb[3 + 4] += b0;
0313     bb[3 + 4] -= b1;
0314 
0315     TGLVertex3 bbv[8];
0316     for (int i = 0; i < 8; ++i) {
0317       bbv[i].Set(bb[i].fX, bb[i].fY, bb[i].fZ);
0318     }
0319     bbox.Set(bbv);
0320   }
0321 }  // namespace
0322 
0323 void FW3DViewBase::updateClipPlanes(bool resetCamera) {
0324   //  TEveScene* gs = (TEveScene*)gEve->GetScenes()->FindChild(TString("TopGeoNodeScene"));
0325   //printf("node scene %p\n", gs);
0326   if (m_clipEnable.value()) {
0327     float theta = m_clipTheta.value();
0328     float phi = m_clipPhi.value();
0329     using namespace TMath;
0330     TEveVector in(Sin(theta) * Cos(phi), Sin(theta) * Sin(phi), Cos(theta));
0331 
0332     // one side of cross section plane is paralel to XY plane
0333     TEveVector normXY(0., 1., 0);
0334     TEveVector b0 = in.Cross(normXY);
0335     TEveVector b1 = in.Cross(b0);
0336 
0337     float delta1 = m_clipDelta1.value();
0338     float delta2 = m_clipDelta2.value();
0339     b0.Normalize();
0340     b0 *= Sin(delta1);
0341     b1.Normalize();
0342     b1 *= Sin(delta2);
0343 
0344     TEveVector c[4];
0345     c[0] += b0;
0346     c[0] += b1;
0347     c[1] -= b0;
0348     c[1] += b1;
0349     c[2] -= b0;
0350     c[2] -= b1;
0351     c[3] += b0;
0352     c[3] -= b1;
0353     for (int i = 0; i < 4; ++i)
0354       c[i] += in;
0355 
0356     TEveVector aOff = in;
0357     aOff.NegateXYZ();
0358     aOff.Normalize();
0359     aOff *= m_clipAppexOffset.value();
0360     ((Clipsi*)m_glClip)->SetAppexOffset(aOff);
0361 
0362     ((Clipsi*)m_glClip)->SetPlaneInfo(&c[0]);
0363 
0364     if (resetCamera) {
0365       TGLBoundingBox bbox;
0366       float es = getBBoxLineLength(eventScene(), in);
0367       float gs = getBBoxLineLength(geoScene(), in);
0368       setBBoxClipped(bbox, in, b0, b1, TMath::Max(es, gs));
0369 
0370       /*
0371     TEvePointSet* bmarker = new TEvePointSet(8);
0372     bmarker->Reset(4);
0373     bmarker->SetName("bbox");
0374     bmarker->SetMarkerColor(kOrange);
0375     bmarker->SetMarkerStyle(3);
0376     bmarker->SetMarkerSize(0.2);
0377     for (int i = 0; i < 8; ++i)
0378         bmarker->SetPoint(i, bbox[i].X(), bbox[i].Y(), bbox[i].Z());
0379     eventScene()->AddElement(bmarker);
0380       */
0381 
0382       TGLCamera& cam = viewerGL()->CurrentCamera();
0383       cam.SetExternalCenter(true);
0384       cam.SetCenterVec(bbox.Center().X(), bbox.Center().Y(), bbox.Center().Z());
0385       cam.Setup(bbox, true);
0386     } else {
0387       eventScene()->Repaint();
0388     }
0389   }
0390 
0391   gEve->Redraw3D();
0392 }
0393 
0394 void FW3DViewBase::updateHGCalVisibility(bool) {
0395   if (!m_clipEnable.value())
0396     return;
0397 
0398   long lmin = m_clipHGCalLayerBegin.value();
0399   long lmax = m_clipHGCalLayerEnd.value();
0400 
0401   // real min, max
0402   long r_lmin = std::min(lmin, lmax);
0403   long r_lmax = std::max(lmin, lmax);
0404 
0405   TEveElementList const* const HGCalEE = m_geometry->getHGCalEE();
0406   if (HGCalEE) {
0407     for (const auto& it : HGCalEE->RefChildren()) {
0408       std::string title(it->GetElementTitle());
0409       int layer = stoi(title.substr(title.length() - 2));
0410       it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
0411     }
0412   }
0413 
0414   TEveElementList const* const HGCalHSi = m_geometry->getHGCalHSi();
0415   if (HGCalHSi) {
0416     for (const auto& it : HGCalHSi->RefChildren()) {
0417       std::string title(it->GetElementTitle());
0418       int layer = stoi(title.substr(title.length() - 2));
0419       it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
0420     }
0421   }
0422 
0423   TEveElementList const* const HGCalHSc = m_geometry->getHGCalHSc();
0424   if (HGCalHSc) {
0425     for (const auto& it : HGCalHSc->RefChildren()) {
0426       std::string title(it->GetElementTitle());
0427       int layer = stoi(title.substr(title.length() - 2));
0428       it->SetRnrState(layer >= r_lmin && layer <= r_lmax);
0429     }
0430   }
0431 
0432   gEve->Redraw3D();
0433 }
0434 
0435 //______________________________________________________________________________
0436 void FW3DViewBase::addTo(FWConfiguration& iTo) const {
0437   // take care of parameters
0438   FWEveView::addTo(iTo);
0439   TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
0440   if (camera)
0441     addToPerspectiveCamera(camera, "Plain3D", iTo);
0442 }
0443 
0444 //______________________________________________________________________________
0445 void FW3DViewBase::setFrom(const FWConfiguration& iFrom) {
0446   // take care of parameters
0447   FWEveView::setFrom(iFrom);
0448 
0449   TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
0450   if (camera)
0451     setFromPerspectiveCamera(camera, "Plain3D", iFrom);
0452 
0453   if (iFrom.version() < 5) {
0454     // transparency moved to common preferences in FWEveView version 5
0455     std::string tName("Detector Transparency");
0456     std::istringstream s(iFrom.valueForKey(tName)->value());
0457     int transp;
0458     s >> transp;
0459     context().colorManager()->setGeomTransparency(transp, false);
0460   }
0461 }
0462 
0463 bool FW3DViewBase::requestGLHandlerPick() const { return m_DMT->m_action != FW3DViewDistanceMeasureTool::kNone; }
0464 
0465 void FW3DViewBase::setCurrentDMTVertex(double x, double y, double z) {
0466   if (m_DMT->m_action == FW3DViewDistanceMeasureTool::kNone)
0467     printf("ERROR!!!! FW3DViewBase::setCurrentDMTVertex \n");
0468 
0469   m_DMTline->SetPoint(m_DMT->m_action, x, y, z);
0470   m_DMTline->ElementChanged();
0471   viewerGL()->RequestDraw();
0472 
0473   m_DMT->refCurrentVertex().Set(x, y, z);
0474   m_DMT->resetAction();
0475 }
0476 
0477 void FW3DViewBase::populateController(ViewerParameterGUI& gui) const {
0478   FWEveView::populateController(gui);
0479 
0480   gui.requestTab("Detector")
0481       .addParam(&m_showMuonBarrel)
0482       .addParam(&m_showMuonEndcap)
0483       .addParam(&m_showTrackerBarrel)
0484       .addParam(&m_showTrackerEndcap)
0485       .addParam(&m_showHGCalEE)
0486       .addParam(&m_showHGCalHSi)
0487       .addParam(&m_showHGCalHSc)
0488       .addParam(&m_showPixelBarrel)
0489       .addParam(&m_showPixelEndcap)
0490       .addParam(&m_showEcalBarrel)
0491       .addParam(&m_showMtdBarrel)
0492       .addParam(&m_showMtdEndcap)
0493       .addParam(&m_rnrStyle)
0494       .addParam(&m_selectable);
0495 
0496   gui.requestTab("Clipping")
0497       .addParam(&m_clipEnable)
0498       .addParam(&m_clipTheta)
0499       .addParam(&m_clipPhi)
0500       .addParam(&m_clipDelta1)
0501       .addParam(&m_clipDelta2)
0502       .addParam(&m_clipAppexOffset)
0503       .addParam(&m_clipHGCalLayerBegin)
0504       .addParam(&m_clipHGCalLayerEnd);
0505 
0506   gui.requestTab("Style").separator();
0507   gui.getTabContainer()->AddFrame(
0508       new TGTextButton(gui.getTabContainer(),
0509                        "Root controls",
0510                        Form("TEveGedEditor::SpawnNewEditor((TGLViewer*)0x%lx)", (unsigned long)viewerGL())));
0511 
0512   gui.requestTab("Tools").addParam(&m_cameraType).separator();
0513   gui.getTabContainer()->AddFrame(m_DMT->buildGUI(gui.getTabContainer()),
0514                                   new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
0515 }
0516 
0517 void FW3DViewBase::showEcalBarrel(bool x) {
0518   if (x && m_ecalBarrel->GetPlex()->Size() == 0) {
0519     const FWGeometry* geom = context().getGeom();
0520     std::vector<unsigned int> ids =
0521         geom->getMatchedIds(FWGeometry::Detector::Ecal, FWGeometry::SubDetector::PixelBarrel);
0522     m_ecalBarrel->Reset(TEveBoxSet::kBT_FreeBox, true, ids.size());
0523     for (std::vector<unsigned int>::iterator it = ids.begin(); it != ids.end(); ++it) {
0524       const float* cor = context().getGeom()->getCorners(*it);
0525       m_ecalBarrel->AddBox(cor);
0526     }
0527     m_ecalBarrel->RefitPlex();
0528   }
0529 
0530   if (m_ecalBarrel->GetRnrSelf() != x) {
0531     m_ecalBarrel->SetRnrSelf(x);
0532     gEve->Redraw3D();
0533   }
0534 
0535   // disable enable grid in 3DView
0536   if (typeId() == FWViewType::k3D) {
0537     TEveElement* calo = eventScene()->FindChild("calo barrel");
0538     if (calo) {
0539       TEveCalo3D* c3d = dynamic_cast<TEveCalo3D*>(calo);
0540       c3d->SetRnrFrame(!x, !x);
0541       c3d->ElementChanged();
0542     }
0543   }
0544 }