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@143
|
196 bool haveAdvanced = false;
|
Chris@143
|
197
|
Chris@163
|
198 m_channelBox = new QGroupBox;
|
Chris@163
|
199 m_channelBox->setTitle(tr("Channels"));
|
Chris@163
|
200 advancedLayout->addWidget(m_channelBox);
|
Chris@163
|
201 m_channelBox->setVisible(false);
|
Chris@163
|
202 m_haveChannelBoxData = false;
|
Chris@163
|
203
|
Chris@163
|
204 m_windowBox = new QGroupBox;
|
Chris@163
|
205 m_windowBox->setTitle(tr("Processing"));
|
Chris@163
|
206 advancedLayout->addWidget(m_windowBox);
|
Chris@163
|
207 m_windowBox->setVisible(false);
|
Chris@163
|
208 m_haveWindowBoxData = false;
|
Chris@163
|
209
|
Chris@163
|
210 QHBoxLayout *hbox = new QHBoxLayout;
|
Chris@163
|
211 grid->addLayout(hbox, 4, 0);
|
Chris@163
|
212
|
Chris@163
|
213 m_advancedVisible = false;
|
Chris@163
|
214
|
Chris@163
|
215 m_advancedButton = new QPushButton(tr("Advanced >>"));
|
Chris@163
|
216 m_advancedButton->setCheckable(true);
|
Chris@163
|
217 connect(m_advancedButton, SIGNAL(clicked()), this, SLOT(advancedToggled()));
|
Chris@163
|
218
|
Chris@163
|
219 QSettings settings;
|
Chris@163
|
220 settings.beginGroup("PluginParameterDialog");
|
Chris@163
|
221 m_advancedVisible = settings.value("advancedvisible", false).toBool();
|
Chris@163
|
222 settings.endGroup();
|
Chris@163
|
223
|
Chris@163
|
224 m_advanced->setVisible(false);
|
Chris@163
|
225
|
Chris@163
|
226 hbox->addWidget(m_advancedButton);
|
Chris@163
|
227 m_advancedButton->hide();
|
Chris@163
|
228
|
Chris@163
|
229 QPushButton *ok = new QPushButton(tr("OK"));
|
Chris@163
|
230 QPushButton *cancel = new QPushButton(tr("Cancel"));
|
Chris@163
|
231 hbox->addStretch(10);
|
Chris@163
|
232 hbox->addWidget(ok);
|
Chris@163
|
233 hbox->addWidget(cancel);
|
Chris@163
|
234 connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
|
Chris@163
|
235 connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
|
Chris@163
|
236
|
Chris@163
|
237 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
238 }
|
Chris@163
|
239
|
Chris@163
|
240 PluginParameterDialog::~PluginParameterDialog()
|
Chris@163
|
241 {
|
Chris@163
|
242 }
|
Chris@163
|
243
|
Chris@163
|
244
|
Chris@163
|
245 void
|
Chris@208
|
246 PluginParameterDialog::setOutputLabel(QString text,
|
Chris@208
|
247 QString description)
|
Chris@163
|
248 {
|
Chris@163
|
249 if (text == "") {
|
Chris@208
|
250 m_outputSpacer->hide();
|
Chris@163
|
251 m_outputLabel->hide();
|
Chris@163
|
252 m_outputValue->hide();
|
Chris@208
|
253 m_outputDescription->hide();
|
Chris@163
|
254 } else {
|
Chris@208
|
255 m_outputSpacer->show();
|
Chris@163
|
256 m_outputValue->setText(text);
|
Chris@163
|
257 m_outputValue->setWordWrap(true);
|
Chris@208
|
258 m_outputDescription->setText(description);
|
Chris@163
|
259 m_outputLabel->show();
|
Chris@163
|
260 m_outputValue->show();
|
Chris@208
|
261 if (description != "") {
|
Chris@208
|
262 m_outputDescription->show();
|
Chris@208
|
263 } else {
|
Chris@208
|
264 m_outputDescription->hide();
|
Chris@208
|
265 }
|
Chris@163
|
266 }
|
Chris@163
|
267 }
|
Chris@163
|
268
|
Chris@163
|
269 void
|
Chris@163
|
270 PluginParameterDialog::setChannelArrangement(int sourceChannels,
|
Chris@163
|
271 int targetChannels,
|
Chris@163
|
272 int defaultChannel)
|
Chris@163
|
273 {
|
Chris@163
|
274 m_channel = defaultChannel;
|
Chris@163
|
275
|
Chris@69
|
276 if (sourceChannels != targetChannels) {
|
Chris@69
|
277
|
Chris@69
|
278 // At the moment we can only cope with the case where
|
Chris@69
|
279 // sourceChannels > targetChannels and targetChannels == 1
|
Chris@69
|
280
|
Chris@69
|
281 if (sourceChannels < targetChannels) {
|
Chris@69
|
282
|
Chris@69
|
283 QMessageBox::warning
|
Chris@163
|
284 (parentWidget(),
|
Chris@69
|
285 tr("Channel mismatch"),
|
Chris@69
|
286 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
|
287 QMessageBox::Ok,
|
Chris@69
|
288 QMessageBox::NoButton);
|
Chris@69
|
289
|
Chris@69
|
290 } else {
|
Chris@69
|
291
|
Chris@163
|
292 if (m_haveChannelBoxData) {
|
Chris@163
|
293 std::cerr << "WARNING: PluginParameterDialog::setChannelArrangement: Calling more than once on same dialog is not currently implemented" << std::endl;
|
Chris@163
|
294 return;
|
Chris@163
|
295 }
|
Chris@69
|
296
|
Chris@69
|
297 QVBoxLayout *channelLayout = new QVBoxLayout;
|
Chris@163
|
298 m_channelBox->setLayout(channelLayout);
|
Chris@69
|
299
|
Chris@69
|
300 if (targetChannels != 1) {
|
Chris@69
|
301
|
Chris@69
|
302 channelLayout->addWidget
|
Chris@69
|
303 (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
|
304 .arg(targetChannels)
|
Chris@69
|
305 .arg(sourceChannels)
|
Chris@69
|
306 .arg(targetChannels)));
|
Chris@69
|
307
|
Chris@69
|
308 } else {
|
Chris@69
|
309
|
Chris@69
|
310 channelLayout->addWidget(new QLabel(tr("This plugin only has a single channel input,\nbut the source has %1 channels.").arg(sourceChannels)));
|
Chris@69
|
311
|
Chris@69
|
312 QComboBox *channelCombo = new QComboBox;
|
Chris@76
|
313 channelCombo->addItem(tr("Use mean of source channels"));
|
Chris@69
|
314 for (int i = 0; i < sourceChannels; ++i) {
|
Chris@69
|
315 channelCombo->addItem(tr("Use channel %1 only").arg(i + 1));
|
Chris@69
|
316 }
|
Chris@69
|
317
|
Chris@69
|
318 connect(channelCombo, SIGNAL(activated(int)),
|
Chris@69
|
319 this, SLOT(channelComboChanged(int)));
|
Chris@69
|
320
|
Chris@69
|
321 channelLayout->addWidget(channelCombo);
|
Chris@69
|
322 }
|
Chris@163
|
323
|
Chris@163
|
324 m_channelBox->setVisible(true);
|
Chris@163
|
325 m_haveChannelBoxData = true;
|
Chris@163
|
326 m_advancedButton->show();
|
Chris@69
|
327 }
|
Chris@69
|
328 }
|
Chris@69
|
329
|
Chris@163
|
330 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
331 }
|
Chris@163
|
332
|
Chris@163
|
333 void
|
Chris@163
|
334 PluginParameterDialog::setShowProcessingOptions(bool showWindowSize,
|
Chris@163
|
335 bool showFrequencyDomainOptions)
|
Chris@163
|
336 {
|
Chris@163
|
337 if (m_haveWindowBoxData) {
|
Chris@163
|
338 std::cerr << "WARNING: PluginParameterDialog::setShowProcessingOptions: Calling more than once on same dialog is not currently implemented" << std::endl;
|
Chris@163
|
339 return;
|
Chris@163
|
340 }
|
Chris@163
|
341
|
Chris@140
|
342 if (showWindowSize) {
|
Chris@140
|
343
|
Chris@147
|
344 Vamp::PluginHostAdapter *fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin);
|
Chris@140
|
345 int size = 1024;
|
Chris@140
|
346 int increment = 1024;
|
Chris@140
|
347 if (fePlugin) {
|
Chris@140
|
348 size = fePlugin->getPreferredBlockSize();
|
Chris@207
|
349 std::cerr << "Feature extraction plugin \"" << fePlugin->getName() << "\" reports preferred block size as " << size << std::endl;
|
Chris@140
|
350 if (size == 0) size = 1024;
|
Chris@140
|
351 increment = fePlugin->getPreferredStepSize();
|
Chris@146
|
352 if (increment == 0) {
|
Chris@146
|
353 if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) {
|
Chris@146
|
354 increment = size;
|
Chris@146
|
355 } else {
|
Chris@146
|
356 increment = size/2;
|
Chris@146
|
357 }
|
Chris@146
|
358 }
|
Chris@140
|
359 }
|
Chris@140
|
360
|
Chris@140
|
361 QGridLayout *windowLayout = new QGridLayout;
|
Chris@163
|
362 m_windowBox->setLayout(windowLayout);
|
Chris@140
|
363
|
Chris@140
|
364 if (showFrequencyDomainOptions) {
|
Chris@140
|
365 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0);
|
Chris@140
|
366 } else {
|
Chris@140
|
367 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0);
|
Chris@140
|
368 }
|
Chris@140
|
369
|
Chris@143
|
370 std::cerr << "size: " << size << ", increment: " << increment << std::endl;
|
Chris@143
|
371
|
Chris@140
|
372 QComboBox *blockSizeCombo = new QComboBox;
|
Chris@140
|
373 blockSizeCombo->setEditable(true);
|
Chris@147
|
374 bool found = false;
|
Chris@143
|
375 for (int i = 0; i < 14; ++i) {
|
Chris@140
|
376 int val = pow(2, i + 3);
|
Chris@140
|
377 blockSizeCombo->addItem(QString("%1").arg(val));
|
Chris@147
|
378 if (val == size) {
|
Chris@147
|
379 blockSizeCombo->setCurrentIndex(i);
|
Chris@147
|
380 found = true;
|
Chris@147
|
381 }
|
Chris@147
|
382 }
|
Chris@147
|
383 if (!found) {
|
Chris@147
|
384 blockSizeCombo->addItem(QString("%1").arg(size));
|
Chris@147
|
385 blockSizeCombo->setCurrentIndex(blockSizeCombo->count() - 1);
|
Chris@140
|
386 }
|
Chris@143
|
387 blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this));
|
Chris@155
|
388 connect(blockSizeCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
389 this, SLOT(blockSizeComboChanged(const QString &)));
|
Chris@140
|
390 windowLayout->addWidget(blockSizeCombo, 0, 1);
|
Chris@140
|
391
|
Chris@148
|
392 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0);
|
Chris@148
|
393
|
Chris@148
|
394 QComboBox *incrementCombo = new QComboBox;
|
Chris@148
|
395 incrementCombo->setEditable(true);
|
Chris@148
|
396 found = false;
|
Chris@148
|
397 for (int i = 0; i < 14; ++i) {
|
Chris@148
|
398 int val = pow(2, i + 3);
|
Chris@148
|
399 incrementCombo->addItem(QString("%1").arg(val));
|
Chris@148
|
400 if (val == increment) {
|
Chris@148
|
401 incrementCombo->setCurrentIndex(i);
|
Chris@148
|
402 found = true;
|
Chris@148
|
403 }
|
Chris@148
|
404 }
|
Chris@148
|
405 if (!found) {
|
Chris@148
|
406 incrementCombo->addItem(QString("%1").arg(increment));
|
Chris@148
|
407 incrementCombo->setCurrentIndex(incrementCombo->count() - 1);
|
Chris@148
|
408 }
|
Chris@148
|
409 incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this));
|
Chris@155
|
410 connect(incrementCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
411 this, SLOT(incrementComboChanged(const QString &)));
|
Chris@148
|
412 windowLayout->addWidget(incrementCombo, 1, 1);
|
Chris@148
|
413
|
Chris@140
|
414 if (showFrequencyDomainOptions) {
|
Chris@140
|
415
|
Chris@140
|
416 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0);
|
Chris@140
|
417 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector;
|
Chris@171
|
418 connect(windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
|
Chris@171
|
419 this, SLOT(windowTypeChanged(WindowType)));
|
Chris@140
|
420 windowLayout->addWidget(windowTypeSelector, 2, 1);
|
Chris@140
|
421 }
|
Chris@163
|
422
|
Chris@163
|
423 m_windowBox->setVisible(true);
|
Chris@163
|
424 m_haveWindowBoxData = true;
|
Chris@163
|
425 m_advancedButton->show();
|
Chris@140
|
426 }
|
Chris@140
|
427
|
Chris@163
|
428 setAdvancedVisible(m_advancedVisible);
|
Chris@62
|
429 }
|
Chris@62
|
430
|
Chris@69
|
431 void
|
Chris@164
|
432 PluginParameterDialog::setCandidateInputModels(const QStringList &models)
|
Chris@164
|
433 {
|
Chris@164
|
434 m_inputModels->clear();
|
Chris@164
|
435 m_inputModels->insertItems(0, models);
|
Chris@164
|
436 connect(m_inputModels, SIGNAL(activated(const QString &)),
|
Chris@164
|
437 this, SIGNAL(inputModelChanged(QString)));
|
Chris@164
|
438 m_inputModelBox->show();
|
Chris@164
|
439 }
|
Chris@164
|
440
|
Chris@164
|
441 QString
|
Chris@164
|
442 PluginParameterDialog::getInputModel() const
|
Chris@164
|
443 {
|
Chris@164
|
444 return m_inputModels->currentText();
|
Chris@164
|
445 }
|
Chris@164
|
446
|
Chris@164
|
447 void
|
Chris@145
|
448 PluginParameterDialog::getProcessingParameters(size_t &blockSize) const
|
Chris@145
|
449 {
|
Chris@145
|
450 blockSize = m_blockSize;
|
Chris@145
|
451 return;
|
Chris@145
|
452 }
|
Chris@145
|
453
|
Chris@145
|
454 void
|
Chris@145
|
455 PluginParameterDialog::getProcessingParameters(size_t &stepSize,
|
Chris@145
|
456 size_t &blockSize,
|
Chris@145
|
457 WindowType &windowType) const
|
Chris@145
|
458 {
|
Chris@145
|
459 stepSize = m_stepSize;
|
Chris@145
|
460 blockSize = m_blockSize;
|
Chris@145
|
461 windowType = m_windowType;
|
Chris@146
|
462 return;
|
Chris@145
|
463 }
|
Chris@145
|
464
|
Chris@145
|
465 void
|
Chris@155
|
466 PluginParameterDialog::blockSizeComboChanged(const QString &text)
|
Chris@145
|
467 {
|
Chris@145
|
468 m_blockSize = text.toInt();
|
Chris@146
|
469 std::cerr << "Block size changed to " << m_blockSize << std::endl;
|
Chris@145
|
470 }
|
Chris@145
|
471
|
Chris@145
|
472 void
|
Chris@155
|
473 PluginParameterDialog::incrementComboChanged(const QString &text)
|
Chris@145
|
474 {
|
Chris@145
|
475 m_stepSize = text.toInt();
|
Chris@146
|
476 //!!! rename increment to step size throughout
|
Chris@147
|
477 std::cerr << "Increment changed to " << m_stepSize << std::endl;
|
Chris@145
|
478 }
|
Chris@145
|
479
|
Chris@145
|
480 void
|
Chris@145
|
481 PluginParameterDialog::windowTypeChanged(WindowType type)
|
Chris@145
|
482 {
|
Chris@145
|
483 m_windowType = type;
|
Chris@145
|
484 }
|
Chris@145
|
485
|
Chris@145
|
486 void
|
Chris@143
|
487 PluginParameterDialog::advancedToggled()
|
Chris@143
|
488 {
|
Chris@163
|
489 setAdvancedVisible(!m_advancedVisible);
|
Chris@163
|
490 }
|
Chris@143
|
491
|
Chris@163
|
492 void
|
Chris@163
|
493 PluginParameterDialog::setAdvancedVisible(bool visible)
|
Chris@163
|
494 {
|
Chris@143
|
495 m_advanced->setVisible(visible);
|
Chris@143
|
496
|
Chris@163
|
497 if (visible) {
|
Chris@163
|
498 m_advancedButton->setText(tr("Advanced <<"));
|
Chris@163
|
499 m_advancedButton->setChecked(true);
|
Chris@163
|
500 } else {
|
Chris@163
|
501 m_advancedButton->setText(tr("Advanced >>"));
|
Chris@163
|
502 m_advancedButton->setChecked(false);
|
Chris@163
|
503 }
|
Chris@143
|
504
|
Chris@143
|
505 QSettings settings;
|
Chris@143
|
506 settings.beginGroup("PluginParameterDialog");
|
Chris@143
|
507 settings.setValue("advancedvisible", visible);
|
Chris@143
|
508 settings.endGroup();
|
Chris@143
|
509
|
Chris@143
|
510 std::cerr << "resize to " << sizeHint().width() << " x " << sizeHint().height() << std::endl;
|
Chris@143
|
511
|
Chris@149
|
512 setMinimumHeight(sizeHint().height());
|
Chris@163
|
513 adjustSize();
|
Chris@163
|
514
|
Chris@163
|
515 m_advancedVisible = visible;
|
Chris@163
|
516
|
Chris@163
|
517 // if (visible) setMaximumHeight(sizeHint().height());
|
Chris@163
|
518 // adjustSize();
|
Chris@143
|
519 }
|
Chris@143
|
520
|
Chris@143
|
521 void
|
Chris@69
|
522 PluginParameterDialog::channelComboChanged(int index)
|
Chris@69
|
523 {
|
Chris@69
|
524 m_channel = index - 1;
|
Chris@69
|
525 }
|
Chris@69
|
526
|