CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 <assert.h>
17 #include <iostream>
18 
19 // user include files
21 
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
35  m_param(0),
36  m_widget(0)
37 {
38 }
39 
40 // FWDoubleParameterSetter::FWDoubleParameterSetter(const FWDoubleParameterSetter& rhs)
41 // {
42 // // do actual copying here;
43 // }
44 
46 {
47 }
48 
49 //
50 // assignment operators
51 //
52 // const FWDoubleParameterSetter& FWDoubleParameterSetter::operator=(const FWDoubleParameterSetter& rhs)
53 // {
54 // //An exception safe implementation is
55 // FWDoubleParameterSetter temp(rhs);
56 // swap(rhs);
57 //
58 // return *this;
59 // }
60 
61 //
62 // member functions
63 //
64 
65 void
67 {
68  m_param = dynamic_cast<FWDoubleParameter*>(iParam);
69  assert(0!=m_param);
70 }
71 
72 TGFrame*
73 FWDoubleParameterSetter::build(TGFrame* iParent, bool)
74 {
75  TGCompositeFrame* frame = new TGHorizontalFrame(iParent);
76 
77  // number entry widget
78  TGNumberFormat::ELimit limits = m_param->min()==m_param->max() ?
79  TGNumberFormat::kNELNoLimits :
80  ( m_param->min() > m_param->max() ? TGNumberFormat::kNELLimitMin : TGNumberFormat::kNELLimitMinMax);
81  double min = 0;
82  double max = 1;
83  if(m_param->min()!=m_param->max()) {
84  min=m_param->min();
85  max=m_param->max();
86  }
87  m_widget = new TGNumberEntry
88  (frame, m_param->value(),
89  5, // number of digits
90  0, // widget ID
91  TGNumberFormat::kNESReal, // style
92  TGNumberFormat::kNEAAnyNumber, // input value filter
93  limits, // specify limits
94  min, // min value
95  max); // max value
96 
97  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
98  m_widget->Connect("ValueSet(Long_t)", "FWDoubleParameterSetter", this, "doUpdate(Long_t)");
99 
100  // label
101  frame->AddFrame(new TGLabel(frame,m_param->name().c_str()),
102  new TGLayoutHints(kLHintsLeft|kLHintsCenterY) );
103  return frame;
104 }
105 
106 void
108 {
109  //std::cout <<"doUpdate called"<<std::endl;
110  assert(0!=m_param);
111  assert(0!=m_widget);
112  //std::cout <<m_widget->GetNumberEntry()->GetNumber()<<std::endl;
113  m_param->set(m_widget->GetNumberEntry()->GetNumber());
114  update();
115 }
116 
117 void
119 {
120  m_widget->SetState(x);
121 }
122 //
123 // const member functions
124 //
125 
126 //
127 // static member functions
128 //
FWParameterSetterEditorBase * frame() const
const T & max(const T &a, const T &b)
virtual void attach(FWParameterBase *)
Definition: DDAxes.h:10
virtual TGFrame * build(TGFrame *iParent, bool labelBack=true)
const std::string & name() const