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"
32 //-----------------------------------------------------------------------------
33 /// \class AliMpIteratorPainter
35 /// A painter for a group of pads, which is defined by an iterator
38 /// \author L. Aphecetche
39 //-----------------------------------------------------------------------------
42 ClassImp(AliMpIteratorPainter)
45 //_____________________________________________________________________________
46 AliMpIteratorPainter::AliMpIteratorPainter(AliMpVPadIterator *it)
47 : AliMpVPainter(), fPads(new TObjArray), fPosition(), fDimensions()
49 /// Ctor. Iterator must not be null.
53 AliFatal("Iterator must not be null.");;
56 Double_t xmin(1E9), xmax(-1E9);
57 Double_t ymin(1E9), ymax(-1E9);
59 fPads->SetOwner(kTRUE);
61 while ( !it->IsDone() )
63 AliMpPad pad = it->CurrentItem();
64 fPads->AddLast(new AliMpPad(pad));
65 TVector2 lowerLeft(TVector2(pad.GetPositionX(),pad.GetPositionY())-
66 TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
67 TVector2 upperRight(TVector2(pad.GetPositionX(),pad.GetPositionY())+
68 TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
69 xmin = TMath::Min(lowerLeft.X(),xmin);
70 ymin = TMath::Min(lowerLeft.Y(),ymin);
71 xmax = TMath::Max(upperRight.X(),xmax);
72 ymax = TMath::Max(upperRight.Y(),ymax);
75 fPosition = TVector2((xmin+xmax)/2.0,(ymin+ymax)/2.0);
76 fDimensions = TVector2((xmax-xmin)/2.0,(ymax-ymin)/2.0);
79 //_____________________________________________________________________________
80 AliMpIteratorPainter::~AliMpIteratorPainter()
86 //_____________________________________________________________________________
88 AliMpIteratorPainter::Draw(Option_t* option)
90 /// Append ourselves to the current graphic pad
91 AliMpGraphContext *gr = AliMpGraphContext::Instance();
94 gr->SetPadPosForReal(GetPosition(),GetDimensions());
99 //_____________________________________________________________________________
101 AliMpIteratorPainter::Paint(Option_t*)
103 /// Actual drawing method
105 AliMpGraphContext* gr = AliMpGraphContext::Instance();
108 gPad->Range(0.,0.,1.,1.);
113 while ( ( pad = static_cast<AliMpPad*>(next()) ) )
118 gr->RealToPad(TVector2(pad->GetPositionX(),
119 pad->GetPositionY()),
120 TVector2(pad->GetDimensionX(),
121 pad->GetDimensionY()),
122 padPadPos, padPadDim);
124 TVector2 bl = padPadPos - padPadDim;
125 TVector2 ur = padPadPos + padPadDim;
127 Int_t manuId = pad->GetManuId();
129 Style_t sty = gVirtualX->GetFillStyle();
131 gVirtualX->SetFillStyle(1);
133 gVirtualX->SetFillColor(0);
135 gVirtualX->SetFillColor(38);
137 gVirtualX->SetFillColor(33);
139 gVirtualX->SetFillColor(16);
141 gVirtualX->SetFillColor(44);
143 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
144 gVirtualX->SetFillStyle(0);
145 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
146 gVirtualX->SetFillStyle(sty);
148 Float_t textSize = gVirtualX->GetTextSize();
149 gVirtualX->SetTextSize(10);
150 gVirtualX->SetTextAlign(22);
151 gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0,
152 Form("%d",pad->GetManuChannel()));
154 gVirtualX->SetTextSize(textSize);