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