GGS(GenericGEANT4Simulation)Software  2.7.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
HitOptionFrame.cpp
1 #include "application/gui/HitOptionFrame.h"
2 #include "application/gui/MainWindow.h"
3 
4 HitOptionFrame::HitOptionFrame(std::string det, const TGWindow *p)
5  : TGGroupFrame(p, Form("%s hits", det.c_str()), kVerticalFrame), _det(det) {
6  static const std::string routineName("HitOptionFrame::HitOptionFrame");
7 
8  MainWindow *_mw = (MainWindow *)gEve;
9 
10  cmbox = new TGComboBox(this);
11  for (int i = 0; i < DetectorHit::kHitTypeN; i++) {
12  cmbox->AddEntry(DetectorHit::hitTypeNames[i].c_str(), i);
13  }
14  cmbox->Select(_mw->GetDetectorHitType(_det), kFALSE);
15  cmbox->Resize(150, 20);
16  cmbox->Connect("Selected(Int_t)", "HitOptionFrame", this, "SetDisplayType(Int_t)");
17  AddFrame(cmbox, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX));
18 
19  TGHorizontalFrame *thrFrame = new TGHorizontalFrame(this);
20  {
21  TGLabel *thrLabel = new TGLabel(thrFrame, "Threshold:");
22  thrFrame->AddFrame(thrLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
23 
24  thrField = new TGNumberEntry(thrFrame, 0.001);
25  thrField->SetWidth(80);
26  thrField->SetFormat(TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative);
27  thrField->SetNumber(_mw->GetDetectorHitThreshold(_det));
28  thrField->Connect("ValueSet(Long_t)", "HitOptionFrame", this, "SetThreshold(Long_t)");
29  thrFrame->AddFrame(thrField, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5, 5, 0, 0));
30 
31  TGLabel *unitLabel = new TGLabel(thrFrame, "GeV");
32  thrFrame->AddFrame(unitLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
33  }
34  AddFrame(thrFrame, new TGLayoutHints(kLHintsExpandX | kLHintsCenterX | kLHintsCenterY, 5, 5, 5, 5));
35 
36  TGHorizontalFrame *colFrame = new TGHorizontalFrame(this);
37  {
38  colPick = new TGColorSelect(colFrame);
39  colPick->Connect("ColorSelected(Pixel_t)", "HitOptionFrame", this, "SetColor(Pixel_t)");
40  if (_mw->GetDetectorHitType(_det) == DetectorHit::kColorCodedHit ||
41  _mw->GetDetectorHitType(_det) == DetectorHit::kColorCodedScaleHit)
42  colPick->SetEnabled(kFALSE);
43  colFrame->AddFrame(colPick, new TGLayoutHints(kLHintsRight | kLHintsCenterY));
44 
45  TGLabel *colLabel = new TGLabel(colFrame, "Color:");
46  colFrame->AddFrame(colLabel, new TGLayoutHints(kLHintsRight | kLHintsCenterY));
47  }
48  AddFrame(colFrame, new TGLayoutHints(kLHintsExpandX | kLHintsCenterX | kLHintsCenterY, 5, 5, 5, 5));
49 }
50 
51 void HitOptionFrame::SetDisplayType(Int_t type) {
52  static const std::string routineName("HitOptionFrame::SetDisplayType");
53 
54  MainWindow *_mw = (MainWindow *)gEve;
55  _mw->SetDetectorHitType(_det, static_cast<DetectorHit::hitType>(type));
56 
57  if (_mw->GetDetectorHitType(_det) == DetectorHit::kColorCodedHit ||
58  _mw->GetDetectorHitType(_det) == DetectorHit::kColorCodedScaleHit) {
59  colPick->SetEnabled(kFALSE);
60  } else {
61  colPick->SetEnabled(kTRUE);
62  }
63 }
64 
65 void HitOptionFrame::SetThreshold(Long_t /*val*/) {
66  static const std::string routineName("HitOptionFrame::SetThreshold");
67 
68  // Long_t val is a dummy value that ROOT emits
69  float value = (float)thrField->GetNumber();
70 
71  MainWindow *_mw = (MainWindow *)gEve;
72  _mw->SetDetectorHitThreshold(_det, value);
73 }
74 
75 void HitOptionFrame::SetColor(Pixel_t /*pixel*/) {
76  static const std::string routineName("HitOptionFrame::SetColor");
77 
78  // Pixel_t pixel is a dummy value that ROOT emits
79  Color_t color = TColor::GetColor(colPick->GetColor());
80 
81  COUT(DEBUG) << color << ENDL;
82 
83  MainWindow *_mw = (MainWindow *)gEve;
84  _mw->SetDetectorHitColor(_det, color);
85 }
#define ENDL
Definition: GGSSmartLog.h:105
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
Definition: GGSSmartLog.h:76