CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Fireworks/Core/src/FWLongParameterSetter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWLongParameterSetter
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: FWLongParameterSetter.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 
00018 #include <assert.h>
00019 #include <iostream>
00020 
00021 // user include files
00022 #include "Fireworks/Core/src/FWLongParameterSetter.h"
00023 
00024 
00025 //
00026 // constants, enums and typedefs
00027 //
00028 
00029 //
00030 // static data member definitions
00031 //
00032 
00033 //
00034 // constructors and destructor
00035 //
00036 FWLongParameterSetter::FWLongParameterSetter() :
00037    m_param(0),
00038    m_widget(0)
00039 {
00040 }
00041 
00042 // FWLongParameterSetter::FWLongParameterSetter(const FWLongParameterSetter& rhs)
00043 // {
00044 //    // do actual copying here;
00045 // }
00046 
00047 FWLongParameterSetter::~FWLongParameterSetter()
00048 {
00049 }
00050 
00051 //
00052 // assignment operators
00053 //
00054 // const FWLongParameterSetter& FWLongParameterSetter::operator=(const FWLongParameterSetter& rhs)
00055 // {
00056 //   //An exception safe implementation is
00057 //   FWLongParameterSetter temp(rhs);
00058 //   swap(rhs);
00059 //
00060 //   return *this;
00061 // }
00062 
00063 //
00064 // member functions
00065 //
00066 
00067 void
00068 FWLongParameterSetter::attach(FWParameterBase* iParam)
00069 {
00070    m_param = dynamic_cast<FWLongParameter*>(iParam);
00071    assert(0!=m_param);
00072 }
00073 
00074 TGFrame*
00075 FWLongParameterSetter::build(TGFrame* iParent, bool labelBack)
00076 {
00077    TGCompositeFrame* frame = new TGHorizontalFrame(iParent);
00078 
00079    // number entry widget
00080    TGNumberFormat::ELimit limits = m_param->min()==m_param->max() ?
00081       TGNumberFormat::kNELNoLimits :
00082       ( m_param->min() > m_param->max() ? TGNumberFormat::kNELLimitMin : TGNumberFormat::kNELLimitMinMax);
00083    double min = 0;
00084    double max = 1;
00085    if(m_param->min()!=m_param->max()) {
00086       min=m_param->min();
00087       max=m_param->max();
00088    }
00089    m_widget = new TGNumberEntry
00090       (frame, m_param->value(),
00091        5,                         // number of digits
00092        0,                         // widget ID
00093        TGNumberFormat::kNESInteger, // style
00094        TGNumberFormat::kNEAAnyNumber, // input value filter
00095        limits,                    // specify limits
00096        min,                       // min value
00097        max);                      // max value
00098 
00099    m_widget->Connect("ValueSet(Long_t)", "FWLongParameterSetter", this, "doUpdate(Long_t)");
00100 
00101    // label
00102    TGLabel* label = new TGLabel(frame, m_param->name().c_str());
00103    if (labelBack)
00104    {
00105       frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,6,2,2));
00106       frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2, 2, 0, 0));
00107    }
00108    else
00109    {
00110       frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY) );
00111       frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
00112    }
00113 
00114    return frame;
00115 }
00116 
00117 void
00118 FWLongParameterSetter::doUpdate(Long_t)
00119 {
00120    //std::cout <<"doUpdate called"<<std::endl;
00121    assert(0!=m_param);
00122    assert(0!=m_widget);
00123    //std::cout <<m_widget->GetNumberEntry()->GetNumber()<<std::endl;
00124    m_param->set(m_widget->GetNumberEntry()->GetIntNumber());
00125    update();
00126 }
00127 //
00128 // const member functions
00129 //
00130 
00131 //
00132 // static member functions
00133 //