CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <boost/bind.hpp>
14 
15 
16 #include "TGLPerspectiveCamera.h"
17 #include "TGLViewer.h"
18 #include "TGLScenePad.h"
19 #include "TEveScene.h"
20 #include "TEveViewer.h"
21 
22 #include "TEveManager.h"
23 #include "TEveElement.h"
24 
25 #include "TEveText.h"
26 #include "TGLFontManager.h"
27 
28 #include "TEveTrans.h"
29 #include "TGeoTube.h"
30 #include "TEveGeoNode.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(0),
52  m_showAxes(this, "Show Axes", true ),
53  m_showCylinder(this, "Show Cylinder", true)
54 {
55  createAxis();
56 
57  // made new wireframe scene
58  TEveScene* wns = gEve->SpawnNewScene(Form("Wireframe Scene %s", typeName().c_str()));
59  viewer()->AddScene(wns);
60  TGLScene* gls = wns->GetGLScene();
61  gls->SetStyle(TGLRnrCtx::kWireFrame);
62  gls->SetLOD(TGLRnrCtx::kLODMed);
63  gls->SetSelectable(kFALSE);
64 
65  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
66  TGeoTube* tube = new TGeoTube(129,130,310);
67  m_cylinder = fireworks::getShape("Detector outline", tube, kWhite);
68  m_cylinder->SetPickable(kFALSE);
69  m_cylinder->SetMainColor(kGray+3);
70  wns->AddElement(m_cylinder);
71 
72  TGLViewer* ev = viewerGL();
73  ev->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
74  m_showAxes.changed_.connect(boost::bind(&FWGlimpseView::showAxes,this));
75  m_showCylinder.changed_.connect(boost::bind(&FWGlimpseView::showCylinder,this));
76 }
77 
79 {
80 }
81 
82 
83 //
84 // member functions
85 //
86 
87 void
89 {
90  // create 3D axes
91  TEveElementList* axisHolder = new TEveElementList("GlimpseAxisHolder");
92 
93  TGLFont::EMode fontMode = TGLFont::kPixmap;
94  Int_t fs = 14;
95  Color_t fcol = kGray+1;
96 
97  // X axis
98  TEveStraightLineSet* xAxis = new TEveStraightLineSet( "GlimpseXAxis" );
99  xAxis->SetPickable(kTRUE);
100  xAxis->SetTitle("Energy Scale, 100 GeV, X-axis (LHC center)");
101  xAxis->SetLineStyle(3);
102  xAxis->SetLineColor(fcol);
103  xAxis->AddLine(-100,0,0,100,0,0);
104  axisHolder->AddElement(xAxis);
105 
106  TEveText* xTxt = new TEveText( "X+" );
107  xTxt->PtrMainTrans()->SetPos(100-fs, -fs, 0);
108  xTxt->SetFontMode(fontMode);
109  xTxt->SetMainColor(fcol);
110  axisHolder->AddElement(xTxt);
111 
112  // Y axis
113  TEveStraightLineSet* yAxis = new TEveStraightLineSet( "GlimpseYAxis" );
114  yAxis->SetPickable(kTRUE);
115  yAxis->SetTitle("Energy Scale, 100 GeV, Y-axis (upward)");
116  yAxis->SetLineColor(fcol);
117  yAxis->SetLineStyle(3);
118  yAxis->AddLine(0,-100,0,0,100,0);
119  axisHolder->AddElement(yAxis);
120 
121  TEveText* yTxt = new TEveText( "Y+" );
122  yTxt->PtrMainTrans()->SetPos(0, 100-fs, 0);
123  yTxt->SetFontMode(fontMode);
124  yTxt->SetMainColor(fcol);
125  axisHolder->AddElement(yTxt);
126 
127  // Z axis
128  TEveStraightLineSet* zAxis = new TEveStraightLineSet( "GlimpseZAxis" );
129  zAxis->SetPickable(kTRUE);
130  zAxis->SetTitle("Energy Scale, 100 GeV, Z-axis (west, along beam)");
131  zAxis->SetLineColor(fcol);
132  zAxis->AddLine(0,0,-100,0,0,100);
133  axisHolder->AddElement(zAxis);
134 
135  TEveText* zTxt = new TEveText( "Z+" );
136  zTxt->PtrMainTrans()->SetPos(0, -fs, 100 - zTxt->GetExtrude()*2);
137  zTxt->SetFontMode(fontMode);
138  zTxt->SetMainColor(fcol);
139  axisHolder->AddElement(zTxt);
140 
141  geoScene()->AddElement(axisHolder);
142 }
143 
144 
145 void
147 {
148  if ( m_showAxes.value() )
149  viewerGL()->SetGuideState(TGLUtil::kAxesOrigin, kTRUE, kFALSE, 0);
150  else
151  viewerGL()->SetGuideState(TGLUtil::kAxesNone, kTRUE, kFALSE, 0);
152 }
153 
154 
155 void
157 {
158  if ( m_showCylinder.value() )
159  m_cylinder->SetRnrState(kTRUE);
160  else
161  m_cylinder->SetRnrState(kFALSE);
162 
163  gEve->Redraw3D();
164 }
165 
166 
167 void
169 {
170  FWEveView::addTo(iTo);
171  TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
172  if (camera)
173  addToPerspectiveCamera(camera, typeName(), iTo);
174 }
175 
176 void
178 {
179  FWEveView::setFrom(iFrom);
180  TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
181  if (camera)
182  setFromPerspectiveCamera(camera, typeName(), iFrom);
183 }
184 
virtual void addTo(FWConfiguration &) const
virtual void setFrom(const FWConfiguration &)
Definition: FWEveView.cc:355
const std::string & typeName() const
Definition: FWViewBase.cc:120
bool ev
TGLViewer * viewerGL() const
Definition: FWEveView.cc:197
sigc::signal< void, T > changed_
virtual void setFrom(const FWConfiguration &)
TEveGeoShape * m_cylinder
Definition: FWGlimpseView.h:57
FWGlimpseView(TEveWindowSlot *, FWViewType::EType)
TEveViewer * viewer()
Definition: FWEveView.h:74
virtual ~FWGlimpseView()
void setFromPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, const FWConfiguration &)
Definition: FWEveView.cc:494
TEveScene * geoScene()
Definition: FWEveView.h:76
FWBoolParameter m_showCylinder
Definition: FWGlimpseView.h:61
tuple zAxis
Definition: MetAnalyzer.py:56
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:42
virtual void addTo(FWConfiguration &) const
Definition: FWEveView.cc:337
FWBoolParameter m_showAxes
Definition: FWGlimpseView.h:60
void addToPerspectiveCamera(TGLPerspectiveCamera *, const std::string &, FWConfiguration &) const
Definition: FWEveView.cc:465