#include "Riostream.h"
#include "TROOT.h"
#include "TCrown.h"
#include "TVirtualPad.h"
ClassImp(TCrown)
//Begin_Html
/*
<img src="gif/crown.gif">
*/
//End_Html
TCrown::TCrown(): TEllipse()
{
}
TCrown::TCrown(Double_t x1, Double_t y1,Double_t radin, Double_t radout,Double_t phimin,Double_t phimax)
:TEllipse(x1,y1,radin,radout,phimin,phimax,0)
{
}
TCrown::TCrown(const TCrown &crown) : TEllipse(crown)
{
((TCrown&)crown).Copy(*this);
}
TCrown::~TCrown()
{
}
void TCrown::Copy(TObject &crown) const
{
TEllipse::Copy(crown);
}
Int_t TCrown::DistancetoPrimitive(Int_t px, Int_t py)
{
const Double_t kPI = TMath::Pi();
Double_t x = gPad->AbsPixeltoX(px) - GetX1();
Double_t y = gPad->AbsPixeltoY(py) - GetY1();
Double_t r = TMath::Sqrt(x*x+y*y);
Int_t dist = 9999;
if (r > fR2) return dist;
if (r < fR1) return dist;
if (fPhimax-fPhimin < 360) {
Double_t phi = 180*TMath::ACos(x/r)/kPI;
if (phi < fPhimin) return dist;
if (phi > fPhimax) return dist;
}
if (GetFillColor() && GetFillStyle()) {
return 0;
} else {
if (TMath::Abs(fR2-r)/fR2 < 0.02) return 0;
if (TMath::Abs(fR1-r)/fR1 < 0.02) return 0;
}
return dist;
}
void TCrown::DrawCrown(Double_t x1, Double_t y1,Double_t radin,Double_t radout,Double_t phimin,Double_t phimax,Option_t *option)
{
TCrown *newcrown = new TCrown(x1, y1, radin, radout, phimin, phimax);
TAttLine::Copy(*newcrown);
TAttFill::Copy(*newcrown);
newcrown->AppendPad(option);
}
void TCrown::ExecuteEvent(Int_t event, Int_t px, Int_t py)
{
TEllipse::ExecuteEvent(event,px,py);
}
void TCrown::Paint(Option_t *)
{
const Double_t kPI = TMath::Pi();
const Int_t np = 40;
static Double_t x[2*np+3], y[2*np+3];
TAttLine::Modify();
TAttFill::Modify();
Double_t angle,dx,dy;
Double_t dphi = (fPhimax-fPhimin)*kPI/(180*np);
Double_t ct = TMath::Cos(kPI*fTheta/180);
Double_t st = TMath::Sin(kPI*fTheta/180);
Int_t i;
for (i=0;i<=np;i++) {
angle = fPhimin*kPI/180 + Double_t(i)*dphi;
dx = fR2*TMath::Cos(angle);
dy = fR2*TMath::Sin(angle);
x[i] = fX1 + dx*ct - dy*st;
y[i] = fY1 + dx*st + dy*ct;
}
for (i=0;i<=np;i++) {
angle = fPhimin*kPI/180 + Double_t(i)*dphi;
dx = fR1*TMath::Cos(angle);
dy = fR1*TMath::Sin(angle);
x[2*np-i+1] = fX1 + dx*ct - dy*st;
y[2*np-i+1] = fY1 + dx*st + dy*ct;
}
x[2*np+2] = x[0];
y[2*np+2] = y[0];
if (fPhimax-fPhimin >= 360 ) {
if (GetFillColor() && GetFillStyle()) {
gPad->PaintFillArea(2*np+2,x,y);
}
if (GetLineStyle()) {
gPad->PaintPolyLine(np+1,x,y);
gPad->PaintPolyLine(np+1,&x[np+1],&y[np+1]);
}
} else {
if (GetFillColor() && GetFillStyle()) gPad->PaintFillArea(2*np+2,x,y);
if (GetLineStyle()) gPad->PaintPolyLine(2*np+3,x,y);
}
}
void TCrown::SavePrimitive(ostream &out, Option_t * )
{
out<<" "<<endl;
if (gROOT->ClassSaved(TCrown::Class())) {
out<<" ";
} else {
out<<" TCrown *";
}
out<<"crown = new TCrown("<<fX1<<","<<fY1<<","<<fR1<<","<<fR2
<<","<<fPhimin<<","<<fPhimax<<");"<<endl;
SaveFillAttributes(out,"crown",0,1001);
SaveLineAttributes(out,"crown",1,1,1);
if (GetNoEdges()) out<<" crown->SetNoEdges();"<<endl;
out<<" crown->Draw();"<<endl;
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.