CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/Fireworks/Core/src/FWDoubleParameterSetter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWDoubleParameterSetter
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Mon Mar 10 11:22:32 CDT 2008
00011 // $Id: FWDoubleParameterSetter.cc,v 1.7 2011/02/15 18:32:34 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include "TGLabel.h"
00016 #include "TGNumberEntry.h"
00017 #include <assert.h>
00018 #include <iostream>
00019 
00020 // user include files
00021 #include "Fireworks/Core/src/FWDoubleParameterSetter.h"
00022 
00023 
00024 //
00025 // constants, enums and typedefs
00026 //
00027 
00028 //
00029 // static data member definitions
00030 //
00031 
00032 //
00033 // constructors and destructor
00034 //
00035 FWDoubleParameterSetter::FWDoubleParameterSetter() :
00036    m_param(0),
00037    m_widget(0)
00038 {
00039 }
00040 
00041 // FWDoubleParameterSetter::FWDoubleParameterSetter(const FWDoubleParameterSetter& rhs)
00042 // {
00043 //    // do actual copying here;
00044 // }
00045 
00046 FWDoubleParameterSetter::~FWDoubleParameterSetter()
00047 {
00048 }
00049 
00050 //
00051 // assignment operators
00052 //
00053 // const FWDoubleParameterSetter& FWDoubleParameterSetter::operator=(const FWDoubleParameterSetter& rhs)
00054 // {
00055 //   //An exception safe implementation is
00056 //   FWDoubleParameterSetter temp(rhs);
00057 //   swap(rhs);
00058 //
00059 //   return *this;
00060 // }
00061 
00062 //
00063 // member functions
00064 //
00065 
00066 void
00067 FWDoubleParameterSetter::attach(FWParameterBase* iParam)
00068 {
00069    m_param = dynamic_cast<FWDoubleParameter*>(iParam);
00070    assert(0!=m_param);
00071 }
00072 
00073 TGFrame*
00074 FWDoubleParameterSetter::build(TGFrame* iParent, bool)
00075 {
00076    TGCompositeFrame* frame = new TGHorizontalFrame(iParent);
00077 
00078    // number entry widget
00079    TGNumberFormat::ELimit limits = m_param->min()==m_param->max() ?
00080                                    TGNumberFormat::kNELNoLimits :
00081                                    ( m_param->min() > m_param->max() ? TGNumberFormat::kNELLimitMin : TGNumberFormat::kNELLimitMinMax);
00082    double min = 0;
00083    double max = 1;
00084    if(m_param->min()!=m_param->max()) {
00085       min=m_param->min();
00086       max=m_param->max();
00087    }
00088    m_widget = new TGNumberEntry
00089            (frame, m_param->value(),
00090            5,                         // number of digits
00091            0,                         // widget ID
00092            TGNumberFormat::kNESReal,  // style
00093            TGNumberFormat::kNEAAnyNumber, // input value filter
00094            limits,                    // specify limits
00095            min,                       // min value
00096            max);                      // max value
00097 
00098    frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
00099    m_widget->Connect("ValueSet(Long_t)", "FWDoubleParameterSetter", this, "doUpdate(Long_t)");
00100 
00101    // label
00102    frame->AddFrame(new TGLabel(frame,m_param->name().c_str()),
00103                    new TGLayoutHints(kLHintsLeft|kLHintsCenterY) );
00104    return frame;
00105 }
00106 
00107 void
00108 FWDoubleParameterSetter::doUpdate(Long_t)
00109 {
00110    //std::cout <<"doUpdate called"<<std::endl;
00111    assert(0!=m_param);
00112    assert(0!=m_widget);
00113    //std::cout <<m_widget->GetNumberEntry()->GetNumber()<<std::endl;
00114    m_param->set(m_widget->GetNumberEntry()->GetNumber());
00115    update();
00116 }
00117 
00118 void
00119 FWDoubleParameterSetter::setEnabled(bool x)
00120 {
00121    m_widget->SetState(x);
00122 }
00123 //
00124 // const member functions
00125 //
00126 
00127 //
00128 // static member functions
00129 //