// $Id$ // Category: graphics // // Class AliMpZonePainter // ---------------------- // Class for drawing a zone into canvas // Included in AliRoot: 2003/05/02 // Authors: David Guez, IPN Orsay #include #include #include #include "AliMpZonePainter.h" #include "AliMpGraphContext.h" #include "AliMpZone.h" #include "AliMpSubZone.h" #include "AliMpVRowSegment.h" ClassImp(AliMpZonePainter) //_______________________________________________________________________ AliMpZonePainter::AliMpZonePainter() : AliMpVPainter(), fZone(0) { // default dummy constructor } //_______________________________________________________________________ AliMpZonePainter::AliMpZonePainter(AliMpZone *zone) : AliMpVPainter(), fZone(zone) { // normal constructor } //_____________________________________________________________________________ AliMpZonePainter::AliMpZonePainter(const AliMpZonePainter& right) : AliMpVPainter(right) { // copy constructor (not implemented) Fatal("AliMpZonePainter", "Copy constructor not provided."); } //_______________________________________________________________________ AliMpZonePainter::~AliMpZonePainter() { // destructor } //_____________________________________________________________________________ AliMpZonePainter& AliMpZonePainter::operator=(const AliMpZonePainter& right) { // assignement operator (not implemented) // check assignement to self if (this == &right) return *this; Fatal("operator =", "Assignement operator not provided."); return *this; } //_______________________________________________________________________ Int_t AliMpZonePainter::DistancetoPrimitive(Int_t x, Int_t y) { // dist to the nearest segment center if (x,y) is inside the zone // 9999 otherwise if (fZone->GetNofSubZones()<1) return 9999; AliMpGraphContext *gr = AliMpGraphContext::Instance(); gr->Push(); InitGraphContext(); TVector2 point = TVector2(gPad->AbsPixeltoX(x), gPad->AbsPixeltoY(y)); Double_t res=9999.; for (Int_t isub=0;isubGetNofSubZones();++isub){ // for each sub-zones AliMpSubZone* sub = fZone->GetSubZone(isub); for (Int_t iseg=0;isegGetNofRowSegments();++iseg){ //for each row segments AliMpVRowSegment* seg = sub->GetRowSegment(iseg); TVector2 pos,dim; gr->RealToPad(seg->Position(),seg->Dimensions(),pos,dim); if ( IsInside(point,pos,dim) ){ Double_t value = (point-pos).Mod(); if (valuePop(); return (Int_t)res; } //_______________________________________________________________________ void AliMpZonePainter::DumpObject() { // Draw the owned object fZone->Dump(); } //_______________________________________________________________________ TVector2 AliMpZonePainter::GetPosition() const { // Get the owned object's position if (fZone->GetNofSubZones()<1) return TVector2(0.,0.); TVector2 bl(9999,9999),ur(-9999,-9999); for (Int_t isub=0;isubGetNofSubZones();++isub){ // for each sub-zones AliMpSubZone* sub = fZone->GetSubZone(isub); for (Int_t iseg=0;isegGetNofRowSegments();++iseg){ //for each row segments AliMpVRowSegment* seg = sub->GetRowSegment(iseg); // update the bottom-left corner if (bl.X()>seg->Position().X()-seg->Dimensions().X()) bl.Set(seg->Position().X()-seg->Dimensions().X(),bl.Y()); if (bl.Y()>seg->Position().Y()-seg->Dimensions().Y()) bl.Set(bl.X(),seg->Position().Y()-seg->Dimensions().Y()); // update the upper-right corner if (ur.X()Position().X()+seg->Dimensions().X()) ur.Set(seg->Position().X()+seg->Dimensions().X(),ur.Y()); if (ur.Y()Position().Y()+seg->Dimensions().Y()) ur.Set(ur.X(),seg->Position().Y()+seg->Dimensions().Y()); } //iseg } //isub return (ur+bl)/2.; } //_______________________________________________________________________ TVector2 AliMpZonePainter::GetDimensions() const { // Get the owned object's dimensions if (fZone->GetNofSubZones()<1) return TVector2(0.,0.); TVector2 bl(9999,9999),ur(-9999,-9999); for (Int_t isub=0;isubGetNofSubZones();++isub){ // for each sub-zones AliMpSubZone* sub = fZone->GetSubZone(isub); for (Int_t iseg=0;isegGetNofRowSegments();++iseg){ //for each row segments AliMpVRowSegment* seg = sub->GetRowSegment(iseg); // update the bottom-left corner if (bl.X()>seg->Position().X()-seg->Dimensions().X()) bl.Set(seg->Position().X()-seg->Dimensions().X(),bl.Y()); if (bl.Y()>seg->Position().Y()-seg->Dimensions().Y()) bl.Set(bl.X(),seg->Position().Y()-seg->Dimensions().Y()); // update the upper-right corner if (ur.X()Position().X()+seg->Dimensions().X()) ur.Set(seg->Position().X()+seg->Dimensions().X(),ur.Y()); if (ur.Y()Position().Y()+seg->Dimensions().Y()) ur.Set(ur.X(),seg->Position().Y()+seg->Dimensions().Y()); } //iseg } //isub return (ur-bl)/2.; } //_______________________________________________________________________ void AliMpZonePainter::Draw(Option_t *option) { // Draw the sector on the current pad // The first letter of