39 std::vector<Double_t> fXs1;
40 std::vector<Double_t> fYs1;
43 std::vector<Double_t> fXs2;
44 std::vector<Double_t> fYs2;
48PolyTest2::PolyTest2() :
TNamed(
"polygon_compression_test2",
"polygon_compression_test2")
54 assert(
gPad !=
nullptr &&
"PolyTest2, gPad is null");
56 assert(
gRandom !=
nullptr &&
"PolyTest2, gRandom is null");
58 Double_t xMin = 0., xMax = 0., yMin = 0., yMax = 0.;
59 gPad->GetRange(xMin, yMin, xMax, yMax);
60 assert(xMax - xMin > 0 && yMax - yMin > 0 &&
"PolyTest2, invalid canvas' ranges");
68 const unsigned nVertices = 3 + kNSawPoints;
72 fXs1.resize(nVertices);
73 fYs1.resize(nVertices);
78 const Double_t w1 = 0.2 * (xMax - xMin);
79 const Double_t saw1ToothSize = 0.1 * w1;
80 const Double_t yStep = (yMax - yMin) / (kNSawPoints - 1);
82 for (
unsigned i = 1; i <= kNSawPoints; ++i) {
83 fXs1[i] = w1 +
gRandom->Rndm() * saw1ToothSize;
84 fYs1[i] = yMin + yStep * (i - 1);
87 fXs1[nVertices - 2] = 0.;
88 fYs1[nVertices - 2] = yMax;
90 fXs1[nVertices - 1] = fXs1[0];
91 fYs1[nVertices - 1] = fYs1[0];
97 const Double_t x2Min = xMin + 0.25 * (xMax - xMin);
98 const Double_t h2 = 0.1 * (yMax - yMin);
99 const Double_t saw2ToothSize = 0.1 * h2;
100 const Double_t xStep = (xMax - x2Min) / (kNSawPoints - 1);
102 fXs2.resize(nVertices);
103 fYs2.resize(nVertices);
108 for (
unsigned i = 1; i <= kNSawPoints; ++i) {
109 fXs2[i] = x2Min + xStep * i;
110 fYs2[i] = h2 +
gRandom->Rndm() * saw2ToothSize;
113 fXs2[nVertices - 2] = xMax;
114 fYs2[nVertices - 2] = 0.;
115 fXs2[nVertices - 1] = fXs2[0];
116 fYs2[nVertices - 1] = fYs2[0];
121void PolyTest2::Paint(
const Option_t * )
123 assert(
gPad !=
nullptr &&
"Paint, gPad is null");
127 gPad->PaintFillArea((
Int_t)fXs1.size(), &fXs1[0], &fYs1[0]);
131 gPad->PaintPolyLine((
Int_t)fXs1.size(), &fXs1[0], &fYs1[0]);
135 gPad->PaintFillArea((
Int_t)fXs2.size(), &fXs2[0], &fYs2[0]);
139 gPad->PaintPolyLine((
Int_t)fXs2.size(), &fXs2[0], &fYs2[0]);
147 PolyTest2 *polygon =
new PolyTest2;
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
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.