34 PolyTest1(
unsigned nVertices);
37 void Reset(
unsigned nVertices);
41 kNPointsDefault = 10000
44 std::vector<Double_t> fXs;
45 std::vector<Double_t> fYs;
49PolyTest1::PolyTest1(
unsigned nVertices)
50 :
TNamed(
"polygon_compression_test1",
"polygon_compression_test1")
56void PolyTest1::Reset(
unsigned nVertices)
59 assert(
gPad !=
nullptr &&
"Reset, gPad is null");
61 assert(
gRandom !=
nullptr &&
"Reset, gRandom is null");
63 if (nVertices < kNPointsDefault) {
64 Warning(
"Reset",
"resetting nVertices parameter to %u",
unsigned(kNPointsDefault));
65 nVertices = kNPointsDefault;
68 fXs.resize(nVertices);
69 fYs.resize(nVertices);
71 Double_t xMin = 0., xMax = 0., yMin = 0., yMax = 0.;
72 gPad->GetRange(xMin, yMin, xMax, yMax);
73 assert(xMax - xMin > 0 && yMax - yMin > 0 &&
"Reset, invalid canvas' ranges");
75 const Double_t xCentre = xMin + 0.5 * (xMax - xMin);
76 const Double_t yCentre = yMin + 0.5 * (yMax - yMin);
81 for (
unsigned i = 0; i < nVertices - 1; ++i) {
87 fXs[nVertices - 1] = fXs[0];
88 fYs[nVertices - 1] = fYs[0];
92void PolyTest1::Paint(
const Option_t * )
94 assert(
gPad !=
nullptr &&
"Paint, gPad is null");
97 gPad->PaintFillArea((
Int_t)fXs.size(), &fXs[0], &fYs[0]);
100 gPad->PaintPolyLine((
Int_t)fXs.size(), &fXs[0], &fYs[0]);
108 PolyTest1 * polygon =
new PolyTest1(1000000);
109 polygon->SetLineColor(
kBlue);
110 polygon->SetFillColor(
kRed);
111 polygon->SetLineWidth(1);
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
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 angle
R__EXTERN TRandom * gRandom
Fill Area Attributes class.
virtual void Modify()
Change current fill area attributes if necessary.
virtual void Modify()
Change current line attributes if necessary.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
The TNamed class is the base class for all named ROOT classes.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
Double_t Rndm() override
Machine independent random number generator.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
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 TwoPi()