27#include "TGLIncludes.h"
305 Int_t px = 0, py = 0;
307 pad->XYtoAbsPixel(
pad->GetX1(),
pad->GetY1(), px, py);
309 py =
gPad->GetWh() - py;
326 ::Error(
"TGLPadPainter::SelectDrawable",
327 "function was called not from TPad or TCanvas code\n");
328 throw std::runtime_error(
"");
348 Warning(
"TGLPadPainter::InitPainter",
"GL initalization failed.");
350 Info(
"TGLPadPainter::InitPainter",
"GL initalization successful.");
505 assert(
x !=
nullptr &&
"DrawFillArea, parameter 'x' is null");
506 assert(
y !=
nullptr &&
"DrawFillArea, parameter 'y' is null");
512 ::Error(
"TGLPadPainter::DrawFillArea",
513 "invalid number of points in a polygon");
544 for (
Int_t i = 0; i <
n; ++i) {
546 fVs[i * 3 + 1] =
y[i];
555 for (
Int_t i = 0; i <
n; ++i)
573 for (
Int_t i = 0; i <
n; ++i)
591 for (
Int_t i = 0; i <
n; ++i)
610 for (
Int_t i = 0; i <
n; ++i)
635 for (
Int_t i = 0; i <
n; ++i)
644template<
class ValueType>
991 gROOT->ProcessLine(
Form(
"((TCanvas *)0x%zx)->Flush();", (
size_t)canvas));
1002 ::Error(
"TGLPadPainter::SaveImage",
"TImage creation failed");
1010 ::Error(
"TGLPadPainter::SaveImage",
"null argb array in TImage object");
1024 ((
pix & 0xff0000) >> 16) | (
pix & 0xff000000);
1044 ::Error(
"TGLPadPainter::DrawPixels",
"pixel data is null");
1048 if (std::numeric_limits<UInt_t>::digits >= 32) {
1057 ::Error(
"TGLPadPainter::DrawPixels",
"invalid width");
1063 ::Error(
"TGLPadPainter::DrawPixels",
"invalid height");
1073 (
pad->GetX2() -
pad->GetX1()) +
pad->GetX1();
1104 ::Error(
"TGLPadPainter::DrawPixels",
"no pad found to draw");
1116 assert(
n > 2 &&
"DrawPolygonWithGradient, invalid number of points");
1117 assert(
x !=
nullptr &&
"DrawPolygonWithGradient, parameter 'x' is null");
1118 assert(
y !=
nullptr &&
"DrawPolygonWithGradient, parameter 'y' is null");
1121 "DrawPolygonWithGradient, the current fill color is not a gradient fill");
1161 assert(
lGrad !=
nullptr &&
"DrawPolygonWithGradient, unknown gradient type");
1171 assert(grad !=
nullptr &&
"DrawGradient, parameter 'grad' is null");
1172 assert(
nPoints > 2 &&
"DrawGradient, invalid number of points");
1173 assert(
xs !=
nullptr &&
"DrawGradient, parameter 'xs' is null");
1174 assert(
ys !=
nullptr &&
"DrawGradient, parameter 'ys' is null");
1177 ::Warning(
"TGLPadPainter::DrawGradient",
1178 "extended radial gradient is not supported");
1190 center.fX = bbox.fWidth * center.fX + bbox.fXMin;
1191 center.fY = bbox.fHeight * center.fY + bbox.fYMin;
1193 const auto w =
gPad->GetX2() -
gPad->GetX1();
1194 const auto h =
gPad->GetY2() -
gPad->GetY1();
1213 center.fX =
gPad->XtoPixel(center.fX);
1214 center.fY =
pixelH -
gPad->YtoPixel(center.fY);
1348 assert(grad !=
nullptr &&
"DrawGradient, parameter 'grad' is null");
1349 assert(
n > 2 &&
"DrawGradient, invalid number of points");
1350 assert(
x !=
nullptr &&
"DrawGradient, parameter 'x' is null");
1351 assert(
y !=
nullptr &&
"DrawGradient, parameter 'y' is null");
1387 start.fX = start.fX *
w;
1388 start.fY = start.fY *
h;
1389 end.fX = end.fX *
w;
1390 end.fY = end.fY *
h;
1392 start.fX = start.fX * bbox.fWidth + bbox.fXMin;
1393 start.fY = start.fY * bbox.fHeight + bbox.fYMin;
1394 end.fX = end.fX * bbox.fWidth + bbox.fXMin;
1395 end.fY = end.fY * bbox.fHeight + bbox.fYMin;
1402 start.fX =
gPad->XtoPixel(start.fX);
1403 start.fY =
pixelH -
gPad->YtoPixel(start.fY);
1404 end.fX =
gPad->XtoPixel(end.fX);
1419 (end.fY - start.fY) * (end.fY - start.fY));
1435 if (end.fX > start.fX)
1456 for (
unsigned i = 1; i <
nEdges - 2; ++i)
1468 assert(
n > 2 &&
"DrawTesselation, invalid number of points");
1469 assert(
x !=
nullptr &&
"DrawTesselation, parameter 'x' is null");
1470 assert(
y !=
nullptr &&
"DrawTesselation, parameter 'y' is null");
1475 for (
Int_t i = 0; i <
n; ++i) {
1477 fVs[i * 3 + 1] =
y[i];
1478 fVs[i * 3 + 2] = 0.;
1487 for (
Int_t i = 0; i <
n; ++i)
1497template<
class ValueType>
1503 for (
Int_t i = 0; i <
n; ++i) {
short Style_t
Style number (short)
int Int_t
Signed integer 4 bytes (int)
short Color_t
Color number (short)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
short Width_t
Line width (short)
float Float_t
Float 4 bytes (float)
short Font_t
Font number (short)
short Short_t
Signed Short integer 2 bytes (short)
double Double_t
Double 8 bytes.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
const Double_t lineWidthTS
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pix
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 r
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
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 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
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Double_t GetMaxLineWidth() const
Double_t GetMaxPointSize() const
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
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
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 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
void DrawOpenDiamondCross(UInt_t n, const TPoint *xy) const
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
TColorGradient extends basic TColor.
const Double_t * GetColors() const
Get colors.
SizeType_t GetNumberOfSteps() const
Get number of steps.
ECoordinateMode GetCoordinateMode() const
Get coordinate mode.
const Double_t * GetColorPositions() const
Get color positions.
void RegisterFont(Int_t size, Int_t file, TGLFont::EMode mode, TGLFont &out)
Provide font with given size, file and FTGL class.
static Int_t GetExtendedFontStartIndex()
static const char * GetFontNameFromId(Int_t)
Get font name from TAttAxis font id.
static TObjArray * GetFontFileArray()
Get id to file name map.
void Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
virtual void PostRender() const
Reset GL state after FTFont rendering.
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering.
void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override
Draw text.
void SetLineColor(Color_t lcolor) override
Delegate to gVirtualX.
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)
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode) override
Draw filled or hollow box.
void SetFillColor(Color_t fcolor) override
Delegate to gVirtualX.
void SetTextSizePixels(Int_t npixels) override
Delegate to gVirtualX.
void SetTextFont(Font_t tfont) 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.
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 SetOpacity(Int_t percent) override
Delegate to gVirtualX.
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...
Rgl::Pad::PolygonStippleSet fSSet
Rgl::Pad::MarkerPainter fMarker
void DrawPolyMarker()
Poly-marker.
void SaveViewport()
Extract and save the current viewport.
void SetLineWidth(Width_t lwidth) override
Delegate to gVirtualX.
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 SetTextSize(Float_t tsize) override
Delegate to gVirtualX.
void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override
Draw tesselated polygon (probably, outline only).
Short_t GetTextAlign() const override
Delegate to gVirtualX.
Style_t GetFillStyle() const override
Delegate to gVirtualX.
void SetFillStyle(Style_t fstyle) 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
void SaveProjectionMatrix() const
Save the projection matrix.
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw line segment.
void SaveModelviewMatrix() const
Save the modelview matrix.
void RestoreViewport()
Restore the saved viewport.
static void InitializeIfNeeded()
Initialize globals that require other libraries to be initialized.
static Float_t GetScreenScalingFactor()
Returns scaling factor between screen points and GL viewport pixels.
static TImage * Create()
Create an image.
const Point & GetEnd() const
Get end.
const Point & GetStart() const
Get start.
The most important graphics class in the ROOT system.
Double_t GetRadius() const
Get radius.
const Point & GetCenter() const
Get center.
EGradientType GetGradientType() const
Get gradient type.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual UInt_t GetWh() const =0
virtual UInt_t GetWw() const =0
BoundingRect< ValueType > FindBoundingRect(Int_t nPoints, const ValueType *xs, const ValueType *ys)
void ExtractRGBA(Color_t colorIndex, Float_t *rgba)
void DrawQuadStripWithRadialGradientFill(unsigned nPoints, const Double_t *inner, const Double_t *innerRGBA, const Double_t *outer, const Double_t *outerRGBA)
TODO: is it possible to use GLdouble to avoid problems with Double_t/GLdouble if they are not the sam...
void DrawBoxWithGradientFill(Double_t y1, Double_t y2, Double_t x1, Double_t x2, const Double_t *rgba1, const Double_t *rgba2)
Double_t ACos(Double_t)
Returns the principal value of the arc cosine of x, expressed in radians.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
constexpr Double_t TwoPi()