Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPadPainter.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Olivier Couet, Timur Pocheptsov (vertex merge) 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#include <algorithm>
13#include <limits>
14#include <memory>
15#include <vector>
16
17#include "TPadPainter.h"
18#include "TVirtualX.h"
19#include "TCanvas.h"
20#include "TPoint.h"
21#include "TError.h"
22#include "TImage.h"
23#include "TROOT.h"
24#include "TMath.h"
25#include "TPad.h"
26
27namespace {
28
29//Typedef is fine, but let's pretend we look cool and modern:
30using size_type = std::vector<TPoint>::size_type;
31
32template<typename T>
33void ConvertPoints(TVirtualPad *pad, unsigned nPoints, const T *xs, const T *ys,
34 std::vector<TPoint> &dst);
35inline
36void MergePointsX(std::vector<TPoint> &points, unsigned nMerged, SCoord_t yMin,
38
39inline
40size_type MergePointsInplaceY(std::vector<TPoint> &dst, size_type nMerged, SCoord_t xMin,
41 SCoord_t xMax, SCoord_t xLast, size_type first);
42
43template<typename T>
44void ConvertPointsAndMergePassX(TVirtualPad *pad, unsigned nPoints, const T *x, const T *y,
45 std::vector<TPoint> &dst);
46
47void ConvertPointsAndMergeInplacePassY(std::vector<TPoint> &dst);
48
49template<class T>
50void DrawFillAreaAux(TVirtualPad *pad, Int_t nPoints, const T *xs, const T *ys);
51
52template<typename T>
53void DrawPolyLineAux(TVirtualPad *pad, unsigned nPoints, const T *xs, const T *ys);
54
55template<class T>
56void DrawPolyMarkerAux(TVirtualPad *pad, unsigned nPoints, const T *xs, const T *ys);
57
58
59}
60
61
62/** \class TPadPainter
63\ingroup gpad
64
65Implement TVirtualPadPainter which abstracts painting operations.
66*/
67
68////////////////////////////////////////////////////////////////////////////////
69///Empty ctor. We need it only because of explicit copy ctor.
70
74
75/*
76Line/fill/etc. attributes can be set inside TPad, but not only where:
77many of them are set by base sub-objects of 2d primitives
78(2d primitives usually inherit TAttLine or TAttFill etc.). And these sub-objects
79call gVirtualX->SetLineWidth ... etc. So, if I save some attributes in my painter,
80it will be mess - at any moment I do not know, where to take line attribute - from
81gVirtualX or from my own member. So! All attributed, _ALL_ go to/from gVirtualX.
82*/
83
84
85////////////////////////////////////////////////////////////////////////////////
86/// Delegate to gVirtualX.
87
89{
90 return gVirtualX->GetLineColor();
91}
92
93
94////////////////////////////////////////////////////////////////////////////////
95/// Delegate to gVirtualX.
96
98{
99 return gVirtualX->GetLineStyle();
100}
101
102
103////////////////////////////////////////////////////////////////////////////////
104/// Delegate to gVirtualX.
105
107{
108 return gVirtualX->GetLineWidth();
109}
110
111
112////////////////////////////////////////////////////////////////////////////////
113/// Delegate to gVirtualX.
114
116{
117 gVirtualX->SetLineColor(lcolor);
118}
119
120
121////////////////////////////////////////////////////////////////////////////////
122/// Delegate to gVirtualX.
123
125{
126 gVirtualX->SetLineStyle(lstyle);
127}
128
129
130////////////////////////////////////////////////////////////////////////////////
131/// Delegate to gVirtualX.
132
134{
135 gVirtualX->SetLineWidth(lwidth);
136}
137
138
139////////////////////////////////////////////////////////////////////////////////
140/// Delegate to gVirtualX.
141
143{
144 return gVirtualX->GetFillColor();
145}
146
147
148////////////////////////////////////////////////////////////////////////////////
149/// Delegate to gVirtualX.
150
152{
153 return gVirtualX->GetFillStyle();
154}
155
156
157////////////////////////////////////////////////////////////////////////////////
158/// Delegate to gVirtualX.
159
161{
162 //IsTransparent is implemented as inline function in TAttFill.
163 return gVirtualX->IsTransparent();
164}
165
166
167////////////////////////////////////////////////////////////////////////////////
168/// Delegate to gVirtualX.
169
171{
172 gVirtualX->SetFillColor(fcolor);
173}
174
175
176////////////////////////////////////////////////////////////////////////////////
177/// Delegate to gVirtualX.
178
180{
181 gVirtualX->SetFillStyle(fstyle);
182}
183
184
185////////////////////////////////////////////////////////////////////////////////
186/// Delegate to gVirtualX.
187
189{
190 gVirtualX->SetOpacity(percent);
191}
192
193
194////////////////////////////////////////////////////////////////////////////////
195/// Delegate to gVirtualX.
196
198{
199 return gVirtualX->GetTextAlign();
200}
201
202
203////////////////////////////////////////////////////////////////////////////////
204/// Delegate to gVirtualX.
205
207{
208 return gVirtualX->GetTextAngle();
209}
210
211
212////////////////////////////////////////////////////////////////////////////////
213/// Delegate to gVirtualX.
214
216{
217 return gVirtualX->GetTextColor();
218}
219
220
221////////////////////////////////////////////////////////////////////////////////
222/// Delegate to gVirtualX.
223
225{
226 return gVirtualX->GetTextFont();
227}
228
229
230////////////////////////////////////////////////////////////////////////////////
231/// Delegate to gVirtualX.
232
234{
235 return gVirtualX->GetTextSize();
236}
237
238
239////////////////////////////////////////////////////////////////////////////////
240/// Delegate to gVirtualX.
241
243{
244 return gVirtualX->GetTextMagnitude();
245}
246
247
248////////////////////////////////////////////////////////////////////////////////
249/// Delegate to gVirtualX.
250
252{
253 gVirtualX->SetTextAlign(align);
254}
255
256
257////////////////////////////////////////////////////////////////////////////////
258/// Delegate to gVirtualX.
259
261{
262 gVirtualX->SetTextAngle(tangle);
263}
264
265
266////////////////////////////////////////////////////////////////////////////////
267/// Delegate to gVirtualX.
268
270{
271 gVirtualX->SetTextColor(tcolor);
272}
273
274
275////////////////////////////////////////////////////////////////////////////////
276/// Delegate to gVirtualX.
277
279{
280 gVirtualX->SetTextFont(tfont);
281}
282
283
284////////////////////////////////////////////////////////////////////////////////
285/// Delegate to gVirtualX.
286
288{
289 gVirtualX->SetTextSize(tsize);
290}
291
292
293////////////////////////////////////////////////////////////////////////////////
294/// Delegate to gVirtualX.
295
297{
298 gVirtualX->SetTextSizePixels(npixels);
299}
300
301
302////////////////////////////////////////////////////////////////////////////////
303/// Create a gVirtualX Pixmap.
304
306{
307 return gVirtualX->OpenPixmap(Int_t(w), Int_t(h));
308}
309
310
311////////////////////////////////////////////////////////////////////////////////
312/// Clear the current gVirtualX window.
313
315{
316 gVirtualX->ClearWindow();
317}
318
319
320////////////////////////////////////////////////////////////////////////////////
321/// Copy a gVirtualX pixmap.
322
324{
325 gVirtualX->CopyPixmap(device, px, py);
326}
327
328
329////////////////////////////////////////////////////////////////////////////////
330/// Close the current gVirtualX pixmap.
331
333{
334 gVirtualX->SelectWindow(device);
335 gVirtualX->ClosePixmap();
336}
337
338
339////////////////////////////////////////////////////////////////////////////////
340/// Select the window in which the graphics will go.
341
343{
344 gVirtualX->SelectWindow(device);
345}
346
347////////////////////////////////////////////////////////////////////////////////
348///Noop, for non-gl pad TASImage calls gVirtualX->CopyArea.
349
350void TPadPainter::DrawPixels(const unsigned char * /*pixelData*/, UInt_t /*width*/, UInt_t /*height*/,
351 Int_t /*dstX*/, Int_t /*dstY*/, Bool_t /*enableAlphaBlending*/)
352{
353}
354
355
356////////////////////////////////////////////////////////////////////////////////
357/// Paint a simple line.
358
360{
361 if (GetLineWidth()<=0) return;
362
363 const Int_t px1 = gPad->XtoPixel(x1);
364 const Int_t px2 = gPad->XtoPixel(x2);
365 const Int_t py1 = gPad->YtoPixel(y1);
366 const Int_t py2 = gPad->YtoPixel(y2);
367 gVirtualX->DrawLine(px1, py1, px2, py2);
368}
369
370
371////////////////////////////////////////////////////////////////////////////////
372/// Paint a simple line in normalized coordinates.
373
375{
376 if (GetLineWidth()<=0) return;
377
378 const Int_t px1 = gPad->UtoPixel(u1);
379 const Int_t py1 = gPad->VtoPixel(v1);
380 const Int_t px2 = gPad->UtoPixel(u2);
381 const Int_t py2 = gPad->VtoPixel(v2);
382 gVirtualX->DrawLine(px1, py1, px2, py2);
383}
384
385
386////////////////////////////////////////////////////////////////////////////////
387/// Paint a simple box.
388
390{
391 if (GetLineWidth()<=0 && mode == TVirtualPadPainter::kHollow) return;
392
393 Int_t px1 = gPad->XtoPixel(x1);
394 Int_t px2 = gPad->XtoPixel(x2);
395 Int_t py1 = gPad->YtoPixel(y1);
396 Int_t py2 = gPad->YtoPixel(y2);
397
398 // Box width must be at least one pixel (WTF is this code???)
399 if (TMath::Abs(px2 - px1) < 1)
400 px2 = px1 + 1;
401 if (TMath::Abs(py1 - py2) < 1)
402 py1 = py2 + 1;
403
404 gVirtualX->DrawBox(px1, py1, px2, py2, (TVirtualX::EBoxMode)mode);
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Paint filled area.
409
411{
412 if (nPoints < 3) {
413 ::Error("TPadPainter::DrawFillArea", "invalid number of points %d", nPoints);
414 return;
415 }
416
418}
419
420
421////////////////////////////////////////////////////////////////////////////////
422/// Paint filled area.
423
425{
426 if (nPoints < 3) {
427 ::Error("TPadPainter::DrawFillArea", "invalid number of points %d", nPoints);
428 return;
429 }
430
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Paint Polyline.
436
438{
439 if (GetLineWidth()<=0) return;
440
441 if (n < 2) {
442 ::Error("TPadPainter::DrawPolyLine", "invalid number of points");
443 return;
444 }
445
447}
448
449
450////////////////////////////////////////////////////////////////////////////////
451/// Paint polyline.
452
454{
455 if (GetLineWidth()<=0) return;
456
457 if (n < 2) {
458 ::Error("TPadPainter::DrawPolyLine", "invalid number of points");
459 return;
460 }
461
463}
464
465
466////////////////////////////////////////////////////////////////////////////////
467/// Paint polyline in normalized coordinates.
468
470{
471 if (GetLineWidth()<=0) return;
472
473 if (n < 2) {
474 ::Error("TPadPainter::DrawPolyLineNDC", "invalid number of points %d", n);
475 return;
476 }
477
478 std::vector<TPoint> xy(n);
479
480 for (Int_t i = 0; i < n; ++i) {
481 xy[i].fX = (SCoord_t)gPad->UtoPixel(u[i]);
482 xy[i].fY = (SCoord_t)gPad->VtoPixel(v[i]);
483 }
484
485 gVirtualX->DrawPolyLine(n, &xy[0]);
486}
487
488
489////////////////////////////////////////////////////////////////////////////////
490/// Paint polymarker.
491
493{
494 if (n < 1) {
495 ::Error("TPadPainter::DrawPolyMarker", "invalid number of points %d", n);
496 return;
497 }
498
500}
501
502
503////////////////////////////////////////////////////////////////////////////////
504/// Paint polymarker.
505
507{
508 if (n < 1) {
509 ::Error("TPadPainter::DrawPolyMarker", "invalid number of points %d", n);
510 return;
511 }
512
514}
515
516
517////////////////////////////////////////////////////////////////////////////////
518/// Paint text.
519
521{
522 const Int_t px = gPad->XtoPixel(x);
523 const Int_t py = gPad->YtoPixel(y);
524 const Double_t angle = GetTextAngle();
525 const Double_t mgn = GetTextMagnitude();
526 gVirtualX->DrawText(px, py, angle, mgn, text, (TVirtualX::ETextMode)mode);
527}
528
529
530////////////////////////////////////////////////////////////////////////////////
531/// Special version working with wchar_t and required by TMathText.
532
534{
535 const Int_t px = gPad->XtoPixel(x);
536 const Int_t py = gPad->YtoPixel(y);
537 const Double_t angle = GetTextAngle();
538 const Double_t mgn = GetTextMagnitude();
539 gVirtualX->DrawText(px, py, angle, mgn, text, (TVirtualX::ETextMode)mode);
540}
541
542
543////////////////////////////////////////////////////////////////////////////////
544/// Paint text in normalized coordinates.
545
547{
548 const Int_t px = gPad->UtoPixel(u);
549 const Int_t py = gPad->VtoPixel(v);
550 const Double_t angle = GetTextAngle();
551 const Double_t mgn = GetTextMagnitude();
552 gVirtualX->DrawText(px, py, angle, mgn, text, (TVirtualX::ETextMode)mode);
553}
554
555
556////////////////////////////////////////////////////////////////////////////////
557/// Save the image displayed in the canvas pointed by "pad" into a binary file.
558
559void TPadPainter::SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const
560{
561 if (gVirtualX->InheritsFrom("TGCocoa") && !gROOT->IsBatch() &&
562 pad->GetCanvas() && pad->GetCanvas()->GetCanvasID() != -1) {
563
564 TCanvas * const canvas = pad->GetCanvas();
565 //Force TCanvas::CopyPixmaps.
566 canvas->Flush();
567
568 const UInt_t w = canvas->GetWw();
569 const UInt_t h = canvas->GetWh();
570
571 const std::unique_ptr<unsigned char[]>
572 pixelData(gVirtualX->GetColorBits(canvas->GetCanvasID(), 0, 0, w, h));
573
574 if (pixelData.get()) {
575 const std::unique_ptr<TImage> image(TImage::Create());
576 if (image.get()) {
577 image->DrawRectangle(0, 0, w, h);
578 if (unsigned char *argb = (unsigned char *)image->GetArgbArray()) {
579 //Ohhh.
580 if (sizeof(UInt_t) == 4) {
581 //For sure the data returned from TGCocoa::GetColorBits,
582 //it's 4 * w * h bytes with what TASImage considers to be argb.
583 std::copy(pixelData.get(), pixelData.get() + 4 * w * h, argb);
584 } else {
585 //A bit paranoid, don't you think so?
586 //Will Quartz/TASImage work at all on such a fancy platform? ;)
587 const unsigned shift = std::numeric_limits<unsigned char>::digits;
588 //
589 unsigned *dstPixel = (unsigned *)argb, *end = dstPixel + w * h;
590 const unsigned char *srcPixel = pixelData.get();
591 for (;dstPixel != end; ++dstPixel, srcPixel += 4) {
592 //Looks fishy but should work, trust me :)
593 *dstPixel = srcPixel[0] & (srcPixel[1] << shift) &
594 (srcPixel[2] << 2 * shift) &
595 (srcPixel[3] << 3 * shift);
596 }
597 }
598
599 image->WriteImage(fileName, (TImage::EImageFileTypes)type);
600 //Success.
601 return;
602 }
603 }
604 }
605 }
606
607 if (type == TImage::kGif) {
608 gVirtualX->WriteGIF((char*)fileName);
609 } else {
610 const std::unique_ptr<TImage> img(TImage::Create());
611 if (img.get()) {
612 img->FromPad(pad);
613 img->WriteImage(fileName, (TImage::EImageFileTypes)type);
614 }
615 }
616}
617
618
619////////////////////////////////////////////////////////////////////////////////
620/// Paint text in normalized coordinates.
621
623{
624 const Int_t px = gPad->UtoPixel(u);
625 const Int_t py = gPad->VtoPixel(v);
626 const Double_t angle = GetTextAngle();
627 const Double_t mgn = GetTextMagnitude();
628 gVirtualX->DrawText(px, py, angle, mgn, text, (TVirtualX::ETextMode)mode);
629}
630
631//Aux. private functions.
632namespace {
633
634////////////////////////////////////////////////////////////////////////////////
635///I'm using 'pad' pointer to get rid of this damned gPad.
636///Unfortunately, TPadPainter itself still has to use it.
637///But at least this code does not have to be fixed.
638
639template<typename T>
640void ConvertPoints(TVirtualPad *pad, unsigned nPoints, const T *x, const T *y,
641 std::vector<TPoint> &dst)
642{
643 if (!nPoints)
644 return;
645
646 dst.resize(nPoints);
647
648 for (unsigned i = 0; i < nPoints; ++i) {
649 dst[i].fX = (SCoord_t)pad->XtoPixel(x[i]);
650 dst[i].fY = (SCoord_t)pad->YtoPixel(y[i]);
651 }
652}
653
654////////////////////////////////////////////////////////////////////////////////
655
656inline void MergePointsX(std::vector<TPoint> &points, unsigned nMerged, SCoord_t yMin,
658{
659 const auto firstPointX = points.back().fX;
660 const auto firstPointY = points.back().fY;
661
662 if (nMerged == 2) {
663 points.push_back(TPoint(firstPointX, yLast));//We have not merge anything.
664 } else if (nMerged == 3) {
665 yMin == firstPointY ? points.push_back(TPoint(firstPointX, yMax)) :
666 points.push_back(TPoint(firstPointX, yMin));
667 points.push_back(TPoint(firstPointX, yLast));
668 } else {
669 points.push_back(TPoint(firstPointX, yMin));
670 points.push_back(TPoint(firstPointX, yMax));
671 points.push_back(TPoint(firstPointX, yLast));
672 }
673}
674
675////////////////////////////////////////////////////////////////////////////////
676///Indices below are _valid_.
677
678inline size_type MergePointsInplaceY(std::vector<TPoint> &dst, size_type nMerged, SCoord_t xMin,
679 SCoord_t xMax, SCoord_t xLast, size_type first)
680{
681 const TPoint &firstPoint = dst[first];//This point is never updated.
682
683 if (nMerged == 2) {
684 dst[first + 1].fX = xLast;
685 dst[first + 1].fY = firstPoint.fY;
686 } else if (nMerged == 3) {
687 dst[first + 1].fX = xMin == firstPoint.fX ? xMax : xMin;
688 dst[first + 1].fY = firstPoint.fY;
689 dst[first + 2].fX = xLast;
690 dst[first + 2].fY = firstPoint.fY;
691 } else {
692 dst[first + 1].fX = xMin;
693 dst[first + 1].fY = firstPoint.fY;
694 dst[first + 2].fX = xMax;
695 dst[first + 2].fY = firstPoint.fY;
696 dst[first + 3].fX = xLast;
697 dst[first + 3].fY = firstPoint.fY;
698 nMerged = 4;//Adjust the shift.
699 }
700
701 return nMerged;
702}
703
704////////////////////////////////////////////////////////////////////////////////
705/// I'm using 'pad' pointer to get rid of this damned gPad.
706/// Unfortunately, TPadPainter itself still has to use it.
707/// But at least this code does not have to be fixed.
708
709template<typename T>
710void ConvertPointsAndMergePassX(TVirtualPad *pad, unsigned nPoints, const T *x, const T *y,
711 std::vector<TPoint> &dst)
712{
713 //The "first" pass along X axis.
715 SCoord_t yMin = 0, yMax = 0, yLast = 0;
716 unsigned nMerged = 0;
717
718 //The first pass along X.
719 for (unsigned i = 0; i < nPoints;) {
720 currentPoint.fX = (SCoord_t)pad->XtoPixel(x[i]);
721 currentPoint.fY = (SCoord_t)pad->YtoPixel(y[i]);
722
723 yMin = currentPoint.fY;
724 yMax = yMin;
725
726 dst.push_back(currentPoint);
727 bool merged = false;
728 nMerged = 1;
729
730 for (unsigned j = i + 1; j < nPoints; ++j) {
731 const SCoord_t newX = pad->XtoPixel(x[j]);
732
733 if (newX == currentPoint.fX) {
734 yLast = pad->YtoPixel(y[j]);
736 yMax = TMath::Max(yMax, yLast);//We continue.
737 ++nMerged;
738 } else {
739 if (nMerged > 1)
741 merged = true;
742 break;
743 }
744 }
745
746 if (!merged && nMerged > 1)
748
749 i += nMerged;
750 }
751}
752
753////////////////////////////////////////////////////////////////////////////////
754/// This pass is a bit more complicated, since we have to 'compact' in-place.
755
756void ConvertPointsAndMergeInplacePassY(std::vector<TPoint> &dst)
757{
758 size_type i = 0;
759 for (size_type j = 1, nPoints = dst.size(); i < nPoints;) {
760 //i is always less than j, so i is always valid here.
761 const TPoint &currentPoint = dst[i];
762
765 SCoord_t xLast = 0;
766
767 bool merged = false;
768 size_type nMerged = 1;
769
770 for (; j < nPoints; ++j) {
771 const TPoint &nextPoint = dst[j];
772
773 if (nextPoint.fY == currentPoint.fY) {
774 xLast = nextPoint.fX;
777 ++nMerged;//and we continue ...
778 } else {
779 if (nMerged > 1)
781 merged = true;
782 break;
783 }
784 }
785
786 if (!merged && nMerged > 1)
788
789 i += nMerged;
790
791 if (j < nPoints) {
792 dst[i] = dst[j];
793 ++j;
794 } else
795 break;
796 }
797
798 dst.resize(i);
799}
800
801////////////////////////////////////////////////////////////////////////////////
802/// This is a quite simple algorithm, using the fact, that after conversion many
803/// subsequent vertices can have the same 'x' or 'y' coordinate and this part of
804/// a polygon will look like a line on the screen.
805
806template<typename T>
807void ConvertPointsAndMerge(TVirtualPad *pad, unsigned threshold, unsigned nPoints, const T *x,
808 const T *y, std::vector<TPoint> &dst)
809{
810 //I'm using 'pad' pointer to get rid of this damned gPad.
811 //Unfortunately, TPadPainter itself still has to use it.
812 //But at least this code does not have to be fixed.
813
814 if (!nPoints)
815 return;
816
817 dst.clear();
818 dst.reserve(threshold);
819
821
822 if (dst.size() < threshold)
823 return;
824
826}
827
828////////////////////////////////////////////////////////////////////////////////
829
830template<class T>
831void DrawFillAreaAux(TVirtualPad *pad, Int_t nPoints, const T *xs, const T *ys)
832{
833 std::vector<TPoint> xy;
834
835 const Int_t threshold = Int_t(TMath::Min(pad->GetWw() * pad->GetAbsWNDC(),
836 pad->GetWh() * pad->GetAbsHNDC())) * 2;
837
838 if (threshold <= 0) {
839 //Ooops, pad is invisible or something really bad and stupid happened.
840 ::Error("DrawFillAreaAux", "invalid pad's geometry");
841 return;
842 }
843
844 if (nPoints < threshold)
846 else
848
849 //We close the 'polygon' and it'll be rendered as a polyline by gVirtualX.
850 if (!gVirtualX->GetFillStyle())
851 xy.push_back(xy.front());
852
853 if (xy.size() > 2)
854 gVirtualX->DrawFillArea(xy.size(), &xy[0]);
855}
856
857////////////////////////////////////////////////////////////////////////////////
858
859template<typename T>
860void DrawPolyLineAux(TVirtualPad *pad, unsigned nPoints, const T *xs, const T *ys)
861{
862 std::vector<TPoint> xy;
863
864 const Int_t threshold = Int_t(TMath::Min(pad->GetWw() * pad->GetAbsWNDC(),
865 pad->GetWh() * pad->GetAbsHNDC())) * 2;
866
867 if (threshold <= 0) {//Ooops, pad is invisible or something really bad and stupid happened.
868 ::Error("DrawPolyLineAux", "invalid pad's geometry");
869 return;
870 }
871
872 if (nPoints < (unsigned)threshold)
874 else
876
877 if (xy.size() > 1)
878 gVirtualX->DrawPolyLine(xy.size(), &xy[0]);
879
880}
881
882////////////////////////////////////////////////////////////////////////////////
883
884template<class T>
885void DrawPolyMarkerAux(TVirtualPad *pad, unsigned nPoints, const T *xs, const T *ys)
886{
887 std::vector<TPoint> xy(nPoints);
888
889 for (unsigned i = 0; i < nPoints; ++i) {
890 xy[i].fX = (SCoord_t)pad->XtoPixel(xs[i]);
891 xy[i].fY = (SCoord_t)pad->YtoPixel(ys[i]);
892 }
893
894 gVirtualX->DrawPolyMarker(nPoints, &xy[0]);
895}
896
897}
#define h(i)
Definition RSha256.hxx:106
short Style_t
Style number (short)
Definition RtypesCore.h:96
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
short Width_t
Line width (short)
Definition RtypesCore.h:98
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Font_t
Font number (short)
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
short SCoord_t
Screen coordinates (short)
Definition RtypesCore.h:100
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
Option_t Option_t mgn
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 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 text
Option_t Option_t TPoint TPoint const char y1
#define gROOT
Definition TROOT.h:411
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
The Canvas class.
Definition TCanvas.h:23
Int_t GetCanvasID() const override
Definition TCanvas.h:157
UInt_t GetWw() const override
Definition TCanvas.h:163
UInt_t GetWh() const override
Definition TCanvas.h:164
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1143
EImageFileTypes
Definition TImage.h:36
@ kGif
Definition TImage.h:48
static TImage * Create()
Create an image.
Definition TImage.cxx:34
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.
Color_t GetFillColor() const override
Delegate to gVirtualX.
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.
Float_t GetTextAngle() const override
Delegate to gVirtualX.
void CopyDrawable(Int_t device, Int_t px, Int_t py) override
Copy a gVirtualX pixmap.
void SetFillColor(Color_t fcolor) override
Delegate to gVirtualX.
Float_t GetTextSize() const override
Delegate to gVirtualX.
Style_t GetFillStyle() const override
Delegate to gVirtualX.
void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override
Paint Polyline.
Short_t GetTextAlign() const override
Delegate to gVirtualX.
Style_t GetLineStyle() const override
Delegate to gVirtualX.
Bool_t IsTransparent() const override
Delegate to gVirtualX.
Float_t GetTextMagnitude() const override
Delegate to gVirtualX.
Color_t GetTextColor() const override
Delegate to gVirtualX.
Int_t CreateDrawable(UInt_t w, UInt_t h) override
Create a gVirtualX Pixmap.
void SetTextSize(Float_t tsize) override
Delegate to gVirtualX.
void SetTextAlign(Short_t align) override
Delegate to gVirtualX.
void SetFillStyle(Style_t fstyle) override
Delegate to gVirtualX.
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.
void SetTextAngle(Float_t tangle) override
Delegate to gVirtualX.
void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override
Paint text in normalized coordinates.
void SetTextFont(Font_t tfont) override
Delegate to gVirtualX.
void SaveImage(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 SetLineStyle(Style_t lstyle) override
Delegate to gVirtualX.
Font_t GetTextFont() const override
Delegate to gVirtualX.
void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override
Paint polyline in normalized coordinates.
void ClearDrawable() override
Clear the current gVirtualX window.
void DestroyDrawable(Int_t device) override
Close the current gVirtualX pixmap.
Width_t GetLineWidth() const override
Delegate to gVirtualX.
void SetTextColor(Color_t tcolor) override
Delegate to gVirtualX.
void SetLineWidth(Width_t lwidth) override
Delegate to gVirtualX.
void SetTextSizePixels(Int_t npixels) override
Delegate to gVirtualX.
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 SetLineColor(Color_t lcolor) override
Delegate to gVirtualX.
Color_t GetLineColor() const override
Delegate to gVirtualX.
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Paint a simple line.
void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Paint a simple line in normalized coordinates.
void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override
Paint text.
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
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
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:251
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124