35 if(!dynamic_cast<TH2Poly *>(hist)) {
36 Error(
"TGLH2PolyPainter::TGLH2PolyPainter",
"bad histogram, must be a valid TH2Poly *");
37 throw std::runtime_error(
"bad TH2Poly");
58 fBinInfo =
"Switch to true-color mode to obtain the correct info";
170 glEnable(GL_DEPTH_TEST);
171 glEnable(GL_LIGHTING);
174 glEnable(GL_CULL_FACE);
177 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
185 glDisable(GL_DEPTH_TEST);
186 glDisable(GL_LIGHTING);
187 glDisable(GL_LIGHT0);
188 glDisable(GL_CULL_FACE);
189 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
267 for (
Int_t j = 0; j < nV - 1; ++j) {
274 const Double_t v2[] = {v1[0], v1[1], zMax};
275 const Double_t v3[] = {v0[0], v0[1], zMax};
286 const Double_t v2[] = {v1[0], v1[1], zMax};
287 const Double_t v3[] = {v0[0], v0[1], zMax};
324 if (dynamic_cast<TGraph *>(polyBin->
GetPolygon())) {
329 const TList *gs =
mg->GetListOfGraphs();
331 for (; graphLink && cap !=
fCaps.end(); graphLink = graphLink->
Next(), ++cap) {
356 glNormal3d(0., 0., bottomCap ? -1. : 1.);
362 typedef std::list<Rgl::Pad::MeshPatch_t>::const_iterator CMIter_t;
364 for (CMIter_t p = t.begin(); p != t.end(); ++p) {
365 const std::vector<Double_t> &vs = p->fPatch;
366 glBegin(GLenum(p->fPatchType));
367 for (
UInt_t i = 0; i < vs.size(); i += 3)
368 glVertex3d(vs[i], vs[i + 1],
fZMin);
372 for (CMIter_t p = t.begin(); p != t.end(); ++p) {
373 const std::vector<Double_t> &vs = p->fPatch;
374 glBegin(GLenum(p->fPatchType));
375 for (
UInt_t i = 0; i < vs.size(); i += 3)
397 Error(
"TGLH2PolyPainter::CacheGeometry",
"Empty list of bins in TH2Poly");
415 Error(
"TGH2PolyPainter::InitGeometry",
"Null bin or polygon pointer in a list of bins");
421 Error(
"TGLH2PolyPainter::CacheGeometry",
"Negative bin content and log scale");
432 Error(
"TGLH2PolyPainter::CacheGeometry",
"Bin contains object of unknown type");
452 Error(
"TGLH2PolyPainter::BuildTesselation",
"null array(s) in a polygon");
458 Error(
"TGLH2PolyPainter::BuildTesselation",
"number of vertices in a polygon must be >= 3");
467 GLUtesselator *t = (GLUtesselator *)tess.
GetTess();
469 gluNextContour(t, (GLenum)GLU_UNKNOWN);
471 glNormal3d(0., 0., 1.);
473 for (
Int_t j = 0; j < nV; ++j) {
488 Error(
"TGLH2PolyPainter::BuildTesselation",
"null list of graphs in a multigraph");
495 Error(
"TGLH2PolyPainter::BuildTesselation",
"TGraph expected inside a multigraph, got something else");
516 std::list<Rgl::Pad::Tesselation_t>::iterator cap =
fCaps.begin();
526 if (dynamic_cast<TGraph *>(b->
GetPolygon())) {
529 Rgl::Pad::Tesselation_t::iterator patch = tess.begin();
530 for (; patch != tess.end(); ++patch) {
531 std::vector<Double_t> &mesh = patch->fPatch;
532 for (
UInt_t i = 0,
e = mesh.size() / 3; i <
e; ++i)
538 const TList *gs =
mg->GetListOfGraphs();
539 for (
TObjLink * graphLink = gs->
FirstLink(); graphLink && cap !=
fCaps.end(); graphLink = graphLink->Next(), ++cap) {
541 Rgl::Pad::Tesselation_t::iterator patch = tess.begin();
542 for (; patch != tess.end(); ++patch) {
543 std::vector<Double_t> &mesh = patch->fPatch;
544 for (
UInt_t i = 0,
e = mesh.size() / 3; i <
e; ++i)
560 Error(
"TGLH2PolyPainter::SetBinColor",
"bin index is out of range %d, must be <= %d",
566 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
569 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
571 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
572 const Float_t specColor[] = {0.2f, 0.2f, 0.2f, 0.2f};
573 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
574 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.
f);
621 for (
Int_t j = 0; j < nV; ++j) {
623 fPolygon[j * 3 + 1] = ys[j] * yScale;
627 if (IsPolygonCW(xs, ys, nV))
637 for (
Int_t a = 0;
a <= (nV / 2) - 1;
a++) {
659 if (zVal > frame[4].Z())
661 else if (zVal < frame[0].Z())
675 return TMath::Sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) +
676 (p1[1] - p2[1]) * (p1[1] - p2[1]) +
677 (p1[2] - p2[2]) * (p1[2] - p2[2]));
688 for (
Int_t j = 0; j < n - 1; ++j)
689 signedArea += xs[j] * ys[j + 1] - ys[j] * xs[j + 1];
691 return signedArea < 0.;
virtual const char * GetName() const
Returns name of object.
void RestoreModelviewMatrix() const
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...
Camera for TGLPlotPainter and sub-classes.
void DrawQuadFilled(const TGLVertex3 &v0, const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVector3 &normal)
Draw quad face.
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
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[]
Bool_t GetZLog() const
Get Z log.
void DrawPaletteAxis() const
Not yet.
void swap(TDirectoryEntry &e1, TDirectoryEntry &e2) noexcept
void DrawPlot() const
Draw extruded polygons and plot's frame.
R__EXTERN TStyle * gStyle
std::vector< Int_t > fBinColors
void StartPan(Int_t px, Int_t py)
User clicks somewhere (px, py).
virtual Int_t GetEntries() const
A TMultiGraph is a collection of TGraph (or derived) objects.
const TGLVertex3 * Get3DBox() const
Get 3D box.
Bool_t ClampZ(Double_t &zVal) const
Clamp z value.
void SetBinContentChanged(Bool_t flag)
Helper class to represent a bin in the TH2Poly histogram.
TGLH2PolyPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Ctor.
static constexpr double mg
void MakePolygonCCW() const
Code taken from the original TH2Poly.
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculate a normal vector of a plane.
Bool_t CacheGeometry()
Cache all data for TH2Poly object.
const Double_t gH2PolyScaleXY
void Apply(Double_t phi, Double_t theta) const
Applies rotations and translations before drawing.
const char * GetBinTitle(Int_t bin) const
Returns the bin title.
3 component (x/y/z) vertex class.
void DrawSectionXOZ() const
No sections.
Double_t Log10(Double_t x)
static double p2(double t, double a, double b, double c)
void SetCamera() const
Viewport and projection.
std::list< Rgl::Pad::Tesselation_t >::const_iterator CIter_t
void DrawCaps() const
Caps on bins.
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
void DrawSectionXOY() const
No sections.
static void SetDump(Tesselation_t *t)
void Error(const char *location, const char *msgfmt,...)
void DeInitGL() const
Return some gl states to original values.
virtual Double_t GetBinContent(Int_t bin) const
Returns the content of the input bin For the overflow/underflow/sea bins: -1 | -2 | -3 ---+----+---- ...
void DrawCap(CIter_t cap, Int_t bin, bool bottomCap) const
Draw a cap on top of a bin.
std::list< MeshPatch_t > Tesselation_t
TObject * GetPolygon() const
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
void RestoreProjectionMatrix() const
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 GetContent() const
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 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 Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
static double p1(double t, double a, double b)
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.
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
std::vector< Double_t > fZLevels
virtual TObjLink * FirstLink() const
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...
void DrawBox(Int_t selectedPart, Bool_t selectionPass, const std::vector< Double_t > &zLevels, Bool_t highColor) const
Draw back box for a plot.
Double_t GetYScale() const
std::vector< Double_t > fPolygon
Bool_t GetNewBinAdded() const
Bool_t InitGeometry()
Tesselate polygons, if not done yet.
Wrapper around a TObject so it can be stored in a TList.
void SaveProjectionMatrix() const
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
The color creation and management class.
Bool_t SetRanges(const TH1 *hist, Bool_t errors=kFALSE, Bool_t zBins=kFALSE)
Set bin ranges, ranges.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
void DrawSectionYOZ() const
No sections.
you should not use this method at all Int_t Int_t z
void SetBinColor(Int_t bin) const
Set bin's color.
void InitGL() const
Initialize some gl state variables.
TList * GetListOfGraphs() const
void ProcessEvent(Int_t event, Int_t px, Int_t py)
No events.
Bool_t GetBinContentChanged() const
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
void SetPlotBox(const Rgl::Range_t &xRange, const Rgl::Range_t &yRange, const Rgl::Range_t &zRange)
Set up a frame box.
A Graph is a graphics object made of two arrays X and Y with npoints each.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
const Rgl::Range_t & GetXRangeScaled() const
Scaled range.
AxisAngle::Scalar Distance(const AxisAngle &r1, const R &r2)
Distance between two rotations.
void DrawExtrusion() const
Extruded part of bins.
std::list< Rgl::Pad::Tesselation_t > fCaps
Double_t Sqrt(Double_t x)
Int_t GetHeight() const
viewport[3]
void SaveModelviewMatrix() const
TGLPlotCoordinates * fCoord
const Float_t gOrangeEmission[]
void DrawPalette() const
Not yet.
Double_t GetZScale() const
Double_t GetXScale() const
2D Histogram with Polygonal Bins
void SetNewBinAdded(Bool_t flag)
const char * Data() const