File indexing completed on 2024-04-06 12:11:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "TGLabel.h"
0015 #include "TGNumberEntry.h"
0016 #include <cassert>
0017 #include <iostream>
0018
0019
0020 #include "Fireworks/Core/src/FWDoubleParameterSetter.h"
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 FWDoubleParameterSetter::FWDoubleParameterSetter() : m_param(nullptr), m_widget(nullptr) {}
0034
0035
0036
0037
0038
0039
0040 FWDoubleParameterSetter::~FWDoubleParameterSetter() {}
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
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
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,
0080 0,
0081 TGNumberFormat::kNESReal,
0082 TGNumberFormat::kNEAAnyNumber,
0083 limits,
0084 min,
0085 max);
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
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
0097 assert(nullptr != m_param);
0098 assert(nullptr != m_widget);
0099
0100 m_param->set(m_widget->GetNumberEntry()->GetNumber());
0101 update();
0102 }
0103
0104 void FWDoubleParameterSetter::setEnabled(bool x) { m_widget->SetState(x); }
0105
0106
0107
0108
0109
0110
0111