]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/mapping/AliMpMotifPainter.cxx
Functionality of defunct AliMpManuList is now in AliMpDetElement, filled from DDLStor...
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifPainter.cxx
... / ...
CommitLineData
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
16// $Id$
17// $MpId: AliMpMotifPainter.cxx,v 1.9 2006/05/24 13:58:32 ivana Exp $
18// Category: graphics
19
20//-----------------------------------------------------------------------------
21// Class AliMpMotifPainter
22// -----------------------
23// Class for drawing a motif into canvas
24// Included in AliRoot: 2003/05/02
25// Authors: David Guez, IPN Orsay
26//-----------------------------------------------------------------------------
27
28#include "AliMpMotifPainter.h"
29#include "AliMpGraphContext.h"
30#include "AliMpMotifPosition.h"
31#include "AliMpMotifType.h"
32#include "AliMpMotif.h"
33#include "AliMpConnection.h"
34#include "AliMpIntPair.h"
35#include "AliLog.h"
36
37#include <TVirtualX.h>
38#include <TPad.h>
39
40/// \cond CLASSIMP
41ClassImp(AliMpMotifPainter)
42/// \endcond
43
44//_______________________________________________________________________
45AliMpMotifPainter::AliMpMotifPainter()
46 : AliMpVPainter(),
47 fMotifPos(0)
48{
49 /// Default constructor
50}
51
52//_______________________________________________________________________
53AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos)
54 : AliMpVPainter(),
55 fMotifPos(motifPos)
56{
57 /// Standard constructor
58 AliDebug(1,"Default ctor");
59}
60
61//_______________________________________________________________________
62AliMpMotifPainter::AliMpMotifPainter(AliMpMotifType* motifType)
63: AliMpVPainter(),
64fMotifPos(0x0)
65{
66 /// Constructor from a motif Type. We hereby create a MotifPosition
67 /// object from it, using arbitrary pad sizes, as this is just a way
68 /// to visualize the *shape* of the motif.
69
70 AliDebug(1,"Ctor from motifType");
71
72 const Double_t kdx = 5;
73 const Double_t kdy = 5; // cm but arbitrary anyway
74
75 AliMpVMotif* motif = new AliMpMotif(motifType->GetID(),
76 motifType,
77 TVector2(kdx,kdy));
78
79 fMotifPos = new AliMpMotifPosition(-1,motif,motif->Dimensions());
80}
81
82//_______________________________________________________________________
83AliMpMotifPainter::~AliMpMotifPainter()
84{
85 /// Default constructor
86}
87
88//_______________________________________________________________________
89void AliMpMotifPainter::DumpObject()
90{
91/// Dump the owned object
92
93 fMotifPos->Dump();
94}
95
96//_______________________________________________________________________
97TVector2 AliMpMotifPainter::GetPosition() const
98{
99/// Get the owned object's position
100
101 return fMotifPos->Position();
102}
103
104//_______________________________________________________________________
105TVector2 AliMpMotifPainter::GetDimensions() const
106{
107/// Get the owned object's dimensions
108
109 return fMotifPos->Dimensions();
110}
111
112//_______________________________________________________________________
113void AliMpMotifPainter::Paint(Option_t *option)
114{
115/// Paint the object
116
117 AliMpGraphContext *gr = AliMpGraphContext::Instance();
118 if (!fMotifPos) return;
119 Int_t col=gVirtualX->GetFillColor();
120 gr->Push();
121 gPad->Range(0.,0.,1.,1.);
122 InitGraphContext();
123
124 gVirtualX->SetLineWidth(1);
125
126 switch (option[0]){
127 case 'T':
128 case 'I':
129 case 'X':
130 {
131 PaintWholeBox();
132 Float_t textSize = gVirtualX->GetTextSize();
133 gVirtualX->SetTextSize(10);
134 TString str;
135 switch (option[0]) {
136 case 'T' :
137 str = Form("%d",fMotifPos->GetID());
138 break;
139 case 'I':{
140 switch (option[1]){
141 case '+' :
142 str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(),
143 fMotifPos->GetHighIndicesLimit().GetSecond());
144 break;
145 default:
146 str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(),
147 fMotifPos->GetLowIndicesLimit().GetSecond());
148 }
149 }
150 break;
151 case 'X' :
152 str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(),
153 (GetPosition()-GetDimensions()).Y());
154 break;
155 }
156 gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str);
157
158 gVirtualX->SetTextSize(textSize);
159 }
160 break;
161 case 'P':
162 case 'Z':
163 {
164 //PaintWholeBox(kFALSE);
165 AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType();
166 for (Int_t j=motifType->GetNofPadsY()-1;j>=0;j--){
167 for (Int_t i=0;i<motifType->GetNofPadsX();i++){
168 AliMpIntPair indices(i,j);
169 AliMpConnection* connect =
170 motifType->FindConnectionByLocalIndices(indices);
171 if (connect){
172 TVector2 realPadPos =
173 GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices);
174 TVector2 padPadPos,padPadDim;
175 gr->RealToPad(realPadPos,
176 fMotifPos->GetMotif()->GetPadDimensions(indices),
177 padPadPos,padPadDim);
178 TVector2 bl = padPadPos - padPadDim;
179 TVector2 ur = padPadPos + padPadDim;
180
181 Style_t sty = gVirtualX->GetFillStyle();
182 gVirtualX->SetFillStyle(1);
183 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
184 gVirtualX->SetFillStyle(0);
185 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
186 gVirtualX->SetFillStyle(sty);
187
188 if (option[1]=='T'){
189 Float_t textSize = gVirtualX->GetTextSize();
190 gVirtualX->SetTextSize(10);
191 gVirtualX->SetTextAlign(22);
192 gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0,
193 Form("%d",connect->GetGassiNum()));
194
195 gVirtualX->SetTextSize(textSize);
196 }
197 }
198 }
199 }
200 if ( option[0]=='Z' )
201 {
202 PaintContour(option,kFALSE);
203 }
204 }
205 break;
206
207 case 'C':
208 PaintContour(option,kTRUE);
209 break;
210
211 default:
212 PaintWholeBox(kFALSE);
213 }
214 gr->Pop();
215 gVirtualX->SetFillColor(col);
216}
217
218//_______________________________________________________________________
219void AliMpMotifPainter::PaintContour(Option_t* option, Bool_t fill)
220{
221/// Drawing real motif (not envelop) the real contour
222
223 AliMpGraphContext *gr = AliMpGraphContext::Instance();
224
225 Float_t xl = 0;
226 Float_t yl = 0;
227 Int_t manuId = 0;
228 Int_t searchMotif = -1;
229 TVector2 bl0 = TVector2(999, 999);
230 TVector2 ur0 = TVector2(0,0);
231 TVector2 padPadPos,padPadDim;
232
233 AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType();
234 manuId = fMotifPos->GetID();
235
236 if ( fill )
237 {
238 if (manuId % 5 == 0)
239 gVirtualX->SetFillColor(0);
240 if (manuId % 5 == 1)
241 gVirtualX->SetFillColor(38);
242 if (manuId % 5 == 2)
243 gVirtualX->SetFillColor(33);
244 if (manuId % 5 == 3)
245 gVirtualX->SetFillColor(16);
246 if (manuId % 5 == 4)
247 gVirtualX->SetFillColor(44);
248 }
249
250 Width_t lineW = gPad->GetLineWidth();
251 Width_t lw = lineW*3;
252 Double_t xlw = gPad->PixeltoX(lw/2);
253
254
255 if (option[1] == 'I' && option[2] == ':')
256 searchMotif = atoi(&option[3]);
257
258 gVirtualX->SetLineWidth(lw);
259
260 for (Int_t i = 0; i < motifType->GetNofPadsX(); i++){
261
262 for (Int_t j = 0; j < motifType->GetNofPadsY(); j++){
263
264 AliMpIntPair indices = AliMpIntPair(i,j);
265 AliMpConnection* connect = motifType->FindConnectionByLocalIndices(indices);
266
267 if (connect){
268 TVector2 realPadPos =
269 GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices);
270 gr->RealToPad(realPadPos, fMotifPos->GetMotif()->GetPadDimensions(indices),
271 padPadPos, padPadDim);
272
273 TVector2 bl = padPadPos - padPadDim;
274 TVector2 ur = padPadPos + padPadDim;
275
276 if (bl0.X() > bl.X())
277 bl0 = bl;
278
279 if (ur0.Y() < ur.Y())
280 ur0 = ur;
281
282 if ( fill )
283 {
284 Style_t csty = gVirtualX->GetFillColor();
285 Style_t sty = gVirtualX->GetFillStyle();
286 gVirtualX->SetFillStyle(1);
287 if (manuId == searchMotif)
288 gVirtualX->SetFillColor(5); // yellow
289 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
290 gVirtualX->SetFillStyle(sty);
291 gVirtualX->SetFillColor(csty);
292 }
293
294 if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i,j-1)))
295 {
296 gPad->PaintLine(bl.X()-xlw, bl.Y(), bl.X()+ padPadDim.X()*2 + xlw, bl.Y());
297 }
298
299 if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i,j+1)))
300 {
301 gPad->PaintLine(bl.X()-xlw, bl.Y() + padPadDim.Y()*2, bl.X()+ padPadDim.X()*2+xlw, bl.Y() + padPadDim.Y()*2);
302 }
303 if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i-1,j)))
304 {
305 gPad->PaintLine(bl.X(), bl.Y(), bl.X(), bl.Y()+ padPadDim.Y()*2);
306 }
307
308 if (!motifType->FindConnectionByLocalIndices(AliMpIntPair(i+1,j)))
309 {
310 gPad->PaintLine(bl.X()+padPadDim.X()*2, bl.Y(), bl.X()+padPadDim.X()*2, bl.Y()+ padPadDim.Y()*2);
311 }
312 }
313
314 }
315 }
316
317 switch (option[1]) {
318 // add manudId indexes
319 case 'I' :
320 xl = bl0.X()+ padPadDim.X()/2.;
321
322 yl = bl0.Y() + 1.5*padPadDim.Y();
323
324 Float_t textSize = gVirtualX->GetTextSize();
325 gVirtualX->SetTextSize(12);
326 gVirtualX->SetTextAlign(13);
327 gVirtualX->SetTextAngle(90.);
328
329 gPad->PaintText(xl, yl, Form("%d", manuId));
330
331 gVirtualX->SetTextAngle(0.);
332 gVirtualX->SetTextSize(textSize);
333 break;
334 }
335
336 gVirtualX->SetLineWidth(lineW);
337
338}