1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include "AliMpIteratorPainter.h"
20 #include "AliMpVPadIterator.h"
22 #include "AliMpGraphContext.h"
26 #include "TObjArray.h"
27 #include "TVirtualX.h"
28 #include "TVirtualPad.h"
33 /// \class AliMpIteratorPainter
35 /// A painter for a group of pads, which is defined by an iterator
38 /// \author L. Aphecetche
41 ClassImp(AliMpIteratorPainter)
44 //_____________________________________________________________________________
45 AliMpIteratorPainter::AliMpIteratorPainter(AliMpVPadIterator *it)
46 : AliMpVPainter(), fPads(new TObjArray), fPosition(), fDimensions()
48 /// Ctor. Iterator must not be null.
52 AliFatal("Iterator must not be null.");;
55 Double_t xmin(1E9), xmax(-1E9);
56 Double_t ymin(1E9), ymax(-1E9);
58 fPads->SetOwner(kTRUE);
60 while ( !it->IsDone() )
62 AliMpPad pad = it->CurrentItem();
63 fPads->AddLast(new AliMpPad(pad));
64 TVector2 lowerLeft(pad.Position()-pad.Dimensions());
65 TVector2 upperRight(pad.Position()+pad.Dimensions());
66 xmin = TMath::Min(lowerLeft.X(),xmin);
67 ymin = TMath::Min(lowerLeft.Y(),ymin);
68 xmax = TMath::Max(upperRight.X(),xmax);
69 ymax = TMath::Max(upperRight.Y(),ymax);
72 fPosition = TVector2((xmin+xmax)/2.0,(ymin+ymax)/2.0);
73 fDimensions = TVector2((xmax-xmin)/2.0,(ymax-ymin)/2.0);
76 //_____________________________________________________________________________
77 AliMpIteratorPainter::~AliMpIteratorPainter()
83 //_____________________________________________________________________________
85 AliMpIteratorPainter::Draw(Option_t* option)
87 /// Append ourselves to the current graphic pad
88 AliMpGraphContext *gr = AliMpGraphContext::Instance();
91 gr->SetPadPosForReal(GetPosition(),GetDimensions());
96 //_____________________________________________________________________________
98 AliMpIteratorPainter::Paint(Option_t*)
100 /// Actual drawing method
102 AliMpGraphContext* gr = AliMpGraphContext::Instance();
105 gPad->Range(0.,0.,1.,1.);
110 while ( ( pad = static_cast<AliMpPad*>(next()) ) )
115 gr->RealToPad(pad->Position(),
120 TVector2 bl = padPadPos - padPadDim;
121 TVector2 ur = padPadPos + padPadDim;
123 Int_t manuId = pad->GetLocation().GetFirst();
125 Style_t sty = gVirtualX->GetFillStyle();
127 gVirtualX->SetFillStyle(1);
129 gVirtualX->SetFillColor(0);
131 gVirtualX->SetFillColor(38);
133 gVirtualX->SetFillColor(33);
135 gVirtualX->SetFillColor(16);
137 gVirtualX->SetFillColor(44);
139 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
140 gVirtualX->SetFillStyle(0);
141 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
142 gVirtualX->SetFillStyle(sty);
144 Float_t textSize = gVirtualX->GetTextSize();
145 gVirtualX->SetTextSize(10);
146 gVirtualX->SetTextAlign(22);
147 gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0,
148 Form("%d",pad->GetLocation().GetSecond()));
150 gVirtualX->SetTextSize(textSize);