/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ // $Id$ // $MpId: AliMpSubZonePainter.cxx,v 1.6 2005/08/26 15:43:36 ivana Exp $ // 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 constructor } //_______________________________________________________________________ AliMpSubZonePainter::AliMpSubZonePainter(AliMpSubZone *subZone) : AliMpVPainter(), fSubZone(subZone) { /// Standard constructor } //_____________________________________________________________________________ AliMpSubZonePainter::AliMpSubZonePainter(const AliMpSubZonePainter& right) : AliMpVPainter(right) { /// Protected copy constructor (not provided) Fatal("AliMpSubZonePainter", "Copy constructor not provided."); } //_______________________________________________________________________ AliMpSubZonePainter::~AliMpSubZonePainter() { /// Destructor } //_____________________________________________________________________________ AliMpSubZonePainter& AliMpSubZonePainter::operator=(const AliMpSubZonePainter& right) { /// Assignment operator (not provided) // check assignment to self if (this == &right) return *this; Fatal("operator =", "Assignment 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