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 **************************************************************************/
17 // $MpId: AliMpMotifPainter.cxx,v 1.9 2006/05/24 13:58:32 ivana Exp $
20 // Class AliMpMotifPainter
21 // -----------------------
22 // Class for drawing a motif into canvas
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, IPN Orsay
26 #include "AliMpMotifPainter.h"
27 #include "AliMpGraphContext.h"
28 #include "AliMpMotifPosition.h"
29 #include "AliMpMotifType.h"
30 #include "AliMpConnection.h"
31 #include "AliMpIntPair.h"
33 #include <TVirtualX.h>
37 ClassImp(AliMpMotifPainter)
40 //_______________________________________________________________________
41 AliMpMotifPainter::AliMpMotifPainter()
45 /// Default constructor
48 //_______________________________________________________________________
49 AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos)
53 /// Standard constructor
57 //_______________________________________________________________________
58 AliMpMotifPainter::~AliMpMotifPainter()
60 /// Default constructor
63 //_______________________________________________________________________
64 void AliMpMotifPainter::DumpObject()
66 /// Dump the owned object
71 //_______________________________________________________________________
72 TVector2 AliMpMotifPainter::GetPosition() const
74 /// Get the owned object's position
76 return fMotifPos->Position();
79 //_______________________________________________________________________
80 TVector2 AliMpMotifPainter::GetDimensions() const
82 /// Get the owned object's dimensions
84 return fMotifPos->Dimensions();
87 //_______________________________________________________________________
88 void AliMpMotifPainter::Paint(Option_t *option)
92 AliMpGraphContext *gr = AliMpGraphContext::Instance();
93 if (!fMotifPos) return;
94 Int_t col=gVirtualX->GetFillColor();
96 gPad->Range(0.,0.,1.,1.);
105 Float_t textSize = gVirtualX->GetTextSize();
106 gVirtualX->SetTextSize(10);
110 str = Form("%d",fMotifPos->GetID());
115 str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(),
116 fMotifPos->GetHighIndicesLimit().GetSecond());
119 str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(),
120 fMotifPos->GetLowIndicesLimit().GetSecond());
125 str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(),
126 (GetPosition()-GetDimensions()).Y());
129 gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str);
131 gVirtualX->SetTextSize(textSize);
136 //PaintWholeBox(kFALSE);
137 AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType();
138 for (Int_t j=motifType->GetNofPadsY()-1;j>=0;j--){
139 for (Int_t i=0;i<motifType->GetNofPadsX();i++){
140 AliMpIntPair indices = AliMpIntPair(i,j);
141 AliMpConnection* connect =
142 motifType->FindConnectionByLocalIndices(indices);
144 TVector2 realPadPos =
145 GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices);
146 TVector2 padPadPos,padPadDim;
147 gr->RealToPad(realPadPos,
148 fMotifPos->GetMotif()->GetPadDimensions(indices),
149 padPadPos,padPadDim);
150 TVector2 bl = padPadPos - padPadDim;
151 TVector2 ur = padPadPos + padPadDim;
154 Style_t sty = gVirtualX->GetFillStyle();
155 gVirtualX->SetFillStyle(1);
156 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
157 gVirtualX->SetFillStyle(0);
158 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
159 gVirtualX->SetFillStyle(sty);
161 Float_t textSize = gVirtualX->GetTextSize();
162 gVirtualX->SetTextSize(10);
163 gVirtualX->SetTextAlign(22);
164 // gPad->PaintText(padPadPos.X()-0.01,padPadPos.Y()-0.01,
165 gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0,
166 Form("%d",connect->GetGassiNum()));
168 gVirtualX->SetTextSize(textSize);
179 // drawing real motif (not envelop) the real contour
183 TVector2 bl0 = TVector2(999, 999);
184 TVector2 ur0 = TVector2(0,0);
185 TVector2 padPadPos,padPadDim;
187 AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType();
188 manuId = fMotifPos->GetID();
191 gVirtualX->SetFillColor(0);
193 gVirtualX->SetFillColor(38);
195 gVirtualX->SetFillColor(33);
197 gVirtualX->SetFillColor(16);
199 gVirtualX->SetFillColor(44);
201 for (Int_t i = 0; i < motifType->GetNofPadsX(); i++){
203 for (Int_t j = 0; j < motifType->GetNofPadsY(); j++){
205 AliMpIntPair indices = AliMpIntPair(i,j);
206 AliMpConnection* connect = motifType->FindConnectionByLocalIndices(indices);
208 TVector2 realPadPos =
209 GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices);
210 gr->RealToPad(realPadPos, fMotifPos->GetMotif()->GetPadDimensions(indices),
211 padPadPos, padPadDim);
213 TVector2 bl = padPadPos - padPadDim;
214 TVector2 ur = padPadPos + padPadDim;
215 if (bl0.X() > bl.X())
218 if (ur0.Y() < ur.Y())
221 Style_t sty = gVirtualX->GetFillStyle();
222 gVirtualX->SetFillStyle(1);
223 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
224 gVirtualX->SetFillStyle(0);
226 if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i,j-1)))
227 gPad->PaintLine(bl.X(), bl.Y(), bl.X()+ padPadDim.X()*2, bl.Y());
229 if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i,j+1)))
230 gPad->PaintLine(bl.X(), bl.Y() + padPadDim.Y()*2, bl.X()+ padPadDim.X()*2, bl.Y() + padPadDim.Y()*2);
232 if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i-1,j)))
233 gPad->PaintLine(bl.X(), bl.Y(), bl.X(), bl.Y()+ padPadDim.Y()*2);
235 gVirtualX->SetFillStyle(sty);
242 // add manudId indexes
244 xl = bl0.X()+ padPadDim.X()/2.;
246 yl = bl0.Y() + 1.5*padPadDim.Y();
248 Float_t textSize = gVirtualX->GetTextSize();
249 gVirtualX->SetTextSize(12);
250 gVirtualX->SetTextAlign(13);
251 gVirtualX->SetTextAngle(90.);
253 gPad->PaintText(xl, yl, Form("%d", manuId));
255 gVirtualX->SetTextAngle(0.);
256 gVirtualX->SetTextSize(textSize);
263 PaintWholeBox(kFALSE);
266 gVirtualX->SetFillColor(col);