Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLLegoPainter.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Timur Pocheptsov 14/06/2006
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11#include <algorithm>
12#include <cctype>
13
14#include "KeySymbols.h"
15#include "TVirtualX.h"
16#include "Buttons.h"
17#include "TString.h"
18#include "TColor.h"
19#include "TROOT.h"
20#include "TStyle.h"
21#include "TAxis.h"
22#include "TMath.h"
23#include "TH1.h"
24
25#include "TGLLegoPainter.h"
26#include "TGLPlotCamera.h"
27#include "TGLIncludes.h"
28
29/** \class TGLLegoPainter
30\ingroup opengl
31Plot-painter implementing LEGO rendering of TH2 histograms in
32cartesian, polar, cylindrical and spherical coordinates.
33*/
34
36
37////////////////////////////////////////////////////////////////////////////////
38///Ctor.
39
41 : TGLPlotPainter(hist, cam, coord, kFALSE, kTRUE, kTRUE),
42 fLegoType(kColorSimple),
43 fMinZ(0.),
44 fDrawErrors(kFALSE)
45{
46}
47
48////////////////////////////////////////////////////////////////////////////////
49///Obtain bin's info (i, j, value).
50
52{
53 fBinInfo = "";
54
55 if (fSelectedPart) {
57 if (fHist->Class())
58 fBinInfo += fHist->Class()->GetName();
59 fBinInfo += "::";
61 } else if (!fHighColor) {
64 fBinInfo.Form("(binx = %d; biny = %d; binc = %f)", binI, binJ,
65 fHist->GetBinContent(binI, binJ));
66 } else
67 fBinInfo = "Switch to true-color mode to obtain correct info";
68 }
69
70 return (Char_t *)fBinInfo.Data();
71}
72
73////////////////////////////////////////////////////////////////////////////////
74///Select method.
75
77{
78 Bool_t ret = kFALSE;
79 switch (fCoord->GetCoordType()) {
80 case kGLCartesian:
81 ret = InitGeometryCartesian(); break;
82 case kGLPolar:
83 ret = InitGeometryPolar(); break;
84 case kGLCylindrical:
85 ret = InitGeometryCylindrical(); break;
86 case kGLSpherical:
87 ret = InitGeometrySpherical(); break;
88 default:
89 return kFALSE;
90 }
92 return ret;
93}
94
95////////////////////////////////////////////////////////////////////////////////
96///Geometry for lego in cartesian coords.
97
99{
101 return kFALSE;
102
104
105 //Find bin edges
106 const Int_t nX = fCoord->GetNXBins();
107 const Double_t barWidth = fHist->GetBarWidth(), barOffset = fHist->GetBarOffset();
108 const TGLVertex3 *frame = fBackBox.Get3DBox();
109 fXEdges.resize(nX);
110
111 if (fCoord->GetXLog()) {
112 for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
113 const Double_t xWidth = fXAxis->GetBinWidth(ir);
114 Double_t low = fXAxis->GetBinLowEdge(ir) + xWidth * barOffset;
115 fXEdges[i].first = TMath::Log10(low) * fCoord->GetXScale();
116 fXEdges[i].second = TMath::Log10(low + xWidth * barWidth) * fCoord->GetXScale();
117 if (fXEdges[i].second > frame[1].X())
118 fXEdges[i].second = frame[1].X();
119 if (fXEdges[i].first < frame[0].X())
120 fXEdges[i].first = frame[0].X();
121 if (fXEdges[i].second < frame[0].X())
122 fXEdges[i].second = frame[0].X();
123 }
124 } else {
125 for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
126 const Double_t xWidth = fXAxis->GetBinWidth(ir);
127 fXEdges[i].first = (fXAxis->GetBinLowEdge(ir) + xWidth * barOffset) * fCoord->GetXScale();
128 fXEdges[i].second = fXEdges[i].first + xWidth * barWidth * fCoord->GetXScale();
129 if (fXEdges[i].second > frame[1].X())
130 fXEdges[i].second = frame[1].X();
131 if (fXEdges[i].first < frame[0].X())
132 fXEdges[i].first = frame[0].X();
133 if (fXEdges[i].second < frame[0].X())
134 fXEdges[i].second = frame[0].X();
135 }
136 }
137
138 const Int_t nY = fCoord->GetNYBins();
139 fYEdges.resize(nY);
140
141 if (fCoord->GetYLog()) {
142 for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
143 const Double_t yWidth = fYAxis->GetBinWidth(jr);
144 Double_t low = fYAxis->GetBinLowEdge(jr) + yWidth * barOffset;
145 fYEdges[j].first = TMath::Log10(low) * fCoord->GetYScale();
146 fYEdges[j].second = TMath::Log10(low + yWidth * barWidth) * fCoord->GetYScale();
147 if (fYEdges[j].second > frame[2].Y())
148 fYEdges[j].second = frame[2].Y();
149 if (fYEdges[j].first < frame[0].Y())
150 fYEdges[j].first = frame[0].Y();
151 if (fYEdges[j].second < frame[0].Y())
152 fYEdges[j].second = frame[0].Y();
153 }
154 } else {
155 for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
156 const Double_t yWidth = fYAxis->GetBinWidth(jr);
157 fYEdges[j].first = (fYAxis->GetBinLowEdge(jr) + yWidth * barOffset) * fCoord->GetYScale();
158 fYEdges[j].second = fYEdges[j].first + yWidth * barWidth * fCoord->GetYScale();
159 if (fYEdges[j].second > frame[2].Y())
160 fYEdges[j].second = frame[2].Y();
161 if (fYEdges[j].first < frame[0].Y())
162 fYEdges[j].first = frame[0].Y();
163 if (fYEdges[j].second < frame[0].Y())
164 fYEdges[j].second = frame[0].Y();
165 }
166 }
167
168 fMinZ = frame[0].Z();
169 if (fMinZ < 0.)
170 frame[4].Z() > 0. ? fMinZ = 0. : fMinZ = frame[4].Z();
171
172 if (fCoord->Modified()) {
174 fXOZSectionPos = frame[0].Y();
175 fYOZSectionPos = frame[0].X();
176 fXOYSectionPos = frame[0].Z();
179 }
180
182 fMinMaxVal.second = fMinMaxVal.first;
183
184 for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
185 for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
186 Double_t val = fHist->GetBinContent(i, j);
187 fMinMaxVal.first = TMath::Min(fMinMaxVal.first, val);
188 fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
189 }
190 }
191
192 ClampZ(fMinMaxVal.first);
193 ClampZ(fMinMaxVal.second);
194
195 return kTRUE;
196}
197
198////////////////////////////////////////////////////////////////////////////////
199///Geometry for lego in polar coords.
200
202{
204 return kFALSE;
205
207
208 if (fCoord->Modified()) {
211 }
212
213 const Int_t nY = fCoord->GetNYBins();//yBins.second - yBins.first + 1;
214 fYEdges.resize(nY);
215
216 for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
217 fYEdges[j].first = ((fYAxis->GetBinLowEdge(jr)) - fCoord->GetYRange().first) /
219 fYEdges[j].second = ((fYAxis->GetBinUpEdge(jr)) - fCoord->GetYRange().first) /
221 }
222
223 const Int_t nX = fCoord->GetNXBins();
224 fCosSinTableX.resize(nX + 1);
225 const Double_t fullAngle = fXAxis->GetXmax() - fXAxis->GetXmin();
226 const Double_t phiLow = fXAxis->GetXmin();
227 Double_t angle = 0;
228 for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
229 angle = (fXAxis->GetBinLowEdge(ir) - phiLow) / fullAngle * TMath::TwoPi();
230 fCosSinTableX[i].first = TMath::Cos(angle);
231 fCosSinTableX[i].second = TMath::Sin(angle);
232 }
233 angle = (fXAxis->GetBinUpEdge(fCoord->GetLastXBin()) - phiLow) / fullAngle * TMath::TwoPi();
234 fCosSinTableX[nX].first = TMath::Cos(angle);
235 fCosSinTableX[nX].second = TMath::Sin(angle);
236
237 fMinZ = fBackBox.Get3DBox()[0].Z();
238 if (fMinZ < 0.)
239 fBackBox.Get3DBox()[4].Z() > 0. ? fMinZ = 0. : fMinZ = fBackBox.Get3DBox()[4].Z();
240
242 fMinMaxVal.second = fMinMaxVal.first;
243
244 for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
245 for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
246 Double_t val = fHist->GetBinContent(i, j);
247 fMinMaxVal.first = TMath::Min(fMinMaxVal.first, val);
248 fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
249 }
250 }
251
252 ClampZ(fMinMaxVal.first);
253 ClampZ(fMinMaxVal.second);
254
255 return kTRUE;
256}
257
258////////////////////////////////////////////////////////////////////////////////
259///Geometry for lego in cylindrical coords.
260
262{
264 return kFALSE;
265
267
268 const Int_t nY = fCoord->GetNYBins();
269 fYEdges.resize(nY);
270
271 if (fCoord->GetYLog()) {
272 for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
275 }
276 } else {
277 for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
278 fYEdges[j].first = fYAxis->GetBinLowEdge(jr) * fCoord->GetYScale();
279 fYEdges[j].second = fYAxis->GetBinUpEdge(jr) * fCoord->GetYScale();
280 }
281 }
282
283 const Int_t nX = fCoord->GetNXBins();
284 fCosSinTableX.resize(nX + 1);
285 const Double_t fullAngle = fXAxis->GetXmax() - fXAxis->GetXmin();
286 const Double_t phiLow = fXAxis->GetXmin();
287 Double_t angle = 0.;
288 for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
289 angle = (fXAxis->GetBinLowEdge(ir) - phiLow) / fullAngle * TMath::TwoPi();
290 fCosSinTableX[i].first = TMath::Cos(angle);
291 fCosSinTableX[i].second = TMath::Sin(angle);
292 }
293 angle = (fXAxis->GetBinUpEdge(fCoord->GetLastXBin()) - phiLow) / fullAngle * TMath::TwoPi();
294 fCosSinTableX[nX].first = TMath::Cos(angle);
295 fCosSinTableX[nX].second = TMath::Sin(angle);
296
297 if (fCoord->Modified()) {
300 }
301
302 fMinZ = fCoord->GetZRange().first;
303 if (fMinZ < 0.)
304 fCoord->GetZRange().second > 0. ? fMinZ = 0. : fMinZ = fCoord->GetZRange().second;
305
306
308 fMinMaxVal.second = fMinMaxVal.first;
309
310 for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
311 for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
312 Double_t val = fHist->GetBinContent(i, j);
313 fMinMaxVal.first = TMath::Min(fMinMaxVal.first, val);
314 fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
315 }
316 }
317
318 return kTRUE;
319}
320
321////////////////////////////////////////////////////////////////////////////////
322///Geometry for lego in spherical coords.
323
325{
327 return kFALSE;
328
330
331 const Int_t nY = fCoord->GetNYBins();
332 fCosSinTableY.resize(nY + 1);
333 const Double_t fullTheta = fYAxis->GetXmax() - fYAxis->GetXmin();
334 const Double_t thetaLow = fYAxis->GetXmin();
335 Double_t angle = 0.;
336 for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
337 angle = (fYAxis->GetBinLowEdge(jr) - thetaLow) / fullTheta * TMath::Pi();
338 fCosSinTableY[j].first = TMath::Cos(angle);
339 fCosSinTableY[j].second = TMath::Sin(angle);
340 }
341 angle = (fYAxis->GetBinUpEdge(fCoord->GetLastYBin()) - thetaLow) / fullTheta * TMath::Pi();
342 fCosSinTableY[nY].first = TMath::Cos(angle);
343 fCosSinTableY[nY].second = TMath::Sin(angle);
344
345 const Int_t nX = fCoord->GetNXBins();
346 fCosSinTableX.resize(nX + 1);
347 const Double_t fullPhi = fXAxis->GetXmax() - fXAxis->GetXmin();
348 const Double_t phiLow = fXAxis->GetXmin();
349
350 for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
351 angle = (fXAxis->GetBinLowEdge(ir) - phiLow) / fullPhi * TMath::TwoPi();
352 fCosSinTableX[i].first = TMath::Cos(angle);
353 fCosSinTableX[i].second = TMath::Sin(angle);
354 }
355
356 angle = (fXAxis->GetBinUpEdge(fCoord->GetLastXBin()) - phiLow) / fullPhi * TMath::TwoPi();
357 fCosSinTableX[nX].first = TMath::Cos(angle);
358 fCosSinTableX[nX].second = TMath::Sin(angle);
359
360 fMinZ = fCoord->GetZRange().first;
361 if (fMinZ < 0.)
362 fCoord->GetZRange().second > 0. ? fMinZ = 0. : fMinZ = fCoord->GetZRange().second;
363
365 fMinMaxVal.second = fMinMaxVal.first;
366
367 for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
368 for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
369 Double_t val = fHist->GetBinContent(i, j);
370 fMinMaxVal.first = TMath::Min(fMinMaxVal.first, val);
371 fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
372 }
373 }
374
375
376 return kTRUE;
377}
378
379////////////////////////////////////////////////////////////////////////////////
380///User clicks on a lego with middle mouse button (middle for pad).
381
383{
384 fMousePosition.fX = px;
386 fCamera->StartPan(px, py);
387 fBoxCut.StartMovement(px, py);
388}
389
390////////////////////////////////////////////////////////////////////////////////
391///Move lego or section.
392
394{
398
401 fCamera->Pan(px, py);
402
405 } else if (fSelectedPart > 0) {
406 //Convert py into bottom-top orientation.
407 py = fCamera->GetHeight() - py;
408
411
414
415 if (!fHighColor) {
418 else
419 MoveSection(px, py);
420 } else
421 MoveSection(px, py);
422
425 }
426
429}
430
431////////////////////////////////////////////////////////////////////////////////
432///Parse additional options.
433
435{
436 const Ssiz_t legoPos = option.Index("lego");//"lego" _already_ _exists_ in a string.
437 if (legoPos + 4 < option.Length() && isdigit(option[legoPos + 4])) {
438 switch (option[legoPos + 4] - '0') {
439 case 1:
441 break;
442 case 2:
444 break;
445 case 3:
447 break;
448 default:
450 break;
451 }
452 } else
454 //check 'e' option
455 Ssiz_t ePos = option.Index("e");
456 if (ePos == legoPos + 1)
457 ePos = option.Index("e", legoPos + 4);
458 fDrawErrors = ePos != kNPOS ? kTRUE : kFALSE;
459
460 option.Index("z") == kNPOS ? fDrawPalette = kFALSE : fDrawPalette = kTRUE;
461}
462
463////////////////////////////////////////////////////////////////////////////////
464///Initialize some gl state variables.
465
467{
468 glEnable(GL_DEPTH_TEST);
469 glEnable(GL_LIGHTING);
470 glEnable(GL_LIGHT0);
471 //For lego, back polygons are culled (but not for sections).
472 glEnable(GL_CULL_FACE);
473 glCullFace(GL_BACK);
474
475 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
476}
477
478////////////////////////////////////////////////////////////////////////////////
479///Return some gl states to original values.
480
482{
483 glDisable(GL_DEPTH_TEST);
484 glDisable(GL_LIGHTING);
485 glDisable(GL_LIGHT0);
486 glDisable(GL_CULL_FACE);
487 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
488}
489
490////////////////////////////////////////////////////////////////////////////////
491///Select method corresponding to coordinate system.
492
494{
495 //Shift plot to point of origin.
496 const Rgl::PlotTranslation trGuard(this);
497
498 switch (fCoord->GetCoordType()) {
499 case kGLCartesian:
500 return DrawLegoCartesian();
501 case kGLPolar:
502 return DrawLegoPolar();
503 case kGLCylindrical:
504 return DrawLegoCylindrical();
505 case kGLSpherical:
506 return DrawLegoSpherical();
507 default:;
508 }
509}
510
511////////////////////////////////////////////////////////////////////////////////
512///Lego in cartesian system.
513
515{
516 if (fCoord->GetCoordType() == kGLCartesian) {
518 const TGLDisableGuard cullGuard(GL_CULL_FACE);
519 DrawSections();
520 }
521
522 //const TGLDisableGuard depthTest(GL_DEPTH_TEST); //[0-0]
523
524 if (!fSelectionPass) {
525 glEnable(GL_POLYGON_OFFSET_FILL);//[0
526 glPolygonOffset(1.f, 1.f);
527 SetLegoColor();
529 //Lego is semi-transparent if we have any sections.
530 glEnable(GL_BLEND);//[1
531 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
532 }
533 }
534
535 //Using front point, find the correct order to draw bars from
536 //back to front (it's important only for semi-transparent lego).
537 //Only in cartesian.
538 const Int_t nX = fXEdges.size();
539 const Int_t nY = fYEdges.size();
540 const Int_t frontPoint = fBackBox.GetFrontPoint();
541 Int_t iInit = 0, jInit = 0, irInit = fCoord->GetFirstXBin(), jrInit = fCoord->GetFirstYBin();
542 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit = fCoord->GetLastXBin(), -1);
543 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit = fCoord->GetLastYBin(), -1);
544
546 if (!PreparePalette()) {
549 } else
550 fPalette.EnableTexture(GL_MODULATE);
551 }
552
555
556 for(Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
557 for(Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
558 Double_t zMax = fHist->GetBinContent(ir, jr) * fCoord->GetFactor();
559 if (!ClampZ(zMax))
560 continue;
561
562 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
563
566 else if(!fHighColor && fSelectedPart == binID)
567 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
568
569 if (fLegoType == kCylindricBars) {
570 Rgl::DrawCylinder(&fQuadric, fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
571 fYEdges[j].second, fMinZ, zMax);
572 } else if (fLegoType == kColorLevel && !fSelectionPass) {
573 Rgl::DrawBoxFrontTextured(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
574 fYEdges[j].second, fMinZ, zMax, fPalette.GetTexCoord(fMinZ),
575 fPalette.GetTexCoord(zMax), frontPoint);
576 } else {
577 Rgl::DrawBoxFront(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
578 fYEdges[j].second, fMinZ, zMax, frontPoint);
579 }
580
581 if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
582 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
583 }
584 }
585
588
589 //Draw outlines for non-cylindrical bars.
590 if (!fSelectionPass) {
591 glDisable(GL_POLYGON_OFFSET_FILL);//0]
592 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2 - 2]
594 glColor3d(0., 0., 0.);
595 else
596 glColor4d(0., 0., 0., 0.4);
597 glPolygonMode(GL_FRONT, GL_LINE);//[3
598
599 const TGLEnableGuard blendGuard(GL_BLEND);//[4-4] + 1]
600 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
601 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);//[5-5]
602 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
603
604 for(Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
605 for(Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
606 Double_t zMax = fHist->GetBinContent(ir, jr) * fCoord->GetFactor();
607 if (!ClampZ(zMax))
608 continue;
609 if (fLegoType != kCylindricBars) {
610 Rgl::DrawBoxFront(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
611 fYEdges[j].second, fMinZ, zMax, frontPoint);
612 }
613 if (fDrawErrors && zMax > 0.) {
614 Double_t errorZMax = (fHist->GetBinContent(ir, jr) + fHist->GetBinError(ir, jr)) * fCoord->GetFactor();
615 ClampZ(errorZMax);
616 Rgl::DrawError(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
617 fYEdges[j].second, zMax, errorZMax);
618 }
619 }
620 }
621
622 glPolygonMode(GL_FRONT, GL_FILL);//3]
623 }
624
626 DrawPalette();
627}
628
629////////////////////////////////////////////////////////////////////////////////
630///Lego in polar system.
631
633{
634 const Int_t nX = fCosSinTableX.size() - 1;
635 const Int_t nY = fYEdges.size();
636
637 if (!fSelectionPass) {
638 SetLegoColor();
639 glEnable(GL_POLYGON_OFFSET_FILL);
640 glPolygonOffset(1.f, 1.f);
641 }
642
643 Double_t points[4][2] = {};
644
646 if (!PreparePalette()) {
649 } else
650 fPalette.EnableTexture(GL_MODULATE);
651 }
652
655
656 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
657 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
658 Double_t zMax = fHist->GetBinContent(ir, jr);
659 if (!ClampZ(zMax))
660 continue;
661 points[0][0] = fYEdges[j].first * fCosSinTableX[i].first;
662 points[0][1] = fYEdges[j].first * fCosSinTableX[i].second;
663 points[1][0] = fYEdges[j].second * fCosSinTableX[i].first;
664 points[1][1] = fYEdges[j].second * fCosSinTableX[i].second;
665 points[2][0] = fYEdges[j].second * fCosSinTableX[i + 1].first;
666 points[2][1] = fYEdges[j].second * fCosSinTableX[i + 1].second;
667 points[3][0] = fYEdges[j].first * fCosSinTableX[i + 1].first;
668 points[3][1] = fYEdges[j].first * fCosSinTableX[i + 1].second;
669
670 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
671
674 else if(!fHighColor && fSelectedPart == binID)
675 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
676
679 fPalette.GetTexCoord(zMax));
680 else
682
683 if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
684 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
685 }
686 }
687
690
691 //Draw outlines.
692 if (!fSelectionPass) {
693 glDisable(GL_POLYGON_OFFSET_FILL);//0]
694 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
695 glColor3d(0., 0., 0.);
696 glPolygonMode(GL_FRONT, GL_LINE);//[3
697 const TGLEnableGuard blendGuard(GL_BLEND);
698 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
699 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
700 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
701
702 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
703 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
704 Double_t zMax = fHist->GetBinContent(ir, jr);
705 if (!ClampZ(zMax))
706 continue;
707 points[0][0] = fYEdges[j].first * fCosSinTableX[i].first;
708 points[0][1] = fYEdges[j].first * fCosSinTableX[i].second;
709 points[1][0] = fYEdges[j].second * fCosSinTableX[i].first;
710 points[1][1] = fYEdges[j].second * fCosSinTableX[i].second;
711 points[2][0] = fYEdges[j].second * fCosSinTableX[i + 1].first;
712 points[2][1] = fYEdges[j].second * fCosSinTableX[i + 1].second;
713 points[3][0] = fYEdges[j].first * fCosSinTableX[i + 1].first;
714 points[3][1] = fYEdges[j].first * fCosSinTableX[i + 1].second;
716 }
717 }
718
719 glPolygonMode(GL_FRONT, GL_FILL);//3]
720 }
721
723 DrawPalette();
724}
725
726////////////////////////////////////////////////////////////////////////////////
727///Lego in cylindrical system.
728
730{
731 const Int_t nX = fCosSinTableX.size() - 1;
732 const Int_t nY = fYEdges.size();
733 Double_t legoR = gStyle->GetLegoInnerR();
734 if (legoR > 1. || legoR < 0.)
735 legoR = 0.5;
736 const Double_t rRange = fCoord->GetZLength();
737
738 if (!fSelectionPass) {
739 SetLegoColor();
740 glEnable(GL_POLYGON_OFFSET_FILL);
741 glPolygonOffset(1.f, 1.f);
742 }
743
744 Double_t points[4][2] = {};
745 const Double_t sc = (1 - legoR) * fCoord->GetXScale();
746 legoR *= fCoord->GetXScale();
747
749 if (!PreparePalette()) {
752 } else
753 fPalette.EnableTexture(GL_MODULATE);
754 }
755
758
759 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
760 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
761 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
762 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
763 if (zMin > zMax)
764 std::swap(zMin, zMax);
765
766 points[0][0] = fCosSinTableX[i].first * zMin;
767 points[0][1] = fCosSinTableX[i].second * zMin;
768 points[1][0] = fCosSinTableX[i].first * zMax;
769 points[1][1] = fCosSinTableX[i].second * zMax;
770 points[2][0] = fCosSinTableX[i + 1].first * zMax;
771 points[2][1] = fCosSinTableX[i + 1].second * zMax;
772 points[3][0] = fCosSinTableX[i + 1].first * zMin;
773 points[3][1] = fCosSinTableX[i + 1].second * zMin;
774
775 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
776
779 else if(!fHighColor && fSelectedPart == binID)
780 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
781
785 }else
786 Rgl::DrawTrapezoid(points, fYEdges[j].first, fYEdges[j].second);
787
788 if(!fSelectionPass && !fHighColor && fSelectedPart == binID)
789 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
790 }
791 }
792
795
796 //Draw outlines.
797 if (!fSelectionPass) {
798 glDisable(GL_POLYGON_OFFSET_FILL);//0]
799 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
800 glColor3d(0., 0., 0.);
801 glPolygonMode(GL_FRONT, GL_LINE);//[3
802
803 const TGLEnableGuard blendGuard(GL_BLEND);
804 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
805 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
806 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
807
808 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
809 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
810 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
811 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
812 if (zMin > zMax)
813 std::swap(zMin, zMax);
814
815 points[0][0] = fCosSinTableX[i].first * zMin;
816 points[0][1] = fCosSinTableX[i].second * zMin;
817 points[1][0] = fCosSinTableX[i].first * zMax;
818 points[1][1] = fCosSinTableX[i].second * zMax;
819 points[2][0] = fCosSinTableX[i + 1].first * zMax;
820 points[2][1] = fCosSinTableX[i + 1].second * zMax;
821 points[3][0] = fCosSinTableX[i + 1].first * zMin;
822 points[3][1] = fCosSinTableX[i + 1].second * zMin;
823 Rgl::DrawTrapezoid(points, fYEdges[j].first, fYEdges[j].second);
824 }
825 }
826
827 glPolygonMode(GL_FRONT, GL_FILL);//3]
828 }
829
831 DrawPalette();
832}
833
834////////////////////////////////////////////////////////////////////////////////
835///Lego in spherical system.
836
838{
839 const Int_t nX = fCosSinTableX.size() - 1;
840 const Int_t nY = fCosSinTableY.size() - 1;
841 const Double_t rRange = fCoord->GetZLength();
842 Double_t legoR = gStyle->GetLegoInnerR();
843 if (legoR > 1. || legoR < 0.)
844 legoR = 0.5;
845
846 if (!fSelectionPass) {
847 SetLegoColor();
848 glEnable(GL_POLYGON_OFFSET_FILL);
849 glPolygonOffset(1.f, 1.f);
850 }
851
852 Double_t points[8][3] = {};
853 const Double_t sc = 1 - legoR;
854
856 if (!PreparePalette()) {
859 } else
860 fPalette.EnableTexture(GL_MODULATE);
861 }
862
865
866 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
867 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
868 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
869 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
870 if (zMin > zMax)
871 std::swap(zMin, zMax);
872
873 points[4][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].first;
874 points[4][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].second;
875 points[4][2] = zMin * fCosSinTableY[j].first;
876 points[5][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
877 points[5][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
878 points[5][2] = zMin * fCosSinTableY[j].first;
879 points[6][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
880 points[6][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
881 points[6][2] = zMax * fCosSinTableY[j].first;
882 points[7][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].first;
883 points[7][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].second;
884 points[7][2] = zMax * fCosSinTableY[j].first;
885 points[0][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
886 points[0][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
887 points[0][2] = zMin * fCosSinTableY[j + 1].first;
888 points[1][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
889 points[1][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
890 points[1][2] = zMin * fCosSinTableY[j + 1].first;
891 points[2][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
892 points[2][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
893 points[2][2] = zMax * fCosSinTableY[j + 1].first;
894 points[3][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
895 points[3][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
896 points[3][2] = zMax * fCosSinTableY[j + 1].first;
897
898 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
899
902 else if(!fHighColor && fSelectedPart == binID)
903 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
907 else
909
910 if(!fHighColor && fSelectedPart == binID)
911 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
912 }
913 }
914
917
918 //Draw outlines.
919 if (!fSelectionPass) {
920 glDisable(GL_POLYGON_OFFSET_FILL);//0]
921 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
922 glColor3d(0., 0., 0.);
923 glPolygonMode(GL_FRONT, GL_LINE);//[3
924 const TGLEnableGuard blendGuard(GL_BLEND);
925 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
926 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
927 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
928
929 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
930 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
931 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
932 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
933 if (zMin > zMax)
934 std::swap(zMin, zMax);
935
936 points[4][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].first;
937 points[4][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].second;
938 points[4][2] = zMin * fCosSinTableY[j].first;
939 points[5][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
940 points[5][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
941 points[5][2] = zMin * fCosSinTableY[j].first;
942 points[6][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
943 points[6][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
944 points[6][2] = zMax * fCosSinTableY[j].first;
945 points[7][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].first;
946 points[7][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].second;
947 points[7][2] = zMax * fCosSinTableY[j].first;
948 points[0][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
949 points[0][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
950 points[0][2] = zMin * fCosSinTableY[j + 1].first;
951 points[1][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
952 points[1][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
953 points[1][2] = zMin * fCosSinTableY[j + 1].first;
954 points[2][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
955 points[2][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
956 points[2][2] = zMax * fCosSinTableY[j + 1].first;
957 points[3][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
958 points[3][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
959 points[3][2] = zMax * fCosSinTableY[j + 1].first;
961 }
962 }
963
964 glPolygonMode(GL_FRONT, GL_FILL);//3]
965 }
966
968 DrawPalette();
969}
970
971////////////////////////////////////////////////////////////////////////////////
972///Set lego's color.
973
975{
976 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
977
979 if (const TColor *c = gROOT->GetColor(fHist->GetFillColor()))
980 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
981
982 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
983 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
984 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
985 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
986}
987
988////////////////////////////////////////////////////////////////////////////////
989///XOZ plane parallel section.
990
992{
993 Int_t binY = -1;
994
995 for (Int_t i = 0, e = fYEdges.size(); i < e; ++i) {
996 if (fYEdges[i].first <= fXOZSectionPos && fXOZSectionPos <= fYEdges[i].second) {
997 binY = i;
998 break;
999 }
1000 }
1001
1002 if (binY >= 0) {
1003 binY += fCoord->GetFirstYBin();
1004 glColor3d(1., 0., 0.);
1005 glLineWidth(3.f);
1006 //Draw 2d hist on the profile's plane.
1007 for (UInt_t i = 0, ir = fCoord->GetFirstXBin(), e = fXEdges.size(); i < e; ++i, ++ir) {
1008 Double_t zMax = fHist->GetBinContent(Int_t(ir), binY);
1009 if (!ClampZ(zMax))
1010 continue;
1011
1012 glBegin(GL_LINE_LOOP);
1013 glVertex3d(fXEdges[i].first, fXOZSectionPos, fMinZ);
1014 glVertex3d(fXEdges[i].first, fXOZSectionPos, zMax);
1015 glVertex3d(fXEdges[i].second, fXOZSectionPos, zMax);
1016 glVertex3d(fXEdges[i].second, fXOZSectionPos, fMinZ);
1017 glEnd();
1018 }
1019
1020 glLineWidth(1.f);
1021 }
1022}
1023
1024////////////////////////////////////////////////////////////////////////////////
1025///YOZ plane parallel section.
1026
1028{
1029 Int_t binX = -1;
1030
1031 for (Int_t i = 0, e = fXEdges.size(); i < e; ++i) {
1032 if (fXEdges[i].first <= fYOZSectionPos && fYOZSectionPos <= fXEdges[i].second) {
1033 binX = i;
1034 break;
1035 }
1036 }
1037
1038 if (binX >= 0) {
1039 binX += fCoord->GetFirstXBin();//fBinsX.first;
1040 glColor3d(1., 0., 0.);
1041 glLineWidth(3.f);
1042 //Draw 2d hist on the profile's plane.
1043 for (UInt_t i = 0, ir = fCoord->GetFirstYBin(), e = fYEdges.size(); i < e; ++i, ++ir) {
1044 Double_t zMax = fHist->GetBinContent(binX, ir);
1045 if (!ClampZ(zMax))
1046 continue;
1047
1048 glBegin(GL_LINE_LOOP);
1049 glVertex3d(fYOZSectionPos, fYEdges[i].first, fMinZ);
1050 glVertex3d(fYOZSectionPos, fYEdges[i].first, zMax);
1051 glVertex3d(fYOZSectionPos, fYEdges[i].second, zMax);
1052 glVertex3d(fYOZSectionPos, fYEdges[i].second, fMinZ);
1053 glEnd();
1054 }
1055
1056 glLineWidth(1.f);
1057 }
1058}
1059
1060////////////////////////////////////////////////////////////////////////////////
1061///Empty. No such sections for lego.
1062
1064{
1065}
1066
1067////////////////////////////////////////////////////////////////////////////////
1068///Remove all sections and repaint.
1069
1071{
1072 const TGLVertex3 *frame = fBackBox.Get3DBox();
1073 if (event == kButton1Double && (fXOZSectionPos > frame[0].Y() || fYOZSectionPos > frame[0].X())) {
1074 fXOZSectionPos = frame[0].Y();
1075 fYOZSectionPos = frame[0].X();
1076 if (fBoxCut.IsActive())
1078 //gGLManager->PaintSingleObject(this);
1079 if (!gVirtualX->IsCmdThread())
1080 gROOT->ProcessLineFast(Form("((TGLPlotPainter *)0x%zx)->Paint()", (size_t)this));
1081 else
1082 Paint();
1083 } else if (event == kKeyPress && (py == kKey_c || py == kKey_C)) {
1084 Info("ProcessEvent", "Box cut does not exist for lego");
1085 }
1086}
1087
1088////////////////////////////////////////////////////////////////////////////////
1089///Clamp z value.
1090
1092{
1093 if (fCoord->GetZLog())
1094 if (zVal <= 0.)
1095 return kFALSE;
1096 else
1097 zVal = TMath::Log10(zVal) * fCoord->GetZScale();
1098 else
1099 zVal *= fCoord->GetZScale();
1100
1101 const TGLVertex3 *frame = fBackBox.Get3DBox();
1102
1103 if (zVal > frame[4].Z())
1104 zVal = frame[4].Z();
1105 else if (zVal < frame[0].Z())
1106 zVal = frame[0].Z();
1107
1108 return kTRUE;
1109}
1110
1111////////////////////////////////////////////////////////////////////////////////
1112///Initialize color palette.
1113
1115{
1116 if(fMinMaxVal.first == fMinMaxVal.second)
1117 return kFALSE;//must be std::abs(fMinMaxVal.second - fMinMaxVal.first) < ...
1118
1119 //User-defined contours are disabled, to be fixed in a future.
1122
1123 UInt_t paletteSize = gStyle->GetNumberContours();
1124 if (!paletteSize)
1125 paletteSize = 20;
1126
1127 return fPalette.GeneratePalette(paletteSize, Rgl::Range_t(fMinZ, fMinMaxVal.second));
1128}
1129
1130////////////////////////////////////////////////////////////////////////////////
1131///Draw. Palette.
1132///Originally, fCamera was never null.
1133///It can be a null now because of gl-viewer.
1134
1136{
1137 if (!fCamera) {
1138 //Thank you, gl-viewer!
1139 return;
1140 }
1141
1143
1144 glFinish();
1145
1146 fCamera->SetCamera();
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151///Draw. Palette. Axis.
1152
1154{
1155 gVirtualX->SetDrawMode(TVirtualX::kCopy);//TCanvas by default sets in kInverse
1157}
@ kKeyPress
Definition Buttons.h:20
@ kButton1Double
Definition Buttons.h:24
#define GL_TRUE
Definition GL_glu.h:262
#define GL_FALSE
Definition GL_glu.h:261
#define GL_LINE_LOOP
Definition GL_glu.h:285
@ kKey_C
Definition KeySymbols.h:128
@ kKey_c
Definition KeySymbols.h:160
#define c(i)
Definition RSha256.hxx:101
#define e(i)
Definition RSha256.hxx:103
int Int_t
Definition RtypesCore.h:45
char Char_t
Definition RtypesCore.h:37
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
@ kWhite
Definition Rtypes.h:65
#define X(type, name)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:218
@ kGLSpherical
Definition TGLUtil.h:47
@ kGLCylindrical
Definition TGLUtil.h:46
@ kGLPolar
Definition TGLUtil.h:45
@ kGLCartesian
Definition TGLUtil.h:44
Option_t Option_t option
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
R__EXTERN TStyle * gStyle
Definition TStyle.h:436
#define gVirtualX
Definition TVirtualX.h:337
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:30
Double_t GetXmax() const
Definition TAxis.h:140
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:518
Double_t GetXmin() const
Definition TAxis.h:139
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition TAxis.cxx:540
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:528
The color creation and management class.
Definition TColor.h:21
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1920
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
void TurnOnOff()
Turn the box cut on/off.
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
Bool_t IsActive() const
Plot-painter implementing LEGO rendering of TH2 histograms in cartesian, polar, cylindrical and spher...
Bool_t InitGeometryCartesian()
Geometry for lego in cartesian coords.
Bool_t PreparePalette() const
Initialize color palette.
void DrawSectionXOZ() const override
XOZ plane parallel section.
void DrawSectionXOY() const override
Empty. No such sections for lego.
void DrawLegoSpherical() const
Lego in spherical system.
std::vector< Rgl::Range_t > fXEdges
void StartPan(Int_t px, Int_t py) override
User clicks on a lego with middle mouse button (middle for pad).
Bool_t InitGeometryCylindrical()
Geometry for lego in cylindrical coords.
void AddOption(const TString &stringOption) override
Parse additional options.
TGLLevelPalette fPalette
void InitGL() const override
Initialize some gl state variables.
char * GetPlotInfo(Int_t px, Int_t py) override
Obtain bin's info (i, j, value).
void DrawLegoPolar() const
Lego in polar system.
void DrawSectionYOZ() const override
YOZ plane parallel section.
void Pan(Int_t px, Int_t py) override
Move lego or section.
Bool_t ClampZ(Double_t &zVal) const
Clamp z value.
Bool_t InitGeometrySpherical()
Geometry for lego in spherical coords.
void DrawPlot() const override
Select method corresponding to coordinate system.
TGLQuadric fQuadric
TGLLegoPainter(const TGLLegoPainter &)
void DrawPalette() const
Draw.
void DrawLegoCartesian() const
Lego in cartesian system.
void SetLegoColor() const
Set lego's color.
std::vector< Rgl::Range_t > fYEdges
std::vector< CosSin_t > fCosSinTableX
Rgl::Range_t fMinMaxVal
void DeInitGL() const override
Return some gl states to original values.
void DrawLegoCylindrical() const
Lego in cylindrical system.
std::vector< CosSin_t > fCosSinTableY
Bool_t InitGeometryPolar()
Geometry for lego in polar coords.
void ProcessEvent(Int_t event, Int_t px, Int_t py) override
Remove all sections and repaint.
ELegoType fLegoType
Bool_t InitGeometry() override
Select method.
void DrawPaletteAxis() const override
Draw. Palette. Axis.
void DisableTexture() const
Disable 1D texture.
Definition TGLUtil.cxx:4254
Double_t GetTexCoord(Double_t z) const
Get tex coordinate.
Definition TGLUtil.cxx:4271
Bool_t GeneratePalette(UInt_t paletteSize, const Rgl::Range_t &zRange, Bool_t checkSize=kTRUE)
Try to find colors for palette.
Definition TGLUtil.cxx:4170
void EnableTexture(Int_t mode) const
Enable 1D texture.
Definition TGLUtil.cxx:4235
void SetPlotBox(const Rgl::Range_t &xRange, const Rgl::Range_t &yRange, const Rgl::Range_t &zRange)
Set up a frame box.
const TGLVertex3 * Get3DBox() const
Get 3D box.
void DrawBox(Int_t selectedPart, Bool_t selectionPass, const std::vector< Double_t > &zLevels, Bool_t highColor) const
Draw back box for a plot.
Int_t GetFrontPoint() const
The nearest point.
Camera for TGLPlotPainter and sub-classes.
void StartPan(Int_t px, Int_t py)
User clicks somewhere (px, py).
void Apply(Double_t phi, Double_t theta) const
Applies rotations and translations before drawing.
void SetCamera() const
Viewport and projection.
void Pan(Int_t px, Int_t py)
Pan camera.
Int_t GetHeight() const
viewport[3]
void SetViewVolume(const TGLVertex3 *box)
'box' is the TGLPlotPainter's back box's coordinates.
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
Double_t GetZLength() const
Z length.
Bool_t SetRanges(const TH1 *hist, Bool_t errors=kFALSE, Bool_t zBins=kFALSE)
Set bin ranges, ranges.
Double_t GetYScale() const
const Rgl::Range_t & GetXRangeScaled() const
Scaled range.
Bool_t GetXLog() const
Get X log.
Int_t GetFirstXBin() const
Int_t GetFirstYBin() const
const Rgl::Range_t & GetZRange() const
Z range.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
void ResetModified()
Reset modified.
Bool_t GetYLog() const
Get Y log.
Bool_t GetZLog() const
Get Z log.
Bool_t Modified() const
Modified.
Double_t GetXScale() const
Double_t GetZScale() const
Int_t GetNXBins() const
Number of X bins.
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
const Rgl::Range_t & GetYRange() const
Y range.
Int_t GetLastYBin() const
Int_t GetNYBins() const
Number of Y bins.
Int_t GetLastXBin() const
EGLCoordType GetCoordType() const
Get coordinates type.
Double_t GetYLength() const
Y length.
Double_t GetFactor() const
Get factor.
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms,...
void DrawSections() const
Draw sections (if any).
std::vector< Double_t > fZLevels
Double_t fXOYSectionPos
void RestoreModelviewMatrix() const
Double_t fXOZSectionPos
TGLPlotCoordinates * fCoord
void Paint() override
Draw lego/surf/whatever you can.
TGLPlotBox fBackBox
void SaveProjectionMatrix() const
void SaveModelviewMatrix() const
void MoveSection(Int_t px, Int_t py)
Create dynamic profile using selected plane.
TGLPlotCamera * fCamera
void RestoreProjectionMatrix() const
Double_t fYOZSectionPos
3 component (x/y/z) vertex class.
Definition TGLUtil.h:84
Double_t X() const
Definition TGLUtil.h:119
Double_t Z() const
Definition TGLUtil.h:123
Double_t Y() const
Definition TGLUtil.h:121
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual Float_t GetBarWidth() const
Definition TH1.h:257
virtual Float_t GetBarOffset() const
Definition TH1.h:256
static TClass * Class()
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition TH1.cxx:9054
@ kUserContour
User specified contour levels.
Definition TH1.h:166
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:5052
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
void ResetBit(UInt_t f)
Definition TObject.h:198
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
Float_t GetLegoInnerR() const
Definition TStyle.h:240
Int_t GetNumberContours() const
Definition TStyle.h:241
void DrawTrapezoid(const Double_t ver[][2], Double_t zMin, Double_t zMax, Bool_t color=kTRUE)
Definition TGLUtil.cxx:3357
void DrawTrapezoidTextured(const Double_t ver[][2], Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax)
In polar coordinates, box became trapezoid.
Definition TGLUtil.cxx:3427
const Float_t gNullEmission[]
Definition TGLUtil.cxx:2856
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
Definition TGLUtil.cxx:2900
void SetZLevels(TAxis *zAxis, Double_t zMin, Double_t zMax, Double_t zScale, std::vector< Double_t > &zLevels)
Definition TGLUtil.cxx:3829
void DrawPalette(const TGLPlotCamera *camera, const TGLLevelPalette &palette)
Draw. Palette.
void DrawPaletteAxis(const TGLPlotCamera *camera, const Range_t &minMax, Bool_t logZ)
void DrawTrapezoidTextured2(const Double_t ver[][2], Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax)
In polar coordinates, box became trapezoid.
Definition TGLUtil.cxx:3504
void DrawCylinder(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Cylinder for lego3.
Definition TGLUtil.cxx:3253
void DrawError(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Definition TGLUtil.cxx:3307
std::pair< Double_t, Double_t > Range_t
Definition TGLUtil.h:1202
void DrawBoxFront(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax, Int_t fp)
Draws lego's bar as a 3d box.
Definition TGLUtil.cxx:3016
void DrawBoxFrontTextured(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax, Int_t front)
Draws lego's bar as a 3d box LULULULU.
Definition TGLUtil.cxx:3143
const Float_t gOrangeEmission[]
Definition TGLUtil.cxx:2853
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:594
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:588
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:762
constexpr Double_t TwoPi()
Definition TMath.h:44