FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairEveCut.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 /*
9  * FairEDTabEditor.cxx
10  *
11  * Created on: 5 maj 2020
12  * Author: Daniel Wielanek
13  * E-mail: daniel.wielanek@gmail.com
14  * Warsaw University of Technology, Faculty of Physics
15  */
16 
17  #include "FairEveCut.h"
18  #include <TGFrame.h> // for TGGroupFrame, TGCompositeFrame, kFixedWidth
19  #include <TGLabel.h> // for TGLabel
20  #include <TGLayout.h> // for TGLayoutHints, kLHintsExpandX, kLHintsLeft
21  #include <TGNumberEntry.h> // for TGNumberEntry, TGNumberFormat, TGNumberFo...
22  #include <TGedFrame.h> // for TGedFrame
23 
24 
25 FairEveCut::FairEveCut(TGedFrame *frame, TGCompositeFrame *tab, TString name, Int_t width)
26  : fWidth(width)
27  , fName(name)
28  , fParent(frame)
29  , fTab(tab)
30 {}
31 
33 {
34  TGCompositeFrame *Frame = new TGCompositeFrame(fTab, fWidth, 20, kHorizontalFrame | kFixedWidth);
35  TGTextButton *UpdateButton = new TGTextButton(Frame, "Update");
36  UpdateButton->Connect("Clicked()", fParent->ClassName(), fParent, "Repaint()");
37  Frame->AddFrame(UpdateButton, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 1, 1, 2, 1));
38  fTab->AddFrame(Frame, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
39 }
40 
42 
43 FairEveMinMaxCut::FairEveMinMaxCut(TGedFrame *frame, TGCompositeFrame *tab, TString name, Int_t width)
44  : FairEveCut(frame, tab, name, width)
45  , fUseCut(nullptr)
46  , fLow(nullptr)
47  , fHigh(nullptr)
48 {}
49 
51 {
52  TGGroupFrame *cuts = new TGGroupFrame(fTab, Form("%s Cut", fName.Data()));
53  cuts->SetTitlePos(TGGroupFrame::kCenter);
54 
55  TString label = Form("Use %s cut", fName.Data());
56  TString labelMin = Form("%s min:", fName.Data());
57  TString labelMax = Form("%s max:", fName.Data());
58 
59  TGCompositeFrame *frameUse = new TGCompositeFrame(cuts, fWidth, 30, kHorizontalFrame | kFixedWidth);
60  TGLabel *label_use = new TGLabel(frameUse, label);
61  frameUse->AddFrame(label_use, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 1, 1, 2, 1));
62  fUseCut = new TGCheckButton(frameUse);
63  frameUse->AddFrame(fUseCut, new TGLayoutHints(kLHintsRight | kLHintsExpandX));
64  cuts->AddFrame(frameUse, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
65 
66  TGCompositeFrame *frameMin = new TGCompositeFrame(cuts, fWidth, 30, kHorizontalFrame | kFixedWidth);
67  TGLabel *gLabelMin = new TGLabel(frameMin, labelMin);
68  frameMin->AddFrame(gLabelMin, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 1, 1, 2, 1));
69  fLow = new TGNumberEntry(frameMin, 0, 6, -1, TGNumberFormat::kNESRealTwo);
70  frameMin->AddFrame(fLow, new TGLayoutHints(kLHintsRight | kLHintsExpandX));
71  cuts->AddFrame(frameMin, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
72 
73  TGCompositeFrame *frameMax = new TGCompositeFrame(cuts, fWidth, 30, kHorizontalFrame | kFixedWidth);
74  TGLabel *gLabelMax = new TGLabel(frameMax, labelMax);
75  frameMax->AddFrame(gLabelMax, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 1, 1, 2, 1));
76  fHigh = new TGNumberEntry(frameMax, 10, 6, -1, TGNumberFormat::kNESRealTwo);
77  frameMax->AddFrame(fHigh, new TGLayoutHints(kLHintsRight | kLHintsExpandX));
78  cuts->AddFrame(frameMax, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
79 
80  fTab->AddFrame(cuts, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 2, 1));
81 }
82 
83 Bool_t FairEveMinMaxCut::GetValues(Double_t &min, Double_t &max) const
84 {
85  min = fLow->GetNumber();
86  max = fHigh->GetNumber();
87  return fUseCut->IsOn();
88 }
89 
91 
92 FairEveBoolCut::FairEveBoolCut(TGedFrame *frame, TGCompositeFrame *tab, TString name, Int_t width)
93  : FairEveCut(frame, tab, name, width)
94  , fHasCut(nullptr)
95  , fStatus(kTRUE)
96  , fAutoUpdate(kFALSE)
97 {}
98 
100 {
101  fHasCut = new TGCheckButton(fTab, fName, 1);
102  if (fAutoUpdate) {
103  fHasCut->Connect("Clicked()", fParent->ClassName(), fParent, "Repaint()");
104  }
105  if (fStatus) {
106  fHasCut->SetState(kButtonDown);
107  } else {
108  fHasCut->SetState(kButtonUp);
109  }
110  fTab->AddFrame(fHasCut, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 2, 1));
111 }
112 
114 
115 FairEveIntCut::FairEveIntCut(TGedFrame *frame, TGCompositeFrame *tab, TString name, Int_t width)
116  : FairEveCut(frame, tab, name, width)
117  , fUseCut(nullptr)
118  , fCut(nullptr)
119 {}
120 
122 {
123  TGGroupFrame *cuts = new TGGroupFrame(fTab, Form("%s Cut", fName.Data()));
124  cuts->SetTitlePos(TGGroupFrame::kCenter);
125  cuts->SetLayoutManager(new TGMatrixLayout(cuts, 3, 2));
126  TString label = Form("Use %s cut", fName.Data());
127  TString labelMin = Form("%s:", fName.Data());
128  TGLabel *label_use = new TGLabel(cuts, label);
129  cuts->AddFrame(label_use, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 1, 1, 2, 1));
130  fUseCut = new TGCheckButton(cuts);
131  cuts->AddFrame(fUseCut, new TGLayoutHints(kLHintsRight | kLHintsExpandX));
132  TGLabel *gLabelMin = new TGLabel(cuts, labelMin);
133  cuts->AddFrame(gLabelMin, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 1, 1, 2, 1));
134  fCut = new TGNumberEntry(cuts, 0, 6, -1, TGNumberFormat::kNESInteger);
135  cuts->AddFrame(fCut, new TGLayoutHints(kLHintsRight | kLHintsExpandX));
136  fTab->AddFrame(cuts, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 2, 1));
137 }
138 
139 Bool_t FairEveIntCut::GetValue(Int_t &val) const
140 {
141  val = fCut->GetIntNumber();
142  return fUseCut->IsOn();
143 }
const TString fName
Definition: FairEveCut.h:37
virtual ~FairEveMinMaxCut()
Definition: FairEveCut.cxx:90
TGCompositeFrame * fTab
Definition: FairEveCut.h:39
const Int_t fWidth
Definition: FairEveCut.h:36
FairEveCut(TGedFrame *frame=0, TGCompositeFrame *tab=0, TString name="", Int_t width=170)
Definition: FairEveCut.cxx:25
FairEveMinMaxCut(TGedFrame *frame=0, TGCompositeFrame *tab=0, TString name="", Int_t width=170)
Definition: FairEveCut.cxx:43
FairEveBoolCut(TGedFrame *frame=0, TGCompositeFrame *tab=0, TString name="", Int_t width=170)
Definition: FairEveCut.cxx:92
TGedFrame * fParent
Definition: FairEveCut.h:38
Bool_t GetValue(Int_t &val) const
Definition: FairEveCut.cxx:139
Bool_t GetValues(Double_t &min, Double_t &max) const
Definition: FairEveCut.cxx:83
void AddUpdateButton()
Definition: FairEveCut.cxx:32
virtual ~FairEveBoolCut()
Definition: FairEveCut.cxx:113
FairEveIntCut(TGedFrame *frame=0, TGCompositeFrame *tab=0, TString name="", Int_t width=170)
Definition: FairEveCut.cxx:115
virtual ~FairEveCut()
Definition: FairEveCut.cxx:41