File indexing completed on 2024-04-06 12:11:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <functional>
0014
0015 #include "TGLPerspectiveCamera.h"
0016 #include "TGLViewer.h"
0017 #include "TGLScenePad.h"
0018 #include "TEveScene.h"
0019 #include "TEveViewer.h"
0020
0021 #include "TEveManager.h"
0022 #include "TEveElement.h"
0023
0024 #include "TEveText.h"
0025 #include "TGLFontManager.h"
0026
0027 #include "TEveTrans.h"
0028 #include "TGeoTube.h"
0029 #include "TEveGeoNode.h"
0030 #include "TEveGeoShape.h"
0031 #include "TEveStraightLineSet.h"
0032
0033
0034 #include "Fireworks/Core/interface/FWGlimpseView.h"
0035 #include "Fireworks/Core/interface/BuilderUtils.h"
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 FWGlimpseView::FWGlimpseView(TEveWindowSlot* iParent, FWViewType::EType typeId)
0050 : FWEveView(iParent, typeId),
0051 m_cylinder(nullptr),
0052 m_showAxes(this, "Show Axes", true),
0053 m_showCylinder(this, "Show Cylinder", true) {
0054 createAxis();
0055
0056
0057 TEveScene* wns = gEve->SpawnNewScene(Form("Wireframe Scene %s", typeName().c_str()));
0058 viewer()->AddScene(wns);
0059 TGLScene* gls = wns->GetGLScene();
0060 gls->SetStyle(TGLRnrCtx::kWireFrame);
0061 gls->SetLOD(TGLRnrCtx::kLODMed);
0062 gls->SetSelectable(kFALSE);
0063
0064 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
0065 TGeoTube* tube = new TGeoTube(129, 130, 310);
0066 m_cylinder = fireworks::getShape("Detector outline", tube, kWhite);
0067 m_cylinder->SetPickable(kFALSE);
0068 m_cylinder->SetMainColor(kGray + 3);
0069 wns->AddElement(m_cylinder);
0070
0071 TGLViewer* ev = viewerGL();
0072 ev->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
0073 m_showAxes.changed_.connect(std::bind(&FWGlimpseView::showAxes, this));
0074 m_showCylinder.changed_.connect(std::bind(&FWGlimpseView::showCylinder, this));
0075 }
0076
0077 FWGlimpseView::~FWGlimpseView() {}
0078
0079
0080
0081
0082
0083 void FWGlimpseView::createAxis() {
0084
0085 TEveElementList* axisHolder = new TEveElementList("GlimpseAxisHolder");
0086
0087 TGLFont::EMode fontMode = TGLFont::kPixmap;
0088 Int_t fs = 14;
0089 Color_t fcol = kGray + 1;
0090
0091
0092 TEveStraightLineSet* xAxis = new TEveStraightLineSet("GlimpseXAxis");
0093 xAxis->SetPickable(kTRUE);
0094 xAxis->SetTitle("Energy Scale, 100 GeV, X-axis (LHC center)");
0095 xAxis->SetLineStyle(3);
0096 xAxis->SetLineColor(fcol);
0097 xAxis->AddLine(-100, 0, 0, 100, 0, 0);
0098 axisHolder->AddElement(xAxis);
0099
0100 TEveText* xTxt = new TEveText("X+");
0101 xTxt->PtrMainTrans()->SetPos(100 - fs, -fs, 0);
0102 xTxt->SetFontMode(fontMode);
0103 xTxt->SetMainColor(fcol);
0104 axisHolder->AddElement(xTxt);
0105
0106
0107 TEveStraightLineSet* yAxis = new TEveStraightLineSet("GlimpseYAxis");
0108 yAxis->SetPickable(kTRUE);
0109 yAxis->SetTitle("Energy Scale, 100 GeV, Y-axis (upward)");
0110 yAxis->SetLineColor(fcol);
0111 yAxis->SetLineStyle(3);
0112 yAxis->AddLine(0, -100, 0, 0, 100, 0);
0113 axisHolder->AddElement(yAxis);
0114
0115 TEveText* yTxt = new TEveText("Y+");
0116 yTxt->PtrMainTrans()->SetPos(0, 100 - fs, 0);
0117 yTxt->SetFontMode(fontMode);
0118 yTxt->SetMainColor(fcol);
0119 axisHolder->AddElement(yTxt);
0120
0121
0122 TEveStraightLineSet* zAxis = new TEveStraightLineSet("GlimpseZAxis");
0123 zAxis->SetPickable(kTRUE);
0124 zAxis->SetTitle("Energy Scale, 100 GeV, Z-axis (west, along beam)");
0125 zAxis->SetLineColor(fcol);
0126 zAxis->AddLine(0, 0, -100, 0, 0, 100);
0127 axisHolder->AddElement(zAxis);
0128
0129 TEveText* zTxt = new TEveText("Z+");
0130 zTxt->PtrMainTrans()->SetPos(0, -fs, 100 - zTxt->GetExtrude() * 2);
0131 zTxt->SetFontMode(fontMode);
0132 zTxt->SetMainColor(fcol);
0133 axisHolder->AddElement(zTxt);
0134
0135 geoScene()->AddElement(axisHolder);
0136 }
0137
0138 void FWGlimpseView::showAxes() {
0139 if (m_showAxes.value())
0140 viewerGL()->SetGuideState(TGLUtil::kAxesOrigin, kTRUE, kFALSE, nullptr);
0141 else
0142 viewerGL()->SetGuideState(TGLUtil::kAxesNone, kTRUE, kFALSE, nullptr);
0143 }
0144
0145 void FWGlimpseView::showCylinder() {
0146 if (m_showCylinder.value())
0147 m_cylinder->SetRnrState(kTRUE);
0148 else
0149 m_cylinder->SetRnrState(kFALSE);
0150
0151 gEve->Redraw3D();
0152 }
0153
0154 void FWGlimpseView::addTo(FWConfiguration& iTo) const {
0155 FWEveView::addTo(iTo);
0156 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
0157 if (camera)
0158 addToPerspectiveCamera(camera, typeName(), iTo);
0159 }
0160
0161 void FWGlimpseView::setFrom(const FWConfiguration& iFrom) {
0162 FWEveView::setFrom(iFrom);
0163 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
0164 if (camera)
0165 setFromPerspectiveCamera(camera, typeName(), iFrom);
0166 }