54 CompareAxes(xa, GetXaxis(),
"X");
55 CompareAxes(ya, GetYaxis(),
"Y");
56 CompareAxes(za, GetZaxis(),
"Z");
70 return fPainter->DistancetoPrimitive(px, py);
78 fPainter->ExecuteEvent(event, px, py);
87 static char message[] =
"TH3 composition";
103 fPainter->Paint(
"dummy");
127 static char message[] =
"TH3 composition";
135 if (!fData->fHists.size())
147 fBackBox.SetPlotBox(fCoord->GetXRangeScaled(), fCoord->GetYRangeScaled(), fCoord->GetZRangeScaled());
149 fCamera->SetViewVolume(fBackBox.Get3DBox());
152 const TH3 *
h = fData->fHists[0].first;
154 fCoord->GetFirstYBin(),
155 fCoord->GetFirstZBin());
156 fMinMaxVal.first = fMinMaxVal.second;
158 for (
UInt_t hNum = 0, lastH = fData->fHists.size(); hNum < lastH; ++hNum) {
159 h = fData->fHists[hNum].first;
160 for (
Int_t ir = fCoord->GetFirstXBin(); ir <= fCoord->GetLastXBin(); ++ir) {
161 for (
Int_t jr = fCoord->GetFirstYBin(); jr <= fCoord->GetLastYBin(); ++jr) {
162 for (
Int_t kr = fCoord->GetFirstZBin(); kr <= fCoord->GetLastZBin(); ++kr) {
170 if (fCoord->Modified()) {
171 fUpdateSelection =
kTRUE;
172 fCoord->ResetModified();
183 fMousePosition.fX = px;
184 fMousePosition.fY = fCamera->GetHeight() - py;
185 fCamera->StartPan(px, py);
186 fBoxCut.StartMovement(px, fCamera->GetHeight() - py);
195 if (fSelectedPart >= fSelectionBase) {
196 SaveModelviewMatrix();
197 SaveProjectionMatrix();
199 fCamera->SetCamera();
200 fCamera->Apply(fPadPhi, fPadTheta);
201 fCamera->Pan(px, py);
203 RestoreProjectionMatrix();
204 RestoreModelviewMatrix();
205 }
else if (fSelectedPart > 0) {
208 py = fCamera->GetHeight() - py;
209 SaveModelviewMatrix();
210 SaveProjectionMatrix();
212 fCamera->SetCamera();
213 fCamera->Apply(fPadPhi, fPadTheta);
216 if (fBoxCut.IsActive() && (fSelectedPart >= kXAxis && fSelectedPart <= kZAxis))
217 fBoxCut.MoveBox(px, py, fSelectedPart);
220 RestoreProjectionMatrix();
221 RestoreModelviewMatrix();
224 fMousePosition.fX = px, fMousePosition.fY = py;
225 fUpdateSelection =
kTRUE;
243 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%lx)->Paint()", (
ULong_t)
this));
248 Info(
"ProcessEvent",
"Switch to true color mode to use box cut");
251 fUpdateSelection =
kTRUE;
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);
290 fBackBox.DrawBox(fSelectedPart, fSelectionPass, fZLevels, fHighColor);
292 if (!fSelectionPass) {
293 glEnable(GL_POLYGON_OFFSET_FILL);
294 glPolygonOffset(1.
f, 1.
f);
300 const Int_t frontPoint = fBackBox.GetFrontPoint();
301 Int_t irInit = fCoord->GetFirstXBin(), iInit = 0;
302 const Int_t nX = fCoord->GetNXBins();
303 Int_t jrInit = fCoord->GetFirstYBin(), jInit = 0;
304 const Int_t nY = fCoord->GetNYBins();
305 Int_t krInit = fCoord->GetFirstZBin(), kInit = 0;
306 const Int_t nZ = fCoord->GetNZBins();
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);
310 const Int_t addK = fBackBox.Get2DBox()[frontPoint + 4].Y() < fBackBox.Get2DBox()[frontPoint].Y() ? 1
311 : (kInit = nZ - 1, krInit = fCoord->GetLastZBin(),-1);
312 const Double_t xScale = fCoord->GetXScale();
313 const Double_t yScale = fCoord->GetYScale();
314 const Double_t zScale = fCoord->GetZScale();
315 const TAxis *xA = fXAxis;
316 const TAxis *yA = fYAxis;
317 const TAxis *zA = fZAxis;
323 for (
UInt_t hNum = 0; hNum < fData->fHists.size(); ++hNum) {
324 const TH3 *
h = fData->fHists[hNum].first;
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) {
343 if (fBoxCut.IsActive() && fBoxCut.IsInCut(xMin, xMax, yMin, yMax, zMin, zMax))
355 if (fBoxCut.IsActive())
356 fBoxCut.DrawBox(fSelectionPass, fSelectedPart);
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);
368 for (
UInt_t hNum = 0; hNum < fData->fHists.size(); ++hNum) {
372 const TH3 *
h = fData->fHists[hNum].first;
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) {
388 if (fBoxCut.IsActive() && fBoxCut.IsInCut(xMin, xMax, yMin, yMax, zMin, zMax))
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);
421 void 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);
Camera for TGLPlotPainter and sub-classes.
void Pan(Int_t px, Int_t py)
User's moving mouse cursor, with middle mouse button pressed (for pad).
Int_t GetFirst() const
Return first bin on the axis i.e.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual Int_t GetNbinsZ() const
Short_t Min(Short_t a, Short_t b)
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
void DeInitGL() const
Return back some gl state variables.
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Switch on/off box cut.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Check if "this" is under cursor.
void StartPan(Int_t px, Int_t py)
Move plot or box cut.
void DrawPlot() const
Draw composition of TH3s.
void Info(const char *location, const char *msgfmt,...)
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.
void Error(const char *location, const char *msgfmt,...)
The 3-D histogram classes derived from the 1-D histogram classes.
void Paint(Option_t *option)
Paint a composition of 3d hists.
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.
Int_t GetLast() const
Return last bin on the axis i.e.
Class to manage histogram axis.
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
char * Form(const char *fmt,...)
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms, functions and parametric surfaces.
std::pair< const TH3 *, ETH3BinShape > TH3Pair_t
void SetColor(Int_t color) const
Set material.
virtual Color_t GetFillColor() const
Return the fill area color.
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.
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.
The histogram painter class using OpenGL.
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Mouse and keyboard events.
void InitGL() const
Initialize some gl state variables.
void AddOption(const TString &option)
No options for composition.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
char * GetPlotInfo(Int_t px, Int_t py)
Will be never called from TPad.
Short_t Max(Short_t a, Short_t b)
void AddTH3(const TH3 *hist, ETH3BinShape shape=kBox)
Add TH3 into collection.
virtual Int_t GetNbinsX() const
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
virtual Int_t GetNbinsY() const
const char * Data() const