CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWDoubleParameterSetter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWDoubleParameterSetter
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Mon Mar 10 11:22:32 CDT 2008
11 //
12 
13 // system include files
14 #include "TGLabel.h"
15 #include "TGNumberEntry.h"
16 #include <cassert>
17 #include <iostream>
18 
19 // user include files
21 
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 
30 //
31 // constructors and destructor
32 //
33 FWDoubleParameterSetter::FWDoubleParameterSetter() : m_param(nullptr), m_widget(nullptr) {}
34 
35 // FWDoubleParameterSetter::FWDoubleParameterSetter(const FWDoubleParameterSetter& rhs)
36 // {
37 // // do actual copying here;
38 // }
39 
41 
42 //
43 // assignment operators
44 //
45 // const FWDoubleParameterSetter& FWDoubleParameterSetter::operator=(const FWDoubleParameterSetter& rhs)
46 // {
47 // //An exception safe implementation is
48 // FWDoubleParameterSetter temp(rhs);
49 // swap(rhs);
50 //
51 // return *this;
52 // }
53 
54 //
55 // member functions
56 //
57 
59  m_param = dynamic_cast<FWDoubleParameter*>(iParam);
60  assert(nullptr != m_param);
61 }
62 
63 TGFrame* FWDoubleParameterSetter::build(TGFrame* iParent, bool) {
64  TGCompositeFrame* frame = new TGHorizontalFrame(iParent);
65 
66  // number entry widget
67  TGNumberFormat::ELimit limits =
68  m_param->min() == m_param->max()
69  ? TGNumberFormat::kNELNoLimits
70  : (m_param->min() > m_param->max() ? TGNumberFormat::kNELLimitMin : TGNumberFormat::kNELLimitMinMax);
71  double min = 0;
72  double max = 1;
73  if (m_param->min() != m_param->max()) {
74  min = m_param->min();
75  max = m_param->max();
76  }
77  m_widget = new TGNumberEntry(frame,
78  m_param->value(),
79  5, // number of digits
80  0, // widget ID
81  TGNumberFormat::kNESReal, // style
82  TGNumberFormat::kNEAAnyNumber, // input value filter
83  limits, // specify limits
84  min, // min value
85  max); // max value
86 
87  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 8, 2, 2));
88  m_widget->Connect("ValueSet(Long_t)", "FWDoubleParameterSetter", this, "doUpdate(Long_t)");
89 
90  // label
91  frame->AddFrame(new TGLabel(frame, m_param->name().c_str()), new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
92  return frame;
93 }
94 
96  //std::cout <<"doUpdate called"<<std::endl;
97  assert(nullptr != m_param);
98  assert(nullptr != m_widget);
99  //std::cout <<m_widget->GetNumberEntry()->GetNumber()<<std::endl;
100  m_param->set(m_widget->GetNumberEntry()->GetNumber());
101  update();
102 }
103 
104 void FWDoubleParameterSetter::setEnabled(bool x) { m_widget->SetState(x); }
105 //
106 // const member functions
107 //
108 
109 //
110 // static member functions
111 //
FWParameterSetterEditorBase * frame() const
void attach(FWParameterBase *) override
assert(be >=bs)
TGFrame * build(TGFrame *iParent, bool labelBack=true) override
uint16_t const *__restrict__ x
Definition: gpuClustering.h:39
T min(T a, T b)
Definition: MathUtil.h:58
const std::string & name() const