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