Logo ROOT  
Reference Guide
TGLPadPainter.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_TGLPadPainter
13#define ROOT_TGLPadPainter
14
15#include <deque>
16
17#include "TVirtualPadPainter.h"
18#include "TGLFontManager.h"
19#include "TGLPadUtils.h"
20#include "TPoint.h"
21
22class TLinearGradient;
23class TRadialGradient;
24/*
25The _main_ purpose of TGLPadPainter is to enable 2d gl raphics
26inside standard TPad/TCanvas.
27*/
29private:
34
35 std::vector<Double_t> fVs;//Vertex buffer for tesselator.
36
39
41
42 std::vector<TPoint> fPoly;
44
46
47 template<class Char_t>
49public:
51
52 //Final overriders for TVirtualPadPainter pure virtual functions.
53 //1. Part, which simply delegates to TVirtualX.
54 //Line attributes.
55 Color_t GetLineColor() const;
56 Style_t GetLineStyle() const;
57 Width_t GetLineWidth() const;
58
59 void SetLineColor(Color_t lcolor);
60 void SetLineStyle(Style_t lstyle);
61 void SetLineWidth(Width_t lwidth);
62 //Fill attributes.
63 Color_t GetFillColor() const;
64 Style_t GetFillStyle() const;
65 Bool_t IsTransparent() const;
66
67 void SetFillColor(Color_t fcolor);
68 void SetFillStyle(Style_t fstyle);
69 void SetOpacity(Int_t percent);
70 //Text attributes.
71 Short_t GetTextAlign() const;
72 Float_t GetTextAngle() const;
73 Color_t GetTextColor() const;
74 Font_t GetTextFont() const;
75 Float_t GetTextSize() const;
77
78 void SetTextAlign(Short_t align);
79 void SetTextAngle(Float_t tangle);
80 void SetTextColor(Color_t tcolor);
81 void SetTextFont(Font_t tfont);
82 void SetTextSize(Float_t tsize);
83 void SetTextSizePixels(Int_t npixels);
84
85 //2. "Off-screen management" part.
87 void ClearDrawable();
88 void CopyDrawable(Int_t device, Int_t px, Int_t py);
89 void DestroyDrawable(Int_t device);
90 void SelectDrawable(Int_t device);
91
92 void InitPainter();
93 void InvalidateCS();
94 void LockPainter();
95
98
100 //TPad needs double and float versions.
101 void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y);
102 void DrawFillArea(Int_t n, const Float_t *x, const Float_t *y);
103
104 //TPad needs both double and float versions of DrawPolyLine.
105 void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y);
106 void DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y);
107 void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v);
108
109 //TPad needs both versions.
110 void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y);
111 void DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y);
112
113 void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode);
114 void DrawText(Double_t, Double_t, const wchar_t *, ETextMode);
115 void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode);
116 void DrawTextNDC(Double_t, Double_t, const wchar_t *, ETextMode);
117
118 //jpg, png, gif and bmp output.
119 void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const;
120
121 //TASImage support.
122 void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
123 Int_t dstX, Int_t dstY, Bool_t enableBlending);
124
125
126private:
127
128 //Attention! GL_PROJECTION will become
129 //the current matrix after these calls.
130 void SaveProjectionMatrix()const;
131 void RestoreProjectionMatrix()const;
132
133 //Attention! GL_MODELVIEW will become the
134 //current matrix after these calls.
135 void SaveModelviewMatrix()const;
136 void RestoreModelviewMatrix()const;
137
138 void SaveViewport();
139 void RestoreViewport();
140
141 void DrawPolyMarker();
142
143 //Aux. functions for a gradient and solid fill:
144 void DrawPolygonWithGradient(Int_t n, const Double_t *x, const Double_t *y);
145 //
146 void DrawGradient(const TLinearGradient *gradient, Int_t n, const Double_t *x, const Double_t *y);
147 void DrawGradient(const TRadialGradient *gradient, Int_t n, const Double_t *x, const Double_t *y);
148 //
149 void DrawTesselation(Int_t n, const Double_t *x, const Double_t *y);
150
153
155};
156
157#endif
158
#define h(i)
Definition: RSha256.hxx:106
static const double x2[5]
static const double x1[5]
char Char_t
Definition: RtypesCore.h:31
short Width_t
Definition: RtypesCore.h:80
short Font_t
Definition: RtypesCore.h:77
short Short_t
Definition: RtypesCore.h:37
double Double_t
Definition: RtypesCore.h:57
short Color_t
Definition: RtypesCore.h:81
short Style_t
Definition: RtypesCore.h:78
float Float_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:322
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
int type
Definition: TGX11.cxx:120
A FreeType GL font manager.
A wrapper class for FTFont.
"Delegating" part of TGLPadPainter.
Definition: TGLPadPainter.h:28
Float_t GetTextMagnitude() const
Delegate to gVirtualX.
Color_t GetFillColor() const
Delegate to gVirtualX.
Color_t GetLineColor() const
Delegate to gVirtualX.
Font_t GetTextFont() const
Delegate to gVirtualX.
Style_t GetLineStyle() const
Delegate to gVirtualX.
void SetTextSize(Float_t tsize)
Delegate to gVirtualX.
void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode)
Draw text in NDC.
void SetTextSizePixels(Int_t npixels)
Delegate to gVirtualX.
void DrawGradient(const TLinearGradient *gradient, Int_t n, const Double_t *x, const Double_t *y)
Rgl::Pad::Tesselator fTess
Definition: TGLPadPainter.h:31
void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)
Draw line segment in NDC coordinates.
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode)
Draw filled or hollow box.
std::vector< TPoint > fPoly
Definition: TGLPadPainter.h:42
void DrawTextHelper(Double_t x, Double_t y, const Char_t *text, ETextMode mode)
void SetLineColor(Color_t lcolor)
Delegate to gVirtualX.
TGLPadPainter(const TGLPadPainter &rhs)
Int_t CreateDrawable(UInt_t w, UInt_t h)
Not required at the moment.
void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v)
Poly line in NDC.
void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y)
Draw poly-line in user coordinates.
void DrawPolygonWithGradient(Int_t n, const Double_t *x, const Double_t *y)
At the moment I assume both linear and radial gradients will work the same way - using a stencil buff...
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw line segment.
void SetFillColor(Color_t fcolor)
Delegate to gVirtualX.
void SetTextFont(Font_t tfont)
Delegate to gVirtualX.
TGLPadPainter & operator=(const TGLPadPainter &rhs)
void SetTextAlign(Short_t align)
Delegate to gVirtualX.
Rgl::Pad::GLLimits fLimits
Definition: TGLPadPainter.h:33
Float_t GetTextSize() const
Delegate to gVirtualX.
void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY, Bool_t enableBlending)
TGLFontManager fFM
Definition: TGLPadPainter.h:37
Rgl::Pad::PolygonStippleSet fSSet
Definition: TGLPadPainter.h:30
Rgl::Pad::MarkerPainter fMarker
Definition: TGLPadPainter.h:32
void SetLineStyle(Style_t lstyle)
Delegate to gVirtualX.
void DrawPolyMarker()
Poly-marker.
void SaveViewport()
Extract and save the current viewport.
Width_t GetLineWidth() const
Delegate to gVirtualX.
void LockPainter()
Locked state of painter means, that GL context can be invalid, so no GL calls can be executed.
void SetFillStyle(Style_t fstyle)
Delegate to gVirtualX.
void ClearDrawable()
Not required at the moment.
Int_t fVp[4]
Definition: TGLPadPainter.h:40
Short_t GetTextAlign() const
Delegate to gVirtualX.
Bool_t IsTransparent() const
Delegate to gVirtualX.
void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const
Using TImage save frame-buffer contents as a picture.
void SetOpacity(Int_t percent)
Delegate to gVirtualX.
Style_t GetFillStyle() const
Delegate to gVirtualX.
void RestoreProjectionMatrix() const
Restore the projection matrix.
void SetLineWidth(Width_t lwidth)
Delegate to gVirtualX.
void SetTextColor(Color_t tcolor)
Delegate to gVirtualX.
Float_t GetTextAngle() const
Delegate to gVirtualX.
void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y)
Draw tesselated polygon (probably, outline only).
void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode)
Draw text.
void CopyDrawable(Int_t device, Int_t px, Int_t py)
Not required at the moment.
void DrawTesselation(Int_t n, const Double_t *x, const Double_t *y)
void SelectDrawable(Int_t device)
For gVirtualX this means select pixmap (or window) and all subsequent drawings will go into this pixm...
void InitPainter()
Init gl-pad painter:
Color_t GetTextColor() const
Delegate to gVirtualX.
void DestroyDrawable(Int_t device)
Not required at the moment.
void InvalidateCS()
When TPad::Range for gPad is called, projection must be changed in OpenGL.
void RestoreModelviewMatrix() const
Restore the modelview matrix.
std::vector< Double_t > fVs
Definition: TGLPadPainter.h:35
Bool_t fIsHollowArea
Definition: TGLPadPainter.h:43
void SaveProjectionMatrix() const
Save the projection matrix.
void SetTextAngle(Float_t tangle)
Delegate to gVirtualX.
void SaveModelviewMatrix() const
Save the modelview matrix.
void RestoreViewport()
Restore the saved viewport.
Define a linear color gradient.
Define a radial color gradient.
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16