Logo ROOT   6.12/07
Reference Guide
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 
12 #include "TEveRGBAPaletteOverlay.h"
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
22 Description 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 {
39  fAxis.SetNdivisions(900);
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);
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 }
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
void SetUseAxisColors(Bool_t x)
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition: TAxis.h:154
float Float_t
Definition: RtypesCore.h:53
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:229
Description of TEveRGBAPaletteOverlay.
void SetFontMode(TGLFont::EMode m)
int Int_t
Definition: RtypesCore.h:41
void Set(Double_t x, Double_t y, Double_t z)
Definition: TGLUtil.h:209
An overlay element.
Definition: TGLOverlay.h:22
TGLVector3 & RefTMOff(Int_t i)
Double_t x[n]
Definition: legend1.C:17
const UChar_t * ColorFromValue(Int_t val) const
virtual void Render(TGLRnrCtx &rnrCtx)
Render the overlay.
void PaintAxis(TGLRnrCtx &ctx, TAxis *ax)
GL render TAxis.
void SetLabelAlign(TGLFont::ETextAlignH_e, TGLFont::ETextAlignV_e)
Set label align.
const Bool_t kFALSE
Definition: RtypesCore.h:88
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
TEveRGBAPaletteOverlay(const TEveRGBAPaletteOverlay &)
Double_t GetCAMaxAsDouble() const
void SetLabelPixelFontSize(Int_t fs)
virtual void SetTickLength(Float_t length=0.03)
Set tick mark length The length is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:280
Double_t GetCAMinAsDouble() const
const Bool_t kTRUE
Definition: RtypesCore.h:87
static void Color4ubv(const UChar_t *rgba)
Wrapper for glColor4ubv.
Definition: TGLUtil.cxx:1740