Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "RtypesCore.h"
21
22class TGLPadPainter;//For friend declarations.
23class TAttFill;
24class TAttLine;
25class TAttMarker;
26/*
27
28All code here and in corresponding *.cxx file is only
29for TGLPadPainter. So, it can be limited or wrong
30for something else, but it's OK for TGLPadPainter.
31
32*/
33
34namespace Rgl {
35namespace Pad {
36/*
37Auxiliary class to converts ROOT's polygon stipples from
38RStipples.h into GL's stipples and hold them in a fStipples array.
39*/
41 friend class ::TGLPadPainter;
42 friend class FillAttribSet;
43private:
44 std::vector<unsigned char> fStipples;
45
46 static const UInt_t fgBitSwap[];
47 static UInt_t SwapBits(UInt_t bits);
48
49 enum EGeometry {
50 kRowSize = 4,//For gl, stipple is a 32x32 pixel pattern. So, 4 GLubyte objects form a single line of a stipple.
51 kNRows = 32,
52 kStippleSize = kNRows * kRowSize//4 * 32 == 32 lines.
53 };
54
55 enum EBitMasks {
56 kLow4 = 0xf,
57 kUp4 = 0xf0,
58 k16Bits = 0xff
59 };
60public:
62};
63
64/*
65RAII class to enable/disable selected stipple.
66*/
74
75/*
76"ROOT like" line stipples.
77*/
78
79extern const UShort_t gLineStipples[];
80extern const UInt_t gMaxStipple;
81
82/*
83Set/unset line attributes.
84*/
95
96/*
97Marker painter. Most markers can be painted by standlone functions.
98For circles, it can be usefull to precalculate the marker geometry
99and use it for poly-markers.
100*/
101/*
102Marker painter. Most markers can be painted by standlone functions.
103For circles, it can be usefull to precalculate the marker geometry
104and use it for poly-markers.
105*/
107 enum {
109 kLargeCirclePts = 150
110 };
111
112public:
113 static void DrawMarkers(UInt_t n, const TPoint *xy, const TAttMarker &attr);
114};
115
116//
117// OpenGL's tesselator calls callback functions glBegin(MODE), glVertex3(v), glEnd(),
118// where v can be new vertex (or existing) and MODE is a type of mesh patch.
119// MeshPatch_t is a class to save such a tesselation
120// (instead of using glVertex and glBegin to draw.
121//
125
126 Int_t fPatchType; //GL_QUADS, GL_QUAD_STRIP, etc.
127 std::vector<Double_t> fPatch; //vertices.
128};
129
130typedef std::list<MeshPatch_t> Tesselation_t;
131
133
134
135public:
136 Tesselator(Bool_t dump = kFALSE);
137
138 ~Tesselator();
139
140 void *GetTess()const
141 {
142 return fTess;
143 }
144
145 static void SetDump(Tesselation_t *t)
146 {
147 fVs = t;
148 }
149
151 {
152 return fVs;
153 }
154
155private:
156
157 void *fTess;
158
159 static Tesselation_t *fVs;//the current tesselator's dump.
160};
161
162/*
163In future, this should be an interface to per-pad FBO.
164Currently, in only save sizes and coordinates (?)
165*/
167 friend class ::TGLPadPainter;
168public:
170
171private:
177};
178
180
181class GLLimits {
182public:
183 GLLimits();
184
187private:
190};
191
192//We have a lot of Rect_t/Point_t/TGLRect/TGLBoundingBox blah-blah-blah.
193//What we do not have is a rectangle with floating point types.
194
195template<class ValueType>
197 ValueType fXMin = ValueType();
198 ValueType fYMin = ValueType();
199 ValueType fWidth = ValueType();
200 ValueType fHeight = ValueType();
201 //Sometimes it's more convenient:
202 ValueType fXMax = ValueType();
203 ValueType fYMax = ValueType();
204};
205
206//It's explicitly instantiated for signed integer/fp types (in *.cxx).
207template<class ValueType>
208BoundingRect<ValueType> FindBoundingRect(Int_t nPoints, const ValueType *xs, const ValueType *ys);
209
210
211}//namespace Pad
212}//namespace Rgl
213
214#endif
#define h(i)
Definition RSha256.hxx:106
Basic types used by ROOT and required by TInterpreter.
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
FillAttribSet(const PolygonStippleSet &set, Bool_t ignoreStipple, const TAttFill *att=nullptr)
Polygon stipple, if required.
Double_t GetMaxLineWidth() const
Double_t GetMaxPointSize() const
LineAttribSet(Bool_t smooth, UInt_t stipple, Double_t maxWidth, Bool_t setWidth, const TAttLine *att=nullptr)
Set up line parameters.
static void DrawMarkers(UInt_t n, const TPoint *xy, const TAttMarker &attr)
Auxiliary class to draw markers in a gl-pad.
OffScreenDevice(UInt_t w, UInt_t h, UInt_t x, UInt_t y, Bool_t top)
std::vector< unsigned char > fStipples
Definition TGLPadUtils.h:44
static UInt_t SwapBits(UInt_t bits)
static const UInt_t fgBitSwap[]
Definition TGLPadUtils.h:46
Tesselator(Bool_t dump=kFALSE)
static Tesselation_t * GetDump()
static Tesselation_t * fVs
void * GetTess() const
static void SetDump(Tesselation_t *t)
Fill Area Attributes class.
Definition TAttFill.h:21
Line Attributes class.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:22
"Delegating" part of TGLPadPainter.
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
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)
std::vector< Double_t > fPatch