16#include "TGLIncludes.h"
43 const TAxis *xa =
h->GetXaxis();
44 const TAxis *ya =
h->GetYaxis();
45 const TAxis *za =
h->GetZaxis();
70 return fPainter->DistancetoPrimitive(px, py);
78 fPainter->ExecuteEvent(event, px, py);
87 static char message[] =
"TH3 composition";
127 static char message[] =
"TH3 composition";
243 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%lx)->Paint()", (
ULong_t)
this));
248 Info(
"ProcessEvent",
"Switch to true color mode to use box cut");
261 glEnable(GL_DEPTH_TEST);
262 glEnable(GL_LIGHTING);
264 glEnable(GL_CULL_FACE);
267 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_TRUE);
275 glDisable(GL_DEPTH_TEST);
276 glDisable(GL_LIGHTING);
277 glDisable(GL_LIGHT0);
278 glDisable(GL_CULL_FACE);
279 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_FALSE);
293 glEnable(GL_POLYGON_OFFSET_FILL);
294 glPolygonOffset(1.f, 1.f);
308 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit =
fCoord->
GetLastXBin(), -1);
309 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit =
fCoord->
GetLastYBin(), -1);
328 for(
Int_t ir = irInit, i = iInit; addI > 0 ? i < nX : i >= 0; ir += addI, i += addI) {
329 for(
Int_t jr = jrInit, j = jInit; addJ > 0 ? j < nY : j >= 0; jr += addJ, j += addJ) {
330 for(
Int_t kr = krInit, k = kInit; addK > 0 ? k < nZ : k >= 0; kr += addK, k += addK) {
331 const Double_t binContent =
h->GetBinContent(ir, jr, kr);
358 glDisable(GL_POLYGON_OFFSET_FILL);
360 glColor4d(0., 0., 0., 0.25);
361 glPolygonMode(GL_FRONT, GL_LINE);
364 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
366 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
374 for(
Int_t ir = irInit, i = iInit; addI > 0 ? i < nX : i >= 0; ir += addI, i += addI) {
375 for(
Int_t jr = jrInit, j = jInit; addJ > 0 ? j < nY : j >= 0; jr += addJ, j += addJ) {
376 for(
Int_t kr = krInit, k = kInit; addK > 0 ? k < nZ : k >= 0; kr += addK, k += addK) {
397 glPolygonMode(GL_FRONT, GL_FILL);
405 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.05f};
409 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
411 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
412 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
413 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
414 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
421void AxisError(
const TString & errorMsg)
423 Error(
"TGLTH3Composition::AddTH3",
"%s", errorMsg.
Data());
424 throw std::runtime_error(errorMsg.
Data());
433 AxisError(
"New hist has different number of bins along " + axisName);
439 if (firstBin1 != firstBin2)
440 AxisError(
"New hist has different first bin along " + axisName);
442 if (lastBin1 != lastBin2)
443 AxisError(
"New hist has different last bin along " + axisName);
448 AxisError(
"New hist has different low edge along " + axisName);
450 AxisError(
"New hist has different low edge along " + axisName);
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
char * Form(const char *fmt,...)
Class to manage histogram axis.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Int_t GetFirst() const
Return first bin on the axis i.e.
The color creation and management class.
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
Bool_t IsInCut(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax) const
Check, if box defined by xmin/xmax etc. is in cut.
void DrawBox(Bool_t selectionPass, Int_t selected) const
Draw cut as a semi-transparent box.
void TurnOnOff()
Turn the box cut on/off.
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
The histogram painter class using OpenGL.
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.
const TGLVertex3 * Get2DBox() const
Get 2D 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...
void SetXLog(Bool_t xLog)
If log changed, sections must be reset, set fModified.
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.
Int_t GetFirstXBin() const
Int_t GetFirstYBin() const
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
void ResetModified()
Reset modified.
Bool_t Modified() const
Modified.
Double_t GetXScale() const
Double_t GetZScale() const
Int_t GetLastZBin() const
Int_t GetNXBins() const
Number of X bins.
Int_t GetFirstZBin() const
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
void SetZLog(Bool_t zLog)
If log changed, sections must be reset, set fModified.
void SetYLog(Bool_t yLog)
If log changed, sections must be reset, set fModified.
Int_t GetLastYBin() const
Int_t GetNYBins() const
Number of Y bins.
Int_t GetLastXBin() const
Int_t GetNZBins() const
Number of Z bins.
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms,...
std::vector< Double_t > fZLevels
void RestoreModelviewMatrix() const
virtual void Paint()
Draw lego/surf/whatever you can.
TGLPlotCoordinates * fCoord
void SaveProjectionMatrix() const
void SaveModelviewMatrix() const
void RestoreProjectionMatrix() const
void InitGL() const
Initialize some gl state variables.
void DeInitGL() const
Return back some gl state variables.
void AddOption(const TString &option)
No options for composition.
TGLTH3Composition * fData
std::pair< Double_t, Double_t > fMinMaxVal
void DrawPlot() const
Draw composition of TH3s.
void SetColor(Int_t color) const
Set material.
void Pan(Int_t px, Int_t py)
User's moving mouse cursor, with middle mouse button pressed (for pad).
void StartPan(Int_t px, Int_t py)
Move plot or box cut.
char * GetPlotInfo(Int_t px, Int_t py)
Will be never called from TPad.
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Switch on/off box cut.
TGLTH3CompositionPainter(TGLTH3Composition *data, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Ctor.
void AddTH3(const TH3 *hist, ETH3BinShape shape=kBox)
Add TH3 into collection.
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Mouse and keyboard events.
std::vector< TH3Pair_t > fHists
TGLTH3Composition()
I have to define it, since explicit copy ctor was declared.
std::pair< const TH3 *, ETH3BinShape > TH3Pair_t
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Check if "this" is under cursor.
void Paint(Option_t *option)
Paint a composition of 3d hists.
std::unique_ptr< TGLHistPainter > fPainter
char * GetObjectInfo(Int_t px, Int_t py) const
I cannot show bin content in a status bar - since there can be several bins in one.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
TAxis fZaxis
Z axis descriptor.
TAxis fXaxis
X axis descriptor.
TAxis fYaxis
Y axis descriptor.
The 3-D histogram classes derived from the 1-D histogram classes.
const char * Data() const
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.
void DrawSphere(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Cylinder for lego3.
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)