]>
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 | } | |
196 | } | |
197 | break; | |
198 | default: | |
199 | PaintWholeBox(kFALSE); | |
200 | } | |
201 | gr->Pop(); | |
202 | gVirtualX->SetFillColor(col); | |
203 | } |