34 PolyTest1(
unsigned nVertices);
37 void Reset(
unsigned nVertices);
41 kNPointsDefault = 10000
44 std::vector<Double_t> fXs;
45 std::vector<Double_t> fYs;
49 PolyTest1::PolyTest1(
unsigned nVertices)
50 :
TNamed(
"polygon_compression_test1",
"polygon_compression_test1")
59 assert(
gPad != 0 &&
"Reset, gPad is null");
61 assert(
gRandom != 0 &&
"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) {
83 fXs[i] = xCentre + currR *
TMath::Cos(angle * i);
84 fYs[i] = yCentre + currR *
TMath::Sin(angle * i);
87 fXs[nVertices - 1] = fXs[0];
88 fYs[nVertices - 1] = fYs[0];
92 void PolyTest1::Paint(
const Option_t * )
94 assert(
gPad != 0 &&
"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);
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Short_t Min(Short_t a, Short_t b)
virtual void Modify()
Change current line attributes if necessary.
Fill Area Attributes class.
The TNamed class is the base class for all named ROOT classes.
virtual void Modify()
Change current fill area attributes if necessary.
virtual Double_t Rndm()
Machine independent random number generator.
void Reset(Detail::TBranchProxy *x)
void Warning(const char *location, const char *msgfmt,...)
R__EXTERN TRandom * gRandom
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.