34 if(!dynamic_cast<TH2Poly *>(hist)) {
35 Error(
"TGLH2PolyPainter::TGLH2PolyPainter",
"bad histogram, must be a valid TH2Poly *");
36 throw std::runtime_error(
"bad TH2Poly");
57 fBinInfo =
"Switch to true-color mode to obtain the correct info";
169 glEnable(GL_DEPTH_TEST);
170 glEnable(GL_LIGHTING);
173 glEnable(GL_CULL_FACE);
176 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
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);
266 for (
Int_t j = 0; j < nV - 1; ++j) {
273 const Double_t v2[] = {v1[0], v1[1], zMax};
274 const Double_t v3[] = {v0[0], v0[1], zMax};
285 const Double_t v2[] = {v1[0], v1[1], zMax};
286 const Double_t v3[] = {v0[0], v0[1], zMax};
311 glNormal3d(0., 0., 1.);
325 if (dynamic_cast<TGraph *>(polyBin->
GetPolygon())) {
329 const TList *gs = mg->GetListOfGraphs();
331 for (; graphLink && cap !=
fCaps.end(); graphLink = graphLink->
Next(), ++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)
376 Error(
"TGLH2PolyPainter::CacheGeometry",
"Empty list of bins in TH2Poly");
394 Error(
"TGH2PolyPainter::InitGeometry",
"Null bin or polygon pointer in a list of bins");
400 Error(
"TGLH2PolyPainter::CacheGeometry",
"Negative bin content and log scale");
411 Error(
"TGLH2PolyPainter::CacheGeometry",
"Bin contains object of unknown type");
431 Error(
"TGLH2PolyPainter::BuildTesselation",
"null array(s) in a polygon");
437 Error(
"TGLH2PolyPainter::BuildTesselation",
"number of vertices in a polygon must be >= 3");
446 GLUtesselator *
t = (GLUtesselator *)tess.
GetTess();
448 gluNextContour(t, (GLenum)GLU_UNKNOWN);
450 glNormal3d(0., 0., 1.);
452 for (
Int_t j = 0; j < nV; ++j) {
467 Error(
"TGLH2PolyPainter::BuildTesselation",
"null list of graphs in a multigraph");
474 Error(
"TGLH2PolyPainter::BuildTesselation",
"TGraph expected inside a multigraph, got something else");
495 std::list<Rgl::Pad::Tesselation_t>::iterator cap =
fCaps.begin();
505 if (dynamic_cast<TGraph *>(b->
GetPolygon())) {
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)
517 const TList *gs = mg->GetListOfGraphs();
518 for (
TObjLink * graphLink = gs->
FirstLink(); graphLink && cap !=
fCaps.end(); graphLink = graphLink->Next(), ++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)
539 Error(
"TGLH2PolyPainter::SetBinColor",
"bin index is out of range %d, must be <= %d",
545 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
548 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
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);
600 for (
Int_t j = 0; j < nV; ++j) {
602 fPolygon[j * 3 + 1] = ys[j] * yScale;
606 if (IsPolygonCW(xs, ys, nV))
616 for (
Int_t a = 0;
a <= (nV / 2) - 1;
a++) {
617 const Int_t b = nV - 1 -
a;
638 if (zVal > frame[4].
Z())
640 else if (zVal < frame[0].
Z())
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]));
667 for (
Int_t j = 0; j < n - 1; ++j)
668 signedArea += xs[j] * ys[j + 1] - ys[j] * xs[j + 1];
670 return signedArea < 0.;
virtual Int_t GetEntries() const
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.
Double_t GetBinContent(Int_t bin) const
Returns the content of the input bin For the overflow/underflow/sea bins: -1 | -2 | -3 ---+----+---- ...
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.
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[]
TList * GetListOfGraphs() const
void DrawExtrusion() const
Extruded part of bins.
R__EXTERN TStyle * gStyle
void DrawPlot() const
Draw extruded polygons and plot's frame.
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.
void DrawSectionXOY() const
No sections.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
void InitGL() const
Initialize some gl state variables.
void DrawCaps() const
Caps on bins.
void DrawPalette() const
Not yet.
void DrawPaletteAxis() const
Not yet.
void SetBinContentChanged(Bool_t flag)
const TKDTreeBinning * bins
Double_t GetZScale() const
Helper class to represent a bin in the TH2Poly histogram.
Bool_t GetNewBinAdded() const
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
TGLViewer::ECameraType camera
Bool_t CacheGeometry()
Cache all data for TH2Poly object.
const Double_t gH2PolyScaleXY
const char * Data() const
ClassImp(RooList) TObjOptLink *RooList TObjLink * link
Find the link corresponding to the named object in this list.
void SaveProjectionMatrix() const
static void swap(double &a, double &b)
3 component (x/y/z) vertex class.
void DrawSectionYOZ() const
No sections.
Double_t Log10(Double_t x)
void SetBinColor(Int_t bin) const
Set bin's color.
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
std::list< Rgl::Pad::Tesselation_t >::const_iterator CIter_t
static void SetDump(Tesselation_t *t)
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.
Bool_t GetBinContentChanged() const
std::list< MeshPatch_t > Tesselation_t
Bool_t GetZLog() const
Get Z log.
void RestoreProjectionMatrix() const
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
Bool_t ClampZ(Double_t &zVal) const
Clamp z value.
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).
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.
const char * GetBinTitle(Int_t bin) const
Returns the bin title.
void SaveModelviewMatrix() const
virtual const char * GetName() const
Returns name of object.
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
TObject * GetPolygon() const
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
std::vector< Double_t > fZLevels
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
std::vector< Double_t > fPolygon
void RestoreModelviewMatrix() const
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.
Wrapper around a TObject so it can be stored in a TList.
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 TGLVertex3 * Get3DBox() const
Get 3D box.
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.
A Graph is a graphics object made of two arrays X and Y with npoints each.
AxisAngle::Scalar Distance(const AxisAngle &r1, const R &r2)
Distance between two rotations.
std::list< Rgl::Pad::Tesselation_t > fCaps
Double_t Sqrt(Double_t x)
std::complex< float_v > Z
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...
TGLPlotCoordinates * fCoord
const Float_t gOrangeEmission[]
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...
Int_t GetHeight() const
viewport[3]
2D Histogram with Polygonal Bins
void SetNewBinAdded(Bool_t flag)
void DeInitGL() const
Return some gl states to original values.