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