]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
5f91c9e8 | 16 | // $Id$ |
13985652 | 17 | // $MpId: AliMpMotifPainter.cxx,v 1.9 2006/05/24 13:58:32 ivana Exp $ |
5f91c9e8 | 18 | // Category: graphics |
19 | // | |
20 | // Class AliMpMotifPainter | |
21 | // ----------------------- | |
22 | // Class for drawing a motif into canvas | |
dbe945cc | 23 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 24 | // Authors: David Guez, IPN Orsay |
25 | ||
5f91c9e8 | 26 | #include "AliMpMotifPainter.h" |
27 | #include "AliMpGraphContext.h" | |
28 | #include "AliMpMotifPosition.h" | |
29 | #include "AliMpMotifType.h" | |
30 | #include "AliMpConnection.h" | |
31 | #include "AliMpIntPair.h" | |
32 | ||
2c605e66 | 33 | #include <TVirtualX.h> |
34 | #include <TPad.h> | |
35 | ||
13985652 | 36 | /// \cond CLASSIMP |
5f91c9e8 | 37 | ClassImp(AliMpMotifPainter) |
13985652 | 38 | /// \endcond |
5f91c9e8 | 39 | |
40 | //_______________________________________________________________________ | |
41 | AliMpMotifPainter::AliMpMotifPainter() | |
42 | : AliMpVPainter(), | |
43 | fMotifPos(0) | |
44 | { | |
dee1d5f1 | 45 | /// Default constructor |
5f91c9e8 | 46 | } |
fb1bf5c0 | 47 | |
5f91c9e8 | 48 | //_______________________________________________________________________ |
49 | AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos) | |
50 | : AliMpVPainter(), | |
51 | fMotifPos(motifPos) | |
52 | { | |
dee1d5f1 | 53 | /// Standard constructor |
5f91c9e8 | 54 | |
55 | } | |
fb1bf5c0 | 56 | |
57 | //_____________________________________________________________________________ | |
58 | AliMpMotifPainter::AliMpMotifPainter(const AliMpMotifPainter& right) | |
dee1d5f1 | 59 | : AliMpVPainter(right) |
60 | { | |
61 | /// Protected copy constructor (not provided) | |
62 | ||
fb1bf5c0 | 63 | Fatal("AliMpMotifPainter", "Copy constructor not provided."); |
64 | } | |
65 | ||
5f91c9e8 | 66 | //_______________________________________________________________________ |
2998a151 | 67 | AliMpMotifPainter::~AliMpMotifPainter() |
68 | { | |
dee1d5f1 | 69 | /// Default constructor |
2998a151 | 70 | } |
fb1bf5c0 | 71 | |
72 | //_____________________________________________________________________________ | |
73 | AliMpMotifPainter& | |
74 | AliMpMotifPainter::operator=(const AliMpMotifPainter& right) | |
75 | { | |
dee1d5f1 | 76 | /// Assignment operator (not provided) |
77 | ||
78 | // check assignment to self | |
fb1bf5c0 | 79 | if (this == &right) return *this; |
80 | ||
dee1d5f1 | 81 | Fatal("operator =", "Assignment operator not provided."); |
fb1bf5c0 | 82 | |
83 | return *this; | |
84 | } | |
85 | ||
2998a151 | 86 | //_______________________________________________________________________ |
5f91c9e8 | 87 | void AliMpMotifPainter::DumpObject() |
88 | { | |
dee1d5f1 | 89 | /// Dump the owned object |
5f91c9e8 | 90 | |
dee1d5f1 | 91 | fMotifPos->Dump(); |
5f91c9e8 | 92 | } |
93 | ||
94 | //_______________________________________________________________________ | |
95 | TVector2 AliMpMotifPainter::GetPosition() const | |
96 | { | |
dee1d5f1 | 97 | /// Get the owned object's position |
5f91c9e8 | 98 | |
dee1d5f1 | 99 | return fMotifPos->Position(); |
5f91c9e8 | 100 | } |
dee1d5f1 | 101 | |
5f91c9e8 | 102 | //_______________________________________________________________________ |
103 | TVector2 AliMpMotifPainter::GetDimensions() const | |
104 | { | |
dee1d5f1 | 105 | /// Get the owned object's dimensions |
5f91c9e8 | 106 | |
dee1d5f1 | 107 | return fMotifPos->Dimensions(); |
5f91c9e8 | 108 | } |
109 | ||
110 | //_______________________________________________________________________ | |
111 | void AliMpMotifPainter::Paint(Option_t *option) | |
112 | { | |
dee1d5f1 | 113 | /// Paint the object |
114 | ||
5f91c9e8 | 115 | AliMpGraphContext *gr = AliMpGraphContext::Instance(); |
116 | if (!fMotifPos) return; | |
117 | Int_t col=gVirtualX->GetFillColor(); | |
118 | gr->Push(); | |
119 | gPad->Range(0.,0.,1.,1.); | |
120 | InitGraphContext(); | |
121 | ||
122 | switch (option[0]){ | |
123 | case 'T': | |
124 | case 'I': | |
125 | case 'X': | |
126 | { | |
127 | PaintWholeBox(); | |
128 | Float_t textSize = gVirtualX->GetTextSize(); | |
129 | gVirtualX->SetTextSize(10); | |
130 | TString str; | |
131 | switch (option[0]) { | |
132 | case 'T' : | |
133 | str = Form("%d",fMotifPos->GetID()); | |
134 | break; | |
135 | case 'I':{ | |
136 | switch (option[1]){ | |
137 | case '+' : | |
138 | str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(), | |
139 | fMotifPos->GetHighIndicesLimit().GetSecond()); | |
140 | break; | |
141 | default: | |
142 | str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(), | |
143 | fMotifPos->GetLowIndicesLimit().GetSecond()); | |
144 | } | |
145 | } | |
146 | break; | |
147 | case 'X' : | |
148 | str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(), | |
149 | (GetPosition()-GetDimensions()).Y()); | |
150 | break; | |
151 | } | |
152 | gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str); | |
153 | ||
154 | gVirtualX->SetTextSize(textSize); | |
155 | } | |
156 | break; | |
157 | case 'P': | |
158 | { | |
159 | //PaintWholeBox(kFALSE); | |
160 | AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType(); | |
161 | for (Int_t j=motifType->GetNofPadsY()-1;j>=0;j--){ | |
162 | for (Int_t i=0;i<motifType->GetNofPadsX();i++){ | |
163 | AliMpIntPair indices = AliMpIntPair(i,j); | |
164 | AliMpConnection* connect = | |
165 | motifType->FindConnectionByLocalIndices(indices); | |
166 | if (connect){ | |
167 | TVector2 realPadPos = | |
168 | GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices); | |
169 | TVector2 padPadPos,padPadDim; | |
170 | gr->RealToPad(realPadPos, | |
171 | fMotifPos->GetMotif()->GetPadDimensions(indices), | |
172 | padPadPos,padPadDim); | |
173 | TVector2 bl = padPadPos - padPadDim; | |
174 | TVector2 ur = padPadPos + padPadDim; | |
175 | ||
176 | ||
177 | Style_t sty = gVirtualX->GetFillStyle(); | |
178 | gVirtualX->SetFillStyle(1); | |
179 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
180 | gVirtualX->SetFillStyle(0); | |
181 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
182 | gVirtualX->SetFillStyle(sty); | |
183 | if (option[1]=='T'){ | |
184 | Float_t textSize = gVirtualX->GetTextSize(); | |
185 | gVirtualX->SetTextSize(10); | |
dee1d5f1 | 186 | gVirtualX->SetTextAlign(22); |
187 | // gPad->PaintText(padPadPos.X()-0.01,padPadPos.Y()-0.01, | |
188 | gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0, | |
5f91c9e8 | 189 | Form("%d",connect->GetGassiNum())); |
190 | ||
191 | gVirtualX->SetTextSize(textSize); | |
192 | } | |
193 | } | |
194 | } | |
195 | } | |
0f6198f2 | 196 | |
5f91c9e8 | 197 | } |
198 | break; | |
0f6198f2 | 199 | |
200 | case 'C': | |
201 | { | |
202 | // drawing real motif (not envelop) the real contour | |
203 | Float_t xl = 0; | |
204 | Float_t yl = 0; | |
205 | Int_t manuId = 0; | |
206 | TVector2 bl0 = TVector2(999, 999); | |
207 | TVector2 ur0 = TVector2(0,0); | |
208 | TVector2 padPadPos,padPadDim; | |
209 | ||
210 | AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType(); | |
211 | manuId = fMotifPos->GetID(); | |
212 | ||
213 | if (manuId % 5 == 0) | |
214 | gVirtualX->SetFillColor(0); | |
215 | if (manuId % 5 == 1) | |
216 | gVirtualX->SetFillColor(38); | |
217 | if (manuId % 5 == 2) | |
218 | gVirtualX->SetFillColor(33); | |
219 | if (manuId % 5 == 3) | |
220 | gVirtualX->SetFillColor(16); | |
221 | if (manuId % 5 == 4) | |
222 | gVirtualX->SetFillColor(44); | |
223 | ||
224 | for (Int_t i = 0; i < motifType->GetNofPadsX(); i++){ | |
225 | ||
226 | for (Int_t j = 0; j < motifType->GetNofPadsY(); j++){ | |
227 | ||
228 | AliMpIntPair indices = AliMpIntPair(i,j); | |
229 | AliMpConnection* connect = motifType->FindConnectionByLocalIndices(indices); | |
230 | if (connect){ | |
231 | TVector2 realPadPos = | |
232 | GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices); | |
233 | gr->RealToPad(realPadPos, fMotifPos->GetMotif()->GetPadDimensions(indices), | |
234 | padPadPos, padPadDim); | |
235 | ||
236 | TVector2 bl = padPadPos - padPadDim; | |
237 | TVector2 ur = padPadPos + padPadDim; | |
238 | if (bl0.X() > bl.X()) | |
239 | bl0 = bl; | |
240 | ||
241 | if (ur0.Y() < ur.Y()) | |
242 | ur0 = ur; | |
243 | ||
244 | Style_t sty = gVirtualX->GetFillStyle(); | |
245 | gVirtualX->SetFillStyle(1); | |
246 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
247 | gVirtualX->SetFillStyle(0); | |
248 | ||
249 | if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i,j-1))) | |
250 | gPad->PaintLine(bl.X(), bl.Y(), bl.X()+ padPadDim.X()*2, bl.Y()); | |
251 | ||
252 | if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i,j+1))) | |
253 | gPad->PaintLine(bl.X(), bl.Y() + padPadDim.Y()*2, bl.X()+ padPadDim.X()*2, bl.Y() + padPadDim.Y()*2); | |
254 | ||
255 | if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i-1,j))) | |
256 | gPad->PaintLine(bl.X(), bl.Y(), bl.X(), bl.Y()+ padPadDim.Y()*2); | |
257 | ||
258 | gVirtualX->SetFillStyle(sty); | |
259 | ||
260 | } | |
261 | } | |
262 | } | |
263 | ||
264 | switch (option[1]) { | |
265 | // add manudId indexes | |
266 | case 'I' : | |
267 | xl = bl0.X()+ padPadDim.X()/2.; | |
268 | ||
269 | yl = bl0.Y() + 1.5*padPadDim.Y(); | |
270 | ||
271 | Float_t textSize = gVirtualX->GetTextSize(); | |
272 | gVirtualX->SetTextSize(12); | |
273 | gVirtualX->SetTextAlign(13); | |
274 | gVirtualX->SetTextAngle(90.); | |
275 | ||
276 | gPad->PaintText(xl, yl, Form("%d", manuId)); | |
277 | ||
278 | gVirtualX->SetTextAngle(0.); | |
279 | gVirtualX->SetTextSize(textSize); | |
280 | break; | |
281 | } | |
282 | } | |
283 | break; | |
284 | ||
5f91c9e8 | 285 | default: |
286 | PaintWholeBox(kFALSE); | |
287 | } | |
288 | gr->Pop(); | |
289 | gVirtualX->SetFillColor(col); | |
290 | } |