comparison widgets/PluginParameterBox.cpp @ 62:50429a56680f

* Add plugin parameter dialog, and use it to set up parameters for feature extraction plugins via a semi-opaque (translucent?) configurationXml string which is associated with a given transform instance. This is not yet saved to and restored from the SV file properly. * Remove no-longer-relevant BeatDetect and BeatDetectionFunction transforms (replaced a long time ago with the beat detector plugin).
author Chris Cannam
date Wed, 22 Mar 2006 17:38:29 +0000
parents 4df1a479bf10
children fb02fe13ff47
comparison
equal deleted inserted replaced
61:d072a3b59a0d 62:50429a56680f
23 #include <QLabel> 23 #include <QLabel>
24 24
25 #include <iostream> 25 #include <iostream>
26 #include <string> 26 #include <string>
27 27
28 PluginParameterBox::PluginParameterBox(PluginInstance *plugin) : 28 PluginParameterBox::PluginParameterBox(PluginInstance *plugin, QWidget *parent) :
29 QFrame(parent),
29 m_plugin(plugin) 30 m_plugin(plugin)
30 { 31 {
31 m_layout = new QGridLayout; 32 m_layout = new QGridLayout;
32 setLayout(m_layout); 33 setLayout(m_layout);
33 populate(); 34 populate();
42 { 43 {
43 PluginInstance::ParameterList params = m_plugin->getParameterDescriptors(); 44 PluginInstance::ParameterList params = m_plugin->getParameterDescriptors();
44 45
45 m_params.clear(); 46 m_params.clear();
46 47
48 if (params.empty()) {
49 m_layout->addWidget
50 (new QLabel(tr("This plugin has no adjustable parameters.")),
51 0, 0);
52 }
53
47 for (size_t i = 0; i < params.size(); ++i) { 54 for (size_t i = 0; i < params.size(); ++i) {
48 55
49 QString name = params[i].name.c_str(); 56 QString name = params[i].name.c_str();
50 QString description = params[i].description.c_str(); 57 QString description = params[i].description.c_str();
51 QString unit = params[i].unit.c_str(); 58 QString unit = params[i].unit.c_str();
52 59
53 float min = params[i].minValue; 60 float min = params[i].minValue;
54 float max = params[i].maxValue; 61 float max = params[i].maxValue;
55 float deft = params[i].defaultValue; 62 float deft = params[i].defaultValue;
63 float value = m_plugin->getParameter(params[i].name);
56 64
57 float qtz = 0.0; 65 float qtz = 0.0;
58 if (params[i].isQuantized) qtz = params[i].quantizeStep; 66 if (params[i].isQuantized) qtz = params[i].quantizeStep;
59 67
60 // construct an integer range 68 // construct an integer range
78 dial->setMinimum(imin); 86 dial->setMinimum(imin);
79 dial->setMaximum(imax); 87 dial->setMaximum(imax);
80 dial->setPageStep(1); 88 dial->setPageStep(1);
81 dial->setNotchesVisible((imax - imin) <= 12); 89 dial->setNotchesVisible((imax - imin) <= 12);
82 dial->setDefaultValue(int((deft - min) / qtz)); 90 dial->setDefaultValue(int((deft - min) / qtz));
91 dial->setValue(int((value - min) / qtz));
92 dial->setFixedWidth(32);
93 dial->setFixedHeight(32);
83 connect(dial, SIGNAL(valueChanged(int)), 94 connect(dial, SIGNAL(valueChanged(int)),
84 this, SLOT(dialChanged(int))); 95 this, SLOT(dialChanged(int)));
85 m_layout->addWidget(dial, i, 1); 96 m_layout->addWidget(dial, i, 1);
86 97
87 QDoubleSpinBox *spinbox = new QDoubleSpinBox; 98 QDoubleSpinBox *spinbox = new QDoubleSpinBox;
88 spinbox->setObjectName(name); 99 spinbox->setObjectName(name);
89 spinbox->setMinimum(min); 100 spinbox->setMinimum(min);
90 spinbox->setMaximum(max); 101 spinbox->setMaximum(max);
91 spinbox->setSuffix(unit); 102 spinbox->setSuffix(QString(" %1").arg(unit));
92 spinbox->setSingleStep(qtz); 103 spinbox->setSingleStep(qtz);
93 spinbox->setValue(deft); 104 spinbox->setValue(value);
94 connect(spinbox, SIGNAL(valueChanged(double)), 105 connect(spinbox, SIGNAL(valueChanged(double)),
95 this, SLOT(spinBoxChanged(double))); 106 this, SLOT(spinBoxChanged(double)));
96 m_layout->addWidget(spinbox, i, 2); 107 m_layout->addWidget(spinbox, i, 2);
97 108
98 ParamRec rec; 109 ParamRec rec;