Mercurial > hg > svgui
comparison widgets/PluginParameterDialog.cpp @ 147:e2ad3543c8a1
* stepsize/blocksize from plugin dialog actually working, though with some
puzzlement
author | Chris Cannam |
---|---|
date | Wed, 20 Sep 2006 14:50:40 +0000 |
parents | a1f7d265ac79 |
children | 4e7980e3b48e |
comparison
equal
deleted
inserted
replaced
146:a1f7d265ac79 | 147:e2ad3543c8a1 |
---|---|
17 | 17 |
18 #include "PluginParameterBox.h" | 18 #include "PluginParameterBox.h" |
19 #include "WindowTypeSelector.h" | 19 #include "WindowTypeSelector.h" |
20 | 20 |
21 #include "vamp-sdk/Plugin.h" | 21 #include "vamp-sdk/Plugin.h" |
22 #include "vamp-sdk/PluginHostAdapter.h" | |
22 | 23 |
23 #include <QGridLayout> | 24 #include <QGridLayout> |
24 #include <QLabel> | 25 #include <QLabel> |
25 #include <QGroupBox> | 26 #include <QGroupBox> |
26 #include <QHBoxLayout> | 27 #include <QHBoxLayout> |
73 | 74 |
74 QLabel *outputLabel = 0; | 75 QLabel *outputLabel = 0; |
75 | 76 |
76 if (output != "") { | 77 if (output != "") { |
77 | 78 |
78 Vamp::Plugin *fePlugin = dynamic_cast<Vamp::Plugin *>(plugin); | 79 Vamp::PluginHostAdapter *fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin); |
79 | 80 |
80 if (fePlugin) { | 81 if (fePlugin) { |
81 | 82 |
82 std::vector<Vamp::Plugin::OutputDescriptor> od = | 83 std::vector<Vamp::Plugin::OutputDescriptor> od = |
83 fePlugin->getOutputDescriptors(); | 84 fePlugin->getOutputDescriptors(); |
90 outputLabel->setWordWrap(true); | 91 outputLabel->setWordWrap(true); |
91 break; | 92 break; |
92 } | 93 } |
93 } | 94 } |
94 } | 95 } |
95 } else { | |
96 std::cerr << "Plugin " << plugin << " is not a feature extraction plugin" << std::endl;//!!! | |
97 } | 96 } |
98 } | 97 } |
99 | 98 |
100 QLabel *versionLabel = new QLabel(QString("%1") | 99 QLabel *versionLabel = new QLabel(QString("%1") |
101 .arg(plugin->getPluginVersion())); | 100 .arg(plugin->getPluginVersion())); |
106 | 105 |
107 QLabel *typeLabel = new QLabel(plugin->getType().c_str()); | 106 QLabel *typeLabel = new QLabel(plugin->getType().c_str()); |
108 typeLabel->setWordWrap(true); | 107 typeLabel->setWordWrap(true); |
109 typeLabel->setFont(font); | 108 typeLabel->setFont(font); |
110 | 109 |
111 subgrid->addWidget(new QLabel(tr("Name:")), 0, 0); | 110 QLabel *label = new QLabel(tr("Name:")); |
111 label->setAlignment(Qt::AlignTop | Qt::AlignLeft); | |
112 subgrid->addWidget(label, 0, 0); | |
112 subgrid->addWidget(nameLabel, 0, 1); | 113 subgrid->addWidget(nameLabel, 0, 1); |
113 | 114 |
114 subgrid->addWidget(new QLabel(tr("Type:")), 1, 0); | 115 label = new QLabel(tr("Type:")); |
116 label->setAlignment(Qt::AlignTop | Qt::AlignLeft); | |
117 subgrid->addWidget(label, 1, 0); | |
115 subgrid->addWidget(typeLabel, 1, 1); | 118 subgrid->addWidget(typeLabel, 1, 1); |
116 | 119 |
117 int outputOffset = 0; | 120 int outputOffset = 0; |
118 if (outputLabel) { | 121 if (outputLabel) { |
119 subgrid->addWidget(new QLabel(tr("Output:")), 2, 0); | 122 label = new QLabel(tr("Output:")); |
123 label->setAlignment(Qt::AlignTop | Qt::AlignLeft); | |
124 subgrid->addWidget(label, 2, 0); | |
120 subgrid->addWidget(outputLabel, 2, 1); | 125 subgrid->addWidget(outputLabel, 2, 1); |
121 outputOffset = 1; | 126 outputOffset = 1; |
122 } | 127 } |
123 | 128 |
124 subgrid->addWidget(new QLabel(tr("Maker:")), 2 + outputOffset, 0); | 129 label = new QLabel(tr("Maker:")); |
130 label->setAlignment(Qt::AlignTop | Qt::AlignLeft); | |
131 subgrid->addWidget(label, 2 + outputOffset, 0); | |
125 subgrid->addWidget(makerLabel, 2 + outputOffset, 1); | 132 subgrid->addWidget(makerLabel, 2 + outputOffset, 1); |
126 | 133 |
127 subgrid->addWidget(new QLabel(tr("Copyright: ")), 3 + outputOffset, 0); | 134 label = new QLabel(tr("Copyright: ")); |
135 label->setAlignment(Qt::AlignTop | Qt::AlignLeft); | |
136 subgrid->addWidget(label, 3 + outputOffset, 0); | |
128 subgrid->addWidget(copyrightLabel, 3 + outputOffset, 1); | 137 subgrid->addWidget(copyrightLabel, 3 + outputOffset, 1); |
129 | 138 |
130 subgrid->addWidget(new QLabel(tr("Version:")), 4 + outputOffset, 0); | 139 label = new QLabel(tr("Version:")); |
140 label->setAlignment(Qt::AlignTop | Qt::AlignLeft); | |
141 subgrid->addWidget(label, 4 + outputOffset, 0); | |
131 subgrid->addWidget(versionLabel, 4 + outputOffset, 1); | 142 subgrid->addWidget(versionLabel, 4 + outputOffset, 1); |
132 | 143 |
133 subgrid->setColumnStretch(1, 2); | 144 subgrid->setColumnStretch(1, 2); |
134 | 145 |
135 QGroupBox *paramBox = new QGroupBox; | 146 QGroupBox *paramBox = new QGroupBox; |
204 } | 215 } |
205 } | 216 } |
206 | 217 |
207 if (showWindowSize) { | 218 if (showWindowSize) { |
208 | 219 |
209 Vamp::Plugin *fePlugin = dynamic_cast<Vamp::Plugin *>(plugin); | 220 Vamp::PluginHostAdapter *fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin); |
210 int size = 1024; | 221 int size = 1024; |
211 int increment = 1024; | 222 int increment = 1024; |
212 if (fePlugin) { | 223 if (fePlugin) { |
213 size = fePlugin->getPreferredBlockSize(); | 224 size = fePlugin->getPreferredBlockSize(); |
214 std::cerr << "Feature extraction plugin \"" << fePlugin->getDescription() << "\" reports preferred block size as " << size << std::endl; | 225 std::cerr << "Feature extraction plugin \"" << fePlugin->getDescription() << "\" reports preferred block size as " << size << std::endl; |
220 } else { | 231 } else { |
221 increment = size/2; | 232 increment = size/2; |
222 } | 233 } |
223 } | 234 } |
224 } else { | 235 } else { |
225 std::cerr << "Plugin " << plugin << " is not a feature extraction plugin" << std::endl;//!!! | 236 std::cerr << "Plugin " << plugin << " is not a feature extraction plugin (it's a " << typeid(*plugin).name() << ")" << std::endl;//!!! |
226 } | 237 } |
227 | 238 |
228 QGroupBox *windowBox = new QGroupBox; | 239 QGroupBox *windowBox = new QGroupBox; |
229 windowBox->setTitle(tr("Processing")); | 240 windowBox->setTitle(tr("Processing")); |
230 advancedLayout->addWidget(windowBox); | 241 advancedLayout->addWidget(windowBox); |
244 //!!! deal with block and step sizes (coming from the plugin's | 255 //!!! deal with block and step sizes (coming from the plugin's |
245 // preferences) that don't fit into the default list | 256 // preferences) that don't fit into the default list |
246 | 257 |
247 QComboBox *blockSizeCombo = new QComboBox; | 258 QComboBox *blockSizeCombo = new QComboBox; |
248 blockSizeCombo->setEditable(true); | 259 blockSizeCombo->setEditable(true); |
260 bool found = false; | |
249 for (int i = 0; i < 14; ++i) { | 261 for (int i = 0; i < 14; ++i) { |
250 int val = pow(2, i + 3); | 262 int val = pow(2, i + 3); |
251 blockSizeCombo->addItem(QString("%1").arg(val)); | 263 blockSizeCombo->addItem(QString("%1").arg(val)); |
252 if (val == size) blockSizeCombo->setCurrentIndex(i); | 264 if (val == size) { |
265 blockSizeCombo->setCurrentIndex(i); | |
266 found = true; | |
267 } | |
268 } | |
269 if (!found) { | |
270 blockSizeCombo->addItem(QString("%1").arg(size)); | |
271 blockSizeCombo->setCurrentIndex(blockSizeCombo->count() - 1); | |
253 } | 272 } |
254 blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); | 273 blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); |
255 connect(blockSizeCombo, SIGNAL(textChanged(QString)), | 274 connect(blockSizeCombo, SIGNAL(textChanged(QString)), |
256 this, SLOT(blockSizeComboChanged(QString))); | 275 this, SLOT(blockSizeComboChanged(QString))); |
257 windowLayout->addWidget(blockSizeCombo, 0, 1); | 276 windowLayout->addWidget(blockSizeCombo, 0, 1); |
260 | 279 |
261 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0); | 280 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0); |
262 | 281 |
263 QComboBox *incrementCombo = new QComboBox; | 282 QComboBox *incrementCombo = new QComboBox; |
264 incrementCombo->setEditable(true); | 283 incrementCombo->setEditable(true); |
284 found = false; | |
265 for (int i = 0; i < 14; ++i) { | 285 for (int i = 0; i < 14; ++i) { |
266 int val = pow(2, i + 3); | 286 int val = pow(2, i + 3); |
267 incrementCombo->addItem(QString("%1").arg(val)); | 287 incrementCombo->addItem(QString("%1").arg(val)); |
268 if (val == increment) incrementCombo->setCurrentIndex(i); | 288 if (val == increment) { |
289 incrementCombo->setCurrentIndex(i); | |
290 found = true; | |
291 } | |
292 } | |
293 if (!found) { | |
294 incrementCombo->addItem(QString("%1").arg(increment)); | |
295 incrementCombo->setCurrentIndex(incrementCombo->count() - 1); | |
269 } | 296 } |
270 incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); | 297 incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); |
271 connect(incrementCombo, SIGNAL(textChanged(QString)), | 298 connect(incrementCombo, SIGNAL(textChanged(QString)), |
272 this, SLOT(incrementComboChanged(QString))); | 299 this, SLOT(incrementComboChanged(QString))); |
273 windowLayout->addWidget(incrementCombo, 1, 1); | 300 windowLayout->addWidget(incrementCombo, 1, 1); |
347 void | 374 void |
348 PluginParameterDialog::incrementComboChanged(QString text) | 375 PluginParameterDialog::incrementComboChanged(QString text) |
349 { | 376 { |
350 m_stepSize = text.toInt(); | 377 m_stepSize = text.toInt(); |
351 //!!! rename increment to step size throughout | 378 //!!! rename increment to step size throughout |
352 std::cerr << "Increment changed to " << m_blockSize << std::endl; | 379 std::cerr << "Increment changed to " << m_stepSize << std::endl; |
353 } | 380 } |
354 | 381 |
355 void | 382 void |
356 PluginParameterDialog::windowTypeChanged(WindowType type) | 383 PluginParameterDialog::windowTypeChanged(WindowType type) |
357 { | 384 { |