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