]>
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$ |
2c605e66 | 17 | // $MpId: AliMpMotifPainter.cxx,v 1.8 2006/03/17 11:35:29 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 | ||
5f91c9e8 | 36 | ClassImp(AliMpMotifPainter) |
37 | ||
38 | //_______________________________________________________________________ | |
39 | AliMpMotifPainter::AliMpMotifPainter() | |
40 | : AliMpVPainter(), | |
41 | fMotifPos(0) | |
42 | { | |
dee1d5f1 | 43 | /// Default constructor |
5f91c9e8 | 44 | } |
fb1bf5c0 | 45 | |
5f91c9e8 | 46 | //_______________________________________________________________________ |
47 | AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos) | |
48 | : AliMpVPainter(), | |
49 | fMotifPos(motifPos) | |
50 | { | |
dee1d5f1 | 51 | /// Standard constructor |
5f91c9e8 | 52 | |
53 | } | |
fb1bf5c0 | 54 | |
55 | //_____________________________________________________________________________ | |
56 | AliMpMotifPainter::AliMpMotifPainter(const AliMpMotifPainter& right) | |
dee1d5f1 | 57 | : AliMpVPainter(right) |
58 | { | |
59 | /// Protected copy constructor (not provided) | |
60 | ||
fb1bf5c0 | 61 | Fatal("AliMpMotifPainter", "Copy constructor not provided."); |
62 | } | |
63 | ||
5f91c9e8 | 64 | //_______________________________________________________________________ |
2998a151 | 65 | AliMpMotifPainter::~AliMpMotifPainter() |
66 | { | |
dee1d5f1 | 67 | /// Default constructor |
2998a151 | 68 | } |
fb1bf5c0 | 69 | |
70 | //_____________________________________________________________________________ | |
71 | AliMpMotifPainter& | |
72 | AliMpMotifPainter::operator=(const AliMpMotifPainter& right) | |
73 | { | |
dee1d5f1 | 74 | /// Assignment operator (not provided) |
75 | ||
76 | // check assignment to self | |
fb1bf5c0 | 77 | if (this == &right) return *this; |
78 | ||
dee1d5f1 | 79 | Fatal("operator =", "Assignment operator not provided."); |
fb1bf5c0 | 80 | |
81 | return *this; | |
82 | } | |
83 | ||
2998a151 | 84 | //_______________________________________________________________________ |
5f91c9e8 | 85 | void AliMpMotifPainter::DumpObject() |
86 | { | |
dee1d5f1 | 87 | /// Dump the owned object |
5f91c9e8 | 88 | |
dee1d5f1 | 89 | fMotifPos->Dump(); |
5f91c9e8 | 90 | } |
91 | ||
92 | //_______________________________________________________________________ | |
93 | TVector2 AliMpMotifPainter::GetPosition() const | |
94 | { | |
dee1d5f1 | 95 | /// Get the owned object's position |
5f91c9e8 | 96 | |
dee1d5f1 | 97 | return fMotifPos->Position(); |
5f91c9e8 | 98 | } |
dee1d5f1 | 99 | |
5f91c9e8 | 100 | //_______________________________________________________________________ |
101 | TVector2 AliMpMotifPainter::GetDimensions() const | |
102 | { | |
dee1d5f1 | 103 | /// Get the owned object's dimensions |
5f91c9e8 | 104 | |
dee1d5f1 | 105 | return fMotifPos->Dimensions(); |
5f91c9e8 | 106 | } |
107 | ||
108 | //_______________________________________________________________________ | |
109 | void AliMpMotifPainter::Paint(Option_t *option) | |
110 | { | |
dee1d5f1 | 111 | /// Paint the object |
112 | ||
5f91c9e8 | 113 | AliMpGraphContext *gr = AliMpGraphContext::Instance(); |
114 | if (!fMotifPos) return; | |
115 | Int_t col=gVirtualX->GetFillColor(); | |
116 | gr->Push(); | |
117 | gPad->Range(0.,0.,1.,1.); | |
118 | InitGraphContext(); | |
119 | ||
120 | switch (option[0]){ | |
121 | case 'T': | |
122 | case 'I': | |
123 | case 'X': | |
124 | { | |
125 | PaintWholeBox(); | |
126 | Float_t textSize = gVirtualX->GetTextSize(); | |
127 | gVirtualX->SetTextSize(10); | |
128 | TString str; | |
129 | switch (option[0]) { | |
130 | case 'T' : | |
131 | str = Form("%d",fMotifPos->GetID()); | |
132 | break; | |
133 | case 'I':{ | |
134 | switch (option[1]){ | |
135 | case '+' : | |
136 | str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(), | |
137 | fMotifPos->GetHighIndicesLimit().GetSecond()); | |
138 | break; | |
139 | default: | |
140 | str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(), | |
141 | fMotifPos->GetLowIndicesLimit().GetSecond()); | |
142 | } | |
143 | } | |
144 | break; | |
145 | case 'X' : | |
146 | str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(), | |
147 | (GetPosition()-GetDimensions()).Y()); | |
148 | break; | |
149 | } | |
150 | gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str); | |
151 | ||
152 | gVirtualX->SetTextSize(textSize); | |
153 | } | |
154 | break; | |
155 | case 'P': | |
156 | { | |
157 | //PaintWholeBox(kFALSE); | |
158 | AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType(); | |
159 | for (Int_t j=motifType->GetNofPadsY()-1;j>=0;j--){ | |
160 | for (Int_t i=0;i<motifType->GetNofPadsX();i++){ | |
161 | AliMpIntPair indices = AliMpIntPair(i,j); | |
162 | AliMpConnection* connect = | |
163 | motifType->FindConnectionByLocalIndices(indices); | |
164 | if (connect){ | |
165 | TVector2 realPadPos = | |
166 | GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices); | |
167 | TVector2 padPadPos,padPadDim; | |
168 | gr->RealToPad(realPadPos, | |
169 | fMotifPos->GetMotif()->GetPadDimensions(indices), | |
170 | padPadPos,padPadDim); | |
171 | TVector2 bl = padPadPos - padPadDim; | |
172 | TVector2 ur = padPadPos + padPadDim; | |
173 | ||
174 | ||
175 | Style_t sty = gVirtualX->GetFillStyle(); | |
176 | gVirtualX->SetFillStyle(1); | |
177 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
178 | gVirtualX->SetFillStyle(0); | |
179 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
180 | gVirtualX->SetFillStyle(sty); | |
181 | if (option[1]=='T'){ | |
182 | Float_t textSize = gVirtualX->GetTextSize(); | |
183 | gVirtualX->SetTextSize(10); | |
dee1d5f1 | 184 | gVirtualX->SetTextAlign(22); |
185 | // gPad->PaintText(padPadPos.X()-0.01,padPadPos.Y()-0.01, | |
186 | gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0, | |
5f91c9e8 | 187 | Form("%d",connect->GetGassiNum())); |
188 | ||
189 | gVirtualX->SetTextSize(textSize); | |
190 | } | |
191 | } | |
192 | } | |
193 | } | |
194 | } | |
195 | break; | |
196 | default: | |
197 | PaintWholeBox(kFALSE); | |
198 | } | |
199 | gr->Pop(); | |
200 | gVirtualX->SetFillColor(col); | |
201 | } |