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
26
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor.
29
33 fPalette(p),
34 fPosX(posx),
35 fPosY(posy),
38{
39 fAxis.SetNdivisions(900);
40 fAxisPainter.SetUseAxisColors(kFALSE);
41 fAxisPainter.SetLabelPixelFontSize(10);
42 fAxisPainter.SetFontMode(TGLFont::kPixmap);
44}
45
46////////////////////////////////////////////////////////////////////////////////
47/// Render the overlay.
48
50{
51 const Double_t ca_min = fPalette->GetCAMinAsDouble();
52 const Double_t ca_max = fPalette->GetCAMaxAsDouble();
53
54 // Uninitialized palette.
55 if (ca_min == ca_max) return;
56
57 fAxis.SetLimits(ca_min, ca_max);
58
59 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
60
61 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
62 glDisable(GL_CULL_FACE);
63 glEnable(GL_BLEND);
64 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
65 TGLCapabilitySwitch lights_off(GL_LIGHTING, kFALSE);
66
67 // reset to [0,1] units
68 glMatrixMode(GL_PROJECTION);
69 glPushMatrix();
70 glLoadIdentity();
71 glOrtho(0, 1, 0, 1, 0, 1);
72 glMatrixMode(GL_MODELVIEW);
73 glPushMatrix();
74 glLoadIdentity();
75
76 // position palette
77 glTranslatef(fPosX, fPosY, 0);
78
79 // colored quads
80 {
81 TGLCapabilitySwitch move_to_back(GL_POLYGON_OFFSET_FILL, kTRUE);
82 glPolygonOffset(0.5f, 0.5f);
83
84 glBegin(GL_QUAD_STRIP);
85 TGLUtil::Color4ubv(fPalette->ColorFromValue(fPalette->fCAMin));
86 glVertex2f(0, 0);
87 glVertex2f(0, fHeight);
88 Float_t xs = fWidth / (fPalette->fCAMax - fPalette->fCAMin);
89 Float_t x = xs;
90 for (Int_t i = fPalette->fCAMin + 1; i < fPalette->fCAMax; ++i)
91 {
92 TGLUtil::Color4ubv(fPalette->ColorFromValue(i));
93 glVertex2f(x, 0);
94 glVertex2f(x, fHeight);
95 x += xs;
96 }
97 TGLUtil::Color4ubv(fPalette->ColorFromValue(fPalette->fCAMax));
98 glVertex2f(fWidth, 0);
99 glVertex2f(fWidth, fHeight);
100 glEnd();
101 }
102
103 // axis
104 glPushMatrix();
105 Float_t sf = fWidth / (ca_max - ca_min);
106 glScalef(sf, 1, 1);
107 glTranslatef(-ca_min, 0, 0);
108 fAxis.SetTickLength(0.05*fWidth);
109 fAxisPainter.RefTMOff(0).Set(0, -1, 0);
110 fAxisPainter.PaintAxis(rnrCtx, &fAxis);
111 glPopMatrix();
112
113 // frame around palette
114 glBegin(GL_LINE_LOOP);
115 glVertex2f(0, 0); glVertex2f(fWidth, 0);
116 glVertex2f(fWidth, fHeight); glVertex2f(0, fHeight);
117 glEnd();
118
119 glMatrixMode(GL_PROJECTION);
120 glPopMatrix();
121 glMatrixMode(GL_MODELVIEW);
122 glPopMatrix();
123
124 glPopAttrib();
125}
#define GL_LINE_LOOP
Definition GL_glu.h:285
#define GL_QUAD_STRIP
Definition GL_glu.h:291
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Int_t i
Description of TEveRGBAPaletteOverlay.
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:1779
Double_t x[n]
Definition legend1.C:17