CMS 3D CMS Logo

FWGlimpseView.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWGlimpseView
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Feb 21 11:22:41 EST 2008
11 //
12 
13 #include <functional>
14 
15 #include "TGLPerspectiveCamera.h"
16 #include "TGLViewer.h"
17 #include "TGLScenePad.h"
18 #include "TEveScene.h"
19 #include "TEveViewer.h"
20 
21 #include "TEveManager.h"
22 #include "TEveElement.h"
23 
24 #include "TEveText.h"
25 #include "TGLFontManager.h"
26 
27 #include "TEveTrans.h"
28 #include "TGeoTube.h"
29 #include "TEveGeoNode.h"
30 #include "TEveGeoShape.h"
31 #include "TEveStraightLineSet.h"
32 
33 // user include files
36 
37 //
38 // constants, enums and typedefs
39 //
40 
41 //
42 // static data member definitions
43 //
44 //double FWGlimpseView::m_scale = 1;
45 
46 //
47 // constructors and destructorquery
48 //
49 FWGlimpseView::FWGlimpseView(TEveWindowSlot* iParent, FWViewType::EType typeId)
50  : FWEveView(iParent, typeId),
51  m_cylinder(nullptr),
52  m_showAxes(this, "Show Axes", true),
53  m_showCylinder(this, "Show Cylinder", true) {
54  createAxis();
55 
56  // made new wireframe scene
57  TEveScene* wns = gEve->SpawnNewScene(Form("Wireframe Scene %s", typeName().c_str()));
58  viewer()->AddScene(wns);
59  TGLScene* gls = wns->GetGLScene();
60  gls->SetStyle(TGLRnrCtx::kWireFrame);
61  gls->SetLOD(TGLRnrCtx::kLODMed);
62  gls->SetSelectable(kFALSE);
63 
64  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
65  TGeoTube* tube = new TGeoTube(129, 130, 310);
66  m_cylinder = fireworks::getShape("Detector outline", tube, kWhite);
67  m_cylinder->SetPickable(kFALSE);
68  m_cylinder->SetMainColor(kGray + 3);
69  wns->AddElement(m_cylinder);
70 
71  TGLViewer* ev = viewerGL();
72  ev->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
73  m_showAxes.changed_.connect(std::bind(&FWGlimpseView::showAxes, this));
74  m_showCylinder.changed_.connect(std::bind(&FWGlimpseView::showCylinder, this));
75 }
76 
78 
79 //
80 // member functions
81 //
82 
84  // create 3D axes
85  TEveElementList* axisHolder = new TEveElementList("GlimpseAxisHolder");
86 
87  TGLFont::EMode fontMode = TGLFont::kPixmap;
88  Int_t fs = 14;
89  Color_t fcol = kGray + 1;
90 
91  // X axis
92  TEveStraightLineSet* xAxis = new TEveStraightLineSet("GlimpseXAxis");
93  xAxis->SetPickable(kTRUE);
94  xAxis->SetTitle("Energy Scale, 100 GeV, X-axis (LHC center)");
95  xAxis->SetLineStyle(3);
96  xAxis->SetLineColor(fcol);
97  xAxis->AddLine(-100, 0, 0, 100, 0, 0);
98  axisHolder->AddElement(xAxis);
99 
100  TEveText* xTxt = new TEveText("X+");
101  xTxt->PtrMainTrans()->SetPos(100 - fs, -fs, 0);
102  xTxt->SetFontMode(fontMode);
103  xTxt->SetMainColor(fcol);
104  axisHolder->AddElement(xTxt);
105 
106  // Y axis
107  TEveStraightLineSet* yAxis = new TEveStraightLineSet("GlimpseYAxis");
108  yAxis->SetPickable(kTRUE);
109  yAxis->SetTitle("Energy Scale, 100 GeV, Y-axis (upward)");
110  yAxis->SetLineColor(fcol);
111  yAxis->SetLineStyle(3);
112  yAxis->AddLine(0, -100, 0, 0, 100, 0);
113  axisHolder->AddElement(yAxis);
114 
115  TEveText* yTxt = new TEveText("Y+");
116  yTxt->PtrMainTrans()->SetPos(0, 100 - fs, 0);
117  yTxt->SetFontMode(fontMode);
118  yTxt->SetMainColor(fcol);
119  axisHolder->AddElement(yTxt);
120 
121  // Z axis
122  TEveStraightLineSet* zAxis = new TEveStraightLineSet("GlimpseZAxis");
123  zAxis->SetPickable(kTRUE);
124  zAxis->SetTitle("Energy Scale, 100 GeV, Z-axis (west, along beam)");
125  zAxis->SetLineColor(fcol);
126  zAxis->AddLine(0, 0, -100, 0, 0, 100);
127  axisHolder->AddElement(zAxis);
128 
129  TEveText* zTxt = new TEveText("Z+");
130  zTxt->PtrMainTrans()->SetPos(0, -fs, 100 - zTxt->GetExtrude() * 2);
131  zTxt->SetFontMode(fontMode);
132  zTxt->SetMainColor(fcol);
133  axisHolder->AddElement(zTxt);
134 
135  geoScene()->AddElement(axisHolder);
136 }
137 
139  if (m_showAxes.value())
140  viewerGL()->SetGuideState(TGLUtil::kAxesOrigin, kTRUE, kFALSE, nullptr);
141  else
142  viewerGL()->SetGuideState(TGLUtil::kAxesNone, kTRUE, kFALSE, nullptr);
143 }
144 
146  if (m_showCylinder.value())
147  m_cylinder->SetRnrState(kTRUE);
148  else
149  m_cylinder->SetRnrState(kFALSE);
150 
151  gEve->Redraw3D();
152 }
153 
155  FWEveView::addTo(iTo);
156  TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
157  if (camera)
158  addToPerspectiveCamera(camera, typeName(), iTo);
159 }
160 
162  FWEveView::setFrom(iFrom);
163  TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
164  if (camera)
165  setFromPerspectiveCamera(camera, typeName(), iFrom);
166 }
FWGlimpseView::createAxis
void createAxis()
Definition: FWGlimpseView.cc:83
FWGlimpseView::m_showCylinder
FWBoolParameter m_showCylinder
Definition: FWGlimpseView.h:60
FWViewType::EType
EType
Definition: FWViewType.h:31
FWViewBase::typeName
const std::string & typeName() const
Definition: FWViewBase.cc:107
FWEveView::setFrom
void setFrom(const FWConfiguration &) override
Definition: FWEveView.cc:307
FWGlimpseView::~FWGlimpseView
~FWGlimpseView() override
Definition: FWGlimpseView.cc:77
BuilderUtils.h
fireworks::getShape
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:44
FWGlimpseView::showAxes
void showAxes()
Definition: FWGlimpseView.cc:138
FWGenericParameter::changed_
sigc::signal< void, T > changed_
Definition: FWGenericParameter.h:75
FWEveView
Definition: FWEveView.h:53
FWEveView::setFromPerspectiveCamera
void setFromPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, const FWConfiguration &)
Definition: FWEveView.cc:420
HLT_FULL_cff.zAxis
zAxis
Definition: HLT_FULL_cff.py:46209
FWEveView::viewer
TEveViewer * viewer()
Definition: FWEveView.cc:179
funct::true
true
Definition: Factorize.h:173
HLT_FULL_cff.yAxis
yAxis
Definition: HLT_FULL_cff.py:46210
FWGenericParameter::value
T value() const
Definition: FWGenericParameter.h:50
FWGlimpseView::FWGlimpseView
FWGlimpseView(TEveWindowSlot *, FWViewType::EType)
Definition: FWGlimpseView.cc:49
FWGlimpseView.h
FWEveView::addToPerspectiveCamera
void addToPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, FWConfiguration &) const
Definition: FWEveView.cc:397
FWEveView::addTo
void addTo(FWConfiguration &) const override
Definition: FWEveView.cc:291
FWGlimpseView::m_showAxes
FWBoolParameter m_showAxes
Definition: FWGlimpseView.h:59
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
HLT_FULL_cff.xAxis
xAxis
Definition: HLT_FULL_cff.py:46208
FWEveView::viewerGL
TGLViewer * viewerGL() const
Definition: FWEveView.cc:177
FWGlimpseView::addTo
void addTo(FWConfiguration &) const override
Definition: FWGlimpseView.cc:154
FWConfiguration
Definition: FWConfiguration.h:31
FWEveView::geoScene
TEveScene * geoScene()
Definition: FWEveView.h:80
FWGlimpseView::setFrom
void setFrom(const FWConfiguration &) override
Definition: FWGlimpseView.cc:161
FWGlimpseView::m_cylinder
TEveGeoShape * m_cylinder
Definition: FWGlimpseView.h:56
FWGlimpseView::showCylinder
void showCylinder()
Definition: FWGlimpseView.cc:145