1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include <Riostream.h>
22 #include "MUONChamberGL.h"
24 #include <Alieve/MUONChamber.h>
25 #include <Alieve/MUONChamberData.h>
27 #include <TEveQuadSetGL.h>
28 #include <TGLRnrCtx.h>
29 #include <TGLIncludes.h>
30 using namespace Alieve;
32 //______________________________________________________________________
36 ClassImp(MUONChamberGL)
38 //______________________________________________________________________
39 MUONChamberGL::MUONChamberGL() :
50 //______________________________________________________________________
51 MUONChamberGL::~MUONChamberGL()
59 //______________________________________________________________________
60 Bool_t MUONChamberGL::SetModel(TObject* obj, const Option_t* /*opt*/)
66 if(SetModelCheckClass(obj, Alieve::MUONChamber::Class())) {
68 fChamber = (MUONChamber*) fExternalObj;
69 fQS1.SetModel(&fChamber->fQuadSet1);
70 fQS2.SetModel(&fChamber->fQuadSet2);
79 //______________________________________________________________________
80 void MUONChamberGL::SetBBox()
86 SetAxisAlignedBBox(((MUONChamber*)fExternalObj)->AssertBBox());
90 //______________________________________________________________________
91 void MUONChamberGL::DirectDraw(TGLRnrCtx& rnrCtx) const
97 glDisable(GL_LIGHTING);
99 //Double_t width = 10;
100 //glOrtho(-width,+width,-width,+width,-width,+width);
102 if(fRTS < fChamber->fRTS) {
103 fChamber->UpdateQuads();
104 fRTS = fChamber->fRTS;
107 Bool_t hasData = (fChamber->GetChamberData() != 0);
120 //______________________________________________________________________
121 void MUONChamberGL::DrawQuads(TGLRnrCtx& rnrCtx) const
124 // draw the digits as GL_QUADS
127 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
129 glDisable(GL_LIGHTING);
130 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
131 glEnable(GL_COLOR_MATERIAL);
132 glDisable(GL_CULL_FACE);
134 //Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c);
136 glPolygonMode(GL_FRONT, GL_FILL);
137 glPolygonMode(GL_BACK, GL_LINE);
139 fQS1.DirectDraw(rnrCtx);
141 glPolygonMode(GL_FRONT, GL_LINE);
142 glPolygonMode(GL_BACK, GL_FILL);
144 fQS2.DirectDraw(rnrCtx);
150 //______________________________________________________________________
151 void MUONChamberGL::DrawPoints() const
154 // draw the clusters as GL_QUADS
159 glDisable(GL_LIGHTING);
162 glColor3f(1.0,1.0,1.0);
168 Int_t clsSize = fChamber->fClusterSize;
172 for (Int_t i = 0; i < fChamber->fPointSet1.GetN(); i++) {
174 fChamber->fPointSet1.GetPoint(i,x,y,z);
176 glVertex3f(x-clsSize,y+clsSize,z);
177 glVertex3f(x+clsSize,y-clsSize,z);
179 glVertex3f(x-clsSize,y-clsSize,z);
180 glVertex3f(x+clsSize,y+clsSize,z);
188 Int_t hitSize = fChamber->fHitSize;
192 for (Int_t i = 0; i < fChamber->fPointSet2.GetN(); i++) {
194 fChamber->fPointSet2.GetPoint(i,x,y,z);
196 glVertex3f(x-hitSize,y,z);
197 glVertex3f(x+hitSize,y,z);
199 glVertex3f(x,y-hitSize,z);
200 glVertex3f(x,y+hitSize,z);
210 //______________________________________________________________________
211 void MUONChamberGL::DrawChamberFrame() const
214 // draw the chamber frame as GL_LINE_LOOP
217 MUONChamberData* chamberData = fChamber->GetChamberData();
218 Int_t nDetElem = chamberData->GetNDetElem();
220 Float_t xOrig, yOrig, xRad, yRad, x, y, z;
230 for (Int_t id = 0; id < nDetElem; id++) {
232 frameCoord = chamberData->GetFrameCoord(id);
234 if (fChamber->GetID() < 4) {
236 xOrig = frameCoord[0];
237 yOrig = frameCoord[1];
238 xRad = frameCoord[2];
239 yRad = frameCoord[3];
245 glBegin(GL_LINE_LOOP);
247 glVertex3f(xOrig,yOrig,z);
250 Float_t dstep = TMath::Pi()/2.0 / (Float_t)nstep;
252 for (Int_t istep = 0; istep < nstep; istep++) {
255 x = xOrig + xRad * TMath::Cos(d);
256 y = yOrig + yRad * TMath::Sin(d);
262 glVertex3f(xOrig,yOrig,z);
268 glBegin(GL_LINE_LOOP);
269 glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]);
270 glVertex3f(frameCoord[0],frameCoord[3],frameCoord[4]);
271 glVertex3f(frameCoord[2],frameCoord[3],frameCoord[4]);
272 glVertex3f(frameCoord[2],frameCoord[1],frameCoord[4]);
273 glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]);