GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseLSPlayer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #include <Riostream.h>
24 
25 
26 #ifndef ROOT_KeySymbols
27 #include "KeySymbols.h"
28 #endif
29 
30 #ifndef ROOT_TBox
31 #include "TBox.h"
32 #endif
33 
34 #ifndef ROOT_TCanvas
35 #include "TCanvas.h"
36 #endif
37 
38 #ifndef ROOT_TContextMenu
39 #include "TContextMenu.h"
40 #endif
41 
42 #ifndef ROOT_TGaxis
43 #include "TGaxis.h"
44 #endif
45 
46 #ifndef ROOT_TGToolTip
47 #include "TGToolTip.h"
48 #endif
49 
50 #ifndef ROOT_TList
51 #include "TList.h"
52 #endif
53 
54 #ifndef ROOT_TMath
55 #include "TMath.h"
56 #endif
57 
58 #ifndef ROOT_TMethod
59 #include "TMethod.h"
60 #endif
61 
62 #ifndef ROOT_TPad
63 #include "TPad.h"
64 #endif
65 
66 #ifndef ROOT_TVirtualX
67 #include "TVirtualX.h"
68 #endif
69 
70 #ifndef ROOT_TROOT
71 #include "TROOT.h"
72 #endif
73 
74 #ifndef Gw_BaseLSPlayer
75 #include "BaseLSPlayer.h"
76 #endif
77 
78 #ifndef Gw_BaseNucleus
79 #include "BaseNucleus.h"
80 #endif
81 
82 #ifndef Gw_GammaLink
83 #include "GammaLink.h"
84 #endif
85 
86 #ifndef Gw_NuclearLevel
87 #include "NuclearLevel.h"
88 #endif
89 
90 #ifndef Gw_Peak1D
91 #include "Peak1D.h"
92 #endif
93 
94 #ifndef Gw_EnsdfLevelSchemeReader
95 #include "EnsdfLevelSchemeReader.h"
96 #endif
97 
98 #ifndef Gw_RadLevelSchemeReader
99 #include "RadLevelSchemeReader.h"
100 #endif
101 
102 
103 using namespace Gw;
104 Float_t BaseLSPlayer::fgDefaultSize[4] = {28000, 32000, 0, 6000};
105 Float_t BaseLSPlayer::fgDefaultWidth = 600;
107 
108 //
109 
110 //__________________________________________________________
112  TNamed("BaseLSPlayer", "Default"),
113  fLastX(0),
114  fLastY(0),
115  fBox(new TBox(0, fgDefaultWidth, 0, fgDefaultWidth)),
116  fSelectedLinks(new Cascade()),
117  fSelectedLevels(new Cascade()),
118  fSelectedCascades(new TList()),
119  fNucleiList(new TList()),
120  fLevelScheme(levelScheme),
121  fDrawStyle(kUnknown),
122  fAxis(new LSaxis()),
123  fInfoTip(new TGToolTip(fBox, "", 350)),
124  fIsOnAxis(true),
125  fIsTipsOn(true),
126  fIsLSSelected(false),
127  fCColorSelectedLink(BasePeak::gGateColor.k0),
128  fPositionLabels(0.),
129  fLog("BaseLSPlayer")
130  //,
131  // fURLtoSaveLS("./")
132 {
133  // default constructor
134 
135  fSelectedCascades->SetOwner(false);
136  fNucleiList->SetOwner(true);
137  fAxis->SetLineWidth(2);
138  fAxis->SetNdivisions(510);
139  fAxis->SetLabelSize(0.04);
140 }
141 
142 //__________________________________________________________
144 {
145  // default destructor
146  delete fSelectedLinks; // default wise not owner of the links (levels)
147  delete fSelectedLevels;
148  delete fSelectedCascades;
149  delete fNucleiList;
150  delete fAxis;
151  delete fInfoTip;
152  delete fBox;
153 }
154 
155 //__________________________________________________________
156 void BaseLSPlayer::SetTipText(TObject* select)
157 {
158 
159  TString name(select->ClassName());
160 
161  if ( name.CompareTo("Gw::Link") == 0 ) {
162  Link* link = static_cast<Link*> ( select );
163  fInfoTip->SetText(Form("Strength: %5.1f", link->GetStrength().Get()) );
164  }
165 
166  if ( name.CompareTo("Gw::Level") == 0 ) {
167  fInfoTip->SetText("Level");
168  }
169 
170  if ( select->InheritsFrom("Gw::GammaLink") ) {
171  GammaLink* link = static_cast<GammaLink*> ( select );
172  if (link->IsE())
173  fInfoTip->SetText(Form("Strength: %6.1f\nEnergy: %6.1f\nPolarity: E%d", link->GetStrength().Get(), link->GetEnergy().Get(), link->GetLambda()) );
174  else
175  fInfoTip->SetText(Form("Strength: %6.1f\nEnergy: %6.1f\nPolarity: M%d", link->GetStrength().Get(), link->GetEnergy().Get(), link->GetLambda()) );
176  }
177 
178  if ( select->InheritsFrom("Gw::NuclearLevel") ) {
179  NuclearLevel* level = static_cast<NuclearLevel*> ( select );
180  if ( level->GetParity().IsParity(Parity::kPlus) )
181  fInfoTip->SetText(Form("Energy: %6.1f\nSpin: %s+\nHalf-Live: %6.1f",
182  level->GetEnergy().Get(),
183  level->GetSpin().GetString(),
184  level->GetT().Get()) );
185  else
186  fInfoTip->SetText(Form("Energy: %6.1f\nSpin: %s-\nHalf-Live: %6.1f",
187  level->GetEnergy().Get(),
188  level->GetSpin().GetString(),
189  level->GetT().Get()) );
190  }
191 
192 }
193 
194 //__________________________________________________________
195 Bool_t BaseLSPlayer::Connect(TCanvas *canvas)
196 {
197  fLog.SetProcessMethod("Connect(TCanvas* )");
198 
199  TCanvas *localCanvas = canvas;
200 
201  // in this case connect the current canvas
202  if ( canvas == 0x0 ) {
203  if ( TVirtualPad::Pad() )
204  localCanvas = TVirtualPad::Pad()->GetCanvas();
205  else {
206  fLog << warning << "Pad not existing yet" << nline ;
207  }
208  }
209  if ( localCanvas) {
210  localCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
211  "Gw::BaseLSPlayer",
212  this,
213  "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
214  fContextMenu = localCanvas->GetContextMenu();
215  }
216 
217  fLog << dolog;
218 
219  return localCanvas != 0x0;
220 }
221 
222  //__________________________________________________________
223 Bool_t BaseLSPlayer::Disconnect(TCanvas *canvas)
224 {
225  fLog.SetProcessMethod("Disconnect(TCanvas* )");
226 
227  TCanvas *localCanvas = canvas;
228 
229  // in this case connect the current canvas
230  if ( canvas == 0x0 ) {
231  if ( TVirtualPad::Pad() ) {
232  localCanvas = TVirtualPad::Pad()->GetCanvas();
233  } else {
234  fLog << error << "Pad not existing" << dolog;
235  }
236  }
237  if ( localCanvas ) {
238  TQObject::Disconnect(localCanvas,"HandleMovement(Int_t, Int_t, Int_t, TObject*)",this);
239  }
240 
241  fContextMenu = 0x0;
242 
243  fLog << dolog;
244  return localCanvas != 0x0;
245 }
246 
247 //__________________________________________________________
248 void BaseLSPlayer::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* select)
249 {
250  // handle cursor mouvement
251 
252  TVirtualPad* pad = TVirtualPad::Pad();
253  pad->cd();
254 
255  if (eventType == kButton1Up) {
256 
257  for(int i=0 ; i<GetLinkList().GetEntries() ; i++)
258  {
259  if(GetLinkList().At(i)->InheritsFrom("Gw::Link"))
260  {
261  Link* link = static_cast<Link*>(GetLinkList().At(i));
262 
263  link->RefreshPoints();
264  link->Paint();
265  gPad->Modified();
266  gPad->Update();
267  }
268  }
269  }
270 
271  if (eventType == kMouseMotion) {
272  // to keep track of the last mouse position
273  fLastX = eventX; fLastY = eventY;
274 
275  if ( select->InheritsFrom("Gw::BaseLSPlayer") ||
276  select->InheritsFrom("Gw::Cascade") ||
277  select->InheritsFrom("Gw::LevelScheme") ) {
278  pad->SetCursor(kPointer);
279  }
280 
281  if ( select->InheritsFrom("Gw::Link") ) {
282  Link* link = static_cast<Link*>(select);
283  if ( !link->IsMovable() )
284  pad->SetCursor(kPointer);
285  }
286 
287  if ( select->InheritsFrom("Gw::Level") ) {
288  Level* level = static_cast<Level*>(select);
289  if ( !level->IsMovable() )
290  pad->SetCursor(kPointer);
291  }
292 
293  if (fIsTipsOn) {
294  if ( select->InheritsFrom("Gw::Link") || select->InheritsFrom("Gw::Level")) {
295  SetTipText(select);
296  fInfoTip->Show(fLastX, fLastY);
297  } else
298  fInfoTip->Hide();
299  }
300  }
301 
302  if( eventType == kKeyPress) {
303  TObject *obj = 0x0;
304  Int_t keysym = eventY;
305  Color_t color = 0;
306  Bool_t keyPress = false;
307  switch ((EKeySym) keysym ) {
308  case kKey_s:
309  color = fCColorSelectedLink;
310  keyPress = true;
311  break;
312  case kKey_0:
313  case kKey_x:
314  color = BasePeak::gGateColor.k0;
315  fCColorSelectedLink = color;
316  keyPress = true;
317  break;
318  case kKey_1:
319  case kKey_y:
320  color = BasePeak::gGateColor.k1;
321  fCColorSelectedLink = color;
322  keyPress = true;
323  break;
324  case kKey_2:
325  case kKey_z:
326  color = BasePeak::gGateColor.k2;
327  fCColorSelectedLink = color;
328  keyPress = true;
329  break;
330  case kKey_3:
331  color = BasePeak::gGateColor.k3;
332  fCColorSelectedLink = color;
333  keyPress = true;
334  break;
335 
336  default:
337  keyPress = false;
338  break;
339  }
340 
341  if ( select->InheritsFrom("Gw::Link") && keyPress) {
342  Link* link = static_cast<Link*>(select);
343  if (link->IsSelected()) {
344  link->SetFillColor( Link::GetDefaultColor() );
345  link->DeSelected();
346  fSelectedLinks->Remove(link);
347  } else {
348  link->SetFillColor(color);
349  link->Selected();
350  fSelectedLinks->Add(link);
351  }
352  TIter next(fSelectedLinks);
353  while ( (obj = next()) )
354  link = static_cast<Link*> ( obj );
355  fLevelScheme->SetCLink(link);
356  }
357 
358  if ( (EKeySym)keysym == kKey_s) {
359 
360  if ( select->InheritsFrom("Gw::Level") ) {
361  Level* level = static_cast<Level*>(select);
362  if (level->IsSelected()) {
363  level->SetLineColor( Level::GetDefaultColor(level->GetDefaultColor()) );
364  level->DeSelected();
365  fSelectedLevels->Remove(level);
366  } else {
367  level->SetLineColor( Level::GetDefaultColor(Level::kSelected) );
368  level->Selected();
369  fSelectedLevels->Add(level);
370  }
371  TIter next(fSelectedLevels);
372  while ( (obj = next()) )
373  level = static_cast<Level*> ( obj );
374  fLevelScheme->SetCLevel(level);
375  }
376 
377  Link* link = 0x0;
378  if ( select->InheritsFrom("Gw::Cascade") ) {
379  Cascade* cas = static_cast<Cascade*>(select);
380  if (cas->IsSelected()) {
381  for (Int_t i = 0; i < cas->GetSize(); ++i) {
382  link = static_cast<Link*> (cas->At(i));
383  link->SetFillColor( Link::GetDefaultColor() );
384  link->DeSelected();
385  }
386  cas->DeSelected();
388  fSelectedCascades->Remove(cas);
389  } else {
390  for (Int_t i = 0; i < cas->GetSize(); ++i) {
391  link = static_cast<Link*> (cas->At(i));
392  link->SetFillColor(fCColorSelectedLink);
393  link->Selected();
394  }
395  cas->Selected();
397  fSelectedCascades->Add(cas);
398  }
399  TIter next(fSelectedCascades);
400  while ( (obj = next()) )
401  cas = static_cast<Cascade*> ( obj );
403  }
404  }
405 
406  if ( (EKeySym)keysym == kKey_g)
407  ShowGate();
408 
409  if ( (EKeySym)keysym == kKey_P)
410  DrawProjTot();
411 
412  if ( (EKeySym)keysym == kKey_t) {
413  if (fIsOnAxis == true) {
414  fIsOnAxis = false;
415  fAxis->SetLineColor(GetDefaultToggleColor());
416  fAxis->SetLabelColor(GetDefaultToggleColor());
417  }
418  else if (fIsOnAxis == false) {
419  fIsOnAxis = true;
420  fAxis->SetLineColor(1);
421  fAxis->SetLabelColor(1);
422  }
423  }
424 
425  if ( (EKeySym)keysym == kKey_i) {
426  if (fIsTipsOn == true) {
427  fIsTipsOn = false;
428  fInfoTip->Hide();
429  } else if (fIsTipsOn == false)
430  fIsTipsOn = true;
431  }
432 
433  if ( (EKeySym)keysym == kKey_a) {
434  if (fIsLSSelected == true) {
435  fIsLSSelected = false;
436  DeSelect();
437  } else if (fIsLSSelected == false) {
438  fIsLSSelected = true;
439  Select();
440  }
441  }
442 
443 
444  if ( (EKeySym)keysym == kKey_h) {
445  cout << "Keys used to interact with LSPlayer: " << endl;
446  cout << "\t s: select a link/level/cascade " << endl;
447  cout << "\t 1/x: select a link for a gate on x-axis " << endl;
448  cout << "\t 2/y: select a link for a gate on y-axis " << endl;
449  cout << "\t 3/z: select a link for a gate on z-axis " << endl;
450  cout << "\t 4 : select a link for a gate on t-axis " << endl;
451  cout << "\t a: select the whole level scheme " << endl;
452  cout << "\t g: Show gates " << endl;
453  cout << "\t P: Draw total projection " << endl;
454  cout << "\t i: Toggle on/off information tips that appears when passing over an object" << endl;
455  cout << "\t t: Toggle on/off active LS menu on canvas " << endl;
456  cout << "\t l: Popup dialog box for Add Link method " << endl;
457  cout << "\t e: Popup dialog box for Add Level method " << endl;
458  cout << "\t f: Popup dialog box for Add First Level method " << endl;
459  cout << "\t G: Popup dialog box for Add Ground Level method " << endl;
460  cout << "\t w: Popup dialog box for writing level scheme in a root file " << endl;
461  cout << "\t p: Popup dialog box for making projection from registered correlated space " << endl;
462  }
463 
464  if ( (EKeySym)keysym == kKey_l)
465  PopupAddLink();
466 
467  if ( (EKeySym)keysym == kKey_e)
468  PopupAddLevel();
469 
470  if ( (EKeySym)keysym == kKey_f)
472 
473  if ( (EKeySym)keysym == kKey_G)
475 
476  if ( (EKeySym)keysym == kKey_w)
477  PopupWriteLS();
478 
479  if ( (EKeySym)keysym == kKey_p)
480  PopupDoProject();
481 
482  pad->Modified();
483  pad->Update();
484  }
485 
486  pad->cd();
487 }
488 
489 //__________________________________________________________
490 Int_t BaseLSPlayer::CollectLinks(Option_t* o)
491 {
492  fLog.SetProcessMethod("CollectLinks(Option_t* )");
493 
494  // create link list from pad
495 
496  TVirtualPad* pad = TVirtualPad::Pad();
497  pad->cd();
498 
499  if ( !pad ) {
500  fLog << error << "Pad not existing" << dolog;
501  return 0;
502  }
503 
504  TString opt = o;
505  if ( !opt.Contains("+") )
506  fSelectedLinks->Clear();
507 
508  TObject *obj; Int_t i = 0;
509 
510  TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
511  while ( (obj = next()) ) // iterator skips empty slots
512  if ( obj->InheritsFrom("Gw::Link") ) {
513  if (!fSelectedLinks->FindObject(obj)) {
514  Link* link = static_cast<Link*> (obj);
515  if ( link->IsSelected() ) {
516  fSelectedLinks->Add(obj); i++;
517  }
518  }
519  }
520 
521  fLog << info << Form("Collect %d links", i) << dolog;
522  return i;
523 }
524 
525 //__________________________________________________________
526 Int_t BaseLSPlayer::CollectLevels(Option_t* o)
527 {
528  fLog.SetProcessMethod("CollectLevels(Option_t* )");
529 
530  // create link list from pad
531 
532  TVirtualPad* pad = TVirtualPad::Pad();
533  pad->cd();
534 
535  if ( !pad ) {
536  fLog << error << "Pad not existing" << dolog;
537  return 0;
538  }
539 
540  TString opt = o;
541  if ( !opt.Contains("+") )
542  fSelectedLevels->Clear();
543 
544  TObject *obj; Int_t i = 0;
545 
546  TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
547  while ( (obj = next()) ) // iterator skips empty slots
548  if ( obj->InheritsFrom("Gw::Level") ) {
549  if (!fSelectedLevels->FindObject(obj)) {
550  Level* level = static_cast<Level*> (obj);
551  if ( level->IsSelected() ) {
552  fSelectedLevels->Add(obj); i++;
553  }
554  }
555  }
556 
557  fLog << info << Form("Collect %d levels", i) << dolog;
558  return i;
559 }
560 
561 //__________________________________________________________
562 Int_t BaseLSPlayer::CollectCascades(Option_t* o)
563 {
564  fLog.SetProcessMethod("CollectCascades(Option_t* )");
565 
566  // create link list from pad
567 
568  TVirtualPad* pad = TVirtualPad::Pad();
569  pad->cd();
570 
571  if ( !pad ) {
572  fLog << error << "Pad not existing" << dolog;
573  return 0;
574  }
575 
576  TString opt = o;
577  if ( !opt.Contains("+") )
578  fSelectedCascades->Clear();
579 
580  TObject *obj; Int_t i = 0;
581 
582  TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
583  while ( (obj = next()) ) // iterator skips empty slots
584  if ( obj->InheritsFrom("Gw::Cascade") ) {
585  if (!fSelectedCascades->FindObject(obj)) {
586  Cascade* cas = static_cast<Cascade*> (obj);
587  if ( cas->IsSelected() ) {
588  fSelectedCascades->Add(obj); i++;
589  }
590  }
591  }
592 
593  fLog << info << Form("Collect %d cascades", i) << dolog;
594  return i;
595 }
596 
597 //__________________________________________________________
598 Int_t BaseLSPlayer::DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)
599 {
600  Int_t d;
601  if (fIsOnAxis)
602  d = 9999;
603  else
604  d = 0;
605 
606  return d;
607 }
608 
609 //__________________________________________________________
610 void BaseLSPlayer::Draw(Option_t *opt)
611 {
612  // draw level scheme
613 
614  fLog.SetProcessMethod("Draw(Option_t* )");
615 
616  TString style(opt);
617  style.ToLower();
618 
619  Level *level;
620  Double_t xmin, xmax, ymin, ymax;
621  Double_t xminOld = 0.;
622  Double_t xmaxOld = 0.;
623 // Double_t yminOld = 0.;
624  Double_t ymaxOld = 0.;
625 
626  Double_t xRminOld, xRmaxOld, yRminOld, yRmaxOld;
627  Bool_t p1 = false, p2 = false, pL = false;
628 
629  TList* levels = &fLevelScheme->GetLevelList();
630  TList* links = &fLevelScheme->GetLinkList();
631  TList* cascades = &fLevelScheme->GetCascadeList();
632  TLatex* name = &fLevelScheme->GetNameLatex();
633 
634  // first draw label
635  if (!style.Contains("-t"))
636  name->Draw("");
637 
638  if ( levels->GetSize() == 0 ) return;
639 
640  // switch to current style
641  if (style.Contains("rad") && !IsDrawStyle(kRadware))
642  DoStyle(kRadware);
643 
644  if (style.Contains("ensdf") && !IsDrawStyle(kEnsdf)) {
645  DoStyle(kEnsdf);
646  }
647 
648  // add all levels to the current pad.
649  if (!style.Contains("-le"))
650  levels->Draw("");
651 
652  if (!style.Contains("-b"))
653  cascades->Draw("");
654 
655  if (!style.Contains("-l"))
656  links->Draw("");
657 
658  // loop over all levels to determine the canvas range
659  level = (Level *)levels->First();
660  xmin = level->GetX1(); xmax = level->GetX2(); ymin = level->GetY1(); ymax = level->GetY2();
661 
662  TIter iter(levels);
663  while ( (level = (Level *)iter()) ) {
664  if ( level->GetX1() < xmin ) xmin = level->GetX1();
665  if ( level->GetX2() > xmax ) xmax = level->GetX2();
666  if ( level->GetY1() < ymin ) ymin = level->GetY1();
667  if ( level->GetY1() > ymax ) ymax = level->GetY1();
668  }
669 
670  Double_t xRmin = GetXRmin(xmin, xmax);
671  Double_t xRmax = GetXRmax(xmin, xmax);
672 
673  Double_t yRmin = GetYRmin(ymin, ymax);
674  Double_t yRmax = GetYRmax(ymin, ymax);
675 
676 
677  if ( xmin > xmax || ymin > ymax ) {
678  fLog << error << Form(" Problem when computing pad range, xmin > xmax or ymin > ymax") << dolog;
679  return;
680  }
681 
682  if ( TVirtualPad::Pad() != 0 ) { // in principle, gpad exists
683  TVirtualPad::Pad()->GetRange(xRminOld, yRminOld, xRmaxOld, yRmaxOld);
684 
685  xminOld = GetXMin(xRminOld, xRmaxOld);
686  xmaxOld = GetXMax(xRminOld, xRmaxOld);
687 
688 // yminOld = GetYMin(yRminOld, yRmaxOld);
689  ymaxOld = GetYMax(yRminOld, yRmaxOld);
690 
691  if (xRmin < xRminOld || xRmax > xRmaxOld)
692  p1 = true;
693 
694  if (yRmin < yRminOld || yRmax > xRmaxOld)
695  p2 = true;
696 
697  if ( p1 && p2) {
698  pL= true;
699  p1 = false;
700  p2 = false;
701  }
702  }
703 
704  if (p1) {
705  TVirtualPad::Pad()->Range(xRmin, yRminOld, xRmax, yRmaxOld);
706  fAxis->SetX1(BaseLSPlayer::GetXAxis(xmin, xmax));
707  fAxis->SetX2(BaseLSPlayer::GetXAxis(xmin, xmax));
708  fAxis->SetY1(0.0); fAxis->SetY2(ymaxOld);
709  fAxis->SetWmin(0.0);
710  fAxis->SetWmax(ymaxOld);
711  }
712 
713  if (p2) {
714  TVirtualPad::Pad()->Range(xRminOld, yRmin, xRmaxOld, yRmax);
716  fAxis->SetX1(BaseLSPlayer::GetXAxis(xminOld, xmaxOld));
717  fAxis->SetX2(BaseLSPlayer::GetXAxis(xminOld, xmaxOld));
718  fAxis->SetY1(0.0); fAxis->SetY2(ymax);
719  fAxis->SetWmin(0.0);
720  fAxis->SetWmax(ymax);
721  }
722 
723  if (pL) {
724  TVirtualPad::Pad()->Range(xRmin, yRmin, xRmax, yRmax);
726  fAxis->SetX1(BaseLSPlayer::GetXAxis(xmin, xmax));
727  fAxis->SetX2(BaseLSPlayer::GetXAxis(xmin, xmax));
728  fAxis->SetY1(0.0); fAxis->SetY2(ymax);
729  fAxis->SetWmin(0.0);
730  fAxis->SetWmax(ymax);
731  }
732 
733  name->SetNDC();
734  name->SetX(0.55); name->SetY(0.95);
735 
736  fAxis->Draw();
737 
738  AppendPad();
739  fLog << debug << "End drawing list of levels" << dolog;
740 }
741 
742 //__________________________________________________________
744 {
745  // change existing drawing style
746  fDrawStyle = style;
747 
748  TList* list = &GetLinkList();
749 
750  for (Int_t i = 0; i < list->GetEntries(); ++i) {
751 
752  Link* link = static_cast<Link*> ( list->At(i) );
753 
754  Double_t xi = link->GetX()[1];
755  Double_t xf = link->GetX()[5];;
756  Double_t x, y, offset1 = 0., offset2 = 0., prop;
757 
758  if ( style == kRadware ) {
759  offset1 = TMath::Max(TMath::Abs(link->GetIL()->GetX2() - link->GetIL()->GetX1())/30.,
760  link->GetStrength().Get()/2.0);
761  offset2 = TMath::Min(2.5*offset1, TMath::Abs(link->GetIL()->GetX2() - link->GetIL()->GetX1())/2.);
762  }
763 
764  if ( style == kEnsdf ) {
765  offset1 = TMath::Abs(link->GetIL()->GetX2() - link->GetIL()->GetX1())/70.;
766  offset2 = 5*offset1;
767  }
768 
769  prop = 3.0/4.0;
770 
771  if ( link->GetIL() && link->GetFL() ) {
772 
773  x = xi; y = link->GetY()[1];
774  link->SetPoint(0,x-offset1,y);
775  link->SetPoint(1,x,y);
776  link->SetPoint(2,x+offset1,y);
777  link->SetPoint(8,x-offset1,y);
778 
779  x = xi + prop*(xf-xi);
780  y = link->GetIL()->GetY1() - prop*(link->GetIL()->GetY1() - link->GetFL()->GetY1());
781  link->SetPoint(3,x+offset1,y);
782  link->SetPoint(4,x+offset2,y);
783  link->SetPoint(6,x-offset2,y);
784  link->SetPoint(7,x-offset1,y);
785 
786  x = xf; y = link->GetFL()->GetY1();
787  link->SetPoint(5,x,y);
788  }
789  }
790 }
791 
792 //__________________________________________________________
793 Int_t BaseLSPlayer::ImportLevelScheme(const Char_t* filename, Option_t* opt)
794 {
795  // import file with dedicated readers
796  TString fname(filename);
797  Int_t ok = 0;
798 
799  if ( fname.EndsWith(".ags") ) {
800  RadLevelSchemeReader reader(filename, opt);
801  ok= reader.Import(*fLevelScheme);
802  DoStyle(kRadware);
803  }
804 
805  if ( fname.EndsWith(".ens") ) {
806  EnsdfLevelSchemeReader reader(filename, opt);
807  ok = reader.Import(*fLevelScheme);
808  DoStyle(kEnsdf);
809  }
810 
811  return ok;
812 }
813 
814 //__________________________________________________________
815 Int_t BaseLSPlayer::ReadAGS(const Char_t *filename, Option_t *opt)
816 {
817  // for backward compatibility
818  RadLevelSchemeReader reader(filename, opt);
819  return reader.Import(*fLevelScheme);
820 }
821 
822 //__________________________________________________________
823 Int_t BaseLSPlayer::ReadENSDF(const Char_t *filename, Option_t *opt)
824 {
825  // for backward compatibility
826  EnsdfLevelSchemeReader reader(filename, opt);
827  return reader.Import(*fLevelScheme);
828 }
829 
830 //-----------------------------------------------------------------------------------------
832 
833 //_______________________________________________
834 LSaxis::LSaxis()
835 : TGaxis(),
836  fLastX(0),
837  fLastY1(0),
838  fLastY2(0),
839  fFirst1Zoom(true),
840  fFirst2Zoom(true),
841  fLastY1Zoom(0),
842  fLastY2Zoom(0)
843 {
844 
845 }
846 
847 //__________________________________________________________
848 void LSaxis::SetY1(Double_t y1)
849 {
850  TGaxis::SetY1(y1);
851  if (fFirst1Zoom) {
852  fLastY1Zoom = (Int_t)y1;
853  fFirst1Zoom = false;
854  if (TVirtualPad::Pad() != 0) {
855  Double_t xRmin, yRmin, xRmax, yRmax;
856  TVirtualPad::Pad()->GetRange(xRmin, yRmin, xRmax, yRmax);
857  fLastX1Zoom = Int_t(BaseLSPlayer::GetXMin(xRmin, xRmax)+0.5);
858  }
859  }
860 }
861 
862 //__________________________________________________________
863 void LSaxis::SetY2(Double_t y2)
864 {
865  TGaxis::SetY2(y2);
866  if (fFirst2Zoom) {
867  fLastY2Zoom = (Int_t)y2;
868  fFirst2Zoom = false;
869  if (TVirtualPad::Pad() != 0) {
870  Double_t xRmin, yRmin, xRmax, yRmax;
871  TVirtualPad::Pad()->GetRange(xRmin, yRmin, xRmax, yRmax);
872  fLastX2Zoom = Int_t(BaseLSPlayer::GetXMax(xRmin, xRmax)+0.5);
873  }
874  }
875 }
876 
877 //__________________________________________________________
878 void LSaxis::ExecuteEvent(Int_t eventType, Int_t eventX, Int_t eventY)
879 {
880  // handle cursor mouvement
881 
882  TVirtualPad* pad = TVirtualPad::Pad();
883  pad->cd();
884  static Int_t eventYOld = 0;
885  static Bool_t buttonMotion = false;
886  if (eventType == kMouseMotion) {
887  eventYOld = eventY;
888  pad->SetCursor(kHand);
889  }
890 
891  if (eventType == kButton1Down) {
892  fLastX = eventX; fLastY1 = eventY;
893  gVirtualX->SetLineColor(-1);
894  }
895 
896  if (eventType == kButton1Motion) {
897  gVirtualX->DrawBox(fLastX-10, fLastY1, fLastX+10, eventYOld, TVirtualX::kHollow);
898  gVirtualX->DrawBox(fLastX-10, fLastY1, fLastX+10, eventY, TVirtualX::kHollow);
899  eventYOld = eventY;
900  fLastY2 = eventY;
901  buttonMotion = true;
902  }
903 
904  if (eventType == kButton1Up && buttonMotion) {
905 
906  fLastY1 = (Int_t)gPad->AbsPixeltoY(fLastY1);
907  fLastY2 = (Int_t)gPad->AbsPixeltoY(fLastY2);
908 
909  if (fLastY1 > fLastY2) {
910  Int_t tmp = fLastY2;
911  fLastY2 = fLastY1;
912  fLastY1 = tmp;
913  }
914 
915  SetWmin(fLastY1);
916  SetWmax(fLastY2);
917 
918  Double_t yRmin = BaseLSPlayer::GetYRmin(fLastY1, fLastY2);
919  Double_t yRmax = BaseLSPlayer::GetYRmax(fLastY1, fLastY2);
920 
921  Double_t yMin = BaseLSPlayer::GetYMin(yRmin, yRmax);
922  Double_t yMax = BaseLSPlayer::GetYMax(yRmin, yRmax);
923 
924  SetY1(yMin); SetY2(yMax);
925  pad->Range(pad->GetX1(), yRmin, pad->GetX2(), yRmax);
926  pad->Modified(true);
927  buttonMotion = false;
928  }
929 }
930 
931 //__________________________________________________________
932 void LSaxis::SetRange(Int_t ymin, Int_t ymax, Int_t xmin, Int_t xmax)
933 {
934  TVirtualPad* pad = TVirtualPad::Pad();
935  pad->cd();
936 
937  SetWmin(ymin);
938  SetWmax(ymax);
939 
940  Double_t yRmin = BaseLSPlayer::GetYRmin(ymin, ymax);
941  Double_t yRmax = BaseLSPlayer::GetYRmax(ymin, ymax);
942 
943  Double_t xRmin = BaseLSPlayer::GetXRmin(xmin, xmax);
944  Double_t xRmax = BaseLSPlayer::GetXRmax(xmin, xmax);
945 
946  Double_t yAxisMin = BaseLSPlayer::GetYMin(yRmin, yRmax);
947  Double_t yAxisMax = BaseLSPlayer::GetYMax(yRmin, yRmax);
948 
949 
950  SetY1(yAxisMin); SetY2(yAxisMax);
951  SetX1(xmin-(xmax-xmin)*0.1); SetX2(xmin-(xmax-xmin)*0.1);
952  pad->Range(xRmin, yRmin, xRmax, yRmax);
953  pad->Modified(true);
954 
955  fLastY1Zoom = ymin;
956  fLastY2Zoom = ymax;
957  fLastX1Zoom = xmin;
958  fLastX2Zoom = xmax;
959 }
960 
961 //__________________________________________________________
963 {
964  TVirtualPad* pad = TVirtualPad::Pad();
965  pad->cd();
966 
967  SetWmin(fLastY1Zoom);
968  SetWmax(fLastY2Zoom);
969 
970  Double_t yRmin = BaseLSPlayer::GetYRmin(fLastY1Zoom, fLastY2Zoom);
971  Double_t yRmax = BaseLSPlayer::GetYRmax(fLastY1Zoom, fLastY2Zoom);
972 
973  Double_t yMin = BaseLSPlayer::GetYMin(yRmin, yRmax);
974  Double_t yMax = BaseLSPlayer::GetYMax(yRmin, yRmax);
975 
976  SetY1(yMin); SetY2(yMax);
977 
978  pad->Range(pad->GetX1(), yRmin, pad->GetX2(), yRmax);
979  pad->Modified(true);
980 }
981 
A level Scheme.
Definition: LevelScheme.h:82
virtual Int_t CollectLevels(Option_t *o="")
Collect selected leveks.
TLatex & GetNameLatex()
to get Name latex object
Definition: LevelScheme.h:140
virtual void DeSelected()
unselected link
Definition: Level.h:207
TContextMenu * fContextMenu
Definition: BaseLSPlayer.h:301
static Color_t GetDefaultColor(EDefaultColor d)
Definition: Level.h:62
void SetY2(Double_t y2)
Set Y2.
void SetCCascade(Cascade *cascade)
set current cascade
Definition: LevelScheme.h:198
static Float_t GetYMin(Float_t yRmin, Float_t yRmax)
Definition: BaseLSPlayer.h:155
TGToolTip * fInfoTip
Definition: BaseLSPlayer.h:296
virtual void PopupAddFirstLevel()
Popup AddFirstLevel menu.
Definition: BaseLSPlayer.h:190
virtual Bool_t IsDrawStyle(EDrawStyle style)
get style
Definition: BaseLSPlayer.h:235
virtual void SetTipText(TObject *select)
set text for tool tip info
A cascade is a list of links.
Definition: Cascade.h:51
virtual Bool_t IsSelected()
return selection
Definition: Level.h:210
virtual void Select()
Select all objects.
Definition: BaseLSPlayer.h:199
LogMessage & error(LogMessage &)
virtual ~BaseLSPlayer()
LogMessage & warning(LogMessage &)
static Float_t GetYMax(Float_t yRmin, Float_t yRmax)
Definition: BaseLSPlayer.h:156
void SetCLevel(Level *level)
set current level
Definition: LevelScheme.h:192
A RadLevelSchemeReader class to read radware level scheme files.
Cascade * fSelectedLinks
Definition: BaseLSPlayer.h:285
virtual void DoStyle(EDrawStyle style)
do style
Cascade * fSelectedLevels
pointer to the selected links
Definition: BaseLSPlayer.h:286
virtual EDefaultColor GetDefaultColor()
return default color
Definition: Level.h:240
header file for a NuclearLevel
A nuclear level.
Definition: NuclearLevel.h:66
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance to object.
virtual void DeSelected()
unselected link
Definition: Cascade.h:151
LogMessage & nline(LogMessage &)
EDrawStyle fDrawStyle
pointer on level scheme
Definition: BaseLSPlayer.h:293
virtual void DeSelect()
Deselect all objects.
Definition: BaseLSPlayer.h:202
virtual Int_t ReadAGS(const Char_t *filename, Option_t *opt="152Dy")
for backward compatibility
static GateColor gGateColor
Definition: BasePeak.h:30
virtual void Selected()
Selected link.
Definition: Cascade.h:148
static Float_t GetXMin(Float_t xRmin, Float_t xRmax)
Get size from range.
Definition: BaseLSPlayer.h:152
virtual Int_t ImportLevelScheme(const Char_t *, Option_t *)
to init this level scheme from an existing formatted file (ENSDF, Radware ..)
Color_t fCColorSelectedLink
Definition: BaseLSPlayer.h:302
virtual Int_t Import(LevelScheme &levelScheme)
imported level scheme file
virtual void PopupWriteLS()
Popup write LS menu.
Definition: BaseLSPlayer.h:196
virtual void PopupDoProject()
Popup DoProject menu.
Definition: BaseLSPlayer.h:181
virtual void ShowGate(Option_t *="gate")
Collect gates.
Definition: BaseLSPlayer.h:208
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *select)
Handle Movement.
TList * fNucleiList
pointer to the selected levels
Definition: BaseLSPlayer.h:290
static Float_t GetYRmin(Float_t ymin, Float_t ymax)
Definition: BaseLSPlayer.h:162
virtual Data_T Get() const
get the value, can be overloaded
Definition: Data.h:70
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual void PopupAddLevel()
Popup AddLevel menu.
Definition: BaseLSPlayer.h:187
Parity & GetParity()
get the parity and modify it if it is needed
Definition: NuclearLevel.h:87
Measure< Float_t > & GetEnergy()
Definition: NuclearLevel.h:91
static Int_t GetDefaultToggleColor()
get default color for axis toggle
Definition: BaseLSPlayer.h:148
static Float_t GetYRmax(Float_t ymin, Float_t ymax)
Definition: BaseLSPlayer.h:163
Bool_t Disconnect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.
static Float_t GetXRmax(Float_t xmin, Float_t xmax)
Definition: BaseLSPlayer.h:160
virtual Int_t CollectCascades(Option_t *o="")
Collect selected cascades.
ClassImp(LSaxis) LSaxis
LogMessage & dolog(LogMessage &)
const Char_t * GetString() const
To get the spin as a string.
Definition: Spin.cpp:55
void UnZoom()
Unzoom.
bool IsParity(Parity::EParity) const
Definition: Parity.h:78
static Float_t GetXAxis(Float_t xmin, Float_t xmax)
Get position of axis in X.
Definition: BaseLSPlayer.h:169
Bool_t Connect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.
LogMessage & debug(LogMessage &)
static Float_t GetYLabels(Float_t ymin, Float_t ymax)
Get position of labels in Y.
Definition: BaseLSPlayer.h:166
virtual Bool_t IsSelected()
return selection
Definition: Cascade.h:154
BaseLSPlayer(LevelScheme *levelScheme)
default constructor
LogMessage fLog
Definition: BaseLSPlayer.h:306
virtual void SetLabelColor(EDefaultColor color)
Set color label.
Definition: Cascade.h:169
void SetRange(Int_t ymin, Int_t ymax, Int_t xmin, Int_t xmax)
Set range axis.
header file for a BaseNucleus
void SetY1(Double_t y1)
Set Y1.
header file for a general 1D peak
ADF::LogMessage & endl(ADF::LogMessage &log)
static Bool_t IsMovable()
Definition: Level.h:72
static Float_t GetXRmin(Float_t xmin, Float_t xmax)
Get range from size.
Definition: BaseLSPlayer.h:159
A BasePeak is defined by a height, intensity and a dimension of the peak.
Definition: BasePeak.h:19
TList & GetLevelList()
to get the list of levels
Definition: LevelScheme.h:126
virtual void PopupAddLink()
Popup AddLink menu.
Definition: BaseLSPlayer.h:184
virtual void DrawProjTot(Option_t *="")
Draw projection total.
Definition: BaseLSPlayer.h:211
Spin & GetSpin()
to get the spin and modify it if it is needed
Definition: NuclearLevel.h:84
TList & GetCascadeList()
to get the list of cascades
Definition: LevelScheme.h:130
virtual void SetProcessMethod(const char *)
To set the current method.
LevelScheme * fLevelScheme
Definition: BaseLSPlayer.h:291
Measure< Float_t > & GetT()
Definition: NuclearLevel.h:94
virtual void PopupAddGroundLevel()
Popup AddGroundLevel.
Definition: BaseLSPlayer.h:193
static Float_t fgDefaultSize[]
size of the level scheme per default
Definition: BaseLSPlayer.h:273
LSaxis extented class of TGaxis, allows zooming.
Definition: BaseLSPlayer.h:34
TList * fSelectedCascades
pointer to the selected levels
Definition: BaseLSPlayer.h:288
void SetCLink(Link *link)
set current link
Definition: LevelScheme.h:186
void ExecuteEvent(Int_t eventType, Int_t eventX, Int_t eventY)
Handle Movement.
Float_t fPositionLabels
Definition: BaseLSPlayer.h:304
virtual Int_t CollectLinks(Option_t *o="")
Collect selected links.
virtual void Selected()
Selected link.
Definition: Level.h:204
TList & GetLinkList()
Definition: BaseLSPlayer.h:265
static Float_t GetXMax(Float_t xRmin, Float_t xRmax)
Definition: BaseLSPlayer.h:153
A EnsdfLevelSchemeReader class to read radware level scheme files.
virtual Int_t ReadENSDF(const Char_t *, Option_t *)
for backward compatibility
static Int_t fgDefaultToggleColor
default color of axis when toggle is on
Definition: BaseLSPlayer.h:275
static Float_t fgDefaultWidth
default width for level, box etc...
Definition: BaseLSPlayer.h:274
virtual void Draw(Option_t *opt="")
to draw this level scheme
BaseLSPlayer to work on level scheme.
Definition: BaseLSPlayer.h:106
TList & GetLinkList()
to get the list of links
Definition: LevelScheme.h:128
Base class describing a general level.
Definition: Level.h:53