Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLH2PolyPainter.cxx
Go to the documentation of this file.
1#include <algorithm>
2#include <stdexcept>
3#include <cassert>
4
5#include "TMultiGraph.h"
6#include "TH2Poly.h"
7#include "TGraph.h"
8#include "TStyle.h"
9#include "TError.h"
10#include "TColor.h"
11#include "TMath.h"
12#include "TList.h"
13#include "TROOT.h"
14
15#include "TGLH2PolyPainter.h"
16#include "TGLPlotCamera.h"
17#include "TGLIncludes.h"
18
19/** \class TGLH2PolyPainter
20\ingroup opengl
21Paint TH2Poly.
22*/
23
25
26////////////////////////////////////////////////////////////////////////////////
27///Ctor.
28
30 : TGLPlotPainter(hist, camera, coord, kFALSE, kFALSE, kFALSE),
31 fZLog(kFALSE),
32 fZMin(0.)
33{
34 if(!dynamic_cast<TH2Poly *>(hist)) {
35 Error("TGLH2PolyPainter::TGLH2PolyPainter", "bad histogram, must be a valid TH2Poly *");
36 throw std::runtime_error("bad TH2Poly");
37 }
38}
39
40////////////////////////////////////////////////////////////////////////////////
41///Show number of bin and bin contents, if bin is under the cursor.
42
44{
45 fBinInfo = "";
46 if (fSelectedPart) {
48 if (fHist->Class())
49 fBinInfo += fHist->Class()->GetName();
50 fBinInfo += "::";
52 } else if (!fHighColor) {
53 const Int_t binIndex = fSelectedPart - fSelectionBase + 1;
54 TH2Poly *h = static_cast<TH2Poly *>(fHist);
55 fBinInfo.Form("%s (bin = %d; binc = %f)", h->GetBinTitle(binIndex), binIndex, h->GetBinContent(binIndex));//+ 1: bins in ROOT start from 1.
56 } else
57 fBinInfo = "Switch to true-color mode to obtain the correct info";
58 }
59
60 return (Char_t *)fBinInfo.Data();
61}
62
63////////////////////////////////////////////////////////////////////////////////
64///Tesselate polygons, if not done yet.
65///All pointers are validated here (and in functions called from here).
66///If any pointer is invalid - zero, or has unexpected type (dynamic_cast fails) -
67///InitGeometry will return false and nothing will be painted later.
68///That's why there are no checks in other functions.
69
71{
72 TH2Poly* hp = static_cast<TH2Poly *>(fHist);
73 if (!fCoord->SetRanges(hp))
74 return kFALSE;
75
78 fCoord->GetZRangeScaled(), 1.);
79
80 //This code is different from lego.
81 //Currently, negative bin contents are not supported.
82 fZMin = fBackBox.Get3DBox()[0].Z();
83
84 if (hp->GetNewBinAdded()) {
85 if (!CacheGeometry())
86 return kFALSE;
89 } else if (hp->GetBinContentChanged() || fZLog != fCoord->GetZLog()) {
90 if (!UpdateGeometry())
91 return kFALSE;
93 }
94
95 fZLog = fCoord->GetZLog();
96
97 return kTRUE;
98}
99
100////////////////////////////////////////////////////////////////////////////////
101///User clicks on a lego with middle mouse button (middle for pad).
102
104{
105 fMousePosition.fX = px;
107 fCamera->StartPan(px, py);
108 fBoxCut.StartMovement(px, py);
109}
110
111////////////////////////////////////////////////////////////////////////////////
112///Mouse events handler.
113
115{
116 if (fSelectedPart >= fSelectionBase) {//Pan camera.
119
122 fCamera->Pan(px, py);
123
126 } else if (fSelectedPart > 0) {
127 //Convert py into bottom-top orientation.
128 py = fCamera->GetHeight() - py;
129
132
135
136 if (!fHighColor) {
139 }
140 }
141
144 }
145
148}
149
150////////////////////////////////////////////////////////////////////////////////
151///No additional options.
152
153void TGLH2PolyPainter::AddOption(const TString &/*stringOption*/)
154{
155}
156
157////////////////////////////////////////////////////////////////////////////////
158///No events.
159
160void TGLH2PolyPainter::ProcessEvent(Int_t /*event*/, Int_t /*px*/, Int_t /*py*/)
161{
162}
163
164////////////////////////////////////////////////////////////////////////////////
165///Initialize some gl state variables.
166
168{
169 glEnable(GL_DEPTH_TEST);
170 glEnable(GL_LIGHTING);
171 glEnable(GL_LIGHT0);
172
173 glEnable(GL_CULL_FACE);
174 glCullFace(GL_BACK);
175
176 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
177}
178
179////////////////////////////////////////////////////////////////////////////////
180///Return some gl states to original values.
181
183{
184 glDisable(GL_DEPTH_TEST);
185 glDisable(GL_LIGHTING);
186 glDisable(GL_LIGHT0);
187 glDisable(GL_CULL_FACE);
188 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
189}
190
191namespace {
192
193Double_t Distance(const Double_t *p1, const Double_t *p2);
194Bool_t IsPolygonCW(const Double_t *xs, const Double_t *ys, Int_t n);
195
196}
197
198////////////////////////////////////////////////////////////////////////////////
199///Draw extruded polygons and plot's frame.
200
202{
203 //Shift plot to point of origin.
204 const Rgl::PlotTranslation trGuard(this);
205
207
209 DrawCaps();
210}
211
212////////////////////////////////////////////////////////////////////////////////
213///Extruded part of bins.
214///GL_QUADS, GL_QUAD_STRIP - have the same time on my laptop, so I use
215///GL_QUADS and forgot about vertex arrays (can require more memory BTW).
216
218{
219 TList *bins = static_cast<TH2Poly *>(fHist)->GetBins();
220 Int_t binIndex = 0;
221 for(TObjLink * link = bins->FirstLink(); link; link = link->Next(), ++binIndex) {
222 TH2PolyBin *bin = static_cast<TH2PolyBin *>(link->GetObject());
223 //const Double_t zMax = bin->GetContent() * fCoord->GetZScale();
224 Double_t zMax = bin->GetContent();
225 ClampZ(zMax);
226
227 if (const TGraph * poly = dynamic_cast<TGraph*>(bin->GetPolygon())) {
228 //DrawExtrusion(poly, zMin, zMax, binIndex);
229 DrawExtrusion(poly, fZMin, zMax, binIndex);
230 } else if (const TMultiGraph * mg = dynamic_cast<TMultiGraph*>(bin->GetPolygon())) {
231 //DrawExtrusion(mg, zMin, zMax, binIndex);
232 DrawExtrusion(mg, fZMin, zMax, binIndex);
233 }//else is impossible.
234 }
235}
236
237////////////////////////////////////////////////////////////////////////////////
238///Extrude polygon, described by TGraph.
239
240void TGLH2PolyPainter::DrawExtrusion(const TGraph *poly, Double_t zMin, Double_t zMax, Int_t binIndex)const
241{
242 const Double_t *xs = poly->GetX();
243 const Double_t *ys = poly->GetY();
244
245 const Int_t nV = poly->GetN();
246
247 //nV can never be less than 3 - InitGeometry fails on such polygons.
248 //So, no checks here.
249
250 const Int_t binID = fSelectionBase + binIndex;
251
252 if (fSelectionPass) {
253 if (!fHighColor)
255 } else {
256 SetBinColor(binIndex);
257 if(!fHighColor && fSelectedPart == binID)
258 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
259 }
260
261 //Before, orientation was always done in TH2Poly.
262 //Now we do it every time here.
263 FillTemporaryPolygon(xs, ys, 0., nV); //0. == z is not important here.
264
265 Double_t normal[3] = {};
266 for (Int_t j = 0; j < nV - 1; ++j) {
267 const Double_t v0[] = {fPolygon[j * 3], fPolygon[j * 3 + 1], zMin};
268 const Double_t v1[] = {fPolygon[(j + 1) * 3], fPolygon[(j + 1) * 3 + 1], zMin};
269
270 if (Distance(v0, v1) < 1e-10)
271 continue;
272
273 const Double_t v2[] = {v1[0], v1[1], zMax};
274 const Double_t v3[] = {v0[0], v0[1], zMax};
275
276 TMath::Normal2Plane(v0, v1, v2, normal);
277 Rgl::DrawQuadFilled(v0, v1, v2, v3, normal);
278 }
279
280 //Now, close the polygon.
281 const Double_t v0[] = {fPolygon[(nV - 1) * 3], fPolygon[(nV - 1) * 3 + 1], zMin};
282 const Double_t v1[] = {fPolygon[0], fPolygon[1], zMin};
283
284 if (Distance(v0, v1) > 1e-10) {
285 const Double_t v2[] = {v1[0], v1[1], zMax};
286 const Double_t v3[] = {v0[0], v0[1], zMax};
287
288 TMath::Normal2Plane(v0, v1, v2, normal);
289 Rgl::DrawQuadFilled(v0, v1, v2, v3, normal);
290 }
291
292 if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
293 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
294}
295
296////////////////////////////////////////////////////////////////////////////////
297///Multigraph contains a list of graphs, draw them.
298
299void TGLH2PolyPainter::DrawExtrusion(const TMultiGraph *mg, Double_t zMin, Double_t zMax, Int_t binIndex)const
300{
301 const TList *graphs = mg->GetListOfGraphs();
302 for (TObjLink *link = graphs->FirstLink(); link; link = link->Next())
303 DrawExtrusion((TGraph *)(link->GetObject()), zMin, zMax, binIndex);
304}
305
306////////////////////////////////////////////////////////////////////////////////
307///Caps on bins.
308
310{
311 Int_t binIndex = 0;
312 const TList *bins = static_cast<TH2Poly *>(fHist)->GetBins();
313 CIter_t cap = fCaps.begin();
314
315 assert(bins->FirstLink());
316
317 //Very ugly iteration statement. Number of caps is equal to number of links (in a list
318 //of bins including nested links in multigraphs. But this is not obvious from the code here,
319 //so, I've added check cap != fCaps.end() to make it more or less clear.
320
321 for (TObjLink *link = bins->FirstLink(); link && cap != fCaps.end(); link = link->Next()) {
322 TH2PolyBin *polyBin = static_cast<TH2PolyBin *>(link->GetObject());
323 if (dynamic_cast<TGraph *>(polyBin->GetPolygon())) {
324 DrawCap(cap, binIndex, false/*top cap*/);
325 DrawCap(cap, binIndex, true/*bottom cap*/);
326 ++cap;
327 } else if (TMultiGraph *mg = dynamic_cast<TMultiGraph *>(polyBin->GetPolygon())) {
328 const TList *gs = mg->GetListOfGraphs();
329 TObjLink *graphLink = gs->FirstLink();
330 for (; graphLink && cap != fCaps.end(); graphLink = graphLink->Next(), ++cap) {
331 DrawCap(cap, binIndex, false/*top cap*/);
332 DrawCap(cap, binIndex, true/*bottom cap*/);
333 }
334 }
335
336 ++binIndex;
337 }
338}
339
340////////////////////////////////////////////////////////////////////////////////
341///Draw a cap on top of a bin.
342
343void TGLH2PolyPainter::DrawCap(CIter_t cap, Int_t binIndex, bool bottomCap)const
344{
345 const Int_t binID = fSelectionBase + binIndex;
346 if (fSelectionPass) {
347 if (!fHighColor)
349 } else {
350 SetBinColor(binIndex);
351 if(!fHighColor && fSelectedPart == binID)
352 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
353 }
354
355 glNormal3d(0., 0., bottomCap ? -1. : 1.);
356
357 if (bottomCap)
358 glFrontFace(GL_CW);
359
360 const Rgl::Pad::Tesselation_t &t = *cap;
361 typedef std::list<Rgl::Pad::MeshPatch_t>::const_iterator CMIter_t;
362 if (bottomCap) {
363 for (CMIter_t p = t.begin(); p != t.end(); ++p) {
364 const std::vector<Double_t> &vs = p->fPatch;
365 glBegin(GLenum(p->fPatchType));
366 for (UInt_t i = 0; i < vs.size(); i += 3)
367 glVertex3d(vs[i], vs[i + 1], fZMin);
368 glEnd();
369 }
370 } else {
371 for (CMIter_t p = t.begin(); p != t.end(); ++p) {
372 const std::vector<Double_t> &vs = p->fPatch;
373 glBegin(GLenum(p->fPatchType));
374 for (UInt_t i = 0; i < vs.size(); i += 3)
375 glVertex3dv(&vs[i]);
376 glEnd();
377 }
378 }
379
380
381 if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
382 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
383
384 if (bottomCap) // Restore the counter-clockwise orientation:
385 glFrontFace(GL_CCW);
386}
387
388////////////////////////////////////////////////////////////////////////////////
389///Cache all data for TH2Poly object.
390
392{
393 TH2Poly *hp = static_cast<TH2Poly *>(fHist);
394 TList *bins = hp->GetBins();
395 if (!bins || !bins->GetEntries()) {
396 Error("TGLH2PolyPainter::CacheGeometry", "Empty list of bins in TH2Poly");
397 return kFALSE;
398 }
399
400 const Double_t zMin = fHist->GetMinimum();
401 const Double_t zMax = fHist->GetMaximum();
402 const Int_t nColors = gStyle->GetNumberOfColors();
403
404 fBinColors.clear();
405 fBinColors.reserve(bins->GetEntries());
406 fPolygon.clear();
407 fCaps.clear();
408
409 Rgl::Pad::Tesselator tesselator(kTRUE);
410
411 for (TObjLink * link = bins->FirstLink(); link; link = link->Next()) {
412 TH2PolyBin * bin = static_cast<TH2PolyBin *>(link->GetObject());
413 if (!bin || !bin->GetPolygon()) {
414 Error("TGH2PolyPainter::InitGeometry", "Null bin or polygon pointer in a list of bins");
415 return kFALSE;
416 }
417
418 Double_t binZ = bin->GetContent();
419 if (!ClampZ(binZ)) {
420 Error("TGLH2PolyPainter::CacheGeometry", "Negative bin content and log scale");
421 return kFALSE;
422 }
423
424 if (const TGraph *g = dynamic_cast<TGraph *>(bin->GetPolygon())) {
425 if (!BuildTesselation(tesselator, g, binZ))
426 return kFALSE;
427 } else if (const TMultiGraph *mg = dynamic_cast<TMultiGraph *>(bin->GetPolygon())) {
428 if (!BuildTesselation(tesselator, mg, binZ))
429 return kFALSE;
430 } else {
431 Error("TGLH2PolyPainter::CacheGeometry", "Bin contains object of unknown type");
432 return kFALSE;
433 }
434
435 const Int_t colorIndex = gStyle->GetColorPalette(Int_t(((bin->GetContent() - zMin) / (zMax - zMin)) * (nColors - 1)));
436 fBinColors.push_back(colorIndex);
437 }
438
439 return kTRUE;
440}
441
442////////////////////////////////////////////////////////////////////////////////
443///Tesselate a polygon described by TGraph.
444
446{
447 const Double_t *xs = g->GetX();
448 const Double_t *ys = g->GetY();
449
450 if (!xs || !ys) {
451 Error("TGLH2PolyPainter::BuildTesselation", "null array(s) in a polygon");
452 return kFALSE;
453 }
454
455 const Int_t nV = g->GetN();
456 if (nV < 3) {
457 Error("TGLH2PolyPainter::BuildTesselation", "number of vertices in a polygon must be >= 3");
458 return kFALSE;
459 }
460
461 fCaps.push_back(Rgl::Pad::Tesselation_t());
462 FillTemporaryPolygon(xs, ys, z, nV);
463
464 tess.SetDump(&fCaps.back());
465
466 GLUtesselator *t = (GLUtesselator *)tess.GetTess();
469
470 glNormal3d(0., 0., 1.);
471
472 for (Int_t j = 0; j < nV; ++j) {
473 gluTessVertex(t, &fPolygon[j * 3], &fPolygon[j * 3]);
474 }
475 gluEndPolygon(t);
476
477 return kTRUE;
478}
479
480////////////////////////////////////////////////////////////////////////////////
481///Iterate over multi graph contents and tesselate nested TGraphs.
482
484{
485 const TList *graphs = mg->GetListOfGraphs();
486 if (!graphs) {
487 Error("TGLH2PolyPainter::BuildTesselation", "null list of graphs in a multigraph");
488 return kFALSE;
489 }
490
491 for(TObjLink *link = graphs->FirstLink(); link; link = link->Next()) {
492 const TGraph *graph = dynamic_cast<TGraph *>(link->GetObject());
493 if (!graph) {
494 Error("TGLH2PolyPainter::BuildTesselation", "TGraph expected inside a multigraph, got something else");
495 return kFALSE;
496 }
497
498 if (!BuildTesselation(tess, graph, z))
499 return kFALSE;
500 }
501
502 return kTRUE;
503}
504
505////////////////////////////////////////////////////////////////////////////////
506///Update cap's z-coordinates for all caps.
507///Here no pointers are checked, this was already done
508///by InitGeometry.
509
511{
512 TH2Poly *hp = static_cast<TH2Poly *>(fHist);
513 TList *bins = hp->GetBins();
514
515 std::list<Rgl::Pad::Tesselation_t>::iterator cap = fCaps.begin();
516
517 //Ugly iteration statements, but still, number of links and caps will be
518 //ok - this is checked in InitGeometry. Check cap != fCaps.end() is added
519 //to make it clear (not required).
520 for (TObjLink *link = bins->FirstLink(); link && cap != fCaps.end(); link = link->Next()) {
521 TH2PolyBin *b = static_cast<TH2PolyBin *>(link->GetObject());
522 Double_t z = b->GetContent();
523 ClampZ(z);
524 //Update z coordinate in all patches.
525 if (dynamic_cast<TGraph *>(b->GetPolygon())) {
526 //Only one cap.
527 Rgl::Pad::Tesselation_t &tess = *cap;
528 Rgl::Pad::Tesselation_t::iterator patch = tess.begin();
529 for (; patch != tess.end(); ++patch) {
530 std::vector<Double_t> &mesh = patch->fPatch;
531 for (UInt_t i = 0, e = mesh.size() / 3; i < e; ++i)
532 mesh[i * 3 + 2] = z;
533 }
534
535 ++cap;
536 } else if (const TMultiGraph *mg = dynamic_cast<TMultiGraph *>(b->GetPolygon())) {
537 const TList *gs = mg->GetListOfGraphs();
538 for (TObjLink * graphLink = gs->FirstLink(); graphLink && cap != fCaps.end(); graphLink = graphLink->Next(), ++cap) {
539 Rgl::Pad::Tesselation_t &tess = *cap;
540 Rgl::Pad::Tesselation_t::iterator patch = tess.begin();
541 for (; patch != tess.end(); ++patch) {
542 std::vector<Double_t> &mesh = patch->fPatch;
543 for (UInt_t i = 0, e = mesh.size() / 3; i < e; ++i)
544 mesh[i * 3 + 2] = z;
545 }
546 }
547 }//else is impossible and processed by InitGeometry.
548 }
549
550 return kTRUE;
551}
552
553////////////////////////////////////////////////////////////////////////////////
554///Set bin's color.
555
557{
558 if (binIndex >= Int_t(fBinColors.size())) {
559 Error("TGLH2PolyPainter::SetBinColor", "bin index is out of range %d, must be <= %d",
560 binIndex, int(fBinColors.size()));
561 return;
562 }
563
564 //Convert color index into RGB.
565 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
566
567 if (const TColor *c = gROOT->GetColor(fBinColors[binIndex]))
568 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
569
570 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
571 const Float_t specColor[] = {0.2f, 0.2f, 0.2f, 0.2f};
572 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
573 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
574}
575
576////////////////////////////////////////////////////////////////////////////////
577///No sections.
578
580{
581}
582
583////////////////////////////////////////////////////////////////////////////////
584///No sections.
585
587{
588}
589
590////////////////////////////////////////////////////////////////////////////////
591///No sections.
592
594{
595}
596
597////////////////////////////////////////////////////////////////////////////////
598///Not yet.
599
601{
602}
603
604////////////////////////////////////////////////////////////////////////////////
605///Not yet.
606
608{
609}
610
611////////////////////////////////////////////////////////////////////////////////
612///Since I probably have to re-orient polygon, I need a temporary polygon.
613
615{
616 const Double_t xScale = fCoord->GetXScale();
617 const Double_t yScale = fCoord->GetYScale();
618
619 fPolygon.resize(nV * 3);
620 for (Int_t j = 0; j < nV; ++j) {
621 fPolygon[j * 3] = xs[j] * xScale;
622 fPolygon[j * 3 + 1] = ys[j] * yScale;
623 fPolygon[j * 3 + 2] = z;
624 }
625
626 if (IsPolygonCW(xs, ys, nV))
628}
629
630////////////////////////////////////////////////////////////////////////////////
631///Code taken from the original TH2Poly.
632
634{
635 const Int_t nV = Int_t(fPolygon.size() / 3);
636 for (Int_t a = 0; a <= (nV / 2) - 1; a++) {
637 const Int_t b = nV - 1 - a;
638 std::swap(fPolygon[a * 3], fPolygon[b * 3]);
639 std::swap(fPolygon[a * 3 + 1], fPolygon[b * 3 + 1]);
640 }
641}
642
643////////////////////////////////////////////////////////////////////////////////
644///Clamp z value.
645
647{
648 if (fCoord->GetZLog()) {
649 if (zVal <= 0.)
650 return kFALSE;
651 else
652 zVal = TMath::Log10(zVal) * fCoord->GetZScale();
653 } else
654 zVal *= fCoord->GetZScale();
655
656 const TGLVertex3 *frame = fBackBox.Get3DBox();
657
658 if (zVal > frame[4].Z())
659 zVal = frame[4].Z();
660 else if (zVal < frame[0].Z())
661 zVal = frame[0].Z();
662
663 return kTRUE;
664}
665
666
667namespace {
668
669////////////////////////////////////////////////////////////////////////////////
670///
671
672Double_t Distance(const Double_t *p1, const Double_t *p2)
673{
674 return TMath::Sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) +
675 (p1[1] - p2[1]) * (p1[1] - p2[1]) +
676 (p1[2] - p2[2]) * (p1[2] - p2[2]));
677}
678
679////////////////////////////////////////////////////////////////////////////////
680///Before, TH2Poly always produced good GL polygons - CCW. Now,
681///this code (by Deniz Gunceler) was deleted from TH2Poly.
682
683Bool_t IsPolygonCW(const Double_t *xs, const Double_t *ys, Int_t n)
684{
685 Double_t signedArea = 0.;
686
687 for (Int_t j = 0; j < n - 1; ++j)
688 signedArea += xs[j] * ys[j + 1] - ys[j] * xs[j + 1];
689
690 return signedArea < 0.;
691}
692
693}
#define GL_TRUE
Definition GL_glu.h:262
void gluNextContour(GLUtesselator *tess, GLenum type)
Definition tess.c:630
#define GLU_UNKNOWN
Definition GL_glu.h:229
unsigned int GLenum
Definition GL_glu.h:266
void gluBeginPolygon(GLUtesselator *tess)
Definition tess.c:621
void gluEndPolygon(GLUtesselator *tess)
Definition tess.c:639
#define GL_FALSE
Definition GL_glu.h:261
void gluTessVertex(GLUtesselator *tess, GLdouble *location, GLvoid *data)
Definition tess.c:425
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
bool Bool_t
Definition RtypesCore.h:63
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
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
winID h TVirtualViewer3D TVirtualGLPainter p
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
void * GetTess() const
static void SetDump(Tesselation_t *t)
TIter begin() const
virtual Int_t GetEntries() const
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:1839
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
Bool_t IsActive() const
Paint TH2Poly.
void Pan(Int_t px, Int_t py) override
Mouse events handler.
char * GetPlotInfo(Int_t px, Int_t py) override
Show number of bin and bin contents, if bin is under the cursor.
void FillTemporaryPolygon(const Double_t *xs, const Double_t *ys, Double_t z, Int_t n) const
Since I probably have to re-orient polygon, I need a temporary polygon.
void DrawCaps() const
Caps on bins.
void InitGL() const override
Initialize some gl state variables.
void MakePolygonCCW() const
Code taken from the original TH2Poly.
Bool_t InitGeometry() override
Tesselate polygons, if not done yet.
void DeInitGL() const override
Return some gl states to original values.
std::list< Rgl::Pad::Tesselation_t > fCaps
void DrawSectionXOY() const override
No sections.
Bool_t BuildTesselation(Rgl::Pad::Tesselator &tess, const TGraph *g, Double_t z)
Tesselate a polygon described by TGraph.
std::list< Rgl::Pad::Tesselation_t >::const_iterator CIter_t
void DrawPlot() const override
Draw extruded polygons and plot's frame.
void AddOption(const TString &stringOption) override
No additional options.
void DrawCap(CIter_t cap, Int_t bin, bool bottomCap) const
Draw a cap on top of a bin.
TGLH2PolyPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Ctor.
void DrawPalette() const
Not yet.
Bool_t UpdateGeometry()
Update cap's z-coordinates for all caps.
std::vector< Double_t > fPolygon
Bool_t ClampZ(Double_t &zVal) const
Clamp z value.
Bool_t CacheGeometry()
Cache all data for TH2Poly object.
void DrawSectionXOZ() const override
No sections.
void SetBinColor(Int_t bin) const
Set bin's color.
void DrawPaletteAxis() const override
Not yet.
void DrawSectionYOZ() const override
No sections.
void ProcessEvent(Int_t event, Int_t px, Int_t py) override
No events.
void DrawExtrusion() const
Extruded part of bins.
std::vector< Int_t > fBinColors
void StartPan(Int_t px, Int_t py) override
User clicks on a lego with middle mouse button (middle for pad).
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.
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]
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
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.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
Bool_t GetZLog() const
Get Z log.
Double_t GetXScale() const
Double_t GetZScale() const
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms,...
std::vector< Double_t > fZLevels
void RestoreModelviewMatrix() const
TGLPlotCoordinates * fCoord
TGLPlotBox fBackBox
void SaveProjectionMatrix() const
void SaveModelviewMatrix() const
TGLPlotCamera * fCamera
void RestoreProjectionMatrix() const
3 component (x/y/z) vertex class.
Definition TGLUtil.h:84
Double_t Z() const
Definition TGLUtil.h:123
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
Double_t * GetY() const
Definition TGraph.h:139
Int_t GetN() const
Definition TGraph.h:131
Double_t * GetX() const
Definition TGraph.h:138
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
static TClass * Class()
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
Definition TH1.cxx:8513
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
Definition TH1.cxx:8603
Helper class to represent a bin in the TH2Poly histogram.
Definition TH2Poly.h:25
Double_t GetContent() const
Definition TH2Poly.h:35
TObject * GetPolygon() const
Definition TH2Poly.h:38
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
TList * GetBins()
Returns the TList of all bins in the histogram.
Definition TH2Poly.h:101
Bool_t GetBinContentChanged() const
Definition TH2Poly.h:103
void SetBinContentChanged(Bool_t flag)
Definition TH2Poly.h:122
void SetNewBinAdded(Bool_t flag)
Definition TH2Poly.h:124
Bool_t GetNewBinAdded() const
Definition TH2Poly.h:112
A doubly linked list.
Definition TList.h:38
virtual TObjLink * FirstLink() const
Definition TList.h:102
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition TMultiGraph.h:34
TList * GetListOfGraphs() const
Definition TMultiGraph.h:68
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
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
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Definition TStyle.cxx:1097
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Definition TStyle.cxx:1171
const Int_t n
Definition legend1.C:16
std::list< MeshPatch_t > Tesselation_t
void DrawQuadFilled(const TGLVertex3 &v0, const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVector3 &normal)
Draw quad face.
Definition TGLUtil.cxx:2962
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
const Double_t gH2PolyScaleXY
const Float_t gOrangeEmission[]
Definition TGLUtil.cxx:2853
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculates a normal vector of a plane.
Definition TMath.h:1212
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:662
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:762
Definition graph.py:1