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 "TPadPainterBase.h"
16#include "TGLFontManager.h"
17#include "TGLPadUtils.h"
18#include "TPoint.h"
19#include "GuiTypes.h"
20
21#include <vector>
22
23class TLinearGradient;
24class TRadialGradient;
25/*
26The _main_ purpose of TGLPadPainter is to enable 2d gl raphics
27inside standard TPad/TCanvas.
28*/
30private:
34
35 WinContext_t fWinContext; // context of selected drawable
36 TAttFill fGlFillAtt; // fill attributes used for GL
37
38 std::vector<Double_t> fVs;//Vertex buffer for tesselator.
39
42
44
46
48
50
51 void SelectGLFont(Font_t font, Float_t size);
52
53 template<class ValueType>
54 void DrawPolyMarkerHelper(Int_t n, const ValueType *x, const ValueType *y);
55
56 template<class ValueType>
57 void DrawPolyLineHelper(Int_t n, const ValueType *x, const ValueType *y);
58
59 template<class Char_t>
61
62protected:
63
64 Double_t GetTTFScale() const override { return 1./0.93376068; }
65
66public:
68
69 void SetOpacity(Int_t percent) override;
70 Float_t GetTextMagnitude() const override;
71
72
73 void OnPad(TVirtualPad *) override;
74
75 // Overwrite only attributes setters
76 void SetAttFill(const TAttFill &att) override;
77 void SetAttLine(const TAttLine &att) override;
78 void SetAttMarker(const TAttMarker &att) override;
79
80 //2. "Off-screen management" part.
82 void ClearDrawable() override;
83 void ClearWindow(Int_t device) override;
85 void CopyDrawable(Int_t device, Int_t px, Int_t py) override;
86 void DestroyDrawable(Int_t device) override;
87 void SelectDrawable(Int_t device) override;
88 void UpdateDrawable(Int_t mode) override;
89 void SetDrawMode(Int_t device, Int_t mode) override;
90
91 void InitPainter() override;
92 void InvalidateCS() override;
93 void LockPainter() override;
94
95 Bool_t HasTTFonts() const override;
96
99
101 //TPad needs double and float versions.
102 void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override;
103 void DrawFillArea(Int_t n, const Float_t *x, const Float_t *y) override;
104
105 //TPad needs both double and float versions of DrawPolyLine.
106 void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override;
107 void DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) override;
108 void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override;
109
110 //TPad needs both versions.
111 void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override;
112 void DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) override;
113
114 void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
115 void DrawText(Double_t, Double_t, const wchar_t *, ETextMode) override;
116 void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode) override;
117 void DrawTextNDC(Double_t, Double_t, const wchar_t *, ETextMode) override;
118
119 void DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags = 0) override;
120
121 //jpg, png, gif and bmp output.
122 void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override;
123
124 //TASImage support.
125 void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
127
128 Bool_t IsNative() const override { return kTRUE; }
129
130 Bool_t IsCocoa() const override;
131
132 Bool_t IsSupportAlpha() const override { return kTRUE; }
133
134private:
135
136 //Attention! GL_PROJECTION will become
137 //the current matrix after these calls.
138 void SaveProjectionMatrix()const;
139 void RestoreProjectionMatrix()const;
140
141 //Attention! GL_MODELVIEW will become the
142 //current matrix after these calls.
143 void SaveModelviewMatrix()const;
144 void RestoreModelviewMatrix()const;
145
146 void SaveViewport();
147 void RestoreViewport();
148
149 //Aux. functions for a gradient and solid fill:
150 void DrawPolygonWithGradient(Int_t n, const Double_t *x, const Double_t *y);
151 //
152 void DrawGradient(const TLinearGradient *gradient, Int_t n, const Double_t *x, const Double_t *y);
153 void DrawGradient(const TRadialGradient *gradient, Int_t n, const Double_t *x, const Double_t *y);
154 //
155 void DrawTesselation(Int_t n, const Double_t *x, const Double_t *y);
156
159
161};
162
163#endif
164
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
#define h(i)
Definition RSha256.hxx:106
char * device
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:52
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
short Font_t
Font number (short)
Definition RtypesCore.h:96
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
#define ClassDefOverride(name, id)
Definition Rtypes.h:347
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 ClearWindow
Option_t Option_t DrawFillArea
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint DrawPolyMarker
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
Fill Area Attributes class.
Definition TAttFill.h:21
Line Attributes class.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:22
A FreeType GL font manager.
A wrapper class for FTFont.
"Delegating" part of TGLPadPainter.
void DrawPolyMarkerHelper(Int_t n, const ValueType *x, const ValueType *y)
Poly-marker drawing.
void SetDrawMode(Int_t device, Int_t mode) override
Set drawing mode for specified device.
void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY, Bool_t enableBlending) override
Int_t ResizeDrawable(Int_t device, UInt_t w, UInt_t h) override
Resize a gVirtualX Pixmap.
Double_t GetTTFScale() const override
void DestroyDrawable(Int_t device) override
Not required at the moment.
Bool_t IsNative() const override
void DrawGradient(const TLinearGradient *gradient, Int_t n, const Double_t *x, const Double_t *y)
Rgl::Pad::Tesselator fTess
void SelectGLFont(Font_t font, Float_t size)
Select specified font/size.
void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Draw line segment in NDC coordinates.
WinContext_t fWinContext
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 SetAttLine(const TAttLine &att) override
Set line attributes.
TAttFill fGlFillAtt
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...
Bool_t IsInvertMode()
Returns true when invert mode is configured and painter in locked state Used when non-opaque of objec...
void InvalidateCS() override
When TPad::Range for gPad is called, projection must be changed in OpenGL.
void ClearDrawable() override
Do nothing, sub-pads not cleared in GL.
void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override
Poly line in NDC.
void OnPad(TVirtualPad *) override
Select pad where current painting will be performed.
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 DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags=0) override
Draw image on the GL window.
Rgl::Pad::GLLimits fLimits
void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode) override
Draw text in NDC.
void SetAttFill(const TAttFill &att) override
Set fill attributes.
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
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.
void DrawPolyLineHelper(Int_t n, const ValueType *x, const ValueType *y)
Draw poly-line in user coordinates.
void UpdateDrawable(Int_t mode) override
Call low-level update of selected drawable, redirect to gVirtualX.
void RestoreProjectionMatrix() const
Restore the projection matrix.
void SetAttMarker(const TAttMarker &att) override
Set marker attributes.
Bool_t IsSupportAlpha() const override
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.
void DrawTesselation(Int_t n, const Double_t *x, const Double_t *y)
Bool_t HasTTFonts() const override
Indicate that TTF can be used for text metrics Drawing done with FTGL which is based on Freetype libr...
Int_t CreateDrawable(UInt_t w, UInt_t h) override
Not required at the moment.
void RestoreModelviewMatrix() const
Restore the modelview matrix.
std::vector< Double_t > fVs
Bool_t fIsHollowArea
void SaveProjectionMatrix() const
Save the projection matrix.
Bool_t IsCocoa() const override
Returns true when cocoa backend is used.
void SaveModelviewMatrix() const
Save the modelview matrix.
void RestoreViewport()
Restore the saved viewport.
An abstract interface to image processing library.
Definition TImage.h:29
Extends TVirtualPadPainter interface to simplify work with graphical attributes.
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