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
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);
85 glVertex2f(0, 0);
86 glVertex2f(0, fHeight);
88 Float_t x = xs;
89 for (Int_t i = fPalette->fCAMin + 1; i < fPalette->fCAMax; ++i)
90 {
92 glVertex2f(x, 0);
93 glVertex2f(x, fHeight);
94 x += xs;
95 }
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);
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}
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
winID h TVirtualViewer3D TVirtualGLPainter p
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
virtual void SetTickLength(Float_t length=0.03)
Set tick mark length.
Definition TAttAxis.cxx:265
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition TAttAxis.cxx:214
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition TAxis.h:166
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...
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:1770
void Set(Double_t x, Double_t y, Double_t z)
Definition TGLUtil.h:210
Double_t x[n]
Definition legend1.C:17