Logo ROOT  
Reference Guide
TGLBoxPainter.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Timur Pocheptsov 31/08/2006
3
4/*************************************************************************
5 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11#include <cctype>
12
13#include "KeySymbols.h"
14#include "TVirtualX.h"
15#include "Buttons.h"
16#include "TString.h"
17#include "TROOT.h"
18#include "TMath.h"
19#include "TColor.h"
20#include "TH3.h"
21#include "TVirtualMutex.h"
22
23#include "TPolyMarker3D.h"
24#include "TGLPlotCamera.h"
25#include "TGLBoxPainter.h"
26#include "TGLIncludes.h"
27
28/** \class TGLBoxPainter
29\ingroup opengl
30Paints TH3 histograms by rendering variable-sized boxes matching the
31bin contents.
32*/
33
35
36////////////////////////////////////////////////////////////////////////////////
37/// Normal constructor.
38
40 : TGLPlotPainter(hist, cam, coord, kTRUE, kTRUE, kTRUE),
41 fXOZSlice("XOZ", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kXOZ),
42 fYOZSlice("YOZ", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kYOZ),
43 fXOYSlice("XOY", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kXOY),
44 fType(kBox),
45 fPolymarker(0)
46{
47}
48
49
50////////////////////////////////////////////////////////////////////////////////
51/// Normal constructor.
52
55 : TGLPlotPainter(hist, cam, coord, kFALSE, kFALSE, kFALSE),
56 fXOZSlice("XOZ", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kXOZ),
57 fYOZSlice("YOZ", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kYOZ),
58 fXOYSlice("XOY", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kXOY),
59 fType(kBox),
60 fPolymarker(pm)
61{
62}
63
64////////////////////////////////////////////////////////////////////////////////
65///Show box info (i, j, k, binContent).
66
68{
69 fPlotInfo = "";
70
71 if (fSelectedPart) {
73 if (fHist->Class())
74 fPlotInfo += fHist->Class()->GetName();
75 fPlotInfo += "::";
77 } else if (!fHighColor){
78 const Int_t arr2Dsize = fCoord->GetNYBins() * fCoord->GetNZBins();
79 const Int_t binI = (fSelectedPart - fSelectionBase) / arr2Dsize + fCoord->GetFirstXBin();
80 const Int_t binJ = (fSelectedPart - fSelectionBase) % arr2Dsize / fCoord->GetNZBins() + fCoord->GetFirstYBin();
81 const Int_t binK = (fSelectedPart - fSelectionBase) % arr2Dsize % fCoord->GetNZBins() + fCoord->GetFirstZBin();
82
83 fPlotInfo.Form("(binx = %d; biny = %d; binz = %d; binc = %f)", binI, binJ, binK,
84 fHist->GetBinContent(binI, binJ, binK));
85 } else
86 fPlotInfo = "Switch to true color mode to get correct info";
87 }
88
89 return (Char_t *)fPlotInfo.Data();
90}
91
92////////////////////////////////////////////////////////////////////////////////
93///Set ranges, find min and max bin content.
94
96{
100
101 if (!fCoord->SetRanges(fHist, kFALSE, kTRUE))//kFALSE == drawErrors, kTRUE == zAsBins
102 return kFALSE;
103
106
108 fMinMaxVal.first = fMinMaxVal.second;
109 //Bad. You can up-date some bin value and get wrong picture.
110 for (Int_t ir = fCoord->GetFirstXBin(); ir <= fCoord->GetLastXBin(); ++ir) {
111 for (Int_t jr = fCoord->GetFirstYBin(); jr <= fCoord->GetLastYBin(); ++jr) {
112 for (Int_t kr = fCoord->GetFirstZBin(); kr <= fCoord->GetLastZBin(); ++kr) {
113 fMinMaxVal.second = TMath::Max(fMinMaxVal.second, fHist->GetBinContent(ir, jr, kr));
114 fMinMaxVal.first = TMath::Min(fMinMaxVal.first, fHist->GetBinContent(ir, jr, kr));
115 }
116 }
117 }
118
122
123 if (fPolymarker) {
124 const Double_t xScale = fCoord->GetXScale();
125 const Double_t yScale = fCoord->GetYScale();
126 const Double_t zScale = fCoord->GetZScale();
127
128 fPMPoints.assign(fPolymarker->GetP(), fPolymarker->GetP() + fPolymarker->GetN() * 3);
129 for (unsigned i = 0; i < fPMPoints.size(); i += 3) {
130 fPMPoints[i] *= xScale;
131 fPMPoints[i + 1] *= yScale;
132 fPMPoints[i + 2] *= zScale;
133 }
134 }
135
136 if (fCoord->Modified()) {
142 }
143
144 return kTRUE;
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// User clicks right mouse button (in a pad).
149
151{
152 fMousePosition.fX = px;
154 fCamera->StartPan(px, py);
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// User's moving mouse cursor, with middle mouse button pressed (for pad).
160/// Calculate 3d shift related to 2d mouse movement.
161
163{
164 if (fSelectedPart >= fSelectionBase) {//Pan camera.
167
170 fCamera->Pan(px, py);
171
174 } else if (fSelectedPart > 0) {
175 //Convert py into bottom-top orientation.
176 //Possibly, move box here
177 py = fCamera->GetHeight() - py;
180
183
184
185 if (!fHighColor) {
188 else
189 MoveSection(px, py);
190 } else {
191 MoveSection(px, py);
192 }
193
196 }
197
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Box1 == spheres.
204
206{
207 using namespace std;//isdigit must be in std. But ...
208
209 const Ssiz_t boxPos = option.Index("box");//"box" _already_ _exists_ in a string.
210 if (boxPos + 3 < option.Length() && isdigit(option[boxPos + 3]))
211 option[boxPos + 3] - '0' == 1 ? fType = kBox1 : fType = kBox;
212 else
213 fType = kBox;
214 option.Index("z") == kNPOS ? fDrawPalette = kFALSE : fDrawPalette = kTRUE;
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Remove sections.
219
221{
222 if (event == kButton1Double && (HasSections() || fBoxCut.IsActive())) {
226 if (fBoxCut.IsActive())
228 if (!gVirtualX->IsCmdThread())
229 gROOT->ProcessLineFast(Form("((TGLPlotPainter *)0x%zx)->Paint()", (size_t)this));
230 else
231 Paint();
232 } else if (event == kKeyPress && (py == kKey_c || py == kKey_C)) {
233 if (fHighColor)
234 Info("ProcessEvent", "Switch to true color mode to use box cut");
235 else {
238 }
239 }
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Initialize some gl state variables.
244
246{
247 glEnable(GL_DEPTH_TEST);
248 glEnable(GL_LIGHTING);
249 glEnable(GL_LIGHT0);
250 //For box option back polygons are culled (but not for dynamic profiles).
251 glEnable(GL_CULL_FACE);
252 glCullFace(GL_BACK);
253
254 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
255}
256
257////////////////////////////////////////////////////////////////////////////////
258///Return back some gl state variables.
259
261{
262 glDisable(GL_DEPTH_TEST);
263 glDisable(GL_LIGHTING);
264 glDisable(GL_LIGHT0);
265 glDisable(GL_CULL_FACE);
266 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
267}
268
269namespace {
270
271 /////////////////////////////////////////////////////////////////////////////
272 ///
273
274 void DrawMinusSigns(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax,
275 Double_t zMin, Double_t zMax, Int_t fp, Bool_t onSphere, Bool_t transp)
276 {
277 const TGLDisableGuard depthTest(GL_DEPTH_TEST);
278 const TGLDisableGuard cullFace(GL_CULL_FACE);
279
280 const Double_t ratio = onSphere ? 0.4 : 0.15;
281 const Double_t leftX = xMin + ratio * (xMax - xMin), rightX = xMax - ratio * (xMax - xMin);
282 const Double_t leftY = yMin + ratio * (yMax - yMin), rightY = yMax - ratio * (yMax - yMin);
283 const Double_t lowZ = zMin / 2. + zMax / 2. - 0.1 * (zMax - zMin);
284 const Double_t upZ = zMin / 2. + zMax / 2. + 0.1 * (zMax - zMin);
285
286
287 const Double_t minusVerts[][3] = {{xMin, leftY, lowZ}, {xMin, leftY, upZ}, {xMin, rightY, upZ}, {xMin, rightY, lowZ},
288 {leftX, yMin, lowZ}, {rightX, yMin, lowZ}, {rightX, yMin, upZ}, {leftX, yMin, upZ},
289 {xMax, leftY, lowZ}, {xMax, rightY, lowZ}, {xMax, rightY, upZ}, {xMax, leftY, upZ},
290 {rightX, yMax, lowZ}, {leftX, yMax, lowZ}, {leftX, yMax, upZ}, {rightX, yMax, upZ}};
291 const Int_t minusQuads[][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}};
292
293
294 TGLDisableGuard light(GL_LIGHTING);
295 glColor3d(1., 0., 0.);
296
297 const Int_t frontPlanes[][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0}};//Code duplication again :(
298 const Int_t *verts = minusQuads[frontPlanes[fp][0]];
299
300 glBegin(GL_POLYGON);
301 glVertex3dv(minusVerts[verts[0]]);
302 glVertex3dv(minusVerts[verts[1]]);
303 glVertex3dv(minusVerts[verts[2]]);
304 glVertex3dv(minusVerts[verts[3]]);
305 glEnd();
306
307 verts = minusQuads[frontPlanes[fp][1]];
308
309 glBegin(GL_POLYGON);
310 glVertex3dv(minusVerts[verts[0]]);
311 glVertex3dv(minusVerts[verts[1]]);
312 glVertex3dv(minusVerts[verts[2]]);
313 glVertex3dv(minusVerts[verts[3]]);
314 glEnd();
315
316 const Float_t nullEmission[] = {0.f, 0.f, 0.f, 1.f};
317 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, nullEmission);
318 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, nullEmission);
319
320 glColor4d(0., 0., 0., 0.25);
321 glPolygonMode(GL_FRONT, GL_LINE);
322
323 if (!transp) {
324 glEnable(GL_BLEND);
325 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
326 }
327
328 glEnable(GL_LINE_SMOOTH);
329 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
330
331 verts = minusQuads[frontPlanes[fp][0]];
332
333 glBegin(GL_POLYGON);
334 glVertex3dv(minusVerts[verts[0]]);
335 glVertex3dv(minusVerts[verts[1]]);
336 glVertex3dv(minusVerts[verts[2]]);
337 glVertex3dv(minusVerts[verts[3]]);
338 glEnd();
339
340 verts = minusQuads[frontPlanes[fp][1]];
341
342 glBegin(GL_POLYGON);
343 glVertex3dv(minusVerts[verts[0]]);
344 glVertex3dv(minusVerts[verts[1]]);
345 glVertex3dv(minusVerts[verts[2]]);
346 glVertex3dv(minusVerts[verts[3]]);
347 glEnd();
348
349 glPolygonMode(GL_FRONT, GL_FILL);
350
351 if (!transp)
352 glDisable(GL_BLEND);
353 }
354
355}
356
357////////////////////////////////////////////////////////////////////////////////
358
360{
361 if (fPolymarker)
362 return DrawCloud();
363
364 // Draw set of boxes (spheres)
365
366 //Shift plot to point of origin.
367 const Rgl::PlotTranslation trGuard(this);
368
370 glDisable(GL_CULL_FACE);
371 DrawSections();
372 glEnable(GL_CULL_FACE);
373
374 if (!fSelectionPass) {
375 glEnable(GL_POLYGON_OFFSET_FILL);//[0
376 glPolygonOffset(1.f, 1.f);
377 SetPlotColor();
378 if (HasSections()) {
379 //Boxes are semi-transparent if we have any sections.
380 glEnable(GL_BLEND);//[1
381 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
382 }
383 }
384
385 //Using front point, find the correct order to draw boxes from
386 //back to front/from bottom to top (it's important only for semi-transparent boxes).
387 const Int_t frontPoint = fBackBox.GetFrontPoint();
388 Int_t irInit = fCoord->GetFirstXBin(), iInit = 0;
389 const Int_t nX = fCoord->GetNXBins();
390 Int_t jrInit = fCoord->GetFirstYBin(), jInit = 0;
391 const Int_t nY = fCoord->GetNYBins();
392 Int_t krInit = fCoord->GetFirstZBin(), kInit = 0;
393 const Int_t nZ = fCoord->GetNZBins();
394
395 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit = fCoord->GetLastXBin(), -1);
396 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit = fCoord->GetLastYBin(), -1);
397 const Int_t addK = fBackBox.Get2DBox()[frontPoint + 4].Y() < fBackBox.Get2DBox()[frontPoint].Y() ? 1
398 : (kInit = nZ - 1, krInit = fCoord->GetLastZBin(),-1);
399 const Double_t xScale = fCoord->GetXScale();
400 const Double_t yScale = fCoord->GetYScale();
401 const Double_t zScale = fCoord->GetZScale();
402 const TAxis *xA = fXAxis;
403 const TAxis *yA = fYAxis;
404 const TAxis *zA = fZAxis;
405
408
409 Double_t maxContent = TMath::Max(TMath::Abs(fMinMaxVal.first), TMath::Abs(fMinMaxVal.second));
410 if(!maxContent)//bad, find better way to check zero.
411 maxContent = 1.;
412
413 Double_t wmin = TMath::Max(fHist->GetMinimum(),0.);
416 Double_t binContent;
417
418 for(Int_t ir = irInit, i = iInit; addI > 0 ? i < nX : i >= 0; ir += addI, i += addI) {
419 for(Int_t jr = jrInit, j = jInit; addJ > 0 ? j < nY : j >= 0; jr += addJ, j += addJ) {
420 for(Int_t kr = krInit, k = kInit; addK > 0 ? k < nZ : k >= 0; kr += addK, k += addK) {
421 binContent = fHist->GetBinContent(ir, jr, kr);
422 if (binContent < wmin) continue;
423 if (binContent > wmax) binContent = wmax;
424
425 const Double_t w = TMath::Power(TMath::Abs(binContent-wmin) / (wmax-wmin),1./3.);
426 if (!w)
427 continue;
428
429 const Double_t xMin = xScale * (xA->GetBinLowEdge(ir) / 2 + xA->GetBinUpEdge(ir) / 2 - w * xA->GetBinWidth(ir) / 2);
430 const Double_t xMax = xScale * (xA->GetBinLowEdge(ir) / 2 + xA->GetBinUpEdge(ir) / 2 + w * xA->GetBinWidth(ir) / 2);
431 const Double_t yMin = yScale * (yA->GetBinLowEdge(jr) / 2 + yA->GetBinUpEdge(jr) / 2 - w * yA->GetBinWidth(jr) / 2);
432 const Double_t yMax = yScale * (yA->GetBinLowEdge(jr) / 2 + yA->GetBinUpEdge(jr) / 2 + w * yA->GetBinWidth(jr) / 2);
433 const Double_t zMin = zScale * (zA->GetBinLowEdge(kr) / 2 + zA->GetBinUpEdge(kr) / 2 - w * zA->GetBinWidth(kr) / 2);
434 const Double_t zMax = zScale * (zA->GetBinLowEdge(kr) / 2 + zA->GetBinUpEdge(kr) / 2 + w * zA->GetBinWidth(kr) / 2);
435
436 if (fBoxCut.IsActive() && fBoxCut.IsInCut(xMin, xMax, yMin, yMax, zMin, zMax))
437 continue;
438
439 const Int_t binID = fSelectionBase + i * fCoord->GetNZBins() * fCoord->GetNYBins() + j * fCoord->GetNZBins() + k;
440
443 else if(!fHighColor && fSelectedPart == binID)
444 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
445
446 if (fType == kBox) {
447 Rgl::DrawBoxFront(xMin, xMax, yMin, yMax, zMin, zMax, frontPoint);
448 } else {
449 Rgl::DrawSphere(&fQuadric, xMin, xMax, yMin, yMax, zMin, zMax);
450 }
451
452 if (binContent < 0. && !fSelectionPass)
453 DrawMinusSigns(xMin, xMax, yMin, yMax, zMin, zMax, frontPoint, fType != kBox, HasSections());
454
455 if (!fSelectionPass && !fHighColor && fSelectedPart == binID)
456 glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
457 }
458 }
459 }
460
461 if (fBoxCut.IsActive())
463
464 if (!fSelectionPass && fType != kBox1) {
465 glDisable(GL_POLYGON_OFFSET_FILL);//0]
466 TGLDisableGuard lightGuard(GL_LIGHTING);//[2 - 2]
467 glColor4d(0., 0., 0., 0.25);
468 glPolygonMode(GL_FRONT, GL_LINE);//[3
469
470 const TGLEnableGuard blendGuard(GL_BLEND);//[4-4] + 1]
471 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
472 const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);//[5-5]
473 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
474
475 for(Int_t ir = irInit, i = iInit; addI > 0 ? i < nX : i >= 0; ir += addI, i += addI) {
476 for(Int_t jr = jrInit, j = jInit; addJ > 0 ? j < nY : j >= 0; jr += addJ, j += addJ) {
477 for(Int_t kr = krInit, k = kInit; addK > 0 ? k < nZ : k >= 0; kr += addK, k += addK) {
478 binContent = fHist->GetBinContent(ir, jr, kr);
479 if (binContent < wmin) continue;
480 if (binContent > wmax) binContent = wmax;
481 const Double_t w = TMath::Power(TMath::Abs(binContent-wmin) / (wmax-wmin),1./3.);
482 if (!w)
483 continue;
484
485 const Double_t xMin = xScale * (xA->GetBinLowEdge(ir) / 2 + xA->GetBinUpEdge(ir) / 2 - w * xA->GetBinWidth(ir) / 2);
486 const Double_t xMax = xScale * (xA->GetBinLowEdge(ir) / 2 + xA->GetBinUpEdge(ir) / 2 + w * xA->GetBinWidth(ir) / 2);
487 const Double_t yMin = yScale * (yA->GetBinLowEdge(jr) / 2 + yA->GetBinUpEdge(jr) / 2 - w * yA->GetBinWidth(jr) / 2);
488 const Double_t yMax = yScale * (yA->GetBinLowEdge(jr) / 2 + yA->GetBinUpEdge(jr) / 2 + w * yA->GetBinWidth(jr) / 2);
489 const Double_t zMin = zScale * (zA->GetBinLowEdge(kr) / 2 + zA->GetBinUpEdge(kr) / 2 - w * zA->GetBinWidth(kr) / 2);
490 const Double_t zMax = zScale * (zA->GetBinLowEdge(kr) / 2 + zA->GetBinUpEdge(kr) / 2 + w * zA->GetBinWidth(kr) / 2);
491
492 if (fBoxCut.IsActive() && fBoxCut.IsInCut(xMin, xMax, yMin, yMax, zMin, zMax))
493 continue;
494
495 Rgl::DrawBoxFront(xMin, xMax, yMin, yMax, zMin, zMax, frontPoint);
496 }
497 }
498 }
499
500 glPolygonMode(GL_FRONT, GL_FILL);//3]
501 }
502
504 DrawPalette();
505}
506
507////////////////////////////////////////////////////////////////////////////////
508///Draw a frame and a polymarker inside.
509
511{
512 //Shift plot to the point of origin.
513 const Rgl::PlotTranslation trGuard(this);
514
515 //Frame.
517
519 glColor3fv(fPhysicalShapeColor);
520
521 glDisable(GL_LIGHTING);
522
523 const TGLVertex3 *bb = fBackBox.Get3DBox();
524 const Double_t dX = (bb[1].X() - bb[0].X()) / 40.;
525 const Double_t dY = (bb[3].Y() - bb[0].Y()) / 40.;
526 const Double_t dZ = (bb[4].Z() - bb[0].Z()) / 40.;
527 //Now, draw the cloud of points (polymarker) inside the frame.
529
530 glEnable(GL_LIGHTING);
531}
532
533////////////////////////////////////////////////////////////////////////////////
534/// Set boxes color.
535
537{
538 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.05f};
539
541 diffColor[0] = fPhysicalShapeColor[0];
542 diffColor[1] = fPhysicalShapeColor[1];
543 diffColor[2] = fPhysicalShapeColor[2];
544 } else {
545 if (fHist->GetFillColor() != kWhite)
546 if (const TColor *c = gROOT->GetColor(fHist->GetFillColor()))
547 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
548 }
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/// Draw XOZ parallel section.
558
560{
561 if (fSelectionPass)
562 return;
564}
565
566////////////////////////////////////////////////////////////////////////////////
567/// Draw YOZ parallel section.
568
570{
571 if (fSelectionPass)
572 return;
574}
575
576////////////////////////////////////////////////////////////////////////////////
577/// Draw XOY parallel section.
578
580{
581 if (fSelectionPass)
582 return;
584}
585
586////////////////////////////////////////////////////////////////////////////////
587/// Check, if any section exists.
588
590{
591 return fXOZSectionPos > fBackBox.Get3DBox()[0].Y() || fYOZSectionPos> fBackBox.Get3DBox()[0].X() ||
593}
594
595////////////////////////////////////////////////////////////////////////////////
596///Draw. Palette.
597///Originally, fCamera was never null.
598///It can be a null now because of gl-viewer.
599
601{
602 if (!fCamera) {
603 //Thank you, gl-viewer!
604 return;
605 }
606
607 const TGLLevelPalette * palette = 0;
608 const TGLVertex3 *frame = fBackBox.Get3DBox();
609
610 if (fXOZSectionPos > frame[0].Y())
611 palette = &fXOZSlice.GetPalette();
612 else if (fYOZSectionPos > frame[0].X())
613 palette = &fYOZSlice.GetPalette();
614 else if (fXOYSectionPos > frame[0].Z())
615 palette = &fXOYSlice.GetPalette();
616
617 if (!palette || !palette->GetPaletteSize()) {
618 return;
619 }
620
621 Rgl::DrawPalette(fCamera, *palette);
622
623 glFinish();
624
627}
628
629////////////////////////////////////////////////////////////////////////////////
630///Draw. Palette. Axis.
631
633{
634 if (HasSections()) {
635 gVirtualX->SetDrawMode(TVirtualX::kCopy);//TCanvas by default sets in kInverse
637 }
638}
@ kKeyPress
Definition: Buttons.h:20
@ kButton1Double
Definition: Buttons.h:24
@ kBox
Definition: Buttons.h:29
#define GL_TRUE
Definition: GL_glu.h:262
#define GL_FALSE
Definition: GL_glu.h:261
#define GL_POLYGON
Definition: GL_glu.h:292
@ kKey_C
Definition: KeySymbols.h:128
@ kKey_c
Definition: KeySymbols.h:160
#define c(i)
Definition: RSha256.hxx:101
const Ssiz_t kNPOS
Definition: RtypesCore.h:124
int Int_t
Definition: RtypesCore.h:45
int Ssiz_t
Definition: RtypesCore.h:67
char Char_t
Definition: RtypesCore.h:33
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
float Float_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:364
@ kWhite
Definition: Rtypes.h:65
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition: TError.cxx:220
@ kGLCartesian
Definition: TGLUtil.h:44
#define gROOT
Definition: TROOT.h:404
char * Form(const char *fmt,...)
#define gVirtualX
Definition: TVirtualX.h:338
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
Class to manage histogram axis.
Definition: TAxis.h:30
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition: TAxis.cxx:518
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition: TAxis.cxx:540
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:528
The color creation and management class.
Definition: TColor.h:19
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.
Bool_t IsActive() const
Paints TH3 histograms by rendering variable-sized boxes matching the bin contents.
Definition: TGLBoxPainter.h:32
void StartPan(Int_t px, Int_t py)
User clicks right mouse button (in a pad).
EBoxType fType
Definition: TGLBoxPainter.h:43
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Remove sections.
const TPolyMarker3D * fPolymarker
Definition: TGLBoxPainter.h:50
TGLTH3Slice fYOZSlice
Definition: TGLBoxPainter.h:35
Bool_t HasSections() const
Check, if any section exists.
TGLTH3Slice fXOZSlice
Definition: TGLBoxPainter.h:34
char * GetPlotInfo(Int_t px, Int_t py)
Show box info (i, j, k, binContent).
TGLQuadric fQuadric
Definition: TGLBoxPainter.h:48
void DeInitGL() const
Return back some gl state variables.
std::vector< Double_t > fPMPoints
Definition: TGLBoxPainter.h:51
void DrawSectionXOZ() const
Draw XOZ parallel section.
void DrawSectionYOZ() const
Draw YOZ parallel section.
TString fPlotInfo
Definition: TGLBoxPainter.h:45
Rgl::Range_t fMinMaxVal
Definition: TGLBoxPainter.h:46
void SetPlotColor() const
Set boxes color.
TGLBoxPainter(const TGLBoxPainter &)
void DrawCloud() const
Draw a frame and a polymarker inside.
void Pan(Int_t px, Int_t py)
User's moving mouse cursor, with middle mouse button pressed (for pad).
void DrawPaletteAxis() const
Draw. Palette. Axis.
void InitGL() const
Initialize some gl state variables.
void DrawPlot() const
TGLTH3Slice fXOYSlice
Definition: TGLBoxPainter.h:36
void AddOption(const TString &stringOption)
Box1 == spheres.
void DrawPalette() const
Draw.
void DrawSectionXOY() const
Draw XOY parallel section.
Bool_t InitGeometry()
Set ranges, find min and max bin content.
Int_t GetPaletteSize() const
Get. Palette. Size.
Definition: TGLUtil.cxx:4254
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:198
const TGLVertex3 * Get3DBox() const
Get 3D box.
Definition: TGLPlotBox.cxx:303
const TGLVertex3 * Get2DBox() const
Get 2D box.
Definition: TGLPlotBox.cxx:312
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:184
Int_t GetFrontPoint() const
The nearest point.
Definition: TGLPlotBox.cxx:294
Camera for TGLPlotPainter and sub-classes.
Definition: TGLPlotCamera.h:22
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 GetZLog() const
Get Z log.
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
EGLCoordType GetCoordType() const
Get coordinates type.
Int_t GetNZBins() const
Number of Z bins.
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms,...
void DrawSections() const
Draw sections (if any).
Double_t fPadTheta
const Float_t * fPhysicalShapeColor
std::vector< Double_t > fZLevels
Double_t fXOYSectionPos
void RestoreModelviewMatrix() const
Double_t fXOZSectionPos
TGLBoxCut fBoxCut
virtual void Paint()
Draw lego/surf/whatever you can.
TGLPlotCoordinates * fCoord
TGLPlotBox fBackBox
void SaveProjectionMatrix() const
void SaveModelviewMatrix() const
void MoveSection(Int_t px, Int_t py)
Create dynamic profile using selected plane.
Bool_t fUpdateSelection
TGLPlotCamera * fCamera
void RestoreProjectionMatrix() const
Double_t fYOZSectionPos
A slice of a TH3.
const TGLLevelPalette & GetPalette() const
void SetMinMax(const Rgl::Range_t &newRange)
void DrawSlice(Double_t pos) const
Draw slice.
static void RenderPolyMarkers(const TAttMarker &marker, Char_t transp, Float_t *p, Int_t n, Int_t pick_radius=0, Bool_t selection=kFALSE, Bool_t sec_selection=kFALSE)
Render polymarkers at points specified by p-array.
Definition: TGLUtil.cxx:1974
3 component (x/y/z) vertex class.
Definition: TGLUtil.h:84
Double_t X() const
Definition: TGLUtil.h:119
Double_t Z() const
Definition: TGLUtil.h:123
Double_t Y() const
Definition: TGLUtil.h:121
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
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:8388
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4994
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:8478
The 3-D histogram classes derived from the 1-D histogram classes.
Definition: TH3.h:31
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
SCoord_t fY
Definition: TPoint.h:36
SCoord_t fX
Definition: TPoint.h:35
A 3D polymarker.
Definition: TPolyMarker3D.h:33
virtual Int_t GetN() const
Definition: TPolyMarker3D.h:58
virtual Float_t * GetP() const
Definition: TPolyMarker3D.h:59
Basic string class.
Definition: TString.h:136
Ssiz_t Length() const
Definition: TString.h:410
const char * Data() const
Definition: TString.h:369
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2314
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
const Float_t gNullEmission[]
Definition: TGLUtil.cxx:2847
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
Definition: TGLUtil.cxx:2891
void DrawPalette(const TGLPlotCamera *camera, const TGLLevelPalette &palette)
Draw. Palette.
void DrawPaletteAxis(const TGLPlotCamera *camera, const Range_t &minMax, Bool_t logZ)
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.
Definition: TGLUtil.cxx:3007
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.
Definition: TGLUtil.cxx:3275
const Float_t gOrangeEmission[]
Definition: TGLUtil.cxx:2844
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:735
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
Short_t Abs(Short_t d)
Definition: TMathBase.h:120