Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:10

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWDoubleParameterSetter
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Mon Mar 10 11:22:32 CDT 2008
0011 //
0012 
0013 // system include files
0014 #include "TGLabel.h"
0015 #include "TGNumberEntry.h"
0016 #include <cassert>
0017 #include <iostream>
0018 
0019 // user include files
0020 #include "Fireworks/Core/src/FWDoubleParameterSetter.h"
0021 
0022 //
0023 // constants, enums and typedefs
0024 //
0025 
0026 //
0027 // static data member definitions
0028 //
0029 
0030 //
0031 // constructors and destructor
0032 //
0033 FWDoubleParameterSetter::FWDoubleParameterSetter() : m_param(nullptr), m_widget(nullptr) {}
0034 
0035 // FWDoubleParameterSetter::FWDoubleParameterSetter(const FWDoubleParameterSetter& rhs)
0036 // {
0037 //    // do actual copying here;
0038 // }
0039 
0040 FWDoubleParameterSetter::~FWDoubleParameterSetter() {}
0041 
0042 //
0043 // assignment operators
0044 //
0045 // const FWDoubleParameterSetter& FWDoubleParameterSetter::operator=(const FWDoubleParameterSetter& rhs)
0046 // {
0047 //   //An exception safe implementation is
0048 //   FWDoubleParameterSetter temp(rhs);
0049 //   swap(rhs);
0050 //
0051 //   return *this;
0052 // }
0053 
0054 //
0055 // member functions
0056 //
0057 
0058 void FWDoubleParameterSetter::attach(FWParameterBase* iParam) {
0059   m_param = dynamic_cast<FWDoubleParameter*>(iParam);
0060   assert(nullptr != m_param);
0061 }
0062 
0063 TGFrame* FWDoubleParameterSetter::build(TGFrame* iParent, bool) {
0064   TGCompositeFrame* frame = new TGHorizontalFrame(iParent);
0065 
0066   // number entry widget
0067   TGNumberFormat::ELimit limits =
0068       m_param->min() == m_param->max()
0069           ? TGNumberFormat::kNELNoLimits
0070           : (m_param->min() > m_param->max() ? TGNumberFormat::kNELLimitMin : TGNumberFormat::kNELLimitMinMax);
0071   double min = 0;
0072   double max = 1;
0073   if (m_param->min() != m_param->max()) {
0074     min = m_param->min();
0075     max = m_param->max();
0076   }
0077   m_widget = new TGNumberEntry(frame,
0078                                m_param->value(),
0079                                5,                              // number of digits
0080                                0,                              // widget ID
0081                                TGNumberFormat::kNESReal,       // style
0082                                TGNumberFormat::kNEAAnyNumber,  // input value filter
0083                                limits,                         // specify limits
0084                                min,                            // min value
0085                                max);                           // max value
0086 
0087   frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 8, 2, 2));
0088   m_widget->Connect("ValueSet(Long_t)", "FWDoubleParameterSetter", this, "doUpdate(Long_t)");
0089 
0090   // label
0091   frame->AddFrame(new TGLabel(frame, m_param->name().c_str()), new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
0092   return frame;
0093 }
0094 
0095 void FWDoubleParameterSetter::doUpdate(Long_t) {
0096   //std::cout <<"doUpdate called"<<std::endl;
0097   assert(nullptr != m_param);
0098   assert(nullptr != m_widget);
0099   //std::cout <<m_widget->GetNumberEntry()->GetNumber()<<std::endl;
0100   m_param->set(m_widget->GetNumberEntry()->GetNumber());
0101   update();
0102 }
0103 
0104 void FWDoubleParameterSetter::setEnabled(bool x) { m_widget->SetState(x); }
0105 //
0106 // const member functions
0107 //
0108 
0109 //
0110 // static member functions
0111 //