// $Id$ // Category: graphics // // Class AliMpSubZonePainter // ------------------------- // Class for drawing a subzone into canvas // Included in AliRoot: 2003/05/02 // Authors: David Guez, IPN Orsay #include #include #include #include "AliMpSubZonePainter.h" #include "AliMpGraphContext.h" #include "AliMpSubZone.h" #include "AliMpVRowSegment.h" #include "AliMpVMotif.h" ClassImp(AliMpSubZonePainter) //_______________________________________________________________________ AliMpSubZonePainter::AliMpSubZonePainter() : AliMpVPainter(), fSubZone(0) { // default dummy constructor } //_______________________________________________________________________ AliMpSubZonePainter::AliMpSubZonePainter(AliMpSubZone *subZone) : AliMpVPainter(), fSubZone(subZone) { // normal constructor } //_____________________________________________________________________________ AliMpSubZonePainter::AliMpSubZonePainter(const AliMpSubZonePainter& right) : AliMpVPainter(right) { // copy constructor (not implemented) Fatal("AliMpSubZonePainter", "Copy constructor not provided."); } //_______________________________________________________________________ AliMpSubZonePainter::~AliMpSubZonePainter() { // destructor } //_____________________________________________________________________________ AliMpSubZonePainter& AliMpSubZonePainter::operator=(const AliMpSubZonePainter& right) { // assignement operator (not implemented) // check assignement to self if (this == &right) return *this; Fatal("operator =", "Assignement operator not provided."); return *this; } //_______________________________________________________________________ Int_t AliMpSubZonePainter::DistancetoPrimitive(Int_t x, Int_t y) { // dist to the nearest segment center if (x,y) is inside the sub-zone // 9999 otherwise if (fSubZone->GetNofRowSegments()<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 iseg=0;isegGetNofRowSegments();++iseg){ //for each row segments AliMpVRowSegment* seg = fSubZone->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 AliMpSubZonePainter::DumpObject() { // Draw the owned object fSubZone->Dump(); } //_______________________________________________________________________ TVector2 AliMpSubZonePainter::GetPosition() const { // Get the owned object's position if (fSubZone->GetNofRowSegments()<1) return TVector2(0.,0.); AliMpVRowSegment* seg = fSubZone->GetRowSegment(0); // bl = bottom left position; TVector2 bl = seg->Position()-seg->Dimensions(); // ur = upper right position TVector2 ur = seg->Position()+seg->Dimensions(); for (Int_t iseg=1;isegGetNofRowSegments();++iseg){ seg = fSubZone->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()); } return (ur+bl)/2.; } //_______________________________________________________________________ TVector2 AliMpSubZonePainter::GetDimensions() const { // Get the owned object's dimensions if (fSubZone->GetNofRowSegments()<1) return TVector2(0.,0.); AliMpVRowSegment* seg = fSubZone->GetRowSegment(0); // bl = bottom left position; TVector2 bl = seg->Position()-seg->Dimensions(); // ur = upper right position TVector2 ur = seg->Position()+seg->Dimensions(); for (Int_t iseg=1;isegGetNofRowSegments();++iseg){ seg = fSubZone->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()); } return (ur-bl)/2.; } //_______________________________________________________________________ void AliMpSubZonePainter::Draw(Option_t *option) { // Draw the sector on the current pad // The first letter of