27 class PolyTest2 :
public TNamed,
public TAttLine,
public TAttFill {
31 void Paint(
const Option_t *notUsed);
39 std::vector<Double_t> fXs1;
40 std::vector<Double_t> fYs1;
43 std::vector<Double_t> fXs2;
44 std::vector<Double_t> fYs2;
48 PolyTest2::PolyTest2()
49 : TNamed(
"polygon_compression_test2",
"polygon_compression_test2")
55 assert(gPad != 0 &&
"PolyTest2, gPad is null");
57 assert(gRandom != 0 &&
"PolyTest2, gRandom is null");
59 Double_t xMin = 0., xMax = 0., yMin = 0., yMax = 0.;
60 gPad->GetRange(xMin, yMin, xMax, yMax);
61 assert(xMax - xMin > 0 && yMax - yMin > 0 &&
"PolyTest2, invalid canvas' ranges");
70 const unsigned nVertices = 3 + kNSawPoints;
74 fXs1.resize(nVertices);
75 fYs1.resize(nVertices);
80 const Double_t w1 = 0.2 * (xMax - xMin);
81 const Double_t saw1ToothSize = 0.1 * w1;
82 const Double_t yStep = (yMax - yMin) / (kNSawPoints - 1);
84 for (
unsigned i = 1; i <= kNSawPoints; ++i) {
85 fXs1[i] = w1 + gRandom->Rndm() * saw1ToothSize;
86 fYs1[i] = yMin + yStep * (i - 1);
89 fXs1[nVertices - 2] = 0.;
90 fYs1[nVertices - 2] = yMax;
92 fXs1[nVertices - 1] = fXs1[0];
93 fYs1[nVertices - 1] = fYs1[0];
100 const Double_t x2Min = xMin + 0.25 * (xMax - xMin);
101 const Double_t h2 = 0.1 * (yMax - yMin);
102 const Double_t saw2ToothSize = 0.1 * h2;
103 const Double_t xStep = (xMax - x2Min) / (kNSawPoints - 1);
105 fXs2.resize(nVertices);
106 fYs2.resize(nVertices);
111 for (
unsigned i = 1; i <= kNSawPoints; ++i) {
112 fXs2[i] = x2Min + xStep * i;
113 fYs2[i] = h2 + gRandom->Rndm() * saw2ToothSize;
116 fXs2[nVertices - 2] = xMax;
117 fYs2[nVertices - 2] = 0.;
118 fXs2[nVertices - 1] = fXs2[0];
119 fYs2[nVertices - 1] = fYs2[0];
124 void PolyTest2::Paint(
const Option_t * )
126 assert(gPad != 0 &&
"Paint, gPad is null");
128 SetFillColor(kGreen);
130 gPad->PaintFillArea((Int_t)fXs1.size(), &fXs1[0], &fYs1[0]);
134 gPad->PaintPolyLine((Int_t)fXs1.size(), &fXs1[0], &fYs1[0]);
136 SetFillColor(kOrange);
138 gPad->PaintFillArea((Int_t)fXs2.size(), &fXs2[0], &fYs2[0]);
140 SetLineColor(kMagenta);
142 gPad->PaintPolyLine((Int_t)fXs2.size(), &fXs2[0], &fYs2[0]);
147 TCanvas *
const cnv =
new TCanvas;
150 PolyTest2 * polygon =
new PolyTest2;