Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TEveRGBAPaletteOverlay.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Alja Mrak Tadel 2012
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
13#include "TEveRGBAPalette.h"
14
15#include "TGLIncludes.h"
16#include "TGLAxis.h"
17#include "TGLRnrCtx.h"
18#include "TGLUtil.h"
19
20/** \class TEveRGBAPaletteOverlay
21\ingroup TEve
22Description of TEveRGBAPaletteOverlay
23*/
24
25
26////////////////////////////////////////////////////////////////////////////////
27/// Constructor.
28
30 Float_t width, Float_t height) :
32 fPalette(p),
33 fPosX(posx),
34 fPosY(posy),
35 fWidth(width),
36 fHeight(height)
37{
38 fAxis.SetNdivisions(900);
39 fAxisPainter.SetUseAxisColors(kFALSE);
40 fAxisPainter.SetLabelPixelFontSize(10);
41 fAxisPainter.SetFontMode(TGLFont::kPixmap);
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// Render the overlay.
47
49{
50 const Double_t ca_min = fPalette->GetCAMinAsDouble();
51 const Double_t ca_max = fPalette->GetCAMaxAsDouble();
52
53 // Uninitialized palette.
54 if (ca_min == ca_max) return;
55
56 fAxis.SetLimits(ca_min, ca_max);
57
58 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
59
60 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
61 glDisable(GL_CULL_FACE);
62 glEnable(GL_BLEND);
63 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
64 TGLCapabilitySwitch lights_off(GL_LIGHTING, kFALSE);
65
66 // reset to [0,1] units
67 glMatrixMode(GL_PROJECTION);
68 glPushMatrix();
69 glLoadIdentity();
70 glOrtho(0, 1, 0, 1, 0, 1);
71 glMatrixMode(GL_MODELVIEW);
72 glPushMatrix();
73 glLoadIdentity();
74
75 // position palette
76 glTranslatef(fPosX, fPosY, 0);
77
78 // colored quads
79 {
80 TGLCapabilitySwitch move_to_back(GL_POLYGON_OFFSET_FILL, kTRUE);
81 glPolygonOffset(0.5f, 0.5f);
82
83 glBegin(GL_QUAD_STRIP);
84 TGLUtil::Color4ubv(fPalette->ColorFromValue(fPalette->fCAMin));
85 glVertex2f(0, 0);
86 glVertex2f(0, fHeight);
87 Float_t xs = fWidth / (fPalette->fCAMax - fPalette->fCAMin);
88 Float_t x = xs;
89 for (Int_t i = fPalette->fCAMin + 1; i < fPalette->fCAMax; ++i)
90 {
91 TGLUtil::Color4ubv(fPalette->ColorFromValue(i));
92 glVertex2f(x, 0);
93 glVertex2f(x, fHeight);
94 x += xs;
95 }
96 TGLUtil::Color4ubv(fPalette->ColorFromValue(fPalette->fCAMax));
97 glVertex2f(fWidth, 0);
98 glVertex2f(fWidth, fHeight);
99 glEnd();
100 }
101
102 // axis
103 glPushMatrix();
104 Float_t sf = fWidth / (ca_max - ca_min);
105 glScalef(sf, 1, 1);
106 glTranslatef(-ca_min, 0, 0);
107 fAxis.SetTickLength(0.05*fWidth);
108 fAxisPainter.RefTMOff(0).Set(0, -1, 0);
109 fAxisPainter.PaintAxis(rnrCtx, &fAxis);
110 glPopMatrix();
111
112 // frame around palette
113 glBegin(GL_LINE_LOOP);
114 glVertex2f(0, 0); glVertex2f(fWidth, 0);
115 glVertex2f(fWidth, fHeight); glVertex2f(0, fHeight);
116 glEnd();
117
118 glMatrixMode(GL_PROJECTION);
119 glPopMatrix();
120 glMatrixMode(GL_MODELVIEW);
121 glPopMatrix();
122
123 glPopAttrib();
124}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
void Render(TGLRnrCtx &rnrCtx) override
Render the overlay.
TEveRGBAPaletteOverlay(const TEveRGBAPaletteOverlay &)
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
TGLOverlayElement(const TGLOverlayElement &)=delete
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
static void Color4ubv(const UChar_t *rgba)
Wrapper for glColor4ubv.
Definition TGLUtil.cxx:1770
Double_t x[n]
Definition legend1.C:17