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 using namespace std;
437 const Ssiz_t legoPos = option.Index("lego");//"lego" _already_ _exists_ in a string.
438 if (legoPos + 4 < option.Length() && isdigit(option[legoPos + 4])) {
439 switch (option[legoPos + 4] - '0') {
440 case 1:
442 break;
443 case 2:
445 break;
446 case 3:
448 break;
449 default:
451 break;
452 }
453 } else
455 //check 'e' option
456 Ssiz_t ePos = option.Index("e");
457 if (ePos == legoPos + 1)
458 ePos = option.Index("e", legoPos + 4);
459 fDrawErrors = ePos != kNPOS ? kTRUE : kFALSE;
460
461 option.Index("z") == kNPOS ? fDrawPalette = kFALSE : fDrawPalette = kTRUE;
462}
463
464////////////////////////////////////////////////////////////////////////////////
465///Initialize some gl state variables.
466
468{
469 glEnable(GL_DEPTH_TEST);
470 glEnable(GL_LIGHTING);
471 glEnable(GL_LIGHT0);
472 //For lego, back polygons are culled (but not for sections).
473 glEnable(GL_CULL_FACE);
474 glCullFace(GL_BACK);
475
476 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
477}
478
479////////////////////////////////////////////////////////////////////////////////
480///Return some gl states to original values.
481
483{
484 glDisable(GL_DEPTH_TEST);
485 glDisable(GL_LIGHTING);
486 glDisable(GL_LIGHT0);
487 glDisable(GL_CULL_FACE);
488 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
489}
490
491////////////////////////////////////////////////////////////////////////////////
492///Select method corresponding to coordinate system.
493
495{
496 //Shift plot to point of origin.
497 const Rgl::PlotTranslation trGuard(this);
498
499 switch (fCoord->GetCoordType()) {
500 case kGLCartesian:
501 return DrawLegoCartesian();
502 case kGLPolar:
503 return DrawLegoPolar();
504 case kGLCylindrical:
505 return DrawLegoCylindrical();
506 case kGLSpherical:
507 return DrawLegoSpherical();
508 default:;
509 }
510}
511
512////////////////////////////////////////////////////////////////////////////////
513///Lego in cartesian system.
514
516{
517 if (fCoord->GetCoordType() == kGLCartesian) {
519 const TGLDisableGuard cullGuard(GL_CULL_FACE);
520 DrawSections();
521 }
522
523 //const TGLDisableGuard depthTest(GL_DEPTH_TEST); //[0-0]
524
525 if (!fSelectionPass) {
526 glEnable(GL_POLYGON_OFFSET_FILL);//[0
527 glPolygonOffset(1.f, 1.f);
528 SetLegoColor();
530 //Lego is semi-transparent if we have any sections.
531 glEnable(GL_BLEND);//[1
532 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
533 }
534 }
535
536 //Using front point, find the correct order to draw bars from
537 //back to front (it's important only for semi-transparent lego).
538 //Only in cartesian.
539 const Int_t nX = fXEdges.size();
540 const Int_t nY = fYEdges.size();
541 const Int_t frontPoint = fBackBox.GetFrontPoint();
542 Int_t iInit = 0, jInit = 0, irInit = fCoord->GetFirstXBin(), jrInit = fCoord->GetFirstYBin();
543 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit = fCoord->GetLastXBin(), -1);
544 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit = fCoord->GetLastYBin(), -1);
545
547 if (!PreparePalette()) {
550 } else
551 fPalette.EnableTexture(GL_MODULATE);
552 }
553
556
557 for(Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
558 for(Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
559 Double_t zMax = fHist->GetBinContent(ir, jr) * fCoord->GetFactor();
560 if (!ClampZ(zMax))
561 continue;
562
563 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
564
567 else if(!fHighColor && fSelectedPart == binID)
568 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
569
570 if (fLegoType == kCylindricBars) {
572 fYEdges[j].second, fMinZ, zMax);
573 } else if (fLegoType == kColorLevel && !fSelectionPass) {
575 fYEdges[j].second, fMinZ, zMax, fPalette.GetTexCoord(fMinZ),
576 fPalette.GetTexCoord(zMax), frontPoint);
577 } else {
579 fYEdges[j].second, fMinZ, zMax, frontPoint);
580 }
581
582 if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
583 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
584 }
585 }
586
589
590 //Draw outlines for non-cylindrical bars.
591 if (!fSelectionPass) {
592 glDisable(GL_POLYGON_OFFSET_FILL);//0]
593 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2 - 2]
595 glColor3d(0., 0., 0.);
596 else
597 glColor4d(0., 0., 0., 0.4);
598 glPolygonMode(GL_FRONT, GL_LINE);//[3
599
600 const TGLEnableGuard blendGuard(GL_BLEND);//[4-4] + 1]
601 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
602 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);//[5-5]
603 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
604
605 for(Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
606 for(Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
607 Double_t zMax = fHist->GetBinContent(ir, jr) * fCoord->GetFactor();
608 if (!ClampZ(zMax))
609 continue;
610 if (fLegoType != kCylindricBars) {
612 fYEdges[j].second, fMinZ, zMax, frontPoint);
613 }
614 if (fDrawErrors && zMax > 0.) {
615 Double_t errorZMax = (fHist->GetBinContent(ir, jr) + fHist->GetBinError(ir, jr)) * fCoord->GetFactor();
616 ClampZ(errorZMax);
618 fYEdges[j].second, zMax, errorZMax);
619 }
620 }
621 }
622
623 glPolygonMode(GL_FRONT, GL_FILL);//3]
624 }
625
627 DrawPalette();
628}
629
630////////////////////////////////////////////////////////////////////////////////
631///Lego in polar system.
632
634{
635 const Int_t nX = fCosSinTableX.size() - 1;
636 const Int_t nY = fYEdges.size();
637
638 if (!fSelectionPass) {
639 SetLegoColor();
640 glEnable(GL_POLYGON_OFFSET_FILL);
641 glPolygonOffset(1.f, 1.f);
642 }
643
644 Double_t points[4][2] = {};
645
647 if (!PreparePalette()) {
650 } else
651 fPalette.EnableTexture(GL_MODULATE);
652 }
653
656
657 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
658 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
659 Double_t zMax = fHist->GetBinContent(ir, jr);
660 if (!ClampZ(zMax))
661 continue;
662 points[0][0] = fYEdges[j].first * fCosSinTableX[i].first;
663 points[0][1] = fYEdges[j].first * fCosSinTableX[i].second;
664 points[1][0] = fYEdges[j].second * fCosSinTableX[i].first;
665 points[1][1] = fYEdges[j].second * fCosSinTableX[i].second;
666 points[2][0] = fYEdges[j].second * fCosSinTableX[i + 1].first;
667 points[2][1] = fYEdges[j].second * fCosSinTableX[i + 1].second;
668 points[3][0] = fYEdges[j].first * fCosSinTableX[i + 1].first;
669 points[3][1] = fYEdges[j].first * fCosSinTableX[i + 1].second;
670
671 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
672
675 else if(!fHighColor && fSelectedPart == binID)
676 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
677
680 fPalette.GetTexCoord(zMax));
681 else
683
684 if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
685 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
686 }
687 }
688
691
692 //Draw outlines.
693 if (!fSelectionPass) {
694 glDisable(GL_POLYGON_OFFSET_FILL);//0]
695 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
696 glColor3d(0., 0., 0.);
697 glPolygonMode(GL_FRONT, GL_LINE);//[3
698 const TGLEnableGuard blendGuard(GL_BLEND);
699 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
700 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
701 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
702
703 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
704 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
705 Double_t zMax = fHist->GetBinContent(ir, jr);
706 if (!ClampZ(zMax))
707 continue;
708 points[0][0] = fYEdges[j].first * fCosSinTableX[i].first;
709 points[0][1] = fYEdges[j].first * fCosSinTableX[i].second;
710 points[1][0] = fYEdges[j].second * fCosSinTableX[i].first;
711 points[1][1] = fYEdges[j].second * fCosSinTableX[i].second;
712 points[2][0] = fYEdges[j].second * fCosSinTableX[i + 1].first;
713 points[2][1] = fYEdges[j].second * fCosSinTableX[i + 1].second;
714 points[3][0] = fYEdges[j].first * fCosSinTableX[i + 1].first;
715 points[3][1] = fYEdges[j].first * fCosSinTableX[i + 1].second;
717 }
718 }
719
720 glPolygonMode(GL_FRONT, GL_FILL);//3]
721 }
722
724 DrawPalette();
725}
726
727////////////////////////////////////////////////////////////////////////////////
728///Lego in cylindrical system.
729
731{
732 const Int_t nX = fCosSinTableX.size() - 1;
733 const Int_t nY = fYEdges.size();
734 Double_t legoR = gStyle->GetLegoInnerR();
735 if (legoR > 1. || legoR < 0.)
736 legoR = 0.5;
737 const Double_t rRange = fCoord->GetZLength();
738
739 if (!fSelectionPass) {
740 SetLegoColor();
741 glEnable(GL_POLYGON_OFFSET_FILL);
742 glPolygonOffset(1.f, 1.f);
743 }
744
745 Double_t points[4][2] = {};
746 const Double_t sc = (1 - legoR) * fCoord->GetXScale();
747 legoR *= fCoord->GetXScale();
748
750 if (!PreparePalette()) {
753 } else
754 fPalette.EnableTexture(GL_MODULATE);
755 }
756
759
760 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
761 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
762 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
763 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
764 if (zMin > zMax)
765 std::swap(zMin, zMax);
766
767 points[0][0] = fCosSinTableX[i].first * zMin;
768 points[0][1] = fCosSinTableX[i].second * zMin;
769 points[1][0] = fCosSinTableX[i].first * zMax;
770 points[1][1] = fCosSinTableX[i].second * zMax;
771 points[2][0] = fCosSinTableX[i + 1].first * zMax;
772 points[2][1] = fCosSinTableX[i + 1].second * zMax;
773 points[3][0] = fCosSinTableX[i + 1].first * zMin;
774 points[3][1] = fCosSinTableX[i + 1].second * zMin;
775
776 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
777
780 else if(!fHighColor && fSelectedPart == binID)
781 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
782
786 }else
788
789 if(!fSelectionPass && !fHighColor && fSelectedPart == binID)
790 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
791 }
792 }
793
796
797 //Draw outlines.
798 if (!fSelectionPass) {
799 glDisable(GL_POLYGON_OFFSET_FILL);//0]
800 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
801 glColor3d(0., 0., 0.);
802 glPolygonMode(GL_FRONT, GL_LINE);//[3
803
804 const TGLEnableGuard blendGuard(GL_BLEND);
805 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
806 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
807 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
808
809 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
810 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
811 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
812 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
813 if (zMin > zMax)
814 std::swap(zMin, zMax);
815
816 points[0][0] = fCosSinTableX[i].first * zMin;
817 points[0][1] = fCosSinTableX[i].second * zMin;
818 points[1][0] = fCosSinTableX[i].first * zMax;
819 points[1][1] = fCosSinTableX[i].second * zMax;
820 points[2][0] = fCosSinTableX[i + 1].first * zMax;
821 points[2][1] = fCosSinTableX[i + 1].second * zMax;
822 points[3][0] = fCosSinTableX[i + 1].first * zMin;
823 points[3][1] = fCosSinTableX[i + 1].second * zMin;
825 }
826 }
827
828 glPolygonMode(GL_FRONT, GL_FILL);//3]
829 }
830
832 DrawPalette();
833}
834
835////////////////////////////////////////////////////////////////////////////////
836///Lego in spherical system.
837
839{
840 const Int_t nX = fCosSinTableX.size() - 1;
841 const Int_t nY = fCosSinTableY.size() - 1;
842 const Double_t rRange = fCoord->GetZLength();
843 Double_t legoR = gStyle->GetLegoInnerR();
844 if (legoR > 1. || legoR < 0.)
845 legoR = 0.5;
846
847 if (!fSelectionPass) {
848 SetLegoColor();
849 glEnable(GL_POLYGON_OFFSET_FILL);
850 glPolygonOffset(1.f, 1.f);
851 }
852
853 Double_t points[8][3] = {};
854 const Double_t sc = 1 - legoR;
855
857 if (!PreparePalette()) {
860 } else
861 fPalette.EnableTexture(GL_MODULATE);
862 }
863
866
867 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
868 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
869 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
870 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
871 if (zMin > zMax)
872 std::swap(zMin, zMax);
873
874 points[4][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].first;
875 points[4][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].second;
876 points[4][2] = zMin * fCosSinTableY[j].first;
877 points[5][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
878 points[5][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
879 points[5][2] = zMin * fCosSinTableY[j].first;
880 points[6][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
881 points[6][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
882 points[6][2] = zMax * fCosSinTableY[j].first;
883 points[7][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].first;
884 points[7][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].second;
885 points[7][2] = zMax * fCosSinTableY[j].first;
886 points[0][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
887 points[0][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
888 points[0][2] = zMin * fCosSinTableY[j + 1].first;
889 points[1][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
890 points[1][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
891 points[1][2] = zMin * fCosSinTableY[j + 1].first;
892 points[2][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
893 points[2][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
894 points[2][2] = zMax * fCosSinTableY[j + 1].first;
895 points[3][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
896 points[3][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
897 points[3][2] = zMax * fCosSinTableY[j + 1].first;
898
899 const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;
900
903 else if(!fHighColor && fSelectedPart == binID)
904 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
908 else
910
911 if(!fHighColor && fSelectedPart == binID)
912 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
913 }
914 }
915
918
919 //Draw outlines.
920 if (!fSelectionPass) {
921 glDisable(GL_POLYGON_OFFSET_FILL);//0]
922 const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
923 glColor3d(0., 0., 0.);
924 glPolygonMode(GL_FRONT, GL_LINE);//[3
925 const TGLEnableGuard blendGuard(GL_BLEND);
926 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
927 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
928 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
929
930 for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
931 for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
932 Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
933 Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
934 if (zMin > zMax)
935 std::swap(zMin, zMax);
936
937 points[4][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].first;
938 points[4][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].second;
939 points[4][2] = zMin * fCosSinTableY[j].first;
940 points[5][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
941 points[5][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
942 points[5][2] = zMin * fCosSinTableY[j].first;
943 points[6][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
944 points[6][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
945 points[6][2] = zMax * fCosSinTableY[j].first;
946 points[7][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].first;
947 points[7][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].second;
948 points[7][2] = zMax * fCosSinTableY[j].first;
949 points[0][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
950 points[0][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
951 points[0][2] = zMin * fCosSinTableY[j + 1].first;
952 points[1][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
953 points[1][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
954 points[1][2] = zMin * fCosSinTableY[j + 1].first;
955 points[2][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
956 points[2][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
957 points[2][2] = zMax * fCosSinTableY[j + 1].first;
958 points[3][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
959 points[3][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
960 points[3][2] = zMax * fCosSinTableY[j + 1].first;
962 }
963 }
964
965 glPolygonMode(GL_FRONT, GL_FILL);//3]
966 }
967
969 DrawPalette();
970}
971
972////////////////////////////////////////////////////////////////////////////////
973///Set lego's color.
974
976{
977 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
978
980 if (const TColor *c = gROOT->GetColor(fHist->GetFillColor()))
981 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
982
983 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
984 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
985 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
986 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
987}
988
989////////////////////////////////////////////////////////////////////////////////
990///XOZ plane parallel section.
991
993{
994 Int_t binY = -1;
995
996 for (Int_t i = 0, e = fYEdges.size(); i < e; ++i) {
997 if (fYEdges[i].first <= fXOZSectionPos && fXOZSectionPos <= fYEdges[i].second) {
998 binY = i;
999 break;
1000 }
1001 }
1002
1003 if (binY >= 0) {
1004 binY += fCoord->GetFirstYBin();
1005 glColor3d(1., 0., 0.);
1006 glLineWidth(3.f);
1007 //Draw 2d hist on the profile's plane.
1008 for (UInt_t i = 0, ir = fCoord->GetFirstXBin(), e = fXEdges.size(); i < e; ++i, ++ir) {
1009 Double_t zMax = fHist->GetBinContent(Int_t(ir), binY);
1010 if (!ClampZ(zMax))
1011 continue;
1012
1013 glBegin(GL_LINE_LOOP);
1014 glVertex3d(fXEdges[i].first, fXOZSectionPos, fMinZ);
1015 glVertex3d(fXEdges[i].first, fXOZSectionPos, zMax);
1016 glVertex3d(fXEdges[i].second, fXOZSectionPos, zMax);
1017 glVertex3d(fXEdges[i].second, fXOZSectionPos, fMinZ);
1018 glEnd();
1019 }
1020
1021 glLineWidth(1.f);
1022 }
1023}
1024
1025////////////////////////////////////////////////////////////////////////////////
1026///YOZ plane parallel section.
1027
1029{
1030 Int_t binX = -1;
1031
1032 for (Int_t i = 0, e = fXEdges.size(); i < e; ++i) {
1033 if (fXEdges[i].first <= fYOZSectionPos && fYOZSectionPos <= fXEdges[i].second) {
1034 binX = i;
1035 break;
1036 }
1037 }
1038
1039 if (binX >= 0) {
1040 binX += fCoord->GetFirstXBin();//fBinsX.first;
1041 glColor3d(1., 0., 0.);
1042 glLineWidth(3.f);
1043 //Draw 2d hist on the profile's plane.
1044 for (UInt_t i = 0, ir = fCoord->GetFirstYBin(), e = fYEdges.size(); i < e; ++i, ++ir) {
1045 Double_t zMax = fHist->GetBinContent(binX, ir);
1046 if (!ClampZ(zMax))
1047 continue;
1048
1049 glBegin(GL_LINE_LOOP);
1050 glVertex3d(fYOZSectionPos, fYEdges[i].first, fMinZ);
1051 glVertex3d(fYOZSectionPos, fYEdges[i].first, zMax);
1052 glVertex3d(fYOZSectionPos, fYEdges[i].second, zMax);
1053 glVertex3d(fYOZSectionPos, fYEdges[i].second, fMinZ);
1054 glEnd();
1055 }
1056
1057 glLineWidth(1.f);
1058 }
1059}
1060
1061////////////////////////////////////////////////////////////////////////////////
1062///Empty. No such sections for lego.
1063
1065{
1066}
1067
1068////////////////////////////////////////////////////////////////////////////////
1069///Remove all sections and repaint.
1070
1072{
1073 const TGLVertex3 *frame = fBackBox.Get3DBox();
1074 if (event == kButton1Double && (fXOZSectionPos > frame[0].Y() || fYOZSectionPos > frame[0].X())) {
1075 fXOZSectionPos = frame[0].Y();
1076 fYOZSectionPos = frame[0].X();
1077 if (fBoxCut.IsActive())
1079 //gGLManager->PaintSingleObject(this);
1080 if (!gVirtualX->IsCmdThread())
1081 gROOT->ProcessLineFast(Form("((TGLPlotPainter *)0x%zx)->Paint()", (size_t)this));
1082 else
1083 Paint();
1084 } else if (event == kKeyPress && (py == kKey_c || py == kKey_C)) {
1085 Info("ProcessEvent", "Box cut does not exist for lego");
1086 }
1087}
1088
1089////////////////////////////////////////////////////////////////////////////////
1090///Clamp z value.
1091
1093{
1094 if (fCoord->GetZLog())
1095 if (zVal <= 0.)
1096 return kFALSE;
1097 else
1098 zVal = TMath::Log10(zVal) * fCoord->GetZScale();
1099 else
1100 zVal *= fCoord->GetZScale();
1101
1102 const TGLVertex3 *frame = fBackBox.Get3DBox();
1103
1104 if (zVal > frame[4].Z())
1105 zVal = frame[4].Z();
1106 else if (zVal < frame[0].Z())
1107 zVal = frame[0].Z();
1108
1109 return kTRUE;
1110}
1111
1112////////////////////////////////////////////////////////////////////////////////
1113///Initialize color palette.
1114
1116{
1117 if(fMinMaxVal.first == fMinMaxVal.second)
1118 return kFALSE;//must be std::abs(fMinMaxVal.second - fMinMaxVal.first) < ...
1119
1120 //User-defined contours are disabled, to be fixed in a future.
1123
1124 UInt_t paletteSize = gStyle->GetNumberContours();
1125 if (!paletteSize)
1126 paletteSize = 20;
1127
1128 return fPalette.GeneratePalette(paletteSize, Rgl::Range_t(fMinZ, fMinMaxVal.second));
1129}
1130
1131////////////////////////////////////////////////////////////////////////////////
1132///Draw. Palette.
1133///Originally, fCamera was never null.
1134///It can be a null now because of gl-viewer.
1135
1137{
1138 if (!fCamera) {
1139 //Thank you, gl-viewer!
1140 return;
1141 }
1142
1144
1145 glFinish();
1146
1147 fCamera->SetCamera();
1149}
1150
1151////////////////////////////////////////////////////////////////////////////////
1152///Draw. Palette. Axis.
1153
1155{
1156 gVirtualX->SetDrawMode(TVirtualX::kCopy);//TCanvas by default sets in kInverse
1158}
@ 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:101
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ 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:407
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2467
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
#define gVirtualX
Definition TVirtualX.h:338
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:19
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:1823
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:58
virtual Float_t GetBarWidth() const
Definition TH1.h:255
virtual Float_t GetBarOffset() const
Definition TH1.h:254
static TClass * Class()
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition TH1.cxx:8980
@ kUserContour
User specified contour levels.
Definition TH1.h:164
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:5032
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:380
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2334
Float_t GetLegoInnerR() const
Definition TStyle.h:238
Int_t GetNumberContours() const
Definition TStyle.h:239
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
Definition first.py:1