Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TVirtualPadPainter.h"
16#include "TGLFontManager.h"
17#include "TGLPadUtils.h"
18#include "TPoint.h"
19
20#include <vector>
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 override;
56 Style_t GetLineStyle() const override;
57 Width_t GetLineWidth() const override;
58
59 void SetLineColor(Color_t lcolor) override;
60 void SetLineStyle(Style_t lstyle) override;
61 void SetLineWidth(Width_t lwidth) override;
62 //Fill attributes.
63 Color_t GetFillColor() const override;
64 Style_t GetFillStyle() const override;
65 Bool_t IsTransparent() const override;
66
67 void SetFillColor(Color_t fcolor) override;
68 void SetFillStyle(Style_t fstyle) override;
69 void SetOpacity(Int_t percent) override;
70 //Text attributes.
71 Short_t GetTextAlign() const override;
72 Float_t GetTextAngle() const override;
73 Color_t GetTextColor() const override;
74 Font_t GetTextFont() const override;
75 Float_t GetTextSize() const override;
76 Float_t GetTextMagnitude() const override;
77
78 void SetTextAlign(Short_t align) override;
79 void SetTextAngle(Float_t tangle) override;
80 void SetTextColor(Color_t tcolor) override;
81 void SetTextFont(Font_t tfont) override;
82 void SetTextSize(Float_t tsize) override;
83 void SetTextSizePixels(Int_t npixels) override;
84
85 //2. "Off-screen management" part.
87 void ClearDrawable() override;
88 void CopyDrawable(Int_t device, Int_t px, Int_t py) override;
89 void DestroyDrawable(Int_t device) override;
90 void SelectDrawable(Int_t device) override;
91
92 void InitPainter() override;
93 void InvalidateCS() override;
94 void LockPainter() override;
95
97 void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override;
98
100 //TPad needs double and float versions.
101 void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override;
102 void DrawFillArea(Int_t n, const Float_t *x, const Float_t *y) override;
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) override;
106 void DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) override;
107 void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override;
108
109 //TPad needs both versions.
110 void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override;
111 void DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) override;
112
113 void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
114 void DrawText(Double_t, Double_t, const wchar_t *, ETextMode) override;
115 void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode) override;
116 void DrawTextNDC(Double_t, Double_t, const wchar_t *, ETextMode) override;
117
118 //jpg, png, gif and bmp output.
119 void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override;
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) override;
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
short Style_t
Definition RtypesCore.h:89
short Color_t
Definition RtypesCore.h:92
char Char_t
Definition RtypesCore.h:37
short Width_t
Definition RtypesCore.h:91
float Float_t
Definition RtypesCore.h:57
short Font_t
Definition RtypesCore.h:88
short Short_t
Definition RtypesCore.h:39
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t SetLineWidth
Option_t Option_t SetFillStyle
Option_t Option_t SetTextSize
Option_t Option_t DrawFillArea
Option_t Option_t SetLineColor
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char DrawLine
Option_t Option_t width
Option_t Option_t TPoint TPoint percent
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
Option_t Option_t TPoint TPoint DrawText
Option_t Option_t TPoint TPoint SetOpacity
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
A FreeType GL font manager.
A wrapper class for FTFont.
"Delegating" part of TGLPadPainter.
void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY, Bool_t enableBlending) override
Float_t GetTextSize() const override
Delegate to gVirtualX.
void DestroyDrawable(Int_t device) override
Not required at the moment.
void DrawGradient(const TLinearGradient *gradient, Int_t n, const Double_t *x, const Double_t *y)
Rgl::Pad::Tesselator fTess
Float_t GetTextAngle() const override
Delegate to gVirtualX.
void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Draw line segment in NDC coordinates.
Style_t GetLineStyle() const override
Delegate to gVirtualX.
Color_t GetTextColor() const override
Delegate to gVirtualX.
std::vector< TPoint > fPoly
void DrawTextHelper(Double_t x, Double_t y, const Char_t *text, ETextMode mode)
TGLPadPainter(const TGLPadPainter &rhs)
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode) override
Draw filled or hollow box.
void SetTextSizePixels(Int_t npixels) override
Delegate to gVirtualX.
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 InvalidateCS() override
When TPad::Range for gPad is called, projection must be changed in OpenGL.
void ClearDrawable() override
Not required at the moment.
Color_t GetLineColor() const override
Delegate to gVirtualX.
void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override
Poly line in NDC.
TGLPadPainter & operator=(const TGLPadPainter &rhs)
void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override
Draw poly-line in user coordinates.
void SetTextAlign(Short_t align) override
Delegate to gVirtualX.
Rgl::Pad::GLLimits fLimits
void SetTextAngle(Float_t tangle) override
Delegate to gVirtualX.
void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode) override
Draw text in NDC.
void SetTextColor(Color_t tcolor) override
Delegate to gVirtualX.
void InitPainter() override
Init gl-pad painter:
void SelectDrawable(Int_t device) override
For gVirtualX this means select pixmap (or window) and all subsequent drawings will go into this pixm...
TGLFontManager fFM
Rgl::Pad::PolygonStippleSet fSSet
Rgl::Pad::MarkerPainter fMarker
void DrawPolyMarker()
Poly-marker.
void SaveViewport()
Extract and save the current viewport.
void CopyDrawable(Int_t device, Int_t px, Int_t py) override
Not required at the moment.
void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override
Using TImage save frame-buffer contents as a picture.
Short_t GetTextAlign() const override
Delegate to gVirtualX.
Style_t GetFillStyle() const override
Delegate to gVirtualX.
Font_t GetTextFont() const override
Delegate to gVirtualX.
void RestoreProjectionMatrix() const
Restore the projection matrix.
void SetLineStyle(Style_t lstyle) override
Delegate to gVirtualX.
void LockPainter() override
Locked state of painter means, that GL context can be invalid, so no GL calls can be executed.
Float_t GetTextMagnitude() const override
Delegate to gVirtualX.
Width_t GetLineWidth() const override
Delegate to gVirtualX.
void DrawTesselation(Int_t n, const Double_t *x, const Double_t *y)
Color_t GetFillColor() const override
Delegate to gVirtualX.
Int_t CreateDrawable(UInt_t w, UInt_t h) override
Not required at the moment.
Bool_t IsTransparent() const override
Delegate to gVirtualX.
void RestoreModelviewMatrix() const
Restore the modelview matrix.
std::vector< Double_t > fVs
Bool_t fIsHollowArea
void SaveProjectionMatrix() const
Save the projection matrix.
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
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16