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:
35
36 WinContext_t fWinContext; // context of selected drawable
37 TAttFill fGlFillAtt; // fill attributes used for GL
38
39 std::vector<Double_t> fVs;//Vertex buffer for tesselator.
40
43
45
46 std::vector<TPoint> fPoly;
48
50
51 template<class Char_t>
53public:
55
56 void SetOpacity(Int_t percent) override;
57 Float_t GetTextMagnitude() const override;
58
59
60 void OnPad(TVirtualPad *) override;
61
62 // Overwrite only attributes setters
63 void SetAttFill(const TAttFill &att) override;
64 void SetAttLine(const TAttLine &att) override;
65 void SetAttMarker(const TAttMarker &att) override;
66 void SetAttText(const TAttText &att) override;
67
68 //2. "Off-screen management" part.
70 void ClearDrawable() override;
72 void CopyDrawable(Int_t device, Int_t px, Int_t py) override;
73 void DestroyDrawable(Int_t device) override;
74 void SelectDrawable(Int_t device) override;
75 void UpdateDrawable(Int_t mode) override;
76 void SetDrawMode(Int_t device, Int_t mode) override;
77
78 void InitPainter() override;
79 void InvalidateCS() override;
80 void LockPainter() override;
81
84
86 //TPad needs double and float versions.
87 void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override;
88 void DrawFillArea(Int_t n, const Float_t *x, const Float_t *y) override;
89
90 //TPad needs both double and float versions of DrawPolyLine.
91 void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override;
92 void DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) override;
93 void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override;
94
95 //TPad needs both versions.
96 void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override;
97 void DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) override;
98
99 void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
100 void DrawText(Double_t, Double_t, const wchar_t *, ETextMode) override;
101 void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode) override;
102 void DrawTextNDC(Double_t, Double_t, const wchar_t *, ETextMode) override;
103
104 //jpg, png, gif and bmp output.
105 void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override;
106
107 //TASImage support.
108 void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
110
111 Bool_t IsNative() const override { return kTRUE; }
112
113 Bool_t IsCocoa() const override;
114
115 Bool_t IsSupportAlpha() const override { return kTRUE; }
116
117private:
118
119 //Attention! GL_PROJECTION will become
120 //the current matrix after these calls.
121 void SaveProjectionMatrix()const;
122 void RestoreProjectionMatrix()const;
123
124 //Attention! GL_MODELVIEW will become the
125 //current matrix after these calls.
126 void SaveModelviewMatrix()const;
127 void RestoreModelviewMatrix()const;
128
129 void SaveViewport();
130 void RestoreViewport();
131
132 void DrawPolyMarker();
133
134 //Aux. functions for a gradient and solid fill:
135 void DrawPolygonWithGradient(Int_t n, const Double_t *x, const Double_t *y);
136 //
137 void DrawGradient(const TLinearGradient *gradient, Int_t n, const Double_t *x, const Double_t *y);
138 void DrawGradient(const TRadialGradient *gradient, Int_t n, const Double_t *x, const Double_t *y);
139 //
140 void DrawTesselation(Int_t n, const Double_t *x, const Double_t *y);
141
144
146};
147
148#endif
149
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
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 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:21
Text Attributes class.
Definition TAttText.h:21
A FreeType GL font manager.
A wrapper class for FTFont.
"Delegating" part of TGLPadPainter.
void SetAttText(const TAttText &att) override
Set text attributes.
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.
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 DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Draw line segment in NDC coordinates.
WinContext_t fWinContext
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 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...
void InvalidateCS() override
When TPad::Range for gPad is called, projection must be changed in OpenGL.
void ClearDrawable() override
Call gVirtualX->ClearWindow()
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.
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
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.
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)
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.
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