ROOT  6.06/09
Reference Guide
TGLH2PolyPainter.cxx
Go to the documentation of this file.
1 #include <algorithm>
2 #include <stdexcept>
3 
4 #include "TMultiGraph.h"
5 #include "TH2Poly.h"
6 #include "TGraph.h"
7 #include "TClass.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
21 Paint 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 += "::";
51  fBinInfo += fHist->GetName();
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 
120  fCamera->SetCamera();
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 
133  fCamera->SetCamera();
135 
136  if (!fHighColor) {
138  fBoxCut.MoveBox(px, py, fSelectedPart);
139  }
140  }
141 
144  }
145 
146  fMousePosition.fX = px, fMousePosition.fY = py;
148 }
149 
150 ////////////////////////////////////////////////////////////////////////////////
151 ///No additional options.
152 
153 void TGLH2PolyPainter::AddOption(const TString &/*stringOption*/)
154 {
155 }
156 
157 ////////////////////////////////////////////////////////////////////////////////
158 ///No events.
159 
160 void 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 
191 namespace {
192 
193 Double_t Distance(const Double_t *p1, const Double_t *p2);
194 Bool_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 
208  DrawExtrusion();
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 
240 void 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 
299 void 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  glNormal3d(0., 0., 1.);
312 
313  Int_t binIndex = 0;
314  const TList *bins = static_cast<TH2Poly *>(fHist)->GetBins();
315  CIter_t cap = fCaps.begin();
316 
317  if(!bins->FirstLink())
318  throw 1;
319 
320  //Very ugly iteration statement. Number of caps is equal to number of links (in a list
321  //of bins including nested links in multigraphs. But this is not obvious from the code here,
322  //so, I've added check cap != fCaps.end() to make it more or less clear.
323  for (TObjLink *link = bins->FirstLink(); link && cap != fCaps.end(); link = link->Next()) {
324  TH2PolyBin *polyBin = static_cast<TH2PolyBin *>(link->GetObject());
325  if (dynamic_cast<TGraph *>(polyBin->GetPolygon())) {
326  DrawCap(cap, binIndex);
327  ++cap;
328  } else if (TMultiGraph *mg = dynamic_cast<TMultiGraph *>(polyBin->GetPolygon())) {
329  const TList *gs = mg->GetListOfGraphs();
330  TObjLink *graphLink = gs->FirstLink();
331  for (; graphLink && cap != fCaps.end(); graphLink = graphLink->Next(), ++cap)
332  DrawCap(cap, binIndex);
333  }
334 
335  ++binIndex;
336  }
337 }
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 ///Draw a cap on top of a bin.
341 
342 void TGLH2PolyPainter::DrawCap(CIter_t cap, Int_t binIndex)const
343 {
344  const Int_t binID = fSelectionBase + binIndex;
345  if (fSelectionPass) {
346  if (!fHighColor)
348  } else {
349  SetBinColor(binIndex);
350  if(!fHighColor && fSelectedPart == binID)
351  glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
352  }
353 
354  const Rgl::Pad::Tesselation_t &t = *cap;
355  typedef std::list<Rgl::Pad::MeshPatch_t>::const_iterator CMIter_t;
356  for (CMIter_t p = t.begin(); p != t.end(); ++p) {
357  const std::vector<Double_t> &vs = p->fPatch;
358  glBegin(GLenum(p->fPatchType));
359  for (UInt_t i = 0; i < vs.size(); i += 3)
360  glVertex3dv(&vs[i]);
361  glEnd();
362  }
363 
364  if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
365  glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
366 }
367 
368 ////////////////////////////////////////////////////////////////////////////////
369 ///Cache all data for TH2Poly object.
370 
372 {
373  TH2Poly *hp = static_cast<TH2Poly *>(fHist);
374  TList *bins = hp->GetBins();
375  if (!bins || !bins->GetEntries()) {
376  Error("TGLH2PolyPainter::CacheGeometry", "Empty list of bins in TH2Poly");
377  return kFALSE;
378  }
379 
380  const Double_t zMin = fHist->GetMinimum();
381  const Double_t zMax = fHist->GetMaximum();
382  const Int_t nColors = gStyle->GetNumberOfColors();
383 
384  fBinColors.clear();
385  fBinColors.reserve(bins->GetEntries());
386  fPolygon.clear();
387  fCaps.clear();
388 
389  Rgl::Pad::Tesselator tesselator(kTRUE);
390 
391  for (TObjLink * link = bins->FirstLink(); link; link = link->Next()) {
392  TH2PolyBin * bin = static_cast<TH2PolyBin *>(link->GetObject());
393  if (!bin || !bin->GetPolygon()) {
394  Error("TGH2PolyPainter::InitGeometry", "Null bin or polygon pointer in a list of bins");
395  return kFALSE;
396  }
397 
398  Double_t binZ = bin->GetContent();
399  if (!ClampZ(binZ)) {
400  Error("TGLH2PolyPainter::CacheGeometry", "Negative bin content and log scale");
401  return kFALSE;
402  }
403 
404  if (const TGraph *g = dynamic_cast<TGraph *>(bin->GetPolygon())) {
405  if (!BuildTesselation(tesselator, g, binZ))
406  return kFALSE;
407  } else if (const TMultiGraph *mg = dynamic_cast<TMultiGraph *>(bin->GetPolygon())) {
408  if (!BuildTesselation(tesselator, mg, binZ))
409  return kFALSE;
410  } else {
411  Error("TGLH2PolyPainter::CacheGeometry", "Bin contains object of unknown type");
412  return kFALSE;
413  }
414 
415  const Int_t colorIndex = gStyle->GetColorPalette(Int_t(((bin->GetContent() - zMin) / (zMax - zMin)) * (nColors - 1)));
416  fBinColors.push_back(colorIndex);
417  }
418 
419  return kTRUE;
420 }
421 
422 ////////////////////////////////////////////////////////////////////////////////
423 ///Tesselate a polygon described by TGraph.
424 
426 {
427  const Double_t *xs = g->GetX();
428  const Double_t *ys = g->GetY();
429 
430  if (!xs || !ys) {
431  Error("TGLH2PolyPainter::BuildTesselation", "null array(s) in a polygon");
432  return kFALSE;
433  }
434 
435  const Int_t nV = g->GetN();
436  if (nV < 3) {
437  Error("TGLH2PolyPainter::BuildTesselation", "number of vertices in a polygon must be >= 3");
438  return kFALSE;
439  }
440 
441  fCaps.push_back(Rgl::Pad::Tesselation_t());
442  FillTemporaryPolygon(xs, ys, z, nV);
443 
444  tess.SetDump(&fCaps.back());
445 
446  GLUtesselator *t = (GLUtesselator *)tess.GetTess();
447  gluBeginPolygon(t);
448  gluNextContour(t, (GLenum)GLU_UNKNOWN);
449 
450  glNormal3d(0., 0., 1.);
451 
452  for (Int_t j = 0; j < nV; ++j) {
453  gluTessVertex(t, &fPolygon[j * 3], &fPolygon[j * 3]);
454  }
455  gluEndPolygon(t);
456 
457  return kTRUE;
458 }
459 
460 ////////////////////////////////////////////////////////////////////////////////
461 ///Iterate over multi graph contents and tesselate nested TGraphs.
462 
464 {
465  const TList *graphs = mg->GetListOfGraphs();
466  if (!graphs) {
467  Error("TGLH2PolyPainter::BuildTesselation", "null list of graphs in a multigraph");
468  return kFALSE;
469  }
470 
471  for(TObjLink *link = graphs->FirstLink(); link; link = link->Next()) {
472  const TGraph *graph = dynamic_cast<TGraph *>(link->GetObject());
473  if (!graph) {
474  Error("TGLH2PolyPainter::BuildTesselation", "TGraph expected inside a multigraph, got something else");
475  return kFALSE;
476  }
477 
478  if (!BuildTesselation(tess, graph, z))
479  return kFALSE;
480  }
481 
482  return kTRUE;
483 }
484 
485 ////////////////////////////////////////////////////////////////////////////////
486 ///Update cap's z-coordinates for all caps.
487 ///Here no pointers are checked, this was already done
488 ///by InitGeometry.
489 
491 {
492  TH2Poly *hp = static_cast<TH2Poly *>(fHist);
493  TList *bins = hp->GetBins();
494 
495  std::list<Rgl::Pad::Tesselation_t>::iterator cap = fCaps.begin();
496 
497  //Ugly iteration statements, but still, number of links and caps will be
498  //ok - this is checked in InitGeometry. Check cap != fCaps.end() is added
499  //to make it clear (not required).
500  for (TObjLink *link = bins->FirstLink(); link && cap != fCaps.end(); link = link->Next()) {
501  TH2PolyBin *b = static_cast<TH2PolyBin *>(link->GetObject());
502  Double_t z = b->GetContent();
503  ClampZ(z);
504  //Update z coordinate in all patches.
505  if (dynamic_cast<TGraph *>(b->GetPolygon())) {
506  //Only one cap.
507  Rgl::Pad::Tesselation_t &tess = *cap;
508  Rgl::Pad::Tesselation_t::iterator patch = tess.begin();
509  for (; patch != tess.end(); ++patch) {
510  std::vector<Double_t> &mesh = patch->fPatch;
511  for (UInt_t i = 0, e = mesh.size() / 3; i < e; ++i)
512  mesh[i * 3 + 2] = z;
513  }
514 
515  ++cap;
516  } else if (const TMultiGraph *mg = dynamic_cast<TMultiGraph *>(b->GetPolygon())) {
517  const TList *gs = mg->GetListOfGraphs();
518  for (TObjLink * graphLink = gs->FirstLink(); graphLink && cap != fCaps.end(); graphLink = graphLink->Next(), ++cap) {
519  Rgl::Pad::Tesselation_t &tess = *cap;
520  Rgl::Pad::Tesselation_t::iterator patch = tess.begin();
521  for (; patch != tess.end(); ++patch) {
522  std::vector<Double_t> &mesh = patch->fPatch;
523  for (UInt_t i = 0, e = mesh.size() / 3; i < e; ++i)
524  mesh[i * 3 + 2] = z;
525  }
526  }
527  }//else is impossible and processed by InitGeometry.
528  }
529 
530  return kTRUE;
531 }
532 
533 ////////////////////////////////////////////////////////////////////////////////
534 ///Set bin's color.
535 
537 {
538  if (binIndex >= Int_t(fBinColors.size())) {
539  Error("TGLH2PolyPainter::SetBinColor", "bin index is out of range %d, must be <= %d",
540  binIndex, int(fBinColors.size()));
541  return;
542  }
543 
544  //Convert color index into RGB.
545  Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
546 
547  if (const TColor *c = gROOT->GetColor(fBinColors[binIndex]))
548  c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
549 
550  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
551  const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
552  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
553  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
554 }
555 
556 ////////////////////////////////////////////////////////////////////////////////
557 ///No sections.
558 
560 {
561 }
562 
563 ////////////////////////////////////////////////////////////////////////////////
564 ///No sections.
565 
567 {
568 }
569 
570 ////////////////////////////////////////////////////////////////////////////////
571 ///No sections.
572 
574 {
575 }
576 
577 ////////////////////////////////////////////////////////////////////////////////
578 ///Not yet.
579 
581 {
582 }
583 
584 ////////////////////////////////////////////////////////////////////////////////
585 ///Not yet.
586 
588 {
589 }
590 
591 ////////////////////////////////////////////////////////////////////////////////
592 ///Since I probably have to re-orient polygon, I need a temporary polygon.
593 
595 {
596  const Double_t xScale = fCoord->GetXScale();
597  const Double_t yScale = fCoord->GetYScale();
598 
599  fPolygon.resize(nV * 3);
600  for (Int_t j = 0; j < nV; ++j) {
601  fPolygon[j * 3] = xs[j] * xScale;
602  fPolygon[j * 3 + 1] = ys[j] * yScale;
603  fPolygon[j * 3 + 2] = z;
604  }
605 
606  if (IsPolygonCW(xs, ys, nV))
607  MakePolygonCCW();
608 }
609 
610 ////////////////////////////////////////////////////////////////////////////////
611 ///Code taken from the original TH2Poly.
612 
614 {
615  const Int_t nV = Int_t(fPolygon.size() / 3);
616  for (Int_t a = 0; a <= (nV / 2) - 1; a++) {
617  const Int_t b = nV - 1 - a;
618  std::swap(fPolygon[a * 3], fPolygon[b * 3]);
619  std::swap(fPolygon[a * 3 + 1], fPolygon[b * 3 + 1]);
620  }
621 }
622 
623 ////////////////////////////////////////////////////////////////////////////////
624 ///Clamp z value.
625 
627 {
628  if (fCoord->GetZLog()) {
629  if (zVal <= 0.)
630  return kFALSE;
631  else
632  zVal = TMath::Log10(zVal) * fCoord->GetZScale();
633  } else
634  zVal *= fCoord->GetZScale();
635 
636  const TGLVertex3 *frame = fBackBox.Get3DBox();
637 
638  if (zVal > frame[4].Z())
639  zVal = frame[4].Z();
640  else if (zVal < frame[0].Z())
641  zVal = frame[0].Z();
642 
643  return kTRUE;
644 }
645 
646 
647 namespace {
648 
649 ////////////////////////////////////////////////////////////////////////////////
650 ///
651 
652 Double_t Distance(const Double_t *p1, const Double_t *p2)
653 {
654  return TMath::Sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) +
655  (p1[1] - p2[1]) * (p1[1] - p2[1]) +
656  (p1[2] - p2[2]) * (p1[2] - p2[2]));
657 }
658 
659 ////////////////////////////////////////////////////////////////////////////////
660 ///Before, TH2Poly always produced good GL polygons - CCW. Now,
661 ///this code (by Deniz Gunceler) was deleted from TH2Poly.
662 
663 Bool_t IsPolygonCW(const Double_t *xs, const Double_t *ys, Int_t n)
664 {
665  Double_t signedArea = 0.;
666 
667  for (Int_t j = 0; j < n - 1; ++j)
668  signedArea += xs[j] * ys[j + 1] - ys[j] * xs[j + 1];
669 
670  return signedArea < 0.;
671 }
672 
673 }
virtual Int_t GetEntries() const
Definition: TCollection.h:92
void * GetTess() const
Definition: TGLPadUtils.h:169
Camera for TGLPlotPainter and sub-classes.
Definition: TGLPlotCamera.h:21
void DrawQuadFilled(const TGLVertex3 &v0, const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVector3 &normal)
Draw quad face.
Definition: TGLUtil.cxx:2920
Double_t GetBinContent(Int_t bin) const
Returns the content of the input bin For the overflow/underflow/sea bins: -1 | -2 | -3 ---+----+---- ...
Definition: TH2Poly.cxx:717
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
const Double_t * v1
Definition: TArcBall.cxx:33
char * GetPlotInfo(Int_t px, Int_t py)
Show number of bin and bin contents, if bin is under the cursor.
const Float_t gNullEmission[]
Definition: TGLUtil.cxx:2814
TList * GetListOfGraphs() const
Definition: TMultiGraph.h:71
float Float_t
Definition: RtypesCore.h:53
void DrawExtrusion() const
Extruded part of bins.
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
void DrawPlot() const
Draw extruded polygons and plot's frame.
TH1 * h
Definition: legend2.C:5
std::vector< Int_t > fBinColors
void StartPan(Int_t px, Int_t py)
User clicks somewhere (px, py).
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition: TMultiGraph.h:37
void DrawSectionXOY() const
No sections.
SCoord_t fX
Definition: TPoint.h:37
void swap(ROOT::THist< DIMENSIONS, PRECISION > &a, ROOT::THist< DIMENSIONS, PRECISION > &b) noexcept
Swap two histograms.
Definition: THist.h:196
#define gROOT
Definition: TROOT.h:340
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
SCoord_t fY
Definition: TPoint.h:38
void InitGL() const
Initialize some gl state variables.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void DrawCaps() const
Caps on bins.
TArc * a
Definition: textangle.C:12
void DrawPalette() const
Not yet.
const Bool_t kFALSE
Definition: Rtypes.h:92
void DrawPaletteAxis() const
Not yet.
void SetBinContentChanged(Bool_t flag)
Definition: TH2Poly.h:126
const TKDTreeBinning * bins
Int_t GetN() const
Definition: TGraph.h:132
Double_t GetZScale() const
Helper class to represent a bin in the TH2Poly histogram.
Definition: TH2Poly.h:29
Bool_t GetNewBinAdded() const
Definition: TH2Poly.h:112
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Definition: TMath.h:1032
Bool_t CacheGeometry()
Cache all data for TH2Poly object.
const Double_t gH2PolyScaleXY
const char * Data() const
Definition: TString.h:349
Double_t * GetY() const
Definition: TGraph.h:140
ClassImp(RooList) TObjOptLink *RooList TObjLink * link
Find the link corresponding to the named object in this list.
Definition: RooList.cxx:48
void SaveProjectionMatrix() const
3 component (x/y/z) vertex class.
Definition: TGLUtil.h:86
void DrawSectionYOZ() const
No sections.
Double_t Log10(Double_t x)
Definition: TMath.h:529
void SetBinColor(Int_t bin) const
Set bin's color.
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Definition: TStyle.cxx:796
TGLPlotBox fBackBox
std::list< Rgl::Pad::Tesselation_t >::const_iterator CIter_t
Paint TH2Poly.
static void SetDump(Tesselation_t *t)
Definition: TGLPadUtils.h:174
void Error(const char *location, const char *msgfmt,...)
Double_t GetXScale() const
void Apply(Double_t phi, Double_t theta) const
Applies rotations and translations before drawing.
A doubly linked list.
Definition: TList.h:47
Bool_t GetBinContentChanged() const
Definition: TH2Poly.h:101
std::list< MeshPatch_t > Tesselation_t
Definition: TGLPadUtils.h:159
Bool_t GetZLog() const
Get Z log.
Double_t fPadTheta
void RestoreProjectionMatrix() const
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
Definition: TGLUtil.cxx:2858
Bool_t ClampZ(Double_t &zVal) const
Clamp z value.
TGLPlotCamera * fCamera
Bool_t UpdateGeometry()
Update cap's z-coordinates for all caps.
void StartPan(Int_t px, Int_t py)
User clicks on a lego with middle mouse button (middle for pad).
Double_t * GetX() const
Definition: TGraph.h:139
TList * GetBins()
Definition: TH2Poly.h:97
void AddOption(const TString &stringOption)
No additional options.
Bool_t BuildTesselation(Rgl::Pad::Tesselator &tess, const TGraph *g, Double_t z)
Tesselate a polygon described by TGraph.
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
void Pan(Int_t px, Int_t py)
Pan camera.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
unsigned int UInt_t
Definition: RtypesCore.h:42
const char * GetBinTitle(Int_t bin) const
Returns the bin title.
Definition: TH2Poly.cxx:756
void SaveModelviewMatrix() const
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
ClassImp(TGLH2PolyPainter) TGLH2PolyPainter
Ctor.
void DrawCap(CIter_t cap, Int_t bin) const
Draw a cap on top of a bin.
virtual TObjLink * FirstLink() const
Definition: TList.h:101
TObject * GetPolygon() const
Definition: TH2Poly.h:42
void Pan(Int_t px, Int_t py)
Mouse events handler.
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms, functions and parametric surfaces.
void MakePolygonCCW() const
Code taken from the original TH2Poly.
Double_t GetContent() const
Definition: TH2Poly.h:39
std::vector< Double_t > fZLevels
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Definition: TStyle.cxx:730
Bool_t IsActive() const
std::vector< Double_t > fPolygon
void RestoreModelviewMatrix() const
double f(double x)
double Double_t
Definition: RtypesCore.h:55
void DrawSectionXOZ() const
No sections.
Bool_t InitGeometry()
Tesselate polygons, if not done yet.
void DrawBox(Int_t selectedPart, Bool_t selectionPass, const std::vector< Double_t > &zLevels, Bool_t highColor) const
Draw back box for a plot.
Definition: TGLPlotBox.cxx:183
The TH1 histogram class.
Definition: TH1.h:80
The color creation and management class.
Definition: TColor.h:23
Bool_t SetRanges(const TH1 *hist, Bool_t errors=kFALSE, Bool_t zBins=kFALSE)
Set bin ranges, ranges.
const TGLVertex3 * Get3DBox() const
Get 3D box.
Definition: TGLPlotBox.cxx:302
char Char_t
Definition: RtypesCore.h:29
void ProcessEvent(Int_t event, Int_t px, Int_t py)
No events.
const Rgl::Range_t & GetXRangeScaled() const
Scaled range.
Double_t GetYScale() const
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
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 SetPlotBox(const Rgl::Range_t &xRange, const Rgl::Range_t &yRange, const Rgl::Range_t &zRange)
Set up a frame box.
Definition: TGLPlotBox.cxx:197
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
AxisAngle::Scalar Distance(const AxisAngle &r1, const R &r2)
Distance between two rotations.
Definition: AxisAngle.h:326
Double_t Z() const
Definition: TGLUtil.h:126
std::list< Rgl::Pad::Tesselation_t > fCaps
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
Bool_t fUpdateSelection
std::complex< float_v > Z
Definition: main.cpp:120
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:7921
const Bool_t kTRUE
Definition: Rtypes.h:91
TGLPlotCoordinates * fCoord
const Float_t gOrangeEmission[]
Definition: TGLUtil.cxx:2811
TGLBoxCut fBoxCut
const Int_t n
Definition: legend1.C:16
void SetCamera() const
Viewport and projection.
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:8006
Int_t GetHeight() const
viewport[3]
2D Histogram with Polygonal Bins
Definition: TH2Poly.h:70
void SetNewBinAdded(Bool_t flag)
Definition: TH2Poly.h:128
void DeInitGL() const
Return some gl states to original values.