Chris@62
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@62
|
2
|
Chris@62
|
3 /*
|
Chris@62
|
4 Sonic Visualiser
|
Chris@62
|
5 An audio file viewer and annotation editor.
|
Chris@62
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@182
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@62
|
8
|
Chris@62
|
9 This program is free software; you can redistribute it and/or
|
Chris@62
|
10 modify it under the terms of the GNU General Public License as
|
Chris@62
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@62
|
12 License, or (at your option) any later version. See the file
|
Chris@62
|
13 COPYING included with this distribution for more information.
|
Chris@62
|
14 */
|
Chris@62
|
15
|
Chris@62
|
16 #include "PluginParameterDialog.h"
|
Chris@62
|
17
|
Chris@62
|
18 #include "PluginParameterBox.h"
|
Chris@140
|
19 #include "WindowTypeSelector.h"
|
Chris@62
|
20
|
Chris@106
|
21 #include "vamp-sdk/Plugin.h"
|
Chris@147
|
22 #include "vamp-sdk/PluginHostAdapter.h"
|
Chris@106
|
23
|
Chris@62
|
24 #include <QGridLayout>
|
Chris@62
|
25 #include <QLabel>
|
Chris@62
|
26 #include <QGroupBox>
|
Chris@62
|
27 #include <QHBoxLayout>
|
Chris@143
|
28 #include <QVBoxLayout>
|
Chris@149
|
29 #include <QScrollArea>
|
Chris@62
|
30 #include <QPushButton>
|
Chris@69
|
31 #include <QMessageBox>
|
Chris@69
|
32 #include <QComboBox>
|
Chris@143
|
33 #include <QSettings>
|
Chris@62
|
34
|
Chris@71
|
35 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin,
|
Chris@62
|
36 QWidget *parent) :
|
Chris@62
|
37 QDialog(parent),
|
Chris@62
|
38 m_plugin(plugin),
|
Chris@163
|
39 m_channel(-1),
|
Chris@145
|
40 m_stepSize(0),
|
Chris@145
|
41 m_blockSize(0),
|
Chris@145
|
42 m_windowType(HanningWindow),
|
Chris@62
|
43 m_parameterBox(0)
|
Chris@62
|
44 {
|
Chris@122
|
45 setWindowTitle(tr("Plugin Parameters"));
|
Chris@122
|
46
|
Chris@62
|
47 QGridLayout *grid = new QGridLayout;
|
Chris@62
|
48 setLayout(grid);
|
Chris@62
|
49
|
Chris@62
|
50 QGroupBox *pluginBox = new QGroupBox;
|
Chris@208
|
51 pluginBox->setTitle(plugin->getType().c_str());
|
Chris@62
|
52 grid->addWidget(pluginBox, 0, 0);
|
Chris@62
|
53
|
Chris@62
|
54 QGridLayout *subgrid = new QGridLayout;
|
Chris@62
|
55 pluginBox->setLayout(subgrid);
|
Chris@62
|
56
|
Chris@63
|
57 subgrid->setSpacing(0);
|
Chris@63
|
58 subgrid->setMargin(10);
|
Chris@63
|
59
|
Chris@208
|
60 QFont boldFont(pluginBox->font());
|
Chris@208
|
61 boldFont.setBold(true);
|
Chris@208
|
62
|
Chris@208
|
63 QFont italicFont(pluginBox->font());
|
Chris@208
|
64 italicFont.setItalic(true);
|
Chris@62
|
65
|
Chris@207
|
66 QLabel *nameLabel = new QLabel(plugin->getName().c_str());
|
Chris@146
|
67 nameLabel->setWordWrap(true);
|
Chris@208
|
68 nameLabel->setFont(boldFont);
|
Chris@62
|
69
|
Chris@62
|
70 QLabel *makerLabel = new QLabel(plugin->getMaker().c_str());
|
Chris@146
|
71 makerLabel->setWordWrap(true);
|
Chris@62
|
72
|
Chris@62
|
73 QLabel *versionLabel = new QLabel(QString("%1")
|
Chris@62
|
74 .arg(plugin->getPluginVersion()));
|
Chris@146
|
75 versionLabel->setWordWrap(true);
|
Chris@62
|
76
|
Chris@62
|
77 QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str());
|
Chris@146
|
78 copyrightLabel->setWordWrap(true);
|
Chris@62
|
79
|
Chris@208
|
80 // QLabel *typeLabel = new QLabel(plugin->getType().c_str());
|
Chris@208
|
81 // typeLabel->setWordWrap(true);
|
Chris@208
|
82 // typeLabel->setFont(boldFont);
|
Chris@208
|
83
|
Chris@208
|
84 QLabel *descriptionLabel = 0;
|
Chris@208
|
85 if (plugin->getDescription() != "") {
|
Chris@208
|
86 descriptionLabel = new QLabel(plugin->getDescription().c_str());
|
Chris@208
|
87 descriptionLabel->setWordWrap(true);
|
Chris@208
|
88 descriptionLabel->setFont(italicFont);
|
Chris@208
|
89 }
|
Chris@63
|
90
|
Chris@163
|
91 int row = 0;
|
Chris@163
|
92
|
Chris@147
|
93 QLabel *label = new QLabel(tr("Name:"));
|
Chris@147
|
94 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
95 subgrid->addWidget(label, row, 0);
|
Chris@163
|
96 subgrid->addWidget(nameLabel, row, 1);
|
Chris@163
|
97 row++;
|
Chris@62
|
98
|
Chris@208
|
99 if (descriptionLabel) {
|
Chris@208
|
100 // label = new QLabel(tr("Description:"));
|
Chris@208
|
101 // label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
102 // subgrid->addWidget(label, row, 0);
|
Chris@208
|
103 subgrid->addWidget(descriptionLabel, row, 1);
|
Chris@208
|
104 row++;
|
Chris@208
|
105 }
|
Chris@208
|
106
|
Chris@208
|
107 Vamp::PluginHostAdapter *fePlugin =
|
Chris@208
|
108 dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin);
|
Chris@208
|
109
|
Chris@208
|
110 if (fePlugin) {
|
Chris@208
|
111 label = new QLabel(tr("Version:"));
|
Chris@208
|
112 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
113 subgrid->addWidget(label, row, 0);
|
Chris@208
|
114 subgrid->addWidget(versionLabel, row, 1);
|
Chris@208
|
115 row++;
|
Chris@208
|
116 }
|
Chris@208
|
117
|
Chris@208
|
118 // label = new QLabel(tr("Type:"));
|
Chris@208
|
119 // label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
120 // subgrid->addWidget(label, row, 0);
|
Chris@208
|
121 // subgrid->addWidget(typeLabel, row, 1);
|
Chris@208
|
122 // row++;
|
Chris@62
|
123
|
Chris@147
|
124 label = new QLabel(tr("Maker:"));
|
Chris@147
|
125 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
126 subgrid->addWidget(label, row, 0);
|
Chris@163
|
127 subgrid->addWidget(makerLabel, row, 1);
|
Chris@163
|
128 row++;
|
Chris@63
|
129
|
Chris@147
|
130 label = new QLabel(tr("Copyright: "));
|
Chris@147
|
131 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
132 subgrid->addWidget(label, row, 0);
|
Chris@163
|
133 subgrid->addWidget(copyrightLabel, row, 1);
|
Chris@163
|
134 row++;
|
Chris@208
|
135
|
Chris@208
|
136 m_outputSpacer = new QLabel;
|
Chris@208
|
137 subgrid->addWidget(m_outputSpacer, row, 0);
|
Chris@208
|
138 m_outputSpacer->setFixedHeight(7);
|
Chris@208
|
139 m_outputSpacer->hide();
|
Chris@208
|
140 row++;
|
Chris@106
|
141
|
Chris@208
|
142 m_outputLabel = new QLabel(tr("Output:"));
|
Chris@208
|
143 m_outputLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
144 subgrid->addWidget(m_outputLabel, row, 0);
|
Chris@208
|
145 m_outputValue = new QLabel;
|
Chris@208
|
146 m_outputValue->setFont(boldFont);
|
Chris@208
|
147 subgrid->addWidget(m_outputValue, row, 1);
|
Chris@208
|
148 m_outputLabel->hide();
|
Chris@208
|
149 m_outputValue->hide();
|
Chris@208
|
150 row++;
|
Chris@208
|
151
|
Chris@208
|
152 m_outputDescription = new QLabel;
|
Chris@208
|
153 m_outputDescription->setFont(italicFont);
|
Chris@208
|
154 subgrid->addWidget(m_outputDescription, row, 1);
|
Chris@208
|
155 m_outputDescription->hide();
|
Chris@163
|
156 row++;
|
Chris@62
|
157
|
Chris@62
|
158 subgrid->setColumnStretch(1, 2);
|
Chris@62
|
159
|
Chris@164
|
160 m_inputModelBox = new QGroupBox;
|
Chris@164
|
161 m_inputModelBox->setTitle(tr("Input Source"));
|
Chris@164
|
162 grid->addWidget(m_inputModelBox, 1, 0);
|
Chris@164
|
163
|
Chris@164
|
164 m_inputModels = new QComboBox;
|
Chris@164
|
165 QHBoxLayout *inputLayout = new QHBoxLayout;
|
Chris@164
|
166 m_inputModelBox->setLayout(inputLayout);
|
Chris@164
|
167 inputLayout->addWidget(m_inputModels);
|
Chris@164
|
168 m_inputModelBox->hide();
|
Chris@164
|
169
|
Chris@62
|
170 QGroupBox *paramBox = new QGroupBox;
|
Chris@62
|
171 paramBox->setTitle(tr("Plugin Parameters"));
|
Chris@164
|
172 grid->addWidget(paramBox, 2, 0);
|
Chris@164
|
173 grid->setRowStretch(2, 10);
|
Chris@62
|
174
|
Chris@62
|
175 QHBoxLayout *paramLayout = new QHBoxLayout;
|
Chris@63
|
176 paramLayout->setMargin(0);
|
Chris@62
|
177 paramBox->setLayout(paramLayout);
|
Chris@62
|
178
|
Chris@149
|
179 QScrollArea *scroll = new QScrollArea;
|
Chris@149
|
180 scroll->setWidgetResizable(true);
|
Chris@149
|
181 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@149
|
182 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@149
|
183 paramLayout->addWidget(scroll);
|
Chris@149
|
184
|
Chris@62
|
185 m_parameterBox = new PluginParameterBox(m_plugin);
|
Chris@64
|
186 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)),
|
Chris@64
|
187 this, SIGNAL(pluginConfigurationChanged(QString)));
|
Chris@149
|
188 scroll->setWidget(m_parameterBox);
|
Chris@62
|
189
|
Chris@143
|
190 m_advanced = new QFrame;
|
Chris@143
|
191 QVBoxLayout *advancedLayout = new QVBoxLayout;
|
Chris@143
|
192 advancedLayout->setMargin(0);
|
Chris@143
|
193 m_advanced->setLayout(advancedLayout);
|
Chris@164
|
194 grid->addWidget(m_advanced, 3, 0);
|
Chris@143
|
195
|
Chris@163
|
196 m_channelBox = new QGroupBox;
|
Chris@163
|
197 m_channelBox->setTitle(tr("Channels"));
|
Chris@163
|
198 advancedLayout->addWidget(m_channelBox);
|
Chris@163
|
199 m_channelBox->setVisible(false);
|
Chris@163
|
200 m_haveChannelBoxData = false;
|
Chris@163
|
201
|
Chris@163
|
202 m_windowBox = new QGroupBox;
|
Chris@163
|
203 m_windowBox->setTitle(tr("Processing"));
|
Chris@163
|
204 advancedLayout->addWidget(m_windowBox);
|
Chris@163
|
205 m_windowBox->setVisible(false);
|
Chris@163
|
206 m_haveWindowBoxData = false;
|
Chris@163
|
207
|
Chris@163
|
208 QHBoxLayout *hbox = new QHBoxLayout;
|
Chris@163
|
209 grid->addLayout(hbox, 4, 0);
|
Chris@163
|
210
|
Chris@163
|
211 m_advancedVisible = false;
|
Chris@163
|
212
|
Chris@163
|
213 m_advancedButton = new QPushButton(tr("Advanced >>"));
|
Chris@163
|
214 m_advancedButton->setCheckable(true);
|
Chris@163
|
215 connect(m_advancedButton, SIGNAL(clicked()), this, SLOT(advancedToggled()));
|
Chris@163
|
216
|
Chris@163
|
217 QSettings settings;
|
Chris@163
|
218 settings.beginGroup("PluginParameterDialog");
|
Chris@163
|
219 m_advancedVisible = settings.value("advancedvisible", false).toBool();
|
Chris@163
|
220 settings.endGroup();
|
Chris@163
|
221
|
Chris@163
|
222 m_advanced->setVisible(false);
|
Chris@163
|
223
|
Chris@163
|
224 hbox->addWidget(m_advancedButton);
|
Chris@163
|
225 m_advancedButton->hide();
|
Chris@163
|
226
|
Chris@163
|
227 QPushButton *ok = new QPushButton(tr("OK"));
|
Chris@163
|
228 QPushButton *cancel = new QPushButton(tr("Cancel"));
|
Chris@251
|
229 ok->setDefault(true);
|
Chris@163
|
230 hbox->addStretch(10);
|
Chris@163
|
231 hbox->addWidget(ok);
|
Chris@163
|
232 hbox->addWidget(cancel);
|
Chris@163
|
233 connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
|
Chris@163
|
234 connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
|
Chris@163
|
235
|
Chris@163
|
236 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
237 }
|
Chris@163
|
238
|
Chris@163
|
239 PluginParameterDialog::~PluginParameterDialog()
|
Chris@163
|
240 {
|
Chris@163
|
241 }
|
Chris@163
|
242
|
Chris@163
|
243
|
Chris@163
|
244 void
|
Chris@208
|
245 PluginParameterDialog::setOutputLabel(QString text,
|
Chris@208
|
246 QString description)
|
Chris@163
|
247 {
|
Chris@163
|
248 if (text == "") {
|
Chris@208
|
249 m_outputSpacer->hide();
|
Chris@163
|
250 m_outputLabel->hide();
|
Chris@163
|
251 m_outputValue->hide();
|
Chris@208
|
252 m_outputDescription->hide();
|
Chris@163
|
253 } else {
|
Chris@208
|
254 m_outputSpacer->show();
|
Chris@163
|
255 m_outputValue->setText(text);
|
Chris@163
|
256 m_outputValue->setWordWrap(true);
|
Chris@208
|
257 m_outputDescription->setText(description);
|
Chris@163
|
258 m_outputLabel->show();
|
Chris@163
|
259 m_outputValue->show();
|
Chris@208
|
260 if (description != "") {
|
Chris@208
|
261 m_outputDescription->show();
|
Chris@208
|
262 } else {
|
Chris@208
|
263 m_outputDescription->hide();
|
Chris@208
|
264 }
|
Chris@163
|
265 }
|
Chris@163
|
266 }
|
Chris@163
|
267
|
Chris@163
|
268 void
|
Chris@163
|
269 PluginParameterDialog::setChannelArrangement(int sourceChannels,
|
Chris@163
|
270 int targetChannels,
|
Chris@163
|
271 int defaultChannel)
|
Chris@163
|
272 {
|
Chris@163
|
273 m_channel = defaultChannel;
|
Chris@163
|
274
|
Chris@69
|
275 if (sourceChannels != targetChannels) {
|
Chris@69
|
276
|
Chris@69
|
277 // At the moment we can only cope with the case where
|
Chris@69
|
278 // sourceChannels > targetChannels and targetChannels == 1
|
Chris@69
|
279
|
Chris@69
|
280 if (sourceChannels < targetChannels) {
|
Chris@69
|
281
|
Chris@69
|
282 QMessageBox::warning
|
Chris@163
|
283 (parentWidget(),
|
Chris@69
|
284 tr("Channel mismatch"),
|
Chris@69
|
285 tr("This plugin requires at least %1 input channels, but only %2 %3 available. The plugin probably will not work correctly.").arg(targetChannels).arg(sourceChannels).arg(sourceChannels != 1 ? tr("are") : tr("is")),
|
Chris@69
|
286 QMessageBox::Ok,
|
Chris@69
|
287 QMessageBox::NoButton);
|
Chris@69
|
288
|
Chris@69
|
289 } else {
|
Chris@69
|
290
|
Chris@163
|
291 if (m_haveChannelBoxData) {
|
Chris@163
|
292 std::cerr << "WARNING: PluginParameterDialog::setChannelArrangement: Calling more than once on same dialog is not currently implemented" << std::endl;
|
Chris@163
|
293 return;
|
Chris@163
|
294 }
|
Chris@69
|
295
|
Chris@69
|
296 QVBoxLayout *channelLayout = new QVBoxLayout;
|
Chris@163
|
297 m_channelBox->setLayout(channelLayout);
|
Chris@69
|
298
|
Chris@69
|
299 if (targetChannels != 1) {
|
Chris@69
|
300
|
Chris@69
|
301 channelLayout->addWidget
|
Chris@69
|
302 (new QLabel(tr("This plugin accepts no more than %1 input channels,\nbut %2 are available. Only the first %3 will be used.\n")
|
Chris@69
|
303 .arg(targetChannels)
|
Chris@69
|
304 .arg(sourceChannels)
|
Chris@69
|
305 .arg(targetChannels)));
|
Chris@69
|
306
|
Chris@69
|
307 } else {
|
Chris@69
|
308
|
Chris@69
|
309 channelLayout->addWidget(new QLabel(tr("This plugin only has a single channel input,\nbut the source has %1 channels.").arg(sourceChannels)));
|
Chris@69
|
310
|
Chris@69
|
311 QComboBox *channelCombo = new QComboBox;
|
Chris@76
|
312 channelCombo->addItem(tr("Use mean of source channels"));
|
Chris@69
|
313 for (int i = 0; i < sourceChannels; ++i) {
|
Chris@69
|
314 channelCombo->addItem(tr("Use channel %1 only").arg(i + 1));
|
Chris@69
|
315 }
|
Chris@69
|
316
|
Chris@69
|
317 connect(channelCombo, SIGNAL(activated(int)),
|
Chris@69
|
318 this, SLOT(channelComboChanged(int)));
|
Chris@69
|
319
|
Chris@69
|
320 channelLayout->addWidget(channelCombo);
|
Chris@69
|
321 }
|
Chris@163
|
322
|
Chris@163
|
323 m_channelBox->setVisible(true);
|
Chris@163
|
324 m_haveChannelBoxData = true;
|
Chris@163
|
325 m_advancedButton->show();
|
Chris@69
|
326 }
|
Chris@69
|
327 }
|
Chris@69
|
328
|
Chris@163
|
329 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
330 }
|
Chris@163
|
331
|
Chris@163
|
332 void
|
Chris@163
|
333 PluginParameterDialog::setShowProcessingOptions(bool showWindowSize,
|
Chris@163
|
334 bool showFrequencyDomainOptions)
|
Chris@163
|
335 {
|
Chris@163
|
336 if (m_haveWindowBoxData) {
|
Chris@163
|
337 std::cerr << "WARNING: PluginParameterDialog::setShowProcessingOptions: Calling more than once on same dialog is not currently implemented" << std::endl;
|
Chris@163
|
338 return;
|
Chris@163
|
339 }
|
Chris@163
|
340
|
Chris@140
|
341 if (showWindowSize) {
|
Chris@140
|
342
|
Chris@147
|
343 Vamp::PluginHostAdapter *fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin);
|
Chris@140
|
344 int size = 1024;
|
Chris@140
|
345 int increment = 1024;
|
Chris@140
|
346 if (fePlugin) {
|
Chris@140
|
347 size = fePlugin->getPreferredBlockSize();
|
Chris@207
|
348 std::cerr << "Feature extraction plugin \"" << fePlugin->getName() << "\" reports preferred block size as " << size << std::endl;
|
Chris@140
|
349 if (size == 0) size = 1024;
|
Chris@140
|
350 increment = fePlugin->getPreferredStepSize();
|
Chris@146
|
351 if (increment == 0) {
|
Chris@146
|
352 if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) {
|
Chris@146
|
353 increment = size;
|
Chris@146
|
354 } else {
|
Chris@146
|
355 increment = size/2;
|
Chris@146
|
356 }
|
Chris@146
|
357 }
|
Chris@140
|
358 }
|
Chris@140
|
359
|
Chris@140
|
360 QGridLayout *windowLayout = new QGridLayout;
|
Chris@163
|
361 m_windowBox->setLayout(windowLayout);
|
Chris@140
|
362
|
Chris@140
|
363 if (showFrequencyDomainOptions) {
|
Chris@140
|
364 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0);
|
Chris@140
|
365 } else {
|
Chris@140
|
366 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0);
|
Chris@140
|
367 }
|
Chris@140
|
368
|
Chris@143
|
369 std::cerr << "size: " << size << ", increment: " << increment << std::endl;
|
Chris@143
|
370
|
Chris@140
|
371 QComboBox *blockSizeCombo = new QComboBox;
|
Chris@140
|
372 blockSizeCombo->setEditable(true);
|
Chris@147
|
373 bool found = false;
|
Chris@143
|
374 for (int i = 0; i < 14; ++i) {
|
Chris@249
|
375 int val = 1 << (i + 3);
|
Chris@140
|
376 blockSizeCombo->addItem(QString("%1").arg(val));
|
Chris@147
|
377 if (val == size) {
|
Chris@147
|
378 blockSizeCombo->setCurrentIndex(i);
|
Chris@147
|
379 found = true;
|
Chris@147
|
380 }
|
Chris@147
|
381 }
|
Chris@147
|
382 if (!found) {
|
Chris@147
|
383 blockSizeCombo->addItem(QString("%1").arg(size));
|
Chris@147
|
384 blockSizeCombo->setCurrentIndex(blockSizeCombo->count() - 1);
|
Chris@140
|
385 }
|
Chris@143
|
386 blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this));
|
Chris@155
|
387 connect(blockSizeCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
388 this, SLOT(blockSizeComboChanged(const QString &)));
|
Chris@140
|
389 windowLayout->addWidget(blockSizeCombo, 0, 1);
|
Chris@140
|
390
|
Chris@148
|
391 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0);
|
Chris@148
|
392
|
Chris@148
|
393 QComboBox *incrementCombo = new QComboBox;
|
Chris@148
|
394 incrementCombo->setEditable(true);
|
Chris@148
|
395 found = false;
|
Chris@148
|
396 for (int i = 0; i < 14; ++i) {
|
Chris@249
|
397 int val = 1 << (i + 3);
|
Chris@148
|
398 incrementCombo->addItem(QString("%1").arg(val));
|
Chris@148
|
399 if (val == increment) {
|
Chris@148
|
400 incrementCombo->setCurrentIndex(i);
|
Chris@148
|
401 found = true;
|
Chris@148
|
402 }
|
Chris@148
|
403 }
|
Chris@148
|
404 if (!found) {
|
Chris@148
|
405 incrementCombo->addItem(QString("%1").arg(increment));
|
Chris@148
|
406 incrementCombo->setCurrentIndex(incrementCombo->count() - 1);
|
Chris@148
|
407 }
|
Chris@148
|
408 incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this));
|
Chris@155
|
409 connect(incrementCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
410 this, SLOT(incrementComboChanged(const QString &)));
|
Chris@148
|
411 windowLayout->addWidget(incrementCombo, 1, 1);
|
Chris@148
|
412
|
Chris@140
|
413 if (showFrequencyDomainOptions) {
|
Chris@140
|
414
|
Chris@140
|
415 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0);
|
Chris@140
|
416 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector;
|
Chris@171
|
417 connect(windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
|
Chris@171
|
418 this, SLOT(windowTypeChanged(WindowType)));
|
Chris@140
|
419 windowLayout->addWidget(windowTypeSelector, 2, 1);
|
Chris@140
|
420 }
|
Chris@163
|
421
|
Chris@163
|
422 m_windowBox->setVisible(true);
|
Chris@163
|
423 m_haveWindowBoxData = true;
|
Chris@163
|
424 m_advancedButton->show();
|
Chris@140
|
425 }
|
Chris@140
|
426
|
Chris@163
|
427 setAdvancedVisible(m_advancedVisible);
|
Chris@62
|
428 }
|
Chris@62
|
429
|
Chris@69
|
430 void
|
Chris@164
|
431 PluginParameterDialog::setCandidateInputModels(const QStringList &models)
|
Chris@164
|
432 {
|
Chris@164
|
433 m_inputModels->clear();
|
Chris@164
|
434 m_inputModels->insertItems(0, models);
|
Chris@164
|
435 connect(m_inputModels, SIGNAL(activated(const QString &)),
|
Chris@164
|
436 this, SIGNAL(inputModelChanged(QString)));
|
Chris@164
|
437 m_inputModelBox->show();
|
Chris@164
|
438 }
|
Chris@164
|
439
|
Chris@164
|
440 QString
|
Chris@164
|
441 PluginParameterDialog::getInputModel() const
|
Chris@164
|
442 {
|
Chris@164
|
443 return m_inputModels->currentText();
|
Chris@164
|
444 }
|
Chris@164
|
445
|
Chris@164
|
446 void
|
Chris@145
|
447 PluginParameterDialog::getProcessingParameters(size_t &blockSize) const
|
Chris@145
|
448 {
|
Chris@145
|
449 blockSize = m_blockSize;
|
Chris@145
|
450 return;
|
Chris@145
|
451 }
|
Chris@145
|
452
|
Chris@145
|
453 void
|
Chris@145
|
454 PluginParameterDialog::getProcessingParameters(size_t &stepSize,
|
Chris@145
|
455 size_t &blockSize,
|
Chris@145
|
456 WindowType &windowType) const
|
Chris@145
|
457 {
|
Chris@145
|
458 stepSize = m_stepSize;
|
Chris@145
|
459 blockSize = m_blockSize;
|
Chris@145
|
460 windowType = m_windowType;
|
Chris@146
|
461 return;
|
Chris@145
|
462 }
|
Chris@145
|
463
|
Chris@145
|
464 void
|
Chris@155
|
465 PluginParameterDialog::blockSizeComboChanged(const QString &text)
|
Chris@145
|
466 {
|
Chris@145
|
467 m_blockSize = text.toInt();
|
Chris@146
|
468 std::cerr << "Block size changed to " << m_blockSize << std::endl;
|
Chris@145
|
469 }
|
Chris@145
|
470
|
Chris@145
|
471 void
|
Chris@155
|
472 PluginParameterDialog::incrementComboChanged(const QString &text)
|
Chris@145
|
473 {
|
Chris@145
|
474 m_stepSize = text.toInt();
|
Chris@146
|
475 //!!! rename increment to step size throughout
|
Chris@147
|
476 std::cerr << "Increment changed to " << m_stepSize << std::endl;
|
Chris@145
|
477 }
|
Chris@145
|
478
|
Chris@145
|
479 void
|
Chris@145
|
480 PluginParameterDialog::windowTypeChanged(WindowType type)
|
Chris@145
|
481 {
|
Chris@145
|
482 m_windowType = type;
|
Chris@145
|
483 }
|
Chris@145
|
484
|
Chris@145
|
485 void
|
Chris@143
|
486 PluginParameterDialog::advancedToggled()
|
Chris@143
|
487 {
|
Chris@163
|
488 setAdvancedVisible(!m_advancedVisible);
|
Chris@163
|
489 }
|
Chris@143
|
490
|
Chris@163
|
491 void
|
Chris@163
|
492 PluginParameterDialog::setAdvancedVisible(bool visible)
|
Chris@163
|
493 {
|
Chris@143
|
494 m_advanced->setVisible(visible);
|
Chris@143
|
495
|
Chris@163
|
496 if (visible) {
|
Chris@163
|
497 m_advancedButton->setText(tr("Advanced <<"));
|
Chris@163
|
498 m_advancedButton->setChecked(true);
|
Chris@163
|
499 } else {
|
Chris@163
|
500 m_advancedButton->setText(tr("Advanced >>"));
|
Chris@163
|
501 m_advancedButton->setChecked(false);
|
Chris@163
|
502 }
|
Chris@143
|
503
|
Chris@143
|
504 QSettings settings;
|
Chris@143
|
505 settings.beginGroup("PluginParameterDialog");
|
Chris@143
|
506 settings.setValue("advancedvisible", visible);
|
Chris@143
|
507 settings.endGroup();
|
Chris@143
|
508
|
Chris@213
|
509 // std::cerr << "resize to " << sizeHint().width() << " x " << sizeHint().height() << std::endl;
|
Chris@143
|
510
|
Chris@149
|
511 setMinimumHeight(sizeHint().height());
|
Chris@163
|
512 adjustSize();
|
Chris@163
|
513
|
Chris@163
|
514 m_advancedVisible = visible;
|
Chris@163
|
515
|
Chris@163
|
516 // if (visible) setMaximumHeight(sizeHint().height());
|
Chris@163
|
517 // adjustSize();
|
Chris@143
|
518 }
|
Chris@143
|
519
|
Chris@143
|
520 void
|
Chris@69
|
521 PluginParameterDialog::channelComboChanged(int index)
|
Chris@69
|
522 {
|
Chris@69
|
523 m_channel = index - 1;
|
Chris@69
|
524 }
|
Chris@69
|
525
|