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;
25/*
26
27All code here and in corresponding *.cxx file is only
28for TGLPadPainter. So, it can be limited or wrong
29for something else, but it's OK for TGLPadPainter.
30
31*/
32
33namespace Rgl {
34namespace Pad {
35/*
36Auxiliary class to converts ROOT's polygon stipples from
37RStipples.h into GL's stipples and hold them in a fStipples array.
38*/
40 friend class ::TGLPadPainter;
41 friend class FillAttribSet;
42private:
43 std::vector<unsigned char> fStipples;
44
45 static const UInt_t fgBitSwap[];
46 static UInt_t SwapBits(UInt_t bits);
47
48 enum EGeometry {
49 kRowSize = 4,//For gl, stipple is a 32x32 pixel pattern. So, 4 GLubyte objects form a single line of a stipple.
50 kNRows = 32,
51 kStippleSize = kNRows * kRowSize//4 * 32 == 32 lines.
52 };
53
54 enum EBitMasks {
55 kLow4 = 0xf,
56 kUp4 = 0xf0,
57 k16Bits = 0xff
58 };
59public:
61};
62
63/*
64RAII class to enable/disable selected stipple.
65*/
73
74/*
75"ROOT like" line stipples.
76*/
77
78extern const UShort_t gLineStipples[];
79extern const UInt_t gMaxStipple;
80
81/*
82Set/unset line attributes.
83*/
94
95/*
96Marker painter. Most markers can be painted by standlone functions.
97For circles, it can be usefull to precalculate the marker geometry
98and use it for poly-markers.
99*/
100/*
101Marker painter. Most markers can be painted by standlone functions.
102For circles, it can be usefull to precalculate the marker geometry
103and use it for poly-markers.
104*/
106private:
107 //Different TArrMarker styles.
108 mutable TPoint fStar[8];
109 mutable TPoint fCross[4];
110
111 mutable std::vector<TPoint> fCircle;
112
116
117 enum {
119 kLargeCirclePts = 150
120 };
121
122public:
124 Size_t GetMarkerSize() const;
125 Width_t GetMarkerWidth() const;
126
127 //Each function draw n markers.
128 void DrawDot(UInt_t n, const TPoint *xy)const;
129 void DrawPlus(UInt_t n, const TPoint *xy)const;
130 void DrawStar(UInt_t n, const TPoint *xy)const;
131 void DrawX(UInt_t n, const TPoint *xy)const;
132 void DrawFullDotSmall(UInt_t n, const TPoint *xy)const;
133 void DrawFullDotMedium(UInt_t n, const TPoint *xy)const;
134
135 void DrawCircle(UInt_t n, const TPoint *xy)const;
136 void DrawFullDotLarge(UInt_t n, const TPoint *xy)const;
137
138 void DrawFullSquare(UInt_t n, const TPoint *xy)const;
139 void DrawFullTrianlgeUp(UInt_t n, const TPoint *xy)const;
140 void DrawFullTrianlgeDown(UInt_t n, const TPoint *xy)const;
141 void DrawDiamond(UInt_t n, const TPoint *xy)const;
142 void DrawFullDiamond(UInt_t n, const TPoint *xy)const;
143 void DrawOpenTrianlgeDown(UInt_t n, const TPoint *xy)const;
144 void DrawFullCross(UInt_t n, const TPoint *xy)const;
145 void DrawOpenCross(UInt_t n, const TPoint *xy)const;
146 void DrawFullStar(UInt_t n, const TPoint *xy)const;
147 void DrawOpenStar(UInt_t n, const TPoint *xy)const;
148 void DrawOpenSquareDiagonal(UInt_t n, const TPoint *xy)const;
149 void DrawOpenDiamondCross(UInt_t n, const TPoint *xy)const;
150 void DrawOpenThreeTriangles(UInt_t n, const TPoint *xy)const;
151 void DrawOctagonCross(UInt_t n, const TPoint *xy)const;
152 void DrawFullThreeTriangles(UInt_t n, const TPoint *xy)const;
153 void DrawOpenFourTrianglesX(UInt_t n, const TPoint *xy)const;
154 void DrawFullFourTrianglesX(UInt_t n, const TPoint *xy)const;
155 void DrawOpenDoubleDiamond(UInt_t n, const TPoint *xy)const;
156 void DrawFullDoubleDiamond(UInt_t n, const TPoint *xy)const;
157 void DrawOpenFourTrianglesPlus(UInt_t n, const TPoint *xy)const;
158 void DrawFullFourTrianglesPlus(UInt_t n, const TPoint *xy)const;
159 void DrawOpenCrossX(UInt_t n, const TPoint *xy)const;
160 void DrawFullCrossX(UInt_t n, const TPoint *xy)const;
161 void DrawFourSquaresX(UInt_t n, const TPoint *xy)const;
162 void DrawFourSquaresPlus(UInt_t n, const TPoint *xy)const;
163};
164
165//
166// OpenGL's tesselator calls callback functions glBegin(MODE), glVertex3(v), glEnd(),
167// where v can be new vertex (or existing) and MODE is a type of mesh patch.
168// MeshPatch_t is a class to save such a tesselation
169// (instead of using glVertex and glBegin to draw.
170//
174
175 Int_t fPatchType; //GL_QUADS, GL_QUAD_STRIP, etc.
176 std::vector<Double_t> fPatch; //vertices.
177};
178
179typedef std::list<MeshPatch_t> Tesselation_t;
180
182
183
184public:
185 Tesselator(Bool_t dump = kFALSE);
186
187 ~Tesselator();
188
189 void *GetTess()const
190 {
191 return fTess;
192 }
193
194 static void SetDump(Tesselation_t *t)
195 {
196 fVs = t;
197 }
198
200 {
201 return fVs;
202 }
203
204private:
205
206 void *fTess;
207
208 static Tesselation_t *fVs;//the current tesselator's dump.
209};
210
211/*
212In future, this should be an interface to per-pad FBO.
213Currently, in only save sizes and coordinates (?)
214*/
216 friend class ::TGLPadPainter;
217public:
219
220private:
226};
227
229
230class GLLimits {
231public:
232 GLLimits();
233
236private:
239};
240
241//We have a lot of Rect_t/Point_t/TGLRect/TGLBoundingBox blah-blah-blah.
242//What we do not have is a rectangle with floating point types.
243
244template<class ValueType>
246 ValueType fXMin = ValueType();
247 ValueType fYMin = ValueType();
248 ValueType fWidth = ValueType();
249 ValueType fHeight = ValueType();
250 //Sometimes it's more convenient:
251 ValueType fXMax = ValueType();
252 ValueType fYMax = ValueType();
253};
254
255//It's explicitly instantiated for signed integer/fp types (in *.cxx).
256template<class ValueType>
257BoundingRect<ValueType> FindBoundingRect(Int_t nPoints, const ValueType *xs, const ValueType *ys);
258
259
260}//namespace Pad
261}//namespace Rgl
262
263#endif
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Basic types used by ROOT and required by TInterpreter.
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
float Size_t
Attribute size (float)
Definition RtypesCore.h:103
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
short Width_t
Line width (short)
Definition RtypesCore.h:98
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
Option_t Option_t TPoint xy
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 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.
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
Width_t GetMarkerWidth() const
Get marker width If not set before - use gVirtualX value.
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
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 SetMarkerSizeWidth(Size_t size, Width_t width)
Set marker size and line width.
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
Size_t GetMarkerSize() const
Get marker size If not set before - use gVirtualX value.
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:43
static UInt_t SwapBits(UInt_t bits)
static const UInt_t fgBitSwap[]
Definition TGLPadUtils.h:45
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
"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