31using size_type = std::vector<TPoint>::size_type;
34void ConvertPoints(
TVirtualPad *pad,
unsigned nPoints,
const T *xs,
const T *ys,
37void MergePointsX(std::vector<TPoint> &
points,
unsigned nMerged,
SCoord_t yMin,
41size_type MergePointsInplaceY(std::vector<TPoint> &
dst, size_type nMerged,
SCoord_t xMin,
45void ConvertPointsAndMergePassX(
TVirtualPad *pad,
unsigned nPoints,
const T *
x,
const T *
y,
46 std::vector<TPoint> &
dst);
48void ConvertPointsAndMergeInplacePassY(std::vector<TPoint> &
dst);
131 return gVirtualX->InheritsFrom(
"TGCocoa");
139 return gVirtualX->InheritsFrom(
"TGQuartz");
285 Fatal(
"SetAttText",
"Pad not specified");
356 ::Error(
"TPadPainter::DrawFillArea",
"invalid number of points %d", nPoints);
371 ::Error(
"TPadPainter::DrawFillArea",
"invalid number of points %d", nPoints);
388 ::Error(
"TPadPainter::DrawPolyLine",
"invalid number of points");
405 ::Error(
"TPadPainter::DrawPolyLine",
"invalid number of points");
422 ::Error(
"TPadPainter::DrawPolyLineNDC",
"invalid number of points %d",
n);
426 std::vector<TPoint>
xy(
n);
428 for (
Int_t i = 0; i <
n; ++i) {
445 ::Error(
"TPadPainter::DrawSegments",
"invalid number of segments %d",
n);
449 std::vector<TPoint>
xy(
n*2);
451 for (
Int_t i = 0; i <
n*2; ++i) {
452 if ((i % 2 == 0) && (
x[i] ==
x[i+1]) && (
y[i] ==
y[i+1])) {
476 ::Error(
"TPadPainter::DrawSegmentsNDC",
"invalid number of segments %d",
n);
480 std::vector<TPoint>
xy(
n*2);
482 for (
Int_t i = 0; i <
n*2; ++i) {
483 if ((i % 2 == 0) && (u[i] == u[i+1]) && (
v[i] ==
v[i+1])) {
506 ::Error(
"TPadPainter::DrawPolyMarker",
"invalid number of points %d",
n);
519 ::Error(
"TPadPainter::DrawPolyMarker",
"invalid number of points %d",
n);
541 while (
auto obj = next()) {
544 if (
auto subpad =
dynamic_cast<TPad *
>(obj))
623void ConvertPoints(
TVirtualPad *pad,
unsigned nPoints,
const T *
x,
const T *
y,
624 std::vector<TPoint> &
dst,
Bool_t absCoord)
632 for (
unsigned i = 0; i < nPoints; ++i) {
637 for (
unsigned i = 0; i < nPoints; ++i) {
646inline void MergePointsX(std::vector<TPoint> &
points,
unsigned nMerged,
SCoord_t yMin,
649 const auto firstPointX =
points.back().
fX;
650 const auto firstPointY =
points.back().
fY;
654 }
else if (nMerged == 3) {
655 yMin == firstPointY ?
points.push_back(
TPoint(firstPointX, yMax)) :
668inline size_type MergePointsInplaceY(std::vector<TPoint> &
dst, size_type nMerged,
SCoord_t xMin,
674 dst[first + 1].fX = xLast;
675 dst[first + 1].fY = firstPoint.
fY;
676 }
else if (nMerged == 3) {
677 dst[first + 1].fX = xMin == firstPoint.
fX ? xMax : xMin;
678 dst[first + 1].fY = firstPoint.
fY;
679 dst[first + 2].fX = xLast;
680 dst[first + 2].fY = firstPoint.
fY;
682 dst[first + 1].fX = xMin;
683 dst[first + 1].fY = firstPoint.
fY;
684 dst[first + 2].fX = xMax;
685 dst[first + 2].fY = firstPoint.
fY;
686 dst[first + 3].fX = xLast;
687 dst[first + 3].fY = firstPoint.
fY;
700void ConvertPointsAndMergePassX(
TVirtualPad *pad,
unsigned nPoints,
const T *
x,
const T *
y,
701 std::vector<TPoint> &
dst)
705 SCoord_t yMin = 0, yMax = 0, yLast = 0;
706 unsigned nMerged = 0;
709 for (
unsigned i = 0; i < nPoints;) {
713 yMin = currentPoint.
fY;
716 dst.push_back(currentPoint);
720 for (
unsigned j = i + 1; j < nPoints; ++j) {
723 if (newX == currentPoint.
fX) {
730 MergePointsX(
dst, nMerged, yMin, yMax, yLast);
736 if (!merged && nMerged > 1)
737 MergePointsX(
dst, nMerged, yMin, yMax, yLast);
746void ConvertPointsAndMergeInplacePassY(std::vector<TPoint> &
dst)
749 for (size_type j = 1, nPoints =
dst.size(); i < nPoints;) {
758 size_type nMerged = 1;
760 for (; j < nPoints; ++j) {
763 if (nextPoint.
fY == currentPoint.
fY) {
764 xLast = nextPoint.
fX;
770 nMerged = MergePointsInplaceY(
dst, nMerged, xMin, xMax, xLast, i);
776 if (!merged && nMerged > 1)
777 nMerged = MergePointsInplaceY(
dst, nMerged, xMin, xMax, xLast, i);
797void ConvertPointsAndMerge(
TVirtualPad *pad,
unsigned threshold,
unsigned nPoints,
const T *
x,
798 const T *
y, std::vector<TPoint> &
dst)
808 dst.reserve(threshold);
810 ConvertPointsAndMergePassX(pad, nPoints,
x,
y,
dst);
812 if (
dst.size() < threshold)
815 ConvertPointsAndMergeInplacePassY(
dst);
823 std::vector<TPoint>
xy;
828 if (threshold <= 0) {
830 ::Error(
"DrawFillAreaAux",
"invalid pad's geometry");
834 if (absCoord || (nPoints < threshold))
835 ConvertPoints(pad, nPoints, xs, ys,
xy, absCoord);
837 ConvertPointsAndMerge(pad, threshold, nPoints, xs, ys,
xy);
841 xy.push_back(
xy.front());
852 std::vector<TPoint>
xy;
856 if (threshold == 0) {
857 ::Error(
"DrawPolyLineAux",
"invalid pad's geometry");
861 if (absCoord || (nPoints < threshold))
862 ConvertPoints(pad, nPoints, xs, ys,
xy, absCoord);
864 ConvertPointsAndMerge(pad, threshold, nPoints, xs, ys,
xy);
875 std::vector<TPoint>
xy;
877 ConvertPoints(pad, nPoints, xs, ys,
xy, absCoord);
879 gVirtualX->DrawPolyMarkerW(cont, nPoints,
xy.data());
Handle_t WinContext_t
Window drawing context.
Handle_t Window_t
Window handle.
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
float Float_t
Float 4 bytes (float)
short SCoord_t
Screen coordinates (short)
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
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 const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
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 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 y1
static Bool_t ContainsTImage(const TVirtualPad *pad)
Helper method to check if TImage is present in list of primitives.
R__EXTERN TSystem * gSystem
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Fill Area Attributes class.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual Float_t GetTextSizePixels(TVirtualPad &pad) const
Return the text size in pixels for specified pad.
An abstract interface to image processing library.
virtual void FromX11Window(Window_t, Int_t, Int_t, Int_t, Int_t)
virtual Bool_t IsValid() const
virtual void FromBitmap(const UChar_t *, UInt_t, UInt_t)
virtual void PaintImage(Drawable_t, Int_t, Int_t, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0, Option_t *="")
void SetAttFill(const TAttFill &att) override
Set fill attributes.
ESaveImageResult SaveAsImage(TVirtualPad *pad, const char *fileName, Int_t type) const override
Store pad image into the file One should provide FillImageFromPad implementation in the subclass.
void SetAttText(const TAttText &att) override
Set text attributes.
TAttLine fAttLine
current line attributes
Bool_t fFullyTransparent
if transformed fill attributes fully transparent
void SetAttMarker(const TAttMarker &att) override
Set marker attributes.
void SetAttLine(const TAttLine &att) override
Set line attributes.
TAttFill GetAttFillInternal(Bool_t with_transparency)
Returns fill attributes after modification Checks for special fill styles 4000 .
void DrawSegments(Int_t n, Double_t *x, Double_t *y) override
Paint N segments on the pad.
TPadPainter()
Empty ctor. We need it only because of explicit copy ctor.
void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override
Paint filled area.
void SetAttText(const TAttText &att) override
Set text attributes.
void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY, Bool_t enableAlphaBlending) override
Noop, for non-gl pad TASImage calls gVirtualX->CopyArea.
void UpdateDrawable(Int_t mode) override
Call low-level update of selected drawable, redirect to gVirtualX.
void CopyDrawable(Int_t device, Int_t px, Int_t py) override
Copy a gVirtualX pixmap.
void SetAttMarker(const TAttMarker &att) override
Set marker attributes.
void DrawTTFglyphs(Int_t x, Int_t y, TTFhandle &ttf, ETextMode mode) override
Paint TTF glyps on virtualx device.
void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override
Paint Polyline.
Int_t ResizeDrawable(Int_t device, UInt_t w, UInt_t h) override
Resize a gVirtualX Pixmap.
Float_t GetTextMagnitude() const override
Delegate to gVirtualX.
Bool_t IsX11() const override
Returns true when X11 backend is used.
Bool_t IsSupportAlpha() const override
Returns true if transparent colors are supported.
void ClearWindow(Int_t device) override
Clear specified window - calling gVirtualX->ClearWindowW.
Int_t CreateDrawable(UInt_t w, UInt_t h) override
Create a gVirtualX Pixmap.
void SetAttFill(const TAttFill &att) override
Set fill attributes.
void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override
Paint polymarker.
void SetOpacity(Int_t percent) override
Delegate to gVirtualX.
Bool_t IsCocoa() const override
Returns true when cocoa backend is used.
Bool_t FillImageFromPad(TImage *image, TVirtualPad *pad) const override
Fill image object with the pixel data from the pad Implements special handling for X11 where ASImage ...
void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override
Paint polyline in normalized coordinates.
Bool_t HasTTFonts() const override
Return true if TTF font can be used.
void SetDrawMode(Int_t device, Int_t mode) override
Set drawing mode for specified device.
void ClearDrawable() override
Clear the current gVirtualX window - calling gVirtualX->ClearWindowW.
void DestroyDrawable(Int_t device) override
Close the current gVirtualX pixmap.
void DrawSegmentsNDC(Int_t n, Double_t *u, Double_t *v) override
Paint N segments in normalized coordinates on the pad.
void SetAttLine(const TAttLine &att) override
Set line attributes.
void SelectDrawable(Int_t device) override
Select the window in which the graphics will go.
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode) override
Paint a simple box.
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Paint a simple line.
ESaveImageResult SaveAsImage(TVirtualPad *pad, const char *fileName, Int_t type) const override
Save the image displayed in the canvas pointed by "pad" into a binary file.
void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Paint a simple line in normalized coordinates.
void DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags=0) override
Draw image on the gVirtualX window.
void SetDoubleBuffer(Int_t device, Int_t mode) override
Set double buffer mode for specified device.
The most important graphics class in the ROOT system.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Dynamic handle to work with freetype 2 library.
virtual void const char * fileName
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual Int_t YtoAbsPixel(Double_t y) const =0
virtual TList * GetListOfPrimitives() const =0
virtual Int_t YtoPixel(Double_t y) const =0
virtual UInt_t GetWh() const =0
virtual Int_t XtoAbsPixel(Double_t x) const =0
virtual UInt_t GetPadWidth() const =0
virtual Int_t GetPixmapID() const =0
virtual Double_t GetAbsWNDC() const =0
virtual UInt_t GetPadHeight() const =0
virtual Double_t GetAbsHNDC() const =0
virtual Int_t XtoPixel(Double_t x) const =0
virtual UInt_t GetWw() const =0
virtual Int_t GetCanvasID() const =0
virtual TCanvas * GetCanvas() const =0
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.