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
31 Float_t width, Float_t height) :
33 fPalette(p),
34 fPosX(posx),
35 fPosY(posy),
36 fWidth(width),
37 fHeight(height)
38{
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);
86 glVertex2f(0, 0);
87 glVertex2f(0, fHeight);
89 Float_t x = xs;
90 for (Int_t i = fPalette->fCAMin + 1; i < fPalette->fCAMax; ++i)
91 {
93 glVertex2f(x, 0);
94 glVertex2f(x, fHeight);
95 x += xs;
96 }
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);
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
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
virtual void SetTickLength(Float_t length=0.03)
Set tick mark length.
Definition TAttAxis.cxx:279
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition TAttAxis.cxx:228
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition TAxis.h:154
Description of TEveRGBAPaletteOverlay.
TEveRGBAPaletteOverlay(const TEveRGBAPaletteOverlay &)
virtual void Render(TGLRnrCtx &rnrCtx)
Render the overlay.
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Double_t GetCAMaxAsDouble() const
Double_t GetCAMinAsDouble() const
const UChar_t * ColorFromValue(Int_t val) const
void SetLabelAlign(TGLFont::ETextAlignH_e, TGLFont::ETextAlignV_e)
Set label align.
void SetUseAxisColors(Bool_t x)
void SetLabelPixelFontSize(Int_t fs)
TGLVector3 & RefTMOff(Int_t i)
void SetFontMode(TGLFont::EMode m)
void PaintAxis(TGLRnrCtx &ctx, TAxis *ax)
GL render TAxis.
An overlay element.
Definition TGLOverlay.h:23
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:1773
void Set(Double_t x, Double_t y, Double_t z)
Definition TGLUtil.h:210
Double_t x[n]
Definition legend1.C:17