Logo ROOT   6.16/01
Reference Guide
TGLPadUtils.h
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Timur Pocheptsov 06/05/2009
3
4/*************************************************************************
5 * Copyright (C) 1995-2009, 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#ifndef ROOT_TGLPadUtils
13#define ROOT_TGLPadUtils
14
15#include <vector>
16#include <list>
17
18#include "RStipples.h"
19#include "TPoint.h"
20#include "Rtypes.h"
21
22class TGLPadPainter;//For friend declarations.
23
24/*
25
26All code here and in corresponding *.cxx file is only
27for TGLPadPainter. So, it can be limited or wrong
28for something else, but it's OK for TGLPadPainter.
29
30*/
31
32namespace Rgl {
33namespace Pad {
34/*
35Auxiliary class to converts ROOT's polygon stipples from
36RStipples.h into GL's stipples and hold them in a fStipples array.
37*/
39 friend class ::TGLPadPainter;
40 friend class FillAttribSet;
41private:
42 std::vector<unsigned char> fStipples;
43
44 static const UInt_t fgBitSwap[];
45 static UInt_t SwapBits(UInt_t bits);
46
47 enum EGeometry {
48 kRowSize = 4,//For gl, stipple is a 32x32 pixel pattern. So, 4 GLubyte objects form a single line of a stipple.
49 kNRows = 32,
50 kStippleSize = kNRows * kRowSize//4 * 32 == 32 lines.
51 };
52
53 enum EBitMasks {
54 kLow4 = 0xf,
55 kUp4 = 0xf0,
56 k16Bits = 0xff
57 };
58public:
60};
61
62/*
63RAII class to enable/disable selected stipple.
64*/
68public:
69 FillAttribSet(const PolygonStippleSet & set, Bool_t ignoreStipple);
71};
72
73/*
74"ROOT like" line stipples.
75*/
76
77extern const UShort_t gLineStipples[];
78extern const UInt_t gMaxStipple;
79
80/*
81Set/unset line attributes.
82*/
84private:
89public:
90 LineAttribSet(Bool_t smooth, UInt_t stipple, Double_t maxWidth, Bool_t setWidth);
92};
93
94/*
95Marker painter. Most markers can be painted by standlone functions.
96For circles, it can be usefull to precalculate the marker geometry
97and use it for poly-markers.
98*/
99/*
100Marker painter. Most markers can be painted by standlone functions.
101For circles, it can be usefull to precalculate the marker geometry
102and use it for poly-markers.
103*/
105private:
106 //Different TArrMarker styles.
107 mutable TPoint fStar[8];
108 mutable TPoint fCross[4];
109
110 mutable std::vector<TPoint> fCircle;
111
112 enum {
114 kLargeCirclePts = 150
115 };
116
117public:
118 //Each function draw n markers.
119 void DrawDot(UInt_t n, const TPoint *xy)const;
120 void DrawPlus(UInt_t n, const TPoint *xy)const;
121 void DrawStar(UInt_t n, const TPoint *xy)const;
122 void DrawX(UInt_t n, const TPoint *xy)const;
123 void DrawFullDotSmall(UInt_t n, const TPoint *xy)const;
124 void DrawFullDotMedium(UInt_t n, const TPoint *xy)const;
125
126 void DrawCircle(UInt_t n, const TPoint *xy)const;
127 void DrawFullDotLarge(UInt_t n, const TPoint *xy)const;
128
129 void DrawFullSquare(UInt_t n, const TPoint *xy)const;
130 void DrawFullTrianlgeUp(UInt_t n, const TPoint *xy)const;
131 void DrawFullTrianlgeDown(UInt_t n, const TPoint *xy)const;
132 void DrawDiamond(UInt_t n, const TPoint *xy)const;
133 void DrawFullDiamond(UInt_t n, const TPoint *xy)const;
134 void DrawOpenTrianlgeDown(UInt_t n, const TPoint *xy)const;
135 void DrawFullCross(UInt_t n, const TPoint *xy)const;
136 void DrawOpenCross(UInt_t n, const TPoint *xy)const;
137 void DrawFullStar(UInt_t n, const TPoint *xy)const;
138 void DrawOpenStar(UInt_t n, const TPoint *xy)const;
139 void DrawOpenSquareDiagonal(UInt_t n, const TPoint *xy)const;
140 void DrawOpenDiamondCross(UInt_t n, const TPoint *xy)const;
141 void DrawOpenThreeTriangles(UInt_t n, const TPoint *xy)const;
142 void DrawOctagonCross(UInt_t n, const TPoint *xy)const;
143 void DrawFullThreeTriangles(UInt_t n, const TPoint *xy)const;
144 void DrawOpenFourTrianglesX(UInt_t n, const TPoint *xy)const;
145 void DrawFullFourTrianglesX(UInt_t n, const TPoint *xy)const;
146 void DrawOpenDoubleDiamond(UInt_t n, const TPoint *xy)const;
147 void DrawFullDoubleDiamond(UInt_t n, const TPoint *xy)const;
148 void DrawOpenFourTrianglesPlus(UInt_t n, const TPoint *xy)const;
149 void DrawFullFourTrianglesPlus(UInt_t n, const TPoint *xy)const;
150 void DrawOpenCrossX(UInt_t n, const TPoint *xy)const;
151 void DrawFullCrossX(UInt_t n, const TPoint *xy)const;
152 void DrawFourSquaresX(UInt_t n, const TPoint *xy)const;
153 void DrawFourSquaresPlus(UInt_t n, const TPoint *xy)const;
154};
155
156//
157// OpenGL's tesselator calls callback functions glBegin(MODE), glVertex3(v), glEnd(),
158// where v can be new vertex (or existing) and MODE is a type of mesh patch.
159// MeshPatch_t is a class to save such a tesselation
160// (instead of using glVertex and glBegin to draw.
161//
164 {}
165
166 Int_t fPatchType; //GL_QUADS, GL_QUAD_STRIP, etc.
167 std::vector<Double_t> fPatch; //vertices.
168};
169
170typedef std::list<MeshPatch_t> Tesselation_t;
171
173
174
175public:
176 Tesselator(Bool_t dump = kFALSE);
177
178 ~Tesselator();
179
180 void *GetTess()const
181 {
182 return fTess;
183 }
184
185 static void SetDump(Tesselation_t *t)
186 {
187 fVs = t;
188 }
189
191 {
192 return fVs;
193 }
194
195private:
196
197 void *fTess;
198
199 static Tesselation_t *fVs;//the current tesselator's dump.
200};
201
202/*
203In future, this should be an interface to per-pad FBO.
204Currently, in only save sizes and coordinates (?)
205*/
207 friend class ::TGLPadPainter;
208public:
210
211private:
217};
218
219void ExtractRGBA(Color_t colorIndex, Float_t *rgba);
220
221class GLLimits {
222public:
223 GLLimits();
224
227private:
230};
231
232//We have a lot of Rect_t/Point_t/TGLRect/TGLBoundingBox blah-blah-blah.
233//What we do not have is a rectangle with floating point types.
234
235template<class ValueType>
237 ValueType fXMin = ValueType();
238 ValueType fYMin = ValueType();
239 ValueType fWidth = ValueType();
240 ValueType fHeight = ValueType();
241 //Sometimes it's more convenient:
242 ValueType fXMax = ValueType();
243 ValueType fYMax = ValueType();
244};
245
246//It's explicitly instantiated for signed integer/fp types (in *.cxx).
247template<class ValueType>
248BoundingRect<ValueType> FindBoundingRect(Int_t nPoints, const ValueType *xs, const ValueType *ys);
249
250
251}//namespace Pad
252}//namespace Rgl
253
254#endif
#define h(i)
Definition: RSha256.hxx:106
unsigned short UShort_t
Definition: RtypesCore.h:36
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
short Color_t
Definition: RtypesCore.h:79
float Float_t
Definition: RtypesCore.h:53
int type
Definition: TGX11.cxx:120
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
FillAttribSet(const PolygonStippleSet &set, Bool_t ignoreStipple)
Polygon stipple, if required.
Double_t fMaxLineWidth
Definition: TGLPadUtils.h:228
Double_t GetMaxLineWidth() const
Double_t fMaxPointSize
Definition: TGLPadUtils.h:229
Double_t GetMaxPointSize() const
LineAttribSet(Bool_t smooth, UInt_t stipple, Double_t maxWidth, Bool_t setWidth)
Set up line parameters.
void DrawOpenThreeTriangles(UInt_t n, const TPoint *xy) const
void DrawFullCrossX(UInt_t n, const TPoint *xy) const
void DrawFullDotSmall(UInt_t n, const TPoint *xy) const
void DrawOpenSquareDiagonal(UInt_t n, const TPoint *xy) const
void DrawOpenDoubleDiamond(UInt_t n, const TPoint *xy) const
void DrawFullFourTrianglesX(UInt_t n, const TPoint *xy) const
void DrawFullDotLarge(UInt_t n, const TPoint *xy) const
void DrawFullThreeTriangles(UInt_t n, const TPoint *xy) const
void DrawCircle(UInt_t n, const TPoint *xy) const
void DrawFullFourTrianglesPlus(UInt_t n, const TPoint *xy) const
void DrawOpenCross(UInt_t n, const TPoint *xy) const
void DrawFullCross(UInt_t n, const TPoint *xy) const
void DrawFullTrianlgeDown(UInt_t n, const TPoint *xy) const
void DrawOpenStar(UInt_t n, const TPoint *xy) const
Full star pentagone.
void DrawX(UInt_t n, const TPoint *xy) const
void DrawPlus(UInt_t n, const TPoint *xy) const
void DrawFullTrianlgeUp(UInt_t n, const TPoint *xy) const
void DrawFullSquare(UInt_t n, const TPoint *xy) const
std::vector< TPoint > fCircle
Definition: TGLPadUtils.h:110
void DrawOpenFourTrianglesPlus(UInt_t n, const TPoint *xy) const
void DrawStar(UInt_t n, const TPoint *xy) const
void DrawFullDoubleDiamond(UInt_t n, const TPoint *xy) const
void DrawOpenCrossX(UInt_t n, const TPoint *xy) const
void DrawDot(UInt_t n, const TPoint *xy) const
Simple 1-pixel dots.
void DrawOctagonCross(UInt_t n, const TPoint *xy) const
void DrawFourSquaresX(UInt_t n, const TPoint *xy) const
void DrawFourSquaresPlus(UInt_t n, const TPoint *xy) const
void DrawFullDotMedium(UInt_t n, const TPoint *xy) const
void DrawDiamond(UInt_t n, const TPoint *xy) const
void DrawFullStar(UInt_t n, const TPoint *xy) const
Full star pentagone.
void DrawOpenTrianlgeDown(UInt_t n, const TPoint *xy) const
void DrawFullDiamond(UInt_t n, const TPoint *xy) const
void DrawOpenFourTrianglesX(UInt_t n, const TPoint *xy) const
void DrawOpenDiamondCross(UInt_t n, const TPoint *xy) const
OffScreenDevice(UInt_t w, UInt_t h, UInt_t x, UInt_t y, Bool_t top)
std::vector< unsigned char > fStipples
Definition: TGLPadUtils.h:42
static UInt_t SwapBits(UInt_t bits)
static const UInt_t fgBitSwap[]
Definition: TGLPadUtils.h:44
Tesselator(Bool_t dump=kFALSE)
static Tesselation_t * GetDump()
Definition: TGLPadUtils.h:190
static Tesselation_t * fVs
Definition: TGLPadUtils.h:199
void * GetTess() const
Definition: TGLPadUtils.h:180
static void SetDump(Tesselation_t *t)
Definition: TGLPadUtils.h:185
"Delegating" part of TGLPadPainter.
Definition: TGLPadPainter.h:28
Definition: TPoint.h:31
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
const UShort_t gLineStipples[]
std::list< MeshPatch_t > Tesselation_t
Definition: TGLPadUtils.h:170
BoundingRect< ValueType > FindBoundingRect(Int_t nPoints, const ValueType *xs, const ValueType *ys)
const UInt_t gMaxStipple
void ExtractRGBA(Color_t colorIndex, Float_t *rgba)
MeshPatch_t(Int_t type)
Definition: TGLPadUtils.h:163
std::vector< Double_t > fPatch
Definition: TGLPadUtils.h:167