]>
Commit | Line | Data |
---|---|---|
215d5755 | 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$ | |
18 | ||
19 | #include "AliMpDEVisu.h" | |
e4d2775e | 20 | |
21 | #include "AliMpSlatMotifMap.h" | |
22 | #include "AliMpSt345Reader.h" | |
23 | #include "AliMpSectorReader.h" | |
24 | #include "AliMpSlat.h" | |
25 | #include "AliMpPCB.h" | |
e4d2775e | 26 | #include "AliMpSectorReader.h" |
27 | #include "AliMpSector.h" | |
28 | #include "AliMpRow.h" | |
29 | #include "AliMpVRowSegment.h" | |
e4d2775e | 30 | #include "AliMpVPainter.h" |
e4d2775e | 31 | #include "AliMpMotifPosition.h" |
32 | #include "AliMpMotifMap.h" | |
e4d2775e | 33 | #include "AliMpDEIterator.h" |
34 | #include "AliMpDEManager.h" | |
35 | #include "AliMpDetElement.h" | |
36 | #include "AliMpStationType.h" | |
37 | #include "AliMpSegmentation.h" | |
38 | #include "AliMpPad.h" | |
39 | #include "AliMpDDLStore.h" | |
215d5755 | 40 | #include "AliMpVPadIterator.h" |
e4d2775e | 41 | |
215d5755 | 42 | #include "AliLog.h" |
43 | ||
44 | #include <TMath.h> | |
45 | #include <TString.h> | |
46 | #include <TVector2.h> | |
47 | #include <TCanvas.h> | |
48 | #include <TGButton.h> | |
49 | #include <TRootEmbeddedCanvas.h> | |
50 | #include <TGLabel.h> | |
51 | #include <TGComboBox.h> | |
52 | #include <TGNumberEntry.h> | |
53 | #include <TGTextView.h> | |
54 | #include <TGTextEntry.h> | |
e4d2775e | 55 | |
56 | // Category: graphics | |
57 | // | |
58 | // Class AliMpDEVisu | |
59 | // ----------------------- | |
60 | // GUI for drawing segmentation | |
61 | // motif manu and associated channels | |
62 | // date: 2007/01/26 | |
63 | // Author: Ch. Finck | |
64 | ||
65 | /// \cond CLASSIMP | |
66 | ClassImp(AliMpDEVisu) | |
67 | /// \endcond | |
68 | ||
69 | //_________________________________________________________________ | |
70 | AliMpDEVisu::AliMpDEVisu(UInt_t w, UInt_t h) | |
215d5755 | 71 | : TGFrame(gClient->GetRoot(), w, h), |
72 | fkMainWindow(gClient->GetRoot()), | |
73 | fMain(new TGMainFrame(gClient->GetRoot(), w, h)), | |
74 | fEcanvas(0x0), | |
75 | fChamberCombo(0x0), | |
76 | fDECombo(0x0), | |
77 | fNumberEntry(0x0), | |
78 | fPlaneButton(0x0), | |
79 | fZoomButton(0x0), | |
d58f6c58 | 80 | fNameDECombo(0x0), |
215d5755 | 81 | fLogMessage(0x0), |
82 | fLogFile(0x0), | |
83 | fTrashList(0x0), | |
84 | fDEComboIdx(), | |
d58f6c58 | 85 | fNameDEComboIdx(), |
86 | fDEOccurrence(1026), | |
215d5755 | 87 | fCurrentPlane(AliMp::kBendingPlane), |
88 | fCurrentDetElem(100), | |
89 | fCurrentDEName(), | |
90 | fSegmentation(), | |
91 | fDDLStore(AliMpDDLStore::Instance()), | |
92 | fZoomMode(false) | |
e4d2775e | 93 | { |
215d5755 | 94 | /// Standard constructor |
e4d2775e | 95 | |
215d5755 | 96 | fTrashList.SetOwner(kFALSE); |
97 | ||
98 | // Create canvas widget | |
99 | ||
100 | Int_t width = Int_t(w*0.99); | |
101 | Int_t height = Int_t(h*0.99); | |
102 | ||
103 | fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain, width, height); | |
104 | fEcanvas->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", | |
105 | "AliMpDEVisu", | |
106 | this, | |
107 | "HandleMovement(Int_t, Int_t, Int_t, TObject*)"); | |
108 | ||
109 | // Create a horizontal frame widget with buttons | |
110 | TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,width,height/6); | |
111 | ||
112 | TGTextButton *draw = new TGTextButton(hframe,"&Draw"); | |
113 | draw->Connect("Clicked()","AliMpDEVisu",this,"DrawDE()"); | |
114 | hframe->AddFrame(draw, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
115 | ||
116 | TGTextButton *exit = new TGTextButton(hframe,"&Exit","gApplication->Terminate(0)"); | |
117 | hframe->AddFrame(exit, new TGLayoutHints(kLHintsLeft| kLHintsCenterY,5,5,3,4)); | |
118 | ||
119 | ||
120 | Int_t i = 0; | |
121 | Char_t text[20]; | |
122 | ||
123 | // chamber label | |
124 | TGLabel* chamberLabel = new TGLabel(hframe, "Chamber :"); | |
125 | hframe->AddFrame(chamberLabel, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 20, 0)); | |
126 | fChamberCombo = new TGComboBox(hframe, kChamberCombo); | |
127 | ||
128 | fDEComboIdx.Set(26); | |
129 | for(i = 0; i < 10; i++) | |
130 | { | |
131 | sprintf(text,"%d",i+1); | |
132 | fChamberCombo->AddEntry(text,i); | |
133 | } | |
134 | fChamberCombo->Resize(40,20); | |
135 | fChamberCombo->Select(0); | |
136 | fChamberCombo->Associate(this); | |
137 | hframe->AddFrame(fChamberCombo, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
138 | ||
139 | // DE label | |
140 | TGLabel* detElemLabel = new TGLabel(hframe, "DE :"); | |
141 | hframe->AddFrame(detElemLabel, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 20, 0)); | |
142 | fDECombo = new TGComboBox(hframe, kDECombo); | |
143 | UpdateComboDE(); | |
144 | ||
145 | fDECombo->Resize(80,20); | |
146 | fDECombo->Select(0); | |
147 | fDECombo->Associate(this); | |
148 | hframe->AddFrame(fDECombo, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
d58f6c58 | 149 | fDEOccurrence.Reset(-1); |
150 | ||
215d5755 | 151 | TGTextButton *next = new TGTextButton(hframe,"&Next"); |
152 | next->Connect("Clicked()","AliMpDEVisu",this,"NextDE()"); | |
153 | hframe->AddFrame(next, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,5,5,3,4)); | |
154 | ||
155 | // DE name | |
156 | TGLabel* detElemName = new TGLabel(hframe, "Name :"); | |
157 | hframe->AddFrame(detElemName, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 20, 0)); | |
158 | ||
159 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); | |
160 | fCurrentDEName = detElem->GetDEName(); | |
d58f6c58 | 161 | fNameDECombo = new TGComboBox(hframe, kDEName); |
162 | ||
163 | UpdateNameView(); | |
164 | fNameDECombo->Resize(160, 20); | |
165 | fNameDECombo->Select(0); | |
166 | fNameDECombo->Associate(this); | |
167 | hframe->AddFrame(fNameDECombo, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
215d5755 | 168 | |
169 | // plane type | |
170 | fPlaneButton = new TGCheckButton(hframe, "NB Plane", kPlaneType); | |
171 | fPlaneButton->SetState(kButtonUp); | |
172 | fPlaneButton->Associate(this); | |
173 | hframe->AddFrame(fPlaneButton, new TGLayoutHints(kLHintsLeft, 10, 0, 9, 0)); | |
174 | ||
175 | ||
176 | // button motif | |
177 | TGTextButton* drawManu = new TGTextButton(hframe,"&Search"); | |
178 | drawManu->Connect("Clicked()","AliMpDEVisu",this,"DrawManuMotif(Bool_t)"); | |
179 | drawManu->SetToolTipText("Search for a given manu number"); | |
180 | hframe->AddFrame(drawManu, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
181 | ||
182 | // entry manu | |
183 | fNumberEntry = new TGNumberEntry(hframe, 0, 4, -1, | |
184 | TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, | |
185 | TGNumberFormat::kNELLimitMinMax, 1, 1500); | |
186 | fNumberEntry->Resize(60,20); | |
187 | hframe->AddFrame(fNumberEntry, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 0, 9, 0)); | |
188 | ||
189 | // reset button | |
190 | TGTextButton *resetManu = new TGTextButton(hframe,"&Reset"); | |
191 | resetManu->Connect("Clicked()","AliMpDEVisu",this,"ResetManu()"); | |
192 | hframe->AddFrame(resetManu, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,10,5,3,4)); | |
193 | ||
194 | // delete window button | |
195 | TGTextButton* deletePopup = new TGTextButton(hframe,"&Delete_Popup"); | |
196 | deletePopup->Connect("Clicked()","AliMpDEVisu",this,"DeletePopUp()"); | |
197 | deletePopup->SetToolTipText("Delete motif popup window"); | |
198 | hframe->AddFrame(deletePopup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
199 | ||
200 | ||
201 | // log mesg | |
202 | TGHorizontalFrame *logFrame = new TGHorizontalFrame(fMain, width/2, height/6); | |
203 | ||
204 | TGLabel* logName = new TGLabel(logFrame, "Log MSG:"); | |
205 | logFrame->AddFrame(logName, new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsCenterY, 10, 0, 2, 0)); | |
206 | ||
207 | fLogMessage = new TGTextView(logFrame, width/2, 60); | |
208 | fLogMessage->ShowBottom(); | |
209 | ||
210 | logFrame->AddFrame(fLogMessage, new TGLayoutHints(kLHintsLeft, 10, 0, 2, 0)); | |
211 | ||
212 | // clear log mesg | |
e4d2775e | 213 | TGTextButton* clearLog = new TGTextButton(logFrame,"&Clear"); |
215d5755 | 214 | clearLog->Connect("Clicked()","AliMpDEVisu",this,"ClearLogMessage()"); |
215 | clearLog->SetToolTipText("Clear log message"); | |
216 | logFrame->AddFrame(clearLog, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4)); | |
217 | ||
218 | // save log mesg | |
219 | TGTextButton* saveLog = new TGTextButton(logFrame,"&Save"); | |
220 | saveLog->Connect("Clicked()","AliMpDEVisu",this,"SaveLogMessage()"); | |
221 | saveLog->SetToolTipText("Save log message into file"); | |
222 | logFrame->AddFrame(saveLog, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,5,5,3,4)); | |
223 | ||
224 | // log file name | |
225 | fLogFile = new TGTextEntry(logFrame,"AliMpDEVisu.log"); | |
226 | fLogFile->SetToolTipText("Default log file name"); | |
227 | logFrame->AddFrame(fLogFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 0, 9, 0)); | |
228 | ||
229 | // zoom mode | |
230 | fZoomButton = new TGCheckButton(logFrame, new TGHotString("&Zoom Mode"), kZoomMode); | |
231 | fZoomButton->Associate(this); | |
232 | fZoomButton->SetState(kButtonUp); | |
e4d2775e | 233 | |
215d5755 | 234 | logFrame->AddFrame(fZoomButton, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 20, 0, 9, 0)); |
235 | ||
236 | // frame | |
237 | fMain->AddFrame(hframe, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,10,10)); | |
238 | fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsCenterX, 10,10,10,10)); | |
239 | ||
240 | fMain->AddFrame(logFrame, new TGLayoutHints(kLHintsLeft,2,2,2,10)); | |
241 | ||
242 | // Set a name to the main frame | |
243 | fMain->SetWindowName("MUON Detection Element Visualization"); | |
244 | ||
245 | // Map all subwindows of main frame | |
246 | fMain->MapSubwindows(); | |
247 | ||
248 | // Initialize the layout algorithm | |
249 | fMain->Resize(fMain->GetDefaultSize()); | |
250 | ||
251 | // Map main frame | |
252 | fMain->MapWindow(); | |
253 | ||
254 | // instance segmentation | |
255 | fSegmentation = AliMpSegmentation::Instance()->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); | |
256 | fLogMessage->AddLine("Segmentation loaded"); | |
257 | fLogMessage->ShowBottom(); | |
e4d2775e | 258 | } |
259 | ||
260 | //____________________________________________________________ | |
261 | AliMpDEVisu::~AliMpDEVisu() | |
262 | { | |
215d5755 | 263 | /// Clean up used widgets: frames, buttons, layouthints |
264 | ||
265 | fChamberCombo->Delete(); | |
266 | fDECombo->Delete(); | |
267 | fNumberEntry->Delete(); | |
268 | fPlaneButton->Delete(); | |
d58f6c58 | 269 | fNameDECombo->Delete(); |
215d5755 | 270 | fLogMessage->Delete(); |
271 | fLogFile->Delete(); | |
272 | fMain->Cleanup(); | |
273 | delete fMain; | |
e4d2775e | 274 | } |
275 | ||
276 | //__________________________________________________________ | |
277 | void AliMpDEVisu::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* /*select*/) | |
278 | { | |
215d5755 | 279 | /// handle cursor mouvement |
280 | ||
281 | static Int_t eventXold, eventYold; | |
282 | static Int_t eventX0, eventY0; | |
283 | static Int_t linedrawn; | |
284 | ||
e4d2775e | 285 | |
215d5755 | 286 | // enable again KeyAutoRepeat after HandleKey |
287 | if (eventType == kKeyPress) { | |
288 | gVirtualX->SetKeyAutoRepeat(kTRUE); | |
289 | } | |
e4d2775e | 290 | |
215d5755 | 291 | fEcanvas->GetCanvas()->cd(); |
e4d2775e | 292 | |
215d5755 | 293 | // zoom mode |
294 | if (fZoomMode) { | |
295 | ||
296 | if (eventType == kButton1Down) { | |
297 | gVirtualX->SetLineWidth(3); | |
298 | eventX0 = eventX; eventY0 = eventY; | |
299 | eventXold = eventX; eventYold = eventY; | |
300 | linedrawn = 0; | |
301 | } | |
302 | ||
303 | if (eventType == kButton1Motion) { | |
304 | if (linedrawn) gVirtualX->DrawBox(eventX0, eventY0, eventXold, eventYold, TVirtualX::kHollow); | |
305 | eventXold = eventX; | |
306 | eventYold = eventY; | |
307 | linedrawn = 1; | |
308 | gVirtualX->DrawBox(eventX0, eventY0, eventXold, eventYold, TVirtualX::kHollow); | |
309 | } | |
310 | ||
311 | if (eventType == kButton1Up) | |
312 | { | |
313 | if ( (eventX0 - eventX) && (eventY0 - eventY) ) | |
314 | { | |
315 | PopUpZoom(eventX0,eventY0,eventX,eventY); | |
316 | linedrawn=1; | |
317 | } | |
318 | } | |
319 | ||
320 | ||
321 | } else { | |
322 | ||
323 | // click mode | |
324 | ||
325 | if (eventType == kButton1Down) { | |
326 | ||
327 | // calculated in pixel | |
e4d2775e | 328 | Double_t x = 0.; |
329 | Double_t y = 0.; | |
215d5755 | 330 | |
331 | EventToReal(eventX,eventY,x,y); | |
332 | ||
333 | // get manu | |
334 | AliMpPad pad = fSegmentation->PadByPosition(TVector2(x,y), false); | |
335 | ||
e4d2775e | 336 | if (!pad.IsValid()) { |
215d5755 | 337 | |
338 | fLogMessage->AddLine(Form("PopupManuMotif: No manu for DE: %d at position (%5.2f, %5.2f)", | |
339 | fCurrentDetElem, x, y)); | |
340 | fLogMessage->ShowBottom(); | |
341 | return; | |
e4d2775e | 342 | } |
215d5755 | 343 | |
e4d2775e | 344 | Int_t manu = pad.GetLocation().GetFirst(); |
215d5755 | 345 | |
e4d2775e | 346 | fNumberEntry->SetNumber(manu); |
215d5755 | 347 | |
348 | ||
349 | fLogMessage->AddLine(Form("PopupManuMotif: DE: %d, manu: %d at position: %5.2f, %5.2f", | |
350 | fCurrentDetElem, manu, x, y)); | |
e4d2775e | 351 | fLogMessage->ShowBottom(); |
215d5755 | 352 | |
e4d2775e | 353 | DrawManuMotif(true); |
215d5755 | 354 | |
e4d2775e | 355 | } |
215d5755 | 356 | } |
e4d2775e | 357 | } |
358 | ||
359 | //__________________________________________________________ | |
215d5755 | 360 | void AliMpDEVisu::DrawDE(Bool_t info) |
e4d2775e | 361 | { |
215d5755 | 362 | /// Draws function graphics in randomly choosen interval |
363 | ||
364 | if (info) | |
e4d2775e | 365 | InfoDE(); |
215d5755 | 366 | |
367 | fEcanvas->GetCanvas()->cd(); | |
368 | fEcanvas->GetCanvas()->SetEditable(kTRUE); | |
369 | ||
370 | if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) { | |
e4d2775e | 371 | |
215d5755 | 372 | DrawSlat("PMCI"); |
373 | ||
374 | } else { | |
375 | ||
376 | DrawQuadrant("RSMCI"); | |
377 | ||
378 | } | |
379 | DeletePopUp(); | |
380 | fEcanvas->GetCanvas()->SetEditable(kFALSE); | |
381 | ||
e4d2775e | 382 | } |
383 | ||
384 | //__________________________________________________________ | |
385 | void AliMpDEVisu::DrawManuMotif(Bool_t popup) | |
386 | { | |
71a2d3aa | 387 | /// Draw manu motif in yellow and popup channel motif window |
e4d2775e | 388 | |
215d5755 | 389 | fEcanvas->GetCanvas()->SetEditable(kTRUE); |
390 | ||
391 | if (!fNumberEntry->GetIntNumber()) return; | |
392 | ||
393 | Char_t command[255]; | |
394 | ||
395 | if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) { | |
396 | ||
397 | sprintf(command, "%s%d", "PMCI:", (Int_t)fNumberEntry->GetIntNumber()); | |
398 | ||
399 | DrawSlat(command, popup); | |
400 | ||
401 | } else { | |
402 | ||
403 | sprintf(command, "%s%d", "RSMCI:", (Int_t)fNumberEntry->GetIntNumber()); | |
404 | ||
405 | DrawQuadrant(command, popup); | |
406 | ||
407 | } | |
408 | ||
409 | fEcanvas->GetCanvas()->SetEditable(kFALSE); | |
e4d2775e | 410 | } |
411 | ||
412 | //__________________________________________________________ | |
413 | void AliMpDEVisu::DrawSlat(Option_t* option, Bool_t popup) | |
414 | { | |
215d5755 | 415 | /// draw slat segmentation |
416 | ||
417 | TCanvas *canvas = fEcanvas->GetCanvas(); | |
418 | canvas->Clear(); | |
419 | ||
420 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); | |
421 | TString nameType = detElem->GetSegType(); | |
422 | ||
423 | AliMpSlatMotifMap mm; | |
424 | AliMpSt345Reader reader(mm); | |
425 | AliMpSlat* slatCurrent = reader.ReadSlat(nameType.Data(), fCurrentPlane); | |
426 | AliMpSlat* slatOther = reader.ReadSlat(nameType.Data(), AliMp::OtherPlaneType(fCurrentPlane)); | |
427 | ||
428 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(slatCurrent); | |
429 | painter->Draw(option); | |
430 | ||
431 | canvas->Update(); | |
432 | ||
433 | Int_t numberOfManu = | |
434 | slatCurrent->GetNofElectronicCards() + | |
435 | slatOther->GetNofElectronicCards(); | |
436 | ||
437 | fLogMessage->AddLine(Form("DrawSlat: number of manus: %d", numberOfManu)); | |
438 | fLogMessage->ShowBottom(); | |
439 | ||
440 | if (popup) | |
441 | PopUpManuMotif(slatCurrent); | |
e4d2775e | 442 | |
e4d2775e | 443 | } |
444 | ||
445 | //__________________________________________________________ | |
215d5755 | 446 | void AliMpDEVisu::DrawQuadrant(Option_t* option, Bool_t popup) |
e4d2775e | 447 | { |
215d5755 | 448 | /// draw quadrant segmentation |
449 | ||
450 | TCanvas *canvas = fEcanvas->GetCanvas(); | |
451 | canvas->Clear(); | |
452 | ||
453 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); | |
454 | AliMp::StationType station = detElem->GetStationType(); | |
e4d2775e | 455 | |
215d5755 | 456 | AliMpSectorReader readerCurrent(station, fCurrentPlane); |
457 | AliMpSector* sectorCurrent = readerCurrent.BuildSector(); | |
458 | ||
459 | AliMpSectorReader readerOther(station, AliMp::OtherPlaneType(fCurrentPlane)); | |
460 | AliMpSector* sectorOther = readerOther.BuildSector(); | |
461 | ||
462 | AliMpVPainter *painter = AliMpVPainter::CreatePainter(sectorCurrent); | |
463 | painter->Draw(option); | |
464 | ||
465 | canvas->Update(); | |
466 | ||
467 | Int_t numberOfManu = | |
e4d2775e | 468 | sectorCurrent->GetMotifMap()->GetNofMotifPositions() + |
469 | sectorOther->GetMotifMap()->GetNofMotifPositions(); | |
e4d2775e | 470 | |
215d5755 | 471 | fLogMessage->AddLine(Form("DrawQuadrant: number of manus: %d", numberOfManu)); |
472 | fLogMessage->ShowBottom(); | |
473 | ||
474 | if (popup) | |
475 | PopUpManuMotif(sectorCurrent); | |
476 | ||
477 | } | |
478 | ||
479 | //______________________________________________________________________________ | |
480 | void | |
481 | AliMpDEVisu::EventToReal(Int_t eventX, Int_t eventY, Double_t& x, Double_t& y) const | |
482 | { | |
483 | /// estimate graphic pad sizes | |
e4d2775e | 484 | |
215d5755 | 485 | static TVector2 ul(gPad->XtoPixel(0.01), gPad->YtoPixel(0.99)); |
486 | static TVector2 br(gPad->XtoPixel(0.99), gPad->YtoPixel(0.01)); | |
e4d2775e | 487 | |
215d5755 | 488 | static TVector2 padDim = br - ul; |
489 | ||
490 | // get DE dimension (half size) | |
491 | TVector2 deDim(fSegmentation->Dimensions()*2.0); | |
492 | ||
493 | TVector2 padReal; | |
494 | ||
495 | if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) | |
496 | { | |
497 | // origin at center | |
498 | x = (eventX - ul.X() - padDim.X()/2.)/(padDim.X())*deDim.X(); | |
499 | y = (br.Y() - eventY - padDim.Y()/2.)/(padDim.Y())*deDim.Y(); | |
500 | ||
501 | } | |
502 | else | |
503 | { | |
504 | // origin at bottom left | |
505 | x = (eventX - ul.X())/(padDim.X())*deDim.X(); | |
506 | y = (br.Y() - eventY)/(padDim.Y())*deDim.Y(); | |
507 | } | |
508 | ||
e4d2775e | 509 | } |
510 | ||
511 | //__________________________________________________________ | |
512 | void AliMpDEVisu::ResetManu() | |
513 | { | |
215d5755 | 514 | /// reset manu search entry |
515 | fLogMessage->AddLine("Reset Motif Search Entry:"); | |
516 | fLogMessage->ShowBottom(); | |
517 | fNumberEntry->SetNumber(0); | |
518 | ||
e4d2775e | 519 | } |
520 | ||
521 | //__________________________________________________________ | |
522 | void AliMpDEVisu::DeletePopUp() | |
523 | { | |
524 | /// delete motif popup windows | |
215d5755 | 525 | |
526 | if (fTrashList.GetEntries() > 0) | |
527 | { | |
528 | fLogMessage->AddLine("Delete Motif PopUp Windows:"); | |
529 | fLogMessage->ShowBottom(); | |
530 | ||
531 | fTrashList.Delete(); | |
532 | } | |
e4d2775e | 533 | } |
534 | ||
535 | //__________________________________________________________ | |
536 | void AliMpDEVisu::SaveLogMessage() | |
537 | { | |
215d5755 | 538 | /// save log message into log file |
539 | ||
540 | TString logFile = fLogFile->GetDisplayText(); | |
541 | fLogMessage->GetText()->Save(logFile.Data()); | |
e4d2775e | 542 | |
215d5755 | 543 | fLogMessage->AddLine(Form("SaveLogMessage: saving log message into logfile: %s", logFile.Data())); |
544 | fLogMessage->ShowBottom(); | |
e4d2775e | 545 | } |
546 | ||
547 | //__________________________________________________________ | |
548 | void AliMpDEVisu::ClearLogMessage() | |
549 | { | |
215d5755 | 550 | /// clear log message |
551 | fLogMessage->GetText()->Clear(); | |
552 | fLogMessage->AddLine("ClearLogMessage: clear log messages:"); | |
553 | fLogMessage->ShowBottom(); | |
e4d2775e | 554 | } |
555 | ||
556 | //__________________________________________________________ | |
557 | void AliMpDEVisu::InfoDE() | |
558 | { | |
215d5755 | 559 | /// info concerning the whole DE |
560 | ||
561 | AliMpDetElement* detElem = fDDLStore->GetDetElement(fCurrentDetElem); | |
562 | Int_t ddlId = detElem->GetDdlId(); | |
563 | Int_t numberOfBus = detElem->GetNofBusPatches(); | |
564 | ||
565 | Int_t vec[24]; | |
566 | for (Int_t i = 0; i < detElem->GetNofBusPatches(); ++i) | |
567 | vec[i] = detElem->GetBusPatchId(i); | |
e4d2775e | 568 | |
215d5755 | 569 | Int_t firstBus = TMath::MinElement(detElem->GetNofBusPatches(), vec); |
570 | Int_t lastBus = TMath::MaxElement(detElem->GetNofBusPatches(), vec); | |
571 | ||
572 | detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); | |
573 | Int_t numberOfSerialManu = detElem->GetNofManus(); // number of manu with an identified serial number | |
574 | ||
575 | fLogMessage->AddLine(Form("DrawDE: detection element: %d, name: %s", | |
576 | fCurrentDetElem, fCurrentDEName.Data())); | |
577 | fLogMessage->ShowBottom(); | |
578 | ||
579 | fLogMessage->AddLine(Form("DrawDE: DDL: %d, number of buspatches %d from %d to %d", | |
580 | ddlId, numberOfBus, firstBus, lastBus)); | |
581 | fLogMessage->ShowBottom(); | |
582 | ||
583 | if (numberOfSerialManu != 0) { // not available yet for all DE | |
584 | fLogMessage->AddLine(Form("DrawDE: number of manus with serial number: %d", numberOfSerialManu)); | |
e4d2775e | 585 | fLogMessage->ShowBottom(); |
215d5755 | 586 | } |
587 | ||
e4d2775e | 588 | } |
589 | ||
590 | //__________________________________________________________ | |
591 | Bool_t AliMpDEVisu::ProcessMessage(Long_t msg, Long_t parm1, Long_t /*parm2*/) | |
592 | { | |
215d5755 | 593 | /// process message from widgets actions/entries |
e4d2775e | 594 | |
215d5755 | 595 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); |
596 | ||
597 | switch(GET_MSG(msg)) | |
598 | { | |
e4d2775e | 599 | case kC_COMMAND: |
600 | switch (GET_SUBMSG(msg)) | |
601 | { | |
215d5755 | 602 | case kCM_COMBOBOX: |
603 | ||
604 | switch (parm1) | |
605 | { | |
606 | case kChamberCombo: | |
607 | UpdateComboDE(); | |
608 | UpdateNameView(); | |
609 | break; | |
610 | ||
611 | case kDECombo: | |
612 | UpdateNameView(); | |
613 | break; | |
d58f6c58 | 614 | |
615 | case kDEName: | |
616 | UpdateComboCH(); | |
617 | break; | |
215d5755 | 618 | } |
619 | break; | |
620 | ||
621 | case kCM_CHECKBUTTON: | |
622 | switch (parm1) | |
623 | { | |
624 | case kPlaneType: | |
625 | if (fPlaneButton->GetState() == kButtonDown) { | |
626 | fCurrentPlane = AliMp::kNonBendingPlane; | |
627 | if (fNumberEntry->GetIntNumber() && fNumberEntry->GetIntNumber() <= 1024) | |
628 | fNumberEntry->SetNumber(fNumberEntry->GetIntNumber() + 1024); | |
629 | } else { | |
630 | fCurrentPlane = AliMp::kBendingPlane; | |
631 | if (fNumberEntry->GetIntNumber() && fNumberEntry->GetIntNumber() > 1024) | |
632 | fNumberEntry->SetNumber(fNumberEntry->GetIntNumber() - 1024); | |
633 | } | |
634 | DrawDE(); | |
635 | fSegmentation = AliMpSegmentation::Instance() | |
636 | ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); | |
637 | break; | |
638 | ||
639 | case kZoomMode: | |
640 | if (fZoomButton->GetState() == kButtonDown) | |
641 | fZoomMode = true; | |
642 | else | |
643 | fZoomMode = false; | |
644 | break; | |
645 | } | |
646 | break; | |
647 | ||
e4d2775e | 648 | } |
649 | break; | |
215d5755 | 650 | } |
651 | return true; | |
e4d2775e | 652 | } |
653 | ||
97c15de5 | 654 | //__________________________________________________________ |
655 | void AliMpDEVisu::NextDE() | |
656 | { | |
215d5755 | 657 | /// select next DE |
658 | ||
659 | Int_t next = fDECombo->GetSelected() + 1; | |
660 | ||
661 | if (next < fDECombo->GetNumberOfEntries()) | |
662 | fDECombo->Select(next); | |
663 | else | |
664 | fDECombo->Select(0); | |
665 | ||
666 | UpdateNameView(); | |
667 | DrawDE(); | |
97c15de5 | 668 | } |
669 | ||
d58f6c58 | 670 | //__________________________________________________________ |
671 | void AliMpDEVisu::UpdateComboCH() | |
672 | { | |
673 | /// update Chamber/DE in respect to DE Name | |
674 | ||
675 | fCurrentDEName = fNameDEComboIdx[fNameDECombo->GetSelected()]; | |
676 | ||
677 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDEName); | |
678 | ||
679 | Int_t Idx = AliMpDEManager::GetChamberId(detElem->GetId()); | |
680 | fChamberCombo->Select(Idx); | |
681 | ||
682 | UpdateComboDE(); | |
683 | ||
684 | Idx = detElem->GetId() % 100; | |
685 | fDECombo->Select(Idx); | |
686 | ||
687 | fCurrentDetElem = fDEComboIdx[fDECombo->GetSelected()]; | |
688 | ||
689 | fSegmentation = AliMpSegmentation::Instance() | |
690 | ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); | |
691 | } | |
692 | ||
e4d2775e | 693 | //__________________________________________________________ |
694 | void AliMpDEVisu::UpdateComboDE() | |
695 | { | |
215d5755 | 696 | /// update DE in respect to selected chamber |
697 | ||
698 | fDECombo->RemoveAll(); | |
699 | ||
700 | AliMpDEIterator it; | |
701 | Int_t i = 0; | |
702 | fDEComboIdx.Reset(); | |
215d5755 | 703 | |
704 | for ( it.First(fChamberCombo->GetSelected()); ! it.IsDone(); it.Next() ) { | |
d58f6c58 | 705 | fDECombo->AddEntry(Form("%d",it.CurrentDE()->GetId()), i); |
215d5755 | 706 | fDEComboIdx[i++] = it.CurrentDE()->GetId(); |
707 | } | |
708 | fDECombo->Select(0); | |
e4d2775e | 709 | } |
710 | ||
711 | //__________________________________________________________ | |
712 | void AliMpDEVisu::UpdateNameView() | |
713 | { | |
215d5755 | 714 | /// update DE name in respect to selected DE id. |
d58f6c58 | 715 | |
215d5755 | 716 | fCurrentDetElem = fDEComboIdx[fDECombo->GetSelected()]; |
d58f6c58 | 717 | |
215d5755 | 718 | AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem); |
d58f6c58 | 719 | |
215d5755 | 720 | fCurrentDEName = detElem->GetDEName(); |
e4d2775e | 721 | |
d58f6c58 | 722 | Int_t entry = fNameDECombo->GetNumberOfEntries(); |
723 | if (fDEOccurrence[fCurrentDetElem] == -1) { | |
724 | fNameDECombo->AddEntry(fCurrentDEName.Data(), entry); | |
725 | fNameDEComboIdx[entry] = fCurrentDEName; | |
726 | fDEOccurrence[fCurrentDetElem] = entry; | |
727 | } | |
728 | ||
729 | fNameDECombo->Select(fDEOccurrence[fCurrentDetElem]); | |
215d5755 | 730 | fSegmentation = AliMpSegmentation::Instance() |
731 | ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane)); | |
732 | } | |
e4d2775e | 733 | |
215d5755 | 734 | //______________________________________________________________________________ |
735 | void | |
736 | AliMpDEVisu::CreatePopupWindow(Int_t w, Int_t h, const char* windowName, | |
737 | AliMpVPainter* painter, | |
738 | const char* option) | |
739 | { | |
71a2d3aa | 740 | /// Create transient frame |
215d5755 | 741 | |
742 | TCanvas* c = new TCanvas(windowName,windowName,-200,100,w,h); | |
e4d2775e | 743 | |
215d5755 | 744 | Int_t n = fTrashList.GetEntries(); |
745 | ||
746 | c->Connect("Closed()","AliMpDEVisu",this,Form("ClosePopupWindow(=%d)",n)); | |
747 | ||
748 | fTrashList.AddLast(c); | |
749 | ||
750 | c->Draw(); | |
751 | ||
752 | painter->Draw(option); | |
753 | ||
754 | c->Update(); | |
e4d2775e | 755 | } |
756 | ||
757 | //__________________________________________________________ | |
758 | void AliMpDEVisu::PopUpManuMotif(AliMpSlat* slat) | |
759 | { | |
215d5755 | 760 | /// pop up manu window motif painter for slat |
761 | ||
762 | // motif painter | |
763 | AliMpMotifPosition* motifPosFound = 0x0; | |
764 | AliMpMotifPosition* motifPos = 0x0; | |
765 | Int_t manuId = 0; | |
e4d2775e | 766 | |
215d5755 | 767 | for ( AliMpSlat::Size_t i = 0; i < slat->GetSize(); ++i ) { |
768 | ||
e4d2775e | 769 | AliMpPCB* pcb = slat->GetPCB(i); |
215d5755 | 770 | |
e4d2775e | 771 | for ( AliMpPCB::Size_t j = 0; j < slat->GetPCB(i)->GetSize(); ++j ) { |
772 | ||
97c15de5 | 773 | motifPos = pcb->GetMotifPosition(j); |
e4d2775e | 774 | |
215d5755 | 775 | manuId = motifPos->GetID(); |
e4d2775e | 776 | if (manuId == (Int_t)fNumberEntry->GetIntNumber()) { |
215d5755 | 777 | motifPosFound = motifPos; |
778 | break; | |
e4d2775e | 779 | } |
780 | } | |
781 | if (motifPosFound) | |
215d5755 | 782 | break; |
e4d2775e | 783 | } |
97c15de5 | 784 | |
215d5755 | 785 | if(motifPosFound) |
786 | { | |
787 | InfoManuMotif(motifPosFound); | |
97c15de5 | 788 | |
215d5755 | 789 | TVector2 dimension(motifPosFound->Dimensions()); |
97c15de5 | 790 | |
215d5755 | 791 | Int_t h = 500; |
792 | Int_t w = Int_t(h*dimension.X()/dimension.Y()); | |
793 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(motifPosFound); | |
794 | ||
795 | CreatePopupWindow(w,h,Form("Manu %d",fNumberEntry->GetIntNumber()), | |
796 | painter,"ZT"); | |
797 | } | |
e4d2775e | 798 | } |
215d5755 | 799 | |
e4d2775e | 800 | //__________________________________________________________ |
801 | void AliMpDEVisu::PopUpManuMotif(AliMpSector* sector) | |
802 | { | |
215d5755 | 803 | /// pop up manu window motif painter for sector |
804 | ||
805 | // motif painter | |
806 | AliMpMotifPosition* motifPosFound = 0x0; | |
807 | AliMpMotifPosition* motifPos = 0x0; | |
808 | Int_t manuId = 0; | |
97c15de5 | 809 | |
215d5755 | 810 | for (Int_t iRow = 0; iRow < sector->GetNofRows(); ++iRow) { |
811 | ||
812 | AliMpRow* row = sector->GetRow(iRow); | |
813 | ||
814 | for (Int_t iRowSeg = 0; iRowSeg < sector->GetRow(iRow)->GetNofRowSegments(); ++iRowSeg){ | |
815 | ||
816 | for (Int_t iRowSeg = 0; iRowSeg < row->GetNofRowSegments(); ++iRowSeg) { | |
817 | AliMpVRowSegment *rowSegment = row->GetRowSegment(iRowSeg); | |
818 | ||
819 | for (Int_t iMotif = 0; iMotif < rowSegment->GetNofMotifs(); ++iMotif){ | |
820 | ||
821 | Int_t motifPositionId = rowSegment->GetMotifPositionId(iMotif); | |
822 | motifPos = rowSegment->GetRow() | |
823 | ->GetMotifMap()->FindMotifPosition(motifPositionId); | |
824 | ||
825 | manuId = motifPos->GetID(); | |
826 | if (manuId == (Int_t)fNumberEntry->GetIntNumber()) { | |
827 | motifPosFound = motifPos; | |
828 | break; | |
829 | } | |
830 | } | |
831 | if (motifPosFound) | |
832 | break; | |
833 | } | |
834 | } | |
835 | if (motifPosFound) | |
836 | break; | |
837 | } | |
838 | ||
839 | if(motifPosFound) | |
840 | { | |
e4d2775e | 841 | |
215d5755 | 842 | InfoManuMotif(motifPosFound); |
e4d2775e | 843 | |
215d5755 | 844 | TVector2 dimension(motifPosFound->Dimensions()); |
e4d2775e | 845 | |
215d5755 | 846 | // Create transient frame |
847 | Int_t h = 400; | |
848 | Int_t w = Int_t(h*dimension.X()/dimension.Y()); | |
e4d2775e | 849 | |
215d5755 | 850 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(motifPosFound); |
851 | ||
852 | CreatePopupWindow(w,h,Form("Manu %d",fNumberEntry->GetIntNumber()), | |
853 | painter,"ZT"); | |
854 | ||
855 | } | |
856 | } | |
e4d2775e | 857 | |
215d5755 | 858 | //__________________________________________________________ |
859 | void AliMpDEVisu::InfoManuMotif(AliMpMotifPosition* motifPos) | |
860 | { | |
861 | /// info for popup manu motif | |
e4d2775e | 862 | |
215d5755 | 863 | // log message |
864 | Int_t manuId = fNumberEntry->GetIntNumber(); | |
865 | TVector2 dimension(motifPos->Dimensions()); | |
866 | fLogMessage->AddLine(Form("PopupManuMotif: motif dimension: %5.2f, %5.2f", | |
867 | dimension.X()*2., dimension.Y()*2.)); | |
868 | ||
869 | fLogMessage->AddLine( Form("PopupManuMotif: pad dimension: %4.2f, %4.2f", | |
870 | motifPos->GetMotif()->GetPadDimensions(0).X()*2., | |
871 | motifPos->GetMotif()->GetPadDimensions(0).Y()*2. )); | |
e4d2775e | 872 | |
215d5755 | 873 | fLogMessage->AddLine( Form("PopupManuMotif: manu: %d, serial number: %d, buspatch: %d", |
874 | manuId, | |
875 | fDDLStore->GetDetElement(fCurrentDetElem)->GetManuSerialFromId(manuId), | |
876 | fDDLStore->GetBusPatchId(fCurrentDetElem, manuId)) ); | |
97c15de5 | 877 | |
215d5755 | 878 | fLogMessage->ShowBottom(); |
e4d2775e | 879 | |
215d5755 | 880 | } |
e4d2775e | 881 | |
215d5755 | 882 | //______________________________________________________________________________ |
883 | void AliMpDEVisu::PopUpZoom(Int_t ix0, Int_t iy0, Int_t ix1, Int_t iy1) | |
884 | { | |
885 | /// popup zoom window | |
e4d2775e | 886 | |
215d5755 | 887 | Double_t x0,y0; |
888 | EventToReal(ix0,iy0,x0,y0); | |
889 | Double_t x1,y1; | |
890 | EventToReal(ix1,iy1,x1,y1); | |
e4d2775e | 891 | |
215d5755 | 892 | fLogMessage->AddLine(Form("PopUpZoom: zoom positions (x0, y0: %6.2f, %6.2f), (x1, y1: %6.2f, %6.2f)", |
893 | x0, y0, x1, y1)); | |
894 | fLogMessage->ShowBottom(); | |
895 | ||
896 | // Create transient frame | |
897 | Int_t h = 500;//TMath::Abs(x1-x0); | |
898 | Int_t w = 500;//TMath::Abs(y1-y0); | |
e4d2775e | 899 | |
215d5755 | 900 | AliMpArea area(TVector2((x0+x1)/2.0,(y0+y1)/2.0), |
901 | TVector2(TMath::Abs(x1-x0)/2.0,TMath::Abs(y1-y0)/2.0)); | |
902 | // area.Print(); | |
903 | ||
904 | if ( area.IsValid() ) | |
905 | { | |
906 | AliMpVPadIterator* iterator = fSegmentation->CreateIterator(area); | |
907 | if (iterator) | |
908 | { | |
909 | AliMpVPainter* painter = AliMpVPainter::CreatePainter(iterator); | |
910 | CreatePopupWindow(w,h,"Zoom",painter,""); | |
e4d2775e | 911 | } |
215d5755 | 912 | else |
913 | { | |
914 | AliError("could not get iterator for that area"); | |
e4d2775e | 915 | } |
215d5755 | 916 | |
917 | delete iterator; | |
918 | } | |
97c15de5 | 919 | } |
920 | ||
921 | //__________________________________________________________ | |
215d5755 | 922 | void AliMpDEVisu::ClosePopupWindow(Int_t id) |
97c15de5 | 923 | { |
215d5755 | 924 | /// close signal |
925 | fEcanvas->GetCanvas()->cd(); | |
926 | fTrashList.RemoveAt(id); | |
e4d2775e | 927 | } |