comparison widgets/PluginParameterBox.cpp @ 167:53b9c7656798

* Use RangeMappers in various places in plugin parameters, layer properties, playback parameters &c
author Chris Cannam
date Mon, 16 Oct 2006 20:42:23 +0000
parents 5064eeb1c76f
children d4be66d61c04
comparison
equal deleted inserted replaced
166:48182241f594 167:53b9c7656798
16 #include "PluginParameterBox.h" 16 #include "PluginParameterBox.h"
17 17
18 #include "AudioDial.h" 18 #include "AudioDial.h"
19 19
20 #include "plugin/PluginXml.h" 20 #include "plugin/PluginXml.h"
21
22 #include "base/RangeMapper.h"
21 23
22 #include <QDoubleSpinBox> 24 #include <QDoubleSpinBox>
23 #include <QGridLayout> 25 #include <QGridLayout>
24 #include <QComboBox> 26 #include <QComboBox>
25 #include <QCheckBox> 27 #include <QCheckBox>
148 rec.check = checkbox; 150 rec.check = checkbox;
149 151
150 } else { 152 } else {
151 153
152 AudioDial *dial = new AudioDial; 154 AudioDial *dial = new AudioDial;
153 dial->setObjectName(name); 155 dial->setObjectName(description);
154 dial->setMinimum(imin); 156 dial->setMinimum(imin);
155 dial->setMaximum(imax); 157 dial->setMaximum(imax);
156 dial->setPageStep(1); 158 dial->setPageStep(1);
157 dial->setNotchesVisible((imax - imin) <= 12); 159 dial->setNotchesVisible((imax - imin) <= 12);
158 dial->setDefaultValue(lrintf((deft - min) / qtz)); 160 dial->setDefaultValue(lrintf((deft - min) / qtz));
159 dial->setValue(lrintf((value - min) / qtz)); 161 dial->setValue(lrintf((value - min) / qtz));
160 dial->setFixedWidth(32); 162 dial->setFixedWidth(32);
161 dial->setFixedHeight(32); 163 dial->setFixedHeight(32);
164 dial->setRangeMapper(new LinearRangeMapper
165 (imin, imax, min, max, unit));
162 connect(dial, SIGNAL(valueChanged(int)), 166 connect(dial, SIGNAL(valueChanged(int)),
163 this, SLOT(dialChanged(int))); 167 this, SLOT(dialChanged(int)));
164 m_layout->addWidget(dial, i + offset, 1); 168 m_layout->addWidget(dial, i + offset, 1);
165 169
166 QDoubleSpinBox *spinbox = new QDoubleSpinBox; 170 QDoubleSpinBox *spinbox = new QDoubleSpinBox;
177 rec.dial = dial; 181 rec.dial = dial;
178 rec.spin = spinbox; 182 rec.spin = spinbox;
179 } 183 }
180 184
181 m_params[name] = rec; 185 m_params[name] = rec;
186 m_descriptionMap[description] = name;
182 } 187 }
183 } 188 }
184 189
185 void 190 void
186 PluginParameterBox::dialChanged(int ival) 191 PluginParameterBox::dialChanged(int ival)
187 { 192 {
188 QObject *obj = sender(); 193 QObject *obj = sender();
189 QString name = obj->objectName(); 194 QString name = obj->objectName();
195
196 if (m_params.find(name) == m_params.end() &&
197 m_descriptionMap.find(name) != m_descriptionMap.end()) {
198 name = m_descriptionMap[name];
199 }
190 200
191 if (m_params.find(name) == m_params.end()) { 201 if (m_params.find(name) == m_params.end()) {
192 std::cerr << "WARNING: PluginParameterBox::dialChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; 202 std::cerr << "WARNING: PluginParameterBox::dialChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl;
193 return; 203 return;
194 } 204 }
223 PluginParameterBox::checkBoxChanged(int state) 233 PluginParameterBox::checkBoxChanged(int state)
224 { 234 {
225 QObject *obj = sender(); 235 QObject *obj = sender();
226 QString name = obj->objectName(); 236 QString name = obj->objectName();
227 237
238 if (m_params.find(name) == m_params.end() &&
239 m_descriptionMap.find(name) != m_descriptionMap.end()) {
240 name = m_descriptionMap[name];
241 }
242
228 if (m_params.find(name) == m_params.end()) { 243 if (m_params.find(name) == m_params.end()) {
229 std::cerr << "WARNING: PluginParameterBox::checkBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; 244 std::cerr << "WARNING: PluginParameterBox::checkBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl;
230 return; 245 return;
231 } 246 }
232 247
241 void 256 void
242 PluginParameterBox::spinBoxChanged(double value) 257 PluginParameterBox::spinBoxChanged(double value)
243 { 258 {
244 QObject *obj = sender(); 259 QObject *obj = sender();
245 QString name = obj->objectName(); 260 QString name = obj->objectName();
261
262 if (m_params.find(name) == m_params.end() &&
263 m_descriptionMap.find(name) != m_descriptionMap.end()) {
264 name = m_descriptionMap[name];
265 }
246 266
247 if (m_params.find(name) == m_params.end()) { 267 if (m_params.find(name) == m_params.end()) {
248 std::cerr << "WARNING: PluginParameterBox::spinBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; 268 std::cerr << "WARNING: PluginParameterBox::spinBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl;
249 return; 269 return;
250 } 270 }