Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TGLAxisPainter.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Matevz Tadel 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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
12#include "TGLAxisPainter.h"
13
14#include "TGLRnrCtx.h"
15#include "TGLCamera.h"
16#include "TGLIncludes.h"
17#include "TGLFontManager.h"
18
19#include "TAttAxis.h"
20#include "TAxis.h"
21#include "TH1.h"
22#include "THLimitsFinder.h"
23
24#include "TMath.h"
25#include "TPRegexp.h"
26
27/** \class TGLAxisPainter
28\ingroup opengl
29Utility class to paint axis in GL.
30*/
31
32
33////////////////////////////////////////////////////////////////////////////////
34
36 fExp(0),
37 fMaxDigits(5),
38 fDecimals(0),
39
40 fAttAxis(nullptr), fUseAxisColors(kTRUE),
41
42 fFontMode(TGLFont::kTexture),
43 fDir(1, 0, 0),
44 fTMNDim(1),
47
48 fLabelAlignH(TGLFont::kCenterH),
49 fLabelAlignV(TGLFont::kCenterV),
50 fAllZeroesRE(nullptr)
51{
52 // Constructor.
53
54 fAllZeroesRE = new TPMERegexp("[-+]?0\\.0*$", "o");
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Destructor.
59
64
65////////////////////////////////////////////////////////////////////////////////
66/// Set label align.
67
73
74////////////////////////////////////////////////////////////////////////////////
75/// Find first and last character of a label.
76
77void TGLAxisPainter::LabelsLimits(const char *label, Int_t &first, Int_t &last) const
78{
79 last = strlen(label) - 1;
80 for (Int_t i = 0; i <= last; i++) {
81 if (strchr("1234567890-+.", label[i])) {
82 first = i;
83 return;
84 }
85 }
86 Error("LabelsLimits", "attempt to draw a blank label");
87}
88
89////////////////////////////////////////////////////////////////////////////////
90/// Returns formatted text suitable for display of value.
91
93{
94 s.Form(fFormat, val);
96
97 if (s == "-." || s == "-0")
98 {
99 s = "0";
100 return;
101 }
102
103 Ssiz_t ld = s.Last('.') + 1;
104 if (s.Length() - ld > fDecimals)
105 s.Remove(ld + fDecimals);
106
107
108 if (fDecimals == 0 && s.EndsWith("."))
109 s.Remove(s.Length() -1);
110
111 fAllZeroesRE->Substitute(s, "0", kFALSE);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Construct print format from given primary bin width.
116
118{
119 Double_t absMax = TMath::Max(TMath::Abs(min), TMath::Abs(max));
120 Double_t epsilon = 1e-5;
121 Double_t absMaxLog = TMath::Log10(absMax) + epsilon;
122
123 fExp = 0;
124 Int_t if1, if2;
125 Double_t xmicros = TMath::Power(10, -fMaxDigits);
126 if (bw1 < xmicros && absMaxLog < 0) {
127 // First case : bin width less than 0.001
128 fExp = (Int_t)absMaxLog;
129 if (fExp % 3 == 1) fExp += TMath::Sign(2, fExp);
130 if (fExp % 3 == 2) fExp += TMath::Sign(1, fExp);
131 if1 = fMaxDigits;
132 if2 = fMaxDigits - 2;
133 } else {
134 // Use x 10 n format. (only powers of 3 allowed)
135 Float_t af = (absMax > 1) ? absMaxLog : TMath::Log10(absMax * 0.0001);
136 af += epsilon;
137 Int_t clog = Int_t(af) + 1;
138
139 if (clog > fMaxDigits) {
140 while (true) {
141 fExp++;
142 absMax /= 10;
143 if (fExp % 3 == 0 && absMax <= TMath::Power(10, fMaxDigits - 1)) break;
144 }
145 } else if (clog < -fMaxDigits) {
146 Double_t rne = 1 / TMath::Power(10, fMaxDigits - 2);
147 while (true) {
148 fExp--;
149 absMax *= 10;
150 if (fExp % 3 == 0 && absMax >= rne) break;
151 }
152 }
153
154 Int_t na = 0;
155 for (Int_t i = fMaxDigits - 1; i > 0; i--) {
156 if (TMath::Abs(absMax) < TMath::Power(10, i)) na = fMaxDigits - i;
157 }
158 Double_t size = TMath::Abs(max - min);
159 Int_t ndyn = (Int_t)(size / bw1);
160 while (ndyn) {
161 if (size / ndyn <= 0.999 && na < fMaxDigits - 2) {
162 na++;
163 ndyn /= 10;
164 } else break;
165 }
166 if2 = na;
167 if1 = TMath::Max(clog + na, fMaxDigits) + 1;
168 }
169
170 // compose text format
171 if (TMath::Min(min, max) < 0)if1 = if1 + 1;
172 if1 = TMath::Min(if1, 32);
173
174 // In some cases, if1 and if2 are too small....
175 Double_t dwlabel = bw1 * TMath::Power(10, -fExp);
176 while (dwlabel < TMath::Power(10, -if2)) {
177 if1++;
178 if2++;
179 }
180 if (if1 > 14) if1 = 14;
181 if (if2 > 14) if2 = 14;
182 if (if2) fFormat.Form("%%%d.%df", if1, if2);
183 else fFormat.Form("%%%d.%df", if1 + 1, 1);
184
185 // get decimal number
186 TString chtemp;
187 chtemp.Form("%g", dwlabel);
188 fDecimals = 0;
189 if (chtemp.First('.') != kNPOS)
190 fDecimals = chtemp.Length() - chtemp.First('.') - 1;
191}
192
193// Utility functions.
194
195////////////////////////////////////////////////////////////////////////////////
196/// Render text at the given position. Offset depends of text alignment.
197
199{
201 {
202 font.Render(txt, p.X(), p.Y(), p.Z(), aH, aV);
203 }
204 else
205 {
206 // In case of non pixmap font, size is adjusted to the projected view in order to
207 // be visible on zoom out. In other words texture and polygon fonts imitate
208 // pixmap font behaviour.
209 glPushMatrix();
210 glTranslated(p.X(), p.Y(), p.Z());
212 glScaled(sc, sc, 1);
213 font.Render(txt, 0, 0, 0, aH, aV);
214 glPopMatrix();
215 }
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Set label font derived from TAttAxis.
220
221void TGLAxisPainter::SetLabelFont(TGLRnrCtx &rnrCtx, const char* fontName, Int_t fontSize, Double_t size3d)
222{
223 rnrCtx.RegisterFontNoScale(fontSize, fontName, fFontMode, fLabelFont);
224 fLabel3DFontSize = size3d;
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Render label reading prepared list ov value-pos pairs.
230
232{
233 if (fUseAxisColors)
234 TGLUtil::Color(fAttAxis->GetLabelColor());
235
236 glPushMatrix();
237
238 Float_t off = fAttAxis->GetLabelOffset() + fAttAxis->GetTickLength();
239 TGLVector3 offVec = fTMOff[0] * off;
240 glTranslated(offVec.X(), offVec.Y(), offVec.Z());
241
242 fLabelFont.PreRender();
243 Double_t p = 0.;
244 TString s;
245 for (LabVec_t::const_iterator it = fLabVec.begin(); it != fLabVec.end(); ++it) {
246 FormAxisValue((*it).second, s);
247 p = (*it).first;
249 }
250
251 fLabelFont.PostRender();
252 glPopMatrix();
253}
254
255////////////////////////////////////////////////////////////////////////////////
256/// Set title font derived from TAttAxis.
257
258void TGLAxisPainter::SetTitleFont(TGLRnrCtx &rnrCtx, const char* fontName,
259 Int_t fontSize, Double_t size3d)
260{
261 rnrCtx.RegisterFontNoScale(fontSize, fontName, fFontMode, fTitleFont);
263 fTitle3DFontSize = size3d;
264}
265
266////////////////////////////////////////////////////////////////////////////////
267/// Draw title at given position.
268
270{
271 if (fUseAxisColors)
272 TGLUtil::Color(fAttAxis->GetTitleColor());
273
274 TString title = (fExp) ? Form("%s [10^%d]", txt.Data(), fExp) : txt;
275 fTitleFont.PreRender();
276 RnrText(title, pos, aH, aV, fTitleFont);
277 fTitleFont.PostRender();
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Render axis main line and tick-marks.
282
284{
285 if (fUseAxisColors)
286 TGLUtil::Color(fAttAxis->GetAxisColor());
287
289 glBegin(GL_LINES);
290
291 // Main line.
292 //
293 Float_t min = fTMVec.front().first;
294 Float_t max = fTMVec.back().first;
295 TGLVector3 start = fDir * min;
296 TGLVector3 end = fDir * max;
297 glVertex3dv(start.Arr());
298 glVertex3dv(end.Arr());
299
300 // Tick-marks.
301 // Support three possible directions and two orders.
302 //
303 Float_t tmsOrderFirst = fAttAxis->GetTickLength();
304 Float_t tmsOrderSecond = tmsOrderFirst * 0.5;
305 TGLVector3 pos;
306 TMVec_t::const_iterator it = fTMVec.begin();
307 Int_t nt = fTMVec.size()-1;
308 ++it;
309 for (Int_t t = 1; t < nt; ++t, ++it) {
310 pos = fDir * ((*it).first);
311 for (Int_t dim = 0; dim < fTMNDim; dim++) {
312 glVertex3dv(pos.Arr());
313 if ((*it).second)
314 glVertex3dv((pos + fTMOff[dim]*tmsOrderSecond).Arr());
315 else
316 glVertex3dv((pos + fTMOff[dim]*tmsOrderFirst).Arr());
317 }
318 }
319 glEnd();
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// GL render TAxis.
324
326{
327 fAttAxis = ax;
328 Double_t min = ax->GetXmin();
329 Double_t max = ax->GetXmax();
330 if (min == max)
331 {
332 Error("TGLAxisPainter::PaintAxis", "axis without range");
333 return;
334 }
335
336 //___________________________________________________________________________
337 // Fill labels value-pos and tick-marks position-length.
338
339 Int_t n1a = TMath::FloorNint(fAttAxis->GetNdivisions() / 100);
340 Int_t n2a = fAttAxis->GetNdivisions() - n1a * 100;
341 Int_t bn1, bn2;
342 Double_t bw1, bw2; // primary , secondary bin width
343 Double_t bl1=0, bh1=0, bl2=0, bh2=0; // bin low, high values
344
345 // Read limits from users range
346 THLimitsFinder::Optimize(min, max, n1a, bl1, bh1, bn1, bw1);
347 THLimitsFinder::Optimize(bl1, bl1 + bw1, n2a, bl2, bh2, bn2, bw2);
348
349 //___________________________________________________________________________
350
351 // Get TM. First and last values are reserved for axis range
352 //
353 fTMVec.clear();
354 fLabVec.clear();
355
356 fTMVec.push_back(TM_t(min, -1));
357
358 Double_t v1 = bl1;
359 Double_t v2 = 0;
360 for (Int_t t1 = 0; t1 <= bn1; t1++)
361 {
362 fTMVec.push_back(TM_t(v1, 0));
363 fLabVec.push_back(Lab_t(v1, v1));
364 v2 = v1 + bw2;
365 for (Int_t t2 = 1; t2 < bn2; t2++)
366 {
367 if (v2 > max) break;
368 fTMVec.push_back(TM_t(v2, 1));
369 v2 += bw2;
370 }
371 v1 += bw1;
372 }
373
374 // complete low edges for 1.st order TM
375 v2 = bl1 -bw2;
376 while (v2 > min) {
377 fTMVec.push_back(TM_t(v2, 1));
378 v2 -= bw2;
379 }
380
381 fTMVec.push_back(TM_t(max, -1));
382
383 //___________________________________________________________________________
384 // Get labels. In this case trivial one-one mapping.
385
386 Double_t p = bl1;
387 fLabVec.clear();
388 SetTextFormat(min, max, bw1);
389 for (Int_t i = 0; i <= bn1; i++) {
390 fLabVec.push_back(Lab_t(p, p));
391 p += bw1;
392 }
393
394 //___________________________________________________________________________
395 // Set font.
396
397 // First projected axis length needed if use relative font size.
398 const char* labFontName = TGLFontManager::GetFontNameFromId(fAttAxis->GetLabelFont());
399 const char* titleFontName = TGLFontManager::GetFontNameFromId(fAttAxis->GetTitleFont());
400
401 // pixel font size is set externally for pixmap and bitmap fonts
402 // for texture and polygon fonts font size is set here, to get font resolution
404 {
405 GLdouble mm[16], pm[16];
406 GLint vp[4];
407 glGetDoublev(GL_MODELVIEW_MATRIX, mm);
408 glGetDoublev(GL_PROJECTION_MATRIX, pm);
409 glGetIntegerv(GL_VIEWPORT, vp);
410
411 GLdouble dn[3], up[3];
412 gluProject(fDir.X()*min, fDir.Y()*min, fDir.Z()*min, mm, pm, vp, &dn[0], &dn[1], &dn[2]);
413 gluProject(fDir.X()*max, fDir.Y()*max, fDir.Z()*max, mm, pm, vp, &up[0], &up[1], &up[2]);
414 Double_t len = TMath::Sqrt((up[0] - dn[0]) * (up[0] - dn[0]) +
415 (up[1] - dn[1]) * (up[1] - dn[1]) +
416 (up[2] - dn[2]) * (up[2] - dn[2]));
417
418 fLabelPixelFontSize = TMath::Nint(len*fAttAxis->GetLabelSize());
419 fTitlePixelFontSize = TMath::Nint(len*fAttAxis->GetTitleSize());
420 }
421
422 SetLabelFont(rnrCtx, labFontName, fLabelPixelFontSize, (max - min)*fAttAxis->GetLabelSize());
423 SetTitleFont(rnrCtx, titleFontName, fTitlePixelFontSize, (max - min)*fAttAxis->GetTitleSize());
424
425 //___________________________________________________________________________
426 // Draw.
427
428 if (!fUseAxisColors)
429 TGLUtil::Color(rnrCtx.ColorSet().Markup());
430
431 glDisable(GL_LIGHTING);
432 RnrLines();
433 RnrLabels();
434
435 if (ax->GetTitle())
436 RnrTitle(ax->GetTitle(), fTitlePos, fLabelAlignH, fLabelAlignV);
437}
438
439
440/** \class TGLAxisPainterBox
441\ingroup opengl
442Painter class for axes encompassing a 3D box.
443*/
444
445
446////////////////////////////////////////////////////////////////////////////////
447/// Constructor.
448
451{
452 fAxis[0] = fAxis[1] = fAxis[2] = nullptr;
453}
454
455////////////////////////////////////////////////////////////////////////////////
456/// Destructor.
457
461
462////////////////////////////////////////////////////////////////////////////////
463/// Get position of axes and titles from projected corners.
464
466{
467 Double_t x0 = fAxis[0]->GetXmin();
468 Double_t x1 = fAxis[0]->GetXmax();
469
470 Double_t y0 = fAxis[1]->GetXmin();
471 Double_t y1 = fAxis[1]->GetXmax();
472
473 Double_t z0 = fAxis[2]->GetXmin();
474 Double_t z1 = fAxis[2]->GetXmax();
475
476 // project corner points
477 const GLdouble *pm = rnrCtx.RefCamera().RefLastNoPickProjM().CArr();
478 GLdouble mm[16];
479 GLint vp[4];
480 glGetDoublev(GL_MODELVIEW_MATRIX, mm);
481 glGetIntegerv(GL_VIEWPORT, vp);
482 GLdouble projX[4], projY[4], projZ[4];
483 GLdouble cornerX[4];
484 GLdouble cornerY[4];
485 cornerX[0] = x0; cornerY[0] = y0;
486 cornerX[1] = x1; cornerY[1] = y0;
487 cornerX[2] = x1; cornerY[2] = y1;
488 cornerX[3] = x0; cornerY[3] = y1;
489 gluProject(cornerX[0], cornerY[0], z0, mm, pm, vp, &projX[0], &projY[0], &projZ[0]);
490 gluProject(cornerX[1], cornerY[1], z0, mm, pm, vp, &projX[1], &projY[1], &projZ[1]);
491 gluProject(cornerX[2], cornerY[2], z0, mm, pm, vp, &projX[2], &projY[2], &projZ[2]);
492 gluProject(cornerX[3], cornerY[3], z0, mm, pm, vp, &projX[3], &projY[3], &projZ[3]);
493
494
495 // Z axis location (left most corner)
496 //
497 Int_t idxLeft = 0;
498 Float_t xt = projX[0];
499 for (Int_t i = 1; i < 4; ++i) {
500 if (projX[i] < xt) {
501 xt = projX[i];
502 idxLeft = i;
503 }
504 }
505 fAxisTitlePos[2].Set(cornerX[idxLeft], cornerY[idxLeft], z1);
506
507
508 // XY axis location (closest to eye) first
509 //
510 Float_t zt = 1.f;
511 Float_t zMin = 0.f;
512 Int_t idxFront = 0;
513 for (Int_t i = 0; i < 4; ++i) {
514 if (projZ[i] < zt) {
515 zt = projZ[i];
516 idxFront = i;
517 }
518 if (projZ[i] > zMin) zMin = projZ[i];
519 }
520 Int_t xyIdx = idxFront;
521 if (zMin - zt < 1e-2) xyIdx = 0; // avoid flipping in front view
522
523
524 switch (xyIdx) {
525 case 0:
526 fAxisTitlePos[0].Set(x1, y0, z0);
527 fAxisTitlePos[1].Set(x0, y1, z0);
528 break;
529 case 1:
530 fAxisTitlePos[0].Set(x1, y0, z0);
531 fAxisTitlePos[1].Set(x0, y1, z0);
532 break;
533 case 2:
534 fAxisTitlePos[0].Set(x0, y1, z0);
535 fAxisTitlePos[1].Set(x1, y0, z0);
536 break;
537 case 3:
538 fAxisTitlePos[0].Set(x1, y1, z0);
539 fAxisTitlePos[1].Set(x0, y0, z0);
540 break;
541 }
542}
543
544////////////////////////////////////////////////////////////////////////////////
545/// Draw XYZ axis with bitmap font.
546
548{
549 // set font size first depending on size of projected axis
550 TGLMatrix mm;
551 GLdouble pm[16];
552 GLint vp[4];
553 glGetDoublev(GL_MODELVIEW_MATRIX, mm.Arr());
554 glGetDoublev(GL_PROJECTION_MATRIX, pm);
555 glGetIntegerv(GL_VIEWPORT, vp);
556
557 // determine bitmap font size from length of projected vertical
558 GLdouble dn[3];
559 GLdouble up[3];
560 gluProject(fAxisTitlePos[2].X(), fAxisTitlePos[2].Y(), fAxis[2]->GetXmin(), mm.Arr(), pm, vp, &dn[0], &dn[1], &dn[2]);
561 gluProject(fAxisTitlePos[2].X(), fAxisTitlePos[2].Y(), fAxis[2]->GetXmax(), mm.Arr(), pm, vp, &up[0], &up[1], &up[2]);
562 Double_t len = TMath::Sqrt((up[0] - dn[0]) * (up[0] - dn[0]) +
563 (up[1] - dn[1]) * (up[1] - dn[1]) +
564 (up[2] - dn[2]) * (up[2] - dn[2]));
565 SetLabelPixelFontSize(TMath::CeilNint(len*fAxis[2]->GetLabelSize()));
566 SetTitlePixelFontSize(TMath::CeilNint(len*fAxis[2]->GetTitleSize()));
567
568
569 // Z axis
570 //
571 // tick-mark vector = 10 pixels left
572 TGLVertex3 worldRef(fAxisTitlePos[2].X(), fAxisTitlePos[2].Y(), fAxisTitlePos[2].Z());
573 RefTMOff(0) = rnrCtx.RefCamera().ViewportDeltaToWorld(worldRef, -10, 0, &mm);
574 SetTMNDim(1);
575 RefDir().Set(0., 0., 1.);
577 glPushMatrix();
578 glTranslatef(fAxisTitlePos[2].X(), fAxisTitlePos[2].Y(), 0);
579 RefTitlePos().Set(RefTMOff(0).X(), RefTMOff(0).Y(),fAxisTitlePos[2].Z());
580 PaintAxis(rnrCtx, fAxis[2]);
581 glPopMatrix();
582
583 // XY Axis
584 //
585 SetTMNDim(2);
586 RefTMOff(1).Set(0, 0, fAxis[2]->GetXmin()- fAxis[2]->GetXmax());
588 // X
589 glPushMatrix();
590 RefDir().Set(1, 0, 0);
591 Float_t yOff = fAxis[0]->GetXmax() - fAxis[0]->GetXmin();
592 yOff *= 0.5f;
593 if (fAxisTitlePos[0].Y() < fAxis[1]->GetXmax()) yOff = -yOff;
594 RefTMOff(0).Set(0, yOff, 0);
595 glTranslatef(0, fAxisTitlePos[0].Y(), fAxisTitlePos[0].Z());
596 RefTitlePos().Set(fAxisTitlePos[0].X(), yOff*1.5*fAxis[0]->GetTickLength(), 0);
597 PaintAxis(rnrCtx, fAxis[0]);
598 glPopMatrix();
599
600 // Y
601 glPushMatrix();
602 RefDir().Set(0, 1, 0);
603 Float_t xOff = fAxis[1]->GetXmax() - fAxis[1]->GetXmin();
604 if (fAxisTitlePos[1].X() < fAxis[0]->GetXmax()) xOff = -xOff;
605 RefTMOff(0).Set(xOff, 0, 0);
606 glTranslatef(fAxisTitlePos[1].X(), 0, fAxisTitlePos[1].Z());
607 RefTitlePos().Set(xOff*1.5*fAxis[1]->GetTickLength(), fAxisTitlePos[1].Y(), 0);
608 PaintAxis(rnrCtx, fAxis[1]);
609 glPopMatrix();
610}
611
612////////////////////////////////////////////////////////////////////////////////
613
615 TH1 *histo,
616 const TGLBoundingBox &bbox)
617{
618 fAxis[0] = histo->GetXaxis();
619 fAxis[1] = histo->GetYaxis();
620 fAxis[2] = histo->GetZaxis();
621
622 Double_t sx = (bbox.XMax() - bbox.XMin()) / (fAxis[0]->GetXmax() - fAxis[0]->GetXmin());
623 Double_t sy = (bbox.YMax() - bbox.YMin()) / (fAxis[1]->GetXmax() - fAxis[1]->GetXmin());
624 Double_t sz = (bbox.ZMax() - bbox.ZMin()) / (fAxis[2]->GetXmax() - fAxis[2]->GetXmin());
625
626 // draw
627 glPushMatrix();
628 glScaled(sx, sy, sz);
629 SetAxis3DTitlePos(rnrCtx);
630 DrawAxis3D(rnrCtx);
631 glPopMatrix();
632}
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
start
Definition Rotated.cxx:223
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
int Ssiz_t
String size (currently int).
Definition RtypesCore.h:81
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define X(type, name)
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
Class to manage histogram axis.
Definition TAxis.h:32
void SetAxis3DTitlePos(TGLRnrCtx &rnrCtx)
Get position of axes and titles from projected corners.
void PlotStandard(TGLRnrCtx &rnrCtx, TH1 *histo, const TGLBoundingBox &bbox)
void DrawAxis3D(TGLRnrCtx &rnrCtx)
Draw XYZ axis with bitmap font.
TGLAxisPainterBox()
Constructor.
TGLVector3 fAxisTitlePos[3]
~TGLAxisPainterBox() override
Destructor.
void RnrLabels() const
Render label reading prepared list ov value-pos pairs.
void SetLabelFont(TGLRnrCtx &rnrCtx, const char *fontName, Int_t pixelSize=64, Double_t font3DSize=-1)
Set label font derived from TAttAxis.
TPMERegexp * fAllZeroesRE
void LabelsLimits(const char *label, Int_t &first, Int_t &last) const
Find first and last character of a label.
void RnrLines() const
Render axis main line and tick-marks.
TGLVector3 & RefDir()
Int_t fLabelPixelFontSize
TGLFont::ETextAlignV_e fLabelAlignV
std::pair< Float_t, Int_t > TM_t
TGLVector3 fTitlePos
void SetLabelAlign(TGLFont::ETextAlignH_e, TGLFont::ETextAlignV_e)
Set label align.
TGLVector3 fTMOff[3]
TAttAxis * fAttAxis
Double_t fLabel3DFontSize
void RnrText(const TString &txt, const TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV, const TGLFont &font) const
Render text at the given position. Offset depends of text alignment.
TGLVector3 & RefTitlePos()
TGLFont::ETextAlignH_e fLabelAlignH
Int_t fTitlePixelFontSize
void SetTitleFont(TGLRnrCtx &rnrCtx, const char *fontName, Int_t pixelSize=64, Double_t font3DSize=-1)
Set title font derived from TAttAxis.
TGLAxisPainter(const TGLAxisPainter &)=delete
void FormAxisValue(Double_t x, TString &s) const
Returns formatted text suitable for display of value.
void SetTextFormat(Double_t min, Double_t max, Double_t binWidth)
Construct print format from given primary bin width.
void SetLabelPixelFontSize(Int_t fs)
void RnrTitle(const TString &title, TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV) const
Draw title at given position.
std::pair< Float_t, Float_t > Lab_t
void SetTMNDim(Int_t x)
TGLVector3 & RefTMOff(Int_t i)
Double_t fTitle3DFontSize
virtual ~TGLAxisPainter()
Destructor.
void PaintAxis(TGLRnrCtx &ctx, TAxis *ax)
GL render TAxis.
TGLVector3 fDir
void SetTitlePixelFontSize(Int_t fs)
TGLFont::EMode fFontMode
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
TGLMatrix & RefLastNoPickProjM() const
Definition TGLCamera.h:174
TGLVector3 ViewportDeltaToWorld(const TGLVertex3 &worldRef, Double_t viewportXDelta, Double_t viewportYDelta, TGLMatrix *modviewMat=nullptr) const
Apply a 2D viewport delta (shift) to the projection of worldRef onto viewport, returning the resultan...
TGLColor & Markup()
Definition TGLUtil.h:854
static const char * GetFontNameFromId(Int_t)
Get font name from TAttAxis font id.
A wrapper class for FTFont.
void Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition TGLUtil.h:598
Double_t * Arr()
Definition TGLUtil.h:665
const Double_t * CArr() const
Definition TGLUtil.h:664
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
TGLCamera & RefCamera()
Definition TGLRnrCtx.h:157
static void Color(const TGLColor &color)
Set color from TGLColor.
Definition TGLUtil.cxx:1688
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition TGLUtil.cxx:1934
3 component (x/y/z) vector class.
Definition TGLUtil.h:248
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 * Arr()
Definition TGLUtil.h:127
void Set(Double_t x, Double_t y, Double_t z)
Definition TGLUtil.h:210
Double_t Y() const
Definition TGLUtil.h:121
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
TAxis * GetZaxis()
Definition TH1.h:573
TAxis * GetXaxis()
Definition TH1.h:571
TAxis * GetYaxis()
Definition TH1.h:572
static void Optimize(Double_t A1, Double_t A2, Int_t nold, Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BWID, Option_t *option="")
Static function to compute reasonable axis limits.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition TPRegexp.h:97
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2250
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1170
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:545
const char * Data() const
Definition TString.h:384
@ kLeading
Definition TString.h:284
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition TString.cxx:938
TString & Remove(Ssiz_t pos)
Definition TString.h:694
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2363
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:704
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:174
Int_t FloorNint(Double_t x)
Returns the nearest integer of TMath::Floor(x).
Definition TMath.h:697
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:732
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Definition TMath.h:685
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:773
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
auto * t1
Definition textangle.C:20