CMS 3D CMS Logo

FWEnumParameterSetter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWEnumParameterSetter
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: matevz
10 // Created: Fri Apr 30 15:17:33 CEST 2010
11 //
12 
13 // system include files
14 
15 // user include files
17 #include "TGComboBox.h"
18 #include "TGLabel.h"
19 #include <cassert>
20 
21 //
22 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
32 FWEnumParameterSetter::FWEnumParameterSetter() : m_param(nullptr), m_widget(nullptr) {}
33 
34 // FWEnumParameterSetter::FWEnumParameterSetter(const FWEnumParameterSetter& rhs)
35 // {
36 // // do actual copying here;
37 // }
38 
40 
41 //
42 // assignment operators
43 //
44 // const FWEnumParameterSetter& FWEnumParameterSetter::operator=(const FWEnumParameterSetter& rhs)
45 // {
46 // //An exception safe implementation is
47 // FWEnumParameterSetter temp(rhs);
48 // swap(rhs);
49 //
50 // return *this;
51 // }
52 
53 //
54 // member functions
55 //
56 
58  m_param = dynamic_cast<FWEnumParameter*>(iParam);
59  assert(nullptr != m_param);
60 }
61 
62 TGFrame* FWEnumParameterSetter::build(TGFrame* iParent, bool labelBack) {
63  TGCompositeFrame* frame = new TGHorizontalFrame(iParent);
64 
65  m_widget = new TGComboBox(frame);
66  std::map<Long_t, std::string>::const_iterator me = m_param->entryMap().begin();
67  UInt_t max_len = 0;
68  while (me != m_param->entryMap().end()) {
69  m_widget->AddEntry(me->second.c_str(), static_cast<Int_t>(me->first));
70  if (me->second.length() > max_len)
71  max_len = me->second.length();
72  ++me;
73  }
74  m_widget->Resize(8 * max_len + 20, 20);
75  m_widget->Select(static_cast<Int_t>(m_param->value()), kFALSE);
76 
77  m_widget->Connect("Selected(Int_t)", "FWEnumParameterSetter", this, "doUpdate(Int_t)");
78 
79  // label
80  TGLabel* label = new TGLabel(frame, m_param->name().c_str());
81  if (labelBack) {
82  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 6, 2, 2));
83  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 4, 0, 0));
84  } else {
85  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
86  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 8, 2, 2));
87  }
88  return frame;
89 }
90 
92  assert(nullptr != m_param);
93  assert(nullptr != m_widget);
94  m_param->set((Long_t)id);
95  update();
96 }
97 
98 void FWEnumParameterSetter::setEnabled(bool x) { m_widget->SetEnabled(x); }
99 
100 //
101 // const member functions
102 //
103 
104 //
105 // static member functions
106 //
FWEnumParameter::entryMap
const std::map< Long_t, std::string > & entryMap() const
Definition: FWEnumParameter.h:55
FWEnumParameterSetter::build
TGFrame * build(TGFrame *iParent, bool labelBack=true) override
Definition: FWEnumParameterSetter.cc:62
FWEnumParameterSetter::FWEnumParameterSetter
FWEnumParameterSetter()
Definition: FWEnumParameterSetter.cc:32
FWEnumParameterSetter::~FWEnumParameterSetter
~FWEnumParameterSetter() override
Definition: FWEnumParameterSetter.cc:39
FWParameterBase
Definition: FWParameterBase.h:31
cms::cuda::assert
assert(be >=bs)
FWGenericParameter::set
void set(T iValue)
Definition: FWGenericParameter.h:70
DDAxes::x
FWEnumParameterSetter::attach
void attach(FWParameterBase *) override
Definition: FWEnumParameterSetter.cc:57
FWEnumParameterSetter::m_param
FWEnumParameter * m_param
Definition: FWEnumParameterSetter.h:58
vertices_cff.x
x
Definition: vertices_cff.py:29
FWParameterSetterBase::update
void update() const
Definition: FWParameterSetterBase.cc:74
FWParameterBase::name
const std::string & name() const
Definition: FWParameterBase.h:39
FWGenericParameter::value
T value() const
Definition: FWGenericParameter.h:50
FWParameterSetterBase::frame
FWParameterSetterEditorBase * frame() const
Definition: FWParameterSetterBase.h:51
FWEnumParameterSetter::m_widget
TGComboBox * m_widget
Definition: FWEnumParameterSetter.h:59
FWEnumParameterSetter::setEnabled
void setEnabled(bool) override
Definition: FWEnumParameterSetter.cc:98
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
FWEnumParameterSetter.h
FWEnumParameterSetter::doUpdate
void doUpdate(Int_t id)
Definition: FWEnumParameterSetter.cc:91
label
const char * label
Definition: PFTauDecayModeTools.cc:11