]>
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 | |
5f91c9e8 | 57 | //_______________________________________________________________________ |
2998a151 | 58 | AliMpMotifPainter::~AliMpMotifPainter() |
59 | { | |
dee1d5f1 | 60 | /// Default constructor |
2998a151 | 61 | } |
fb1bf5c0 | 62 | |
2998a151 | 63 | //_______________________________________________________________________ |
5f91c9e8 | 64 | void AliMpMotifPainter::DumpObject() |
65 | { | |
dee1d5f1 | 66 | /// Dump the owned object |
5f91c9e8 | 67 | |
dee1d5f1 | 68 | fMotifPos->Dump(); |
5f91c9e8 | 69 | } |
70 | ||
71 | //_______________________________________________________________________ | |
72 | TVector2 AliMpMotifPainter::GetPosition() const | |
73 | { | |
dee1d5f1 | 74 | /// Get the owned object's position |
5f91c9e8 | 75 | |
dee1d5f1 | 76 | return fMotifPos->Position(); |
5f91c9e8 | 77 | } |
dee1d5f1 | 78 | |
5f91c9e8 | 79 | //_______________________________________________________________________ |
80 | TVector2 AliMpMotifPainter::GetDimensions() const | |
81 | { | |
dee1d5f1 | 82 | /// Get the owned object's dimensions |
5f91c9e8 | 83 | |
dee1d5f1 | 84 | return fMotifPos->Dimensions(); |
5f91c9e8 | 85 | } |
86 | ||
87 | //_______________________________________________________________________ | |
88 | void AliMpMotifPainter::Paint(Option_t *option) | |
89 | { | |
dee1d5f1 | 90 | /// Paint the object |
91 | ||
5f91c9e8 | 92 | AliMpGraphContext *gr = AliMpGraphContext::Instance(); |
93 | if (!fMotifPos) return; | |
94 | Int_t col=gVirtualX->GetFillColor(); | |
95 | gr->Push(); | |
96 | gPad->Range(0.,0.,1.,1.); | |
97 | InitGraphContext(); | |
98 | ||
99 | switch (option[0]){ | |
100 | case 'T': | |
101 | case 'I': | |
102 | case 'X': | |
103 | { | |
104 | PaintWholeBox(); | |
105 | Float_t textSize = gVirtualX->GetTextSize(); | |
106 | gVirtualX->SetTextSize(10); | |
107 | TString str; | |
108 | switch (option[0]) { | |
109 | case 'T' : | |
110 | str = Form("%d",fMotifPos->GetID()); | |
111 | break; | |
112 | case 'I':{ | |
113 | switch (option[1]){ | |
114 | case '+' : | |
115 | str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(), | |
116 | fMotifPos->GetHighIndicesLimit().GetSecond()); | |
117 | break; | |
118 | default: | |
119 | str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(), | |
120 | fMotifPos->GetLowIndicesLimit().GetSecond()); | |
121 | } | |
122 | } | |
123 | break; | |
124 | case 'X' : | |
125 | str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(), | |
126 | (GetPosition()-GetDimensions()).Y()); | |
127 | break; | |
128 | } | |
129 | gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str); | |
130 | ||
131 | gVirtualX->SetTextSize(textSize); | |
132 | } | |
133 | break; | |
134 | case 'P': | |
135 | { | |
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); | |
143 | if (connect){ | |
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; | |
152 | ||
153 | ||
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); | |
160 | if (option[1]=='T'){ | |
161 | Float_t textSize = gVirtualX->GetTextSize(); | |
162 | gVirtualX->SetTextSize(10); | |
dee1d5f1 | 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, | |
5f91c9e8 | 166 | Form("%d",connect->GetGassiNum())); |
167 | ||
168 | gVirtualX->SetTextSize(textSize); | |
169 | } | |
170 | } | |
171 | } | |
172 | } | |
0f6198f2 | 173 | |
5f91c9e8 | 174 | } |
175 | break; | |
0f6198f2 | 176 | |
177 | case 'C': | |
178 | { | |
179 | // drawing real motif (not envelop) the real contour | |
180 | Float_t xl = 0; | |
181 | Float_t yl = 0; | |
182 | Int_t manuId = 0; | |
183 | TVector2 bl0 = TVector2(999, 999); | |
184 | TVector2 ur0 = TVector2(0,0); | |
185 | TVector2 padPadPos,padPadDim; | |
186 | ||
187 | AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType(); | |
188 | manuId = fMotifPos->GetID(); | |
189 | ||
190 | if (manuId % 5 == 0) | |
191 | gVirtualX->SetFillColor(0); | |
192 | if (manuId % 5 == 1) | |
193 | gVirtualX->SetFillColor(38); | |
194 | if (manuId % 5 == 2) | |
195 | gVirtualX->SetFillColor(33); | |
196 | if (manuId % 5 == 3) | |
197 | gVirtualX->SetFillColor(16); | |
198 | if (manuId % 5 == 4) | |
199 | gVirtualX->SetFillColor(44); | |
200 | ||
201 | for (Int_t i = 0; i < motifType->GetNofPadsX(); i++){ | |
202 | ||
203 | for (Int_t j = 0; j < motifType->GetNofPadsY(); j++){ | |
204 | ||
205 | AliMpIntPair indices = AliMpIntPair(i,j); | |
206 | AliMpConnection* connect = motifType->FindConnectionByLocalIndices(indices); | |
207 | if (connect){ | |
208 | TVector2 realPadPos = | |
209 | GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices); | |
210 | gr->RealToPad(realPadPos, fMotifPos->GetMotif()->GetPadDimensions(indices), | |
211 | padPadPos, padPadDim); | |
212 | ||
213 | TVector2 bl = padPadPos - padPadDim; | |
214 | TVector2 ur = padPadPos + padPadDim; | |
215 | if (bl0.X() > bl.X()) | |
216 | bl0 = bl; | |
217 | ||
218 | if (ur0.Y() < ur.Y()) | |
219 | ur0 = ur; | |
220 | ||
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); | |
225 | ||
226 | if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i,j-1))) | |
227 | gPad->PaintLine(bl.X(), bl.Y(), bl.X()+ padPadDim.X()*2, bl.Y()); | |
228 | ||
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); | |
231 | ||
232 | if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i-1,j))) | |
233 | gPad->PaintLine(bl.X(), bl.Y(), bl.X(), bl.Y()+ padPadDim.Y()*2); | |
234 | ||
235 | gVirtualX->SetFillStyle(sty); | |
236 | ||
237 | } | |
238 | } | |
239 | } | |
240 | ||
241 | switch (option[1]) { | |
242 | // add manudId indexes | |
243 | case 'I' : | |
244 | xl = bl0.X()+ padPadDim.X()/2.; | |
245 | ||
246 | yl = bl0.Y() + 1.5*padPadDim.Y(); | |
247 | ||
248 | Float_t textSize = gVirtualX->GetTextSize(); | |
249 | gVirtualX->SetTextSize(12); | |
250 | gVirtualX->SetTextAlign(13); | |
251 | gVirtualX->SetTextAngle(90.); | |
252 | ||
253 | gPad->PaintText(xl, yl, Form("%d", manuId)); | |
254 | ||
255 | gVirtualX->SetTextAngle(0.); | |
256 | gVirtualX->SetTextSize(textSize); | |
257 | break; | |
258 | } | |
259 | } | |
260 | break; | |
261 | ||
5f91c9e8 | 262 | default: |
263 | PaintWholeBox(kFALSE); | |
264 | } | |
265 | gr->Pop(); | |
266 | gVirtualX->SetFillColor(col); | |
267 | } |