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@376
|
21 #include "TextAbbrev.h"
|
Chris@440
|
22 #include "IconLoader.h"
|
Chris@1274
|
23 #include "WidgetScale.h"
|
Chris@294
|
24
|
Chris@442
|
25 #include <vamp-hostsdk/Plugin.h>
|
Chris@442
|
26 #include <vamp-hostsdk/PluginHostAdapter.h>
|
Chris@442
|
27 #include <vamp-hostsdk/PluginWrapper.h>
|
Chris@106
|
28
|
Chris@62
|
29 #include <QGridLayout>
|
Chris@62
|
30 #include <QLabel>
|
Chris@62
|
31 #include <QGroupBox>
|
Chris@62
|
32 #include <QHBoxLayout>
|
Chris@143
|
33 #include <QVBoxLayout>
|
Chris@149
|
34 #include <QScrollArea>
|
Chris@62
|
35 #include <QPushButton>
|
Chris@69
|
36 #include <QMessageBox>
|
Chris@69
|
37 #include <QComboBox>
|
Chris@302
|
38 #include <QCheckBox>
|
Chris@143
|
39 #include <QSettings>
|
Chris@282
|
40 #include <QDialogButtonBox>
|
Chris@440
|
41 #include <QDesktopServices>
|
Chris@440
|
42 #include <QUrl>
|
Chris@62
|
43
|
Chris@682
|
44 #include "base/Debug.h"
|
Chris@682
|
45
|
Chris@71
|
46 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin,
|
Chris@1266
|
47 QWidget *parent) :
|
Chris@62
|
48 QDialog(parent),
|
Chris@62
|
49 m_plugin(plugin),
|
Chris@163
|
50 m_channel(-1),
|
Chris@145
|
51 m_stepSize(0),
|
Chris@145
|
52 m_blockSize(0),
|
Chris@145
|
53 m_windowType(HanningWindow),
|
Chris@1408
|
54 m_parameterBox(nullptr),
|
Chris@807
|
55 m_currentSelectionOnly(false)
|
Chris@62
|
56 {
|
Chris@122
|
57 setWindowTitle(tr("Plugin Parameters"));
|
Chris@122
|
58
|
Chris@62
|
59 QGridLayout *grid = new QGridLayout;
|
Chris@62
|
60 setLayout(grid);
|
Chris@62
|
61
|
Chris@62
|
62 QGroupBox *pluginBox = new QGroupBox;
|
Chris@208
|
63 pluginBox->setTitle(plugin->getType().c_str());
|
Chris@62
|
64 grid->addWidget(pluginBox, 0, 0);
|
Chris@62
|
65
|
Chris@62
|
66 QGridLayout *subgrid = new QGridLayout;
|
Chris@62
|
67 pluginBox->setLayout(subgrid);
|
Chris@62
|
68
|
Chris@63
|
69 subgrid->setSpacing(0);
|
Chris@63
|
70 subgrid->setMargin(10);
|
Chris@63
|
71
|
Chris@208
|
72 QFont boldFont(pluginBox->font());
|
Chris@208
|
73 boldFont.setBold(true);
|
Chris@208
|
74
|
Chris@208
|
75 QFont italicFont(pluginBox->font());
|
Chris@208
|
76 italicFont.setItalic(true);
|
Chris@62
|
77
|
Chris@207
|
78 QLabel *nameLabel = new QLabel(plugin->getName().c_str());
|
Chris@146
|
79 nameLabel->setWordWrap(true);
|
Chris@208
|
80 nameLabel->setFont(boldFont);
|
Chris@62
|
81
|
Chris@62
|
82 QLabel *makerLabel = new QLabel(plugin->getMaker().c_str());
|
Chris@146
|
83 makerLabel->setWordWrap(true);
|
Chris@62
|
84
|
Chris@441
|
85 int version = plugin->getPluginVersion();
|
Chris@441
|
86 QLabel *versionLabel = new QLabel(QString("%1").arg(version));
|
Chris@146
|
87 versionLabel->setWordWrap(true);
|
Chris@62
|
88
|
Chris@62
|
89 QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str());
|
Chris@146
|
90 copyrightLabel->setWordWrap(true);
|
Chris@62
|
91
|
Chris@1408
|
92 QLabel *descriptionLabel = nullptr;
|
Chris@208
|
93 if (plugin->getDescription() != "") {
|
Chris@208
|
94 descriptionLabel = new QLabel(plugin->getDescription().c_str());
|
Chris@208
|
95 descriptionLabel->setWordWrap(true);
|
Chris@208
|
96 descriptionLabel->setFont(italicFont);
|
Chris@208
|
97 }
|
Chris@63
|
98
|
Chris@163
|
99 int row = 0;
|
Chris@163
|
100
|
Chris@147
|
101 QLabel *label = new QLabel(tr("Name:"));
|
Chris@147
|
102 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
103 subgrid->addWidget(label, row, 0);
|
Chris@163
|
104 subgrid->addWidget(nameLabel, row, 1);
|
Chris@440
|
105
|
Chris@440
|
106 m_moreInfo = new QPushButton;
|
Chris@440
|
107 m_moreInfo->setIcon(IconLoader().load("info"));
|
Chris@1274
|
108 m_moreInfo->setFixedSize(WidgetScale::scaleQSize(QSize(16, 16)));
|
Chris@440
|
109 connect(m_moreInfo, SIGNAL(clicked()), this, SLOT(moreInfo()));
|
Chris@440
|
110 subgrid->addWidget(m_moreInfo, row, 2, Qt::AlignTop | Qt::AlignRight);
|
Chris@440
|
111 m_moreInfo->hide();
|
Chris@440
|
112
|
Chris@163
|
113 row++;
|
Chris@62
|
114
|
Chris@208
|
115 if (descriptionLabel) {
|
Chris@440
|
116 subgrid->addWidget(descriptionLabel, row, 1, 1, 2);
|
Chris@208
|
117 row++;
|
Chris@208
|
118 }
|
Chris@208
|
119
|
Chris@441
|
120 if (version >= 0) {
|
Chris@208
|
121 label = new QLabel(tr("Version:"));
|
Chris@208
|
122 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
123 subgrid->addWidget(label, row, 0);
|
Chris@208
|
124 subgrid->addWidget(versionLabel, row, 1);
|
Chris@208
|
125 row++;
|
Chris@208
|
126 }
|
Chris@208
|
127
|
Chris@147
|
128 label = new QLabel(tr("Maker:"));
|
Chris@147
|
129 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
130 subgrid->addWidget(label, row, 0);
|
Chris@163
|
131 subgrid->addWidget(makerLabel, row, 1);
|
Chris@163
|
132 row++;
|
Chris@63
|
133
|
Chris@147
|
134 label = new QLabel(tr("Copyright: "));
|
Chris@147
|
135 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
136 subgrid->addWidget(label, row, 0);
|
Chris@163
|
137 subgrid->addWidget(copyrightLabel, row, 1);
|
Chris@163
|
138 row++;
|
Chris@208
|
139
|
Chris@208
|
140 m_outputSpacer = new QLabel;
|
Chris@208
|
141 subgrid->addWidget(m_outputSpacer, row, 0);
|
Chris@208
|
142 m_outputSpacer->setFixedHeight(7);
|
Chris@208
|
143 m_outputSpacer->hide();
|
Chris@208
|
144 row++;
|
Chris@106
|
145
|
Chris@208
|
146 m_outputLabel = new QLabel(tr("Output:"));
|
Chris@208
|
147 m_outputLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
148 subgrid->addWidget(m_outputLabel, row, 0);
|
Chris@208
|
149 m_outputValue = new QLabel;
|
Chris@208
|
150 m_outputValue->setFont(boldFont);
|
Chris@208
|
151 subgrid->addWidget(m_outputValue, row, 1);
|
Chris@208
|
152 m_outputLabel->hide();
|
Chris@208
|
153 m_outputValue->hide();
|
Chris@208
|
154 row++;
|
Chris@208
|
155
|
Chris@208
|
156 m_outputDescription = new QLabel;
|
Chris@208
|
157 m_outputDescription->setFont(italicFont);
|
Chris@208
|
158 subgrid->addWidget(m_outputDescription, row, 1);
|
Chris@208
|
159 m_outputDescription->hide();
|
Chris@163
|
160 row++;
|
Chris@62
|
161
|
Chris@62
|
162 subgrid->setColumnStretch(1, 2);
|
Chris@62
|
163
|
Chris@164
|
164 m_inputModelBox = new QGroupBox;
|
Chris@302
|
165 m_inputModelBox->setTitle(tr("Input Material"));
|
Chris@164
|
166 grid->addWidget(m_inputModelBox, 1, 0);
|
Chris@164
|
167
|
Chris@164
|
168 m_inputModels = new QComboBox;
|
Chris@302
|
169 QVBoxLayout *inputLayout = new QVBoxLayout;
|
Chris@164
|
170 m_inputModelBox->setLayout(inputLayout);
|
Chris@164
|
171 inputLayout->addWidget(m_inputModels);
|
Chris@302
|
172 m_inputModels->hide();
|
Chris@302
|
173
|
Chris@302
|
174 m_selectionOnly = new QCheckBox(tr("Restrict to selection extents"));
|
Chris@302
|
175 inputLayout->addWidget(m_selectionOnly);
|
Chris@302
|
176 m_selectionOnly->hide();
|
Chris@302
|
177
|
Chris@164
|
178 m_inputModelBox->hide();
|
Chris@164
|
179
|
Chris@62
|
180 QGroupBox *paramBox = new QGroupBox;
|
Chris@62
|
181 paramBox->setTitle(tr("Plugin Parameters"));
|
Chris@164
|
182 grid->addWidget(paramBox, 2, 0);
|
Chris@164
|
183 grid->setRowStretch(2, 10);
|
Chris@62
|
184
|
Chris@62
|
185 QHBoxLayout *paramLayout = new QHBoxLayout;
|
Chris@63
|
186 paramLayout->setMargin(0);
|
Chris@62
|
187 paramBox->setLayout(paramLayout);
|
Chris@62
|
188
|
Chris@149
|
189 QScrollArea *scroll = new QScrollArea;
|
Chris@149
|
190 scroll->setWidgetResizable(true);
|
Chris@149
|
191 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@149
|
192 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@149
|
193 paramLayout->addWidget(scroll);
|
Chris@149
|
194
|
Chris@62
|
195 m_parameterBox = new PluginParameterBox(m_plugin);
|
Chris@64
|
196 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)),
|
Chris@64
|
197 this, SIGNAL(pluginConfigurationChanged(QString)));
|
Chris@149
|
198 scroll->setWidget(m_parameterBox);
|
Chris@62
|
199
|
Chris@143
|
200 m_advanced = new QFrame;
|
Chris@143
|
201 QVBoxLayout *advancedLayout = new QVBoxLayout;
|
Chris@143
|
202 advancedLayout->setMargin(0);
|
Chris@143
|
203 m_advanced->setLayout(advancedLayout);
|
Chris@164
|
204 grid->addWidget(m_advanced, 3, 0);
|
Chris@143
|
205
|
Chris@163
|
206 m_channelBox = new QGroupBox;
|
Chris@163
|
207 m_channelBox->setTitle(tr("Channels"));
|
Chris@163
|
208 advancedLayout->addWidget(m_channelBox);
|
Chris@163
|
209 m_channelBox->setVisible(false);
|
Chris@163
|
210 m_haveChannelBoxData = false;
|
Chris@163
|
211
|
Chris@163
|
212 m_windowBox = new QGroupBox;
|
Chris@163
|
213 m_windowBox->setTitle(tr("Processing"));
|
Chris@163
|
214 advancedLayout->addWidget(m_windowBox);
|
Chris@163
|
215 m_windowBox->setVisible(false);
|
Chris@163
|
216 m_haveWindowBoxData = false;
|
Chris@163
|
217
|
Chris@163
|
218 QHBoxLayout *hbox = new QHBoxLayout;
|
Chris@163
|
219 grid->addLayout(hbox, 4, 0);
|
Chris@163
|
220
|
Chris@163
|
221 m_advancedVisible = false;
|
Chris@163
|
222
|
Chris@163
|
223 m_advancedButton = new QPushButton(tr("Advanced >>"));
|
Chris@163
|
224 m_advancedButton->setCheckable(true);
|
Chris@163
|
225 connect(m_advancedButton, SIGNAL(clicked()), this, SLOT(advancedToggled()));
|
Chris@163
|
226
|
Chris@163
|
227 QSettings settings;
|
Chris@163
|
228 settings.beginGroup("PluginParameterDialog");
|
Chris@163
|
229 m_advancedVisible = settings.value("advancedvisible", false).toBool();
|
Chris@163
|
230 settings.endGroup();
|
Chris@163
|
231
|
Chris@456
|
232 m_advanced->hide();
|
Chris@163
|
233
|
Chris@163
|
234 hbox->addWidget(m_advancedButton);
|
Chris@163
|
235 m_advancedButton->hide();
|
Chris@163
|
236
|
Chris@282
|
237 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
|
Chris@282
|
238 QDialogButtonBox::Cancel);
|
Chris@282
|
239 hbox->addWidget(bb);
|
Chris@294
|
240 connect(bb, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
|
Chris@282
|
241 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
|
Chris@460
|
242 bb->button(QDialogButtonBox::Ok)->setDefault(true);
|
Chris@163
|
243
|
Chris@163
|
244 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
245 }
|
Chris@163
|
246
|
Chris@163
|
247 PluginParameterDialog::~PluginParameterDialog()
|
Chris@163
|
248 {
|
Chris@163
|
249 }
|
Chris@163
|
250
|
Chris@456
|
251 int
|
Chris@456
|
252 PluginParameterDialog::exec()
|
Chris@456
|
253 {
|
Chris@456
|
254 show();
|
Chris@456
|
255 setAdvancedVisible(m_advancedVisible);
|
Chris@456
|
256 return QDialog::exec();
|
Chris@456
|
257 }
|
Chris@456
|
258
|
Chris@163
|
259
|
Chris@163
|
260 void
|
Chris@208
|
261 PluginParameterDialog::setOutputLabel(QString text,
|
Chris@208
|
262 QString description)
|
Chris@163
|
263 {
|
Chris@163
|
264 if (text == "") {
|
Chris@208
|
265 m_outputSpacer->hide();
|
Chris@163
|
266 m_outputLabel->hide();
|
Chris@163
|
267 m_outputValue->hide();
|
Chris@208
|
268 m_outputDescription->hide();
|
Chris@163
|
269 } else {
|
Chris@208
|
270 m_outputSpacer->show();
|
Chris@163
|
271 m_outputValue->setText(text);
|
Chris@163
|
272 m_outputValue->setWordWrap(true);
|
Chris@208
|
273 m_outputDescription->setText(description);
|
Chris@309
|
274 m_outputDescription->setWordWrap(true);
|
Chris@163
|
275 m_outputLabel->show();
|
Chris@163
|
276 m_outputValue->show();
|
Chris@208
|
277 if (description != "") {
|
Chris@208
|
278 m_outputDescription->show();
|
Chris@208
|
279 } else {
|
Chris@208
|
280 m_outputDescription->hide();
|
Chris@208
|
281 }
|
Chris@163
|
282 }
|
Chris@163
|
283 }
|
Chris@163
|
284
|
Chris@163
|
285 void
|
Chris@440
|
286 PluginParameterDialog::setMoreInfoUrl(QString moreInfoUrl)
|
Chris@440
|
287 {
|
Chris@440
|
288 m_moreInfoUrl = moreInfoUrl;
|
Chris@440
|
289 if (m_moreInfoUrl != "") {
|
Chris@440
|
290 m_moreInfo->show();
|
Chris@440
|
291 } else {
|
Chris@440
|
292 m_moreInfo->hide();
|
Chris@440
|
293 }
|
Chris@440
|
294 }
|
Chris@440
|
295
|
Chris@440
|
296 void
|
Chris@163
|
297 PluginParameterDialog::setChannelArrangement(int sourceChannels,
|
Chris@163
|
298 int targetChannels,
|
Chris@163
|
299 int defaultChannel)
|
Chris@163
|
300 {
|
Chris@163
|
301 m_channel = defaultChannel;
|
Chris@163
|
302
|
Chris@69
|
303 if (sourceChannels != targetChannels) {
|
Chris@69
|
304
|
Chris@69
|
305 // At the moment we can only cope with the case where
|
Chris@69
|
306 // sourceChannels > targetChannels and targetChannels == 1
|
Chris@69
|
307
|
Chris@69
|
308 if (sourceChannels < targetChannels) {
|
Chris@69
|
309
|
Chris@69
|
310 QMessageBox::warning
|
Chris@163
|
311 (parentWidget(),
|
Chris@69
|
312 tr("Channel mismatch"),
|
Chris@69
|
313 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
|
314 QMessageBox::Ok,
|
Chris@69
|
315 QMessageBox::NoButton);
|
Chris@69
|
316
|
Chris@69
|
317 } else {
|
Chris@69
|
318
|
Chris@163
|
319 if (m_haveChannelBoxData) {
|
Chris@682
|
320 cerr << "WARNING: PluginParameterDialog::setChannelArrangement: Calling more than once on same dialog is not currently implemented" << endl;
|
Chris@163
|
321 return;
|
Chris@163
|
322 }
|
Chris@69
|
323
|
Chris@69
|
324 QVBoxLayout *channelLayout = new QVBoxLayout;
|
Chris@163
|
325 m_channelBox->setLayout(channelLayout);
|
Chris@69
|
326
|
Chris@69
|
327 if (targetChannels != 1) {
|
Chris@69
|
328
|
Chris@69
|
329 channelLayout->addWidget
|
Chris@69
|
330 (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
|
331 .arg(targetChannels)
|
Chris@69
|
332 .arg(sourceChannels)
|
Chris@69
|
333 .arg(targetChannels)));
|
Chris@69
|
334
|
Chris@69
|
335 } else {
|
Chris@69
|
336
|
Chris@69
|
337 channelLayout->addWidget(new QLabel(tr("This plugin only has a single channel input,\nbut the source has %1 channels.").arg(sourceChannels)));
|
Chris@69
|
338
|
Chris@69
|
339 QComboBox *channelCombo = new QComboBox;
|
Chris@76
|
340 channelCombo->addItem(tr("Use mean of source channels"));
|
Chris@69
|
341 for (int i = 0; i < sourceChannels; ++i) {
|
Chris@69
|
342 channelCombo->addItem(tr("Use channel %1 only").arg(i + 1));
|
Chris@69
|
343 }
|
Chris@69
|
344
|
Chris@69
|
345 connect(channelCombo, SIGNAL(activated(int)),
|
Chris@69
|
346 this, SLOT(channelComboChanged(int)));
|
Chris@69
|
347
|
Chris@69
|
348 channelLayout->addWidget(channelCombo);
|
Chris@69
|
349 }
|
Chris@163
|
350
|
Chris@163
|
351 m_channelBox->setVisible(true);
|
Chris@163
|
352 m_haveChannelBoxData = true;
|
Chris@163
|
353 m_advancedButton->show();
|
Chris@69
|
354 }
|
Chris@69
|
355 }
|
Chris@69
|
356
|
Chris@163
|
357 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
358 }
|
Chris@163
|
359
|
Chris@163
|
360 void
|
Chris@163
|
361 PluginParameterDialog::setShowProcessingOptions(bool showWindowSize,
|
Chris@163
|
362 bool showFrequencyDomainOptions)
|
Chris@163
|
363 {
|
Chris@163
|
364 if (m_haveWindowBoxData) {
|
Chris@682
|
365 cerr << "WARNING: PluginParameterDialog::setShowProcessingOptions: Calling more than once on same dialog is not currently implemented" << endl;
|
Chris@163
|
366 return;
|
Chris@163
|
367 }
|
Chris@163
|
368
|
Chris@140
|
369 if (showWindowSize) {
|
Chris@140
|
370
|
Chris@309
|
371 Vamp::Plugin *fePlugin = dynamic_cast<Vamp::Plugin *>(m_plugin);
|
Chris@309
|
372 if (!fePlugin) fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin);
|
Chris@309
|
373 if (!fePlugin) fePlugin = dynamic_cast<Vamp::HostExt::PluginWrapper *>(m_plugin);
|
Chris@140
|
374 int size = 1024;
|
Chris@140
|
375 int increment = 1024;
|
Chris@140
|
376 if (fePlugin) {
|
Chris@908
|
377 size = int(fePlugin->getPreferredBlockSize());
|
Chris@682
|
378 cerr << "Feature extraction plugin \"" << fePlugin->getName() << "\" reports preferred block size as " << size << endl;
|
Chris@140
|
379 if (size == 0) size = 1024;
|
Chris@908
|
380 increment = int(fePlugin->getPreferredStepSize());
|
Chris@146
|
381 if (increment == 0) {
|
Chris@146
|
382 if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) {
|
Chris@146
|
383 increment = size;
|
Chris@146
|
384 } else {
|
Chris@146
|
385 increment = size/2;
|
Chris@146
|
386 }
|
Chris@146
|
387 }
|
Chris@140
|
388 }
|
Chris@140
|
389
|
Chris@140
|
390 QGridLayout *windowLayout = new QGridLayout;
|
Chris@163
|
391 m_windowBox->setLayout(windowLayout);
|
Chris@140
|
392
|
Chris@140
|
393 if (showFrequencyDomainOptions) {
|
Chris@140
|
394 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0);
|
Chris@140
|
395 } else {
|
Chris@140
|
396 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0);
|
Chris@140
|
397 }
|
Chris@140
|
398
|
Chris@682
|
399 cerr << "size: " << size << ", increment: " << increment << endl;
|
Chris@143
|
400
|
Chris@140
|
401 QComboBox *blockSizeCombo = new QComboBox;
|
Chris@140
|
402 blockSizeCombo->setEditable(true);
|
Chris@147
|
403 bool found = false;
|
Chris@143
|
404 for (int i = 0; i < 14; ++i) {
|
Chris@249
|
405 int val = 1 << (i + 3);
|
Chris@140
|
406 blockSizeCombo->addItem(QString("%1").arg(val));
|
Chris@147
|
407 if (val == size) {
|
Chris@147
|
408 blockSizeCombo->setCurrentIndex(i);
|
Chris@147
|
409 found = true;
|
Chris@147
|
410 }
|
Chris@147
|
411 }
|
Chris@147
|
412 if (!found) {
|
Chris@147
|
413 blockSizeCombo->addItem(QString("%1").arg(size));
|
Chris@147
|
414 blockSizeCombo->setCurrentIndex(blockSizeCombo->count() - 1);
|
Chris@140
|
415 }
|
Chris@545
|
416 blockSizeCombo->setValidator(new QIntValidator(1, int(pow(2., 18)), this));
|
Chris@155
|
417 connect(blockSizeCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
418 this, SLOT(blockSizeComboChanged(const QString &)));
|
Chris@140
|
419 windowLayout->addWidget(blockSizeCombo, 0, 1);
|
Chris@140
|
420
|
Chris@148
|
421 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0);
|
Chris@148
|
422
|
Chris@148
|
423 QComboBox *incrementCombo = new QComboBox;
|
Chris@148
|
424 incrementCombo->setEditable(true);
|
Chris@148
|
425 found = false;
|
Chris@148
|
426 for (int i = 0; i < 14; ++i) {
|
Chris@249
|
427 int val = 1 << (i + 3);
|
Chris@148
|
428 incrementCombo->addItem(QString("%1").arg(val));
|
Chris@148
|
429 if (val == increment) {
|
Chris@148
|
430 incrementCombo->setCurrentIndex(i);
|
Chris@148
|
431 found = true;
|
Chris@148
|
432 }
|
Chris@148
|
433 }
|
Chris@148
|
434 if (!found) {
|
Chris@148
|
435 incrementCombo->addItem(QString("%1").arg(increment));
|
Chris@148
|
436 incrementCombo->setCurrentIndex(incrementCombo->count() - 1);
|
Chris@148
|
437 }
|
Chris@545
|
438 incrementCombo->setValidator(new QIntValidator(1, int(pow(2., 18)), this));
|
Chris@155
|
439 connect(incrementCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
440 this, SLOT(incrementComboChanged(const QString &)));
|
Chris@148
|
441 windowLayout->addWidget(incrementCombo, 1, 1);
|
Chris@148
|
442
|
Chris@140
|
443 if (showFrequencyDomainOptions) {
|
Chris@140
|
444
|
Chris@140
|
445 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0);
|
Chris@140
|
446 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector;
|
Chris@171
|
447 connect(windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
|
Chris@171
|
448 this, SLOT(windowTypeChanged(WindowType)));
|
Chris@140
|
449 windowLayout->addWidget(windowTypeSelector, 2, 1);
|
Chris@140
|
450 }
|
Chris@163
|
451
|
Chris@163
|
452 m_windowBox->setVisible(true);
|
Chris@163
|
453 m_haveWindowBoxData = true;
|
Chris@163
|
454 m_advancedButton->show();
|
Chris@140
|
455 }
|
Chris@140
|
456
|
Chris@163
|
457 setAdvancedVisible(m_advancedVisible);
|
Chris@62
|
458 }
|
Chris@62
|
459
|
Chris@69
|
460 void
|
Chris@336
|
461 PluginParameterDialog::setCandidateInputModels(const QStringList &models,
|
Chris@336
|
462 QString defaultModel)
|
Chris@164
|
463 {
|
Chris@164
|
464 m_inputModels->clear();
|
Chris@294
|
465
|
Chris@294
|
466 QSettings settings;
|
Chris@294
|
467 settings.beginGroup("PluginParameterDialog");
|
Chris@294
|
468 QString lastModel = settings.value("lastinputmodel").toString();
|
Chris@294
|
469 settings.endGroup();
|
Chris@294
|
470
|
Chris@336
|
471 if (defaultModel == "") defaultModel = lastModel;
|
Chris@336
|
472
|
Chris@302
|
473 m_inputModels->show();
|
Chris@302
|
474
|
Chris@294
|
475 m_inputModelList = models;
|
Chris@294
|
476 m_inputModels->addItems(TextAbbrev::abbreviate(models, 80));
|
Chris@296
|
477 m_inputModels->setCurrentIndex(0);
|
Chris@294
|
478
|
Chris@336
|
479 if (defaultModel != "") {
|
Chris@294
|
480 for (int i = 0; i < models.size(); ++i) {
|
Chris@336
|
481 if (defaultModel == models[i]) {
|
Chris@294
|
482 m_inputModels->setCurrentIndex(i);
|
Chris@296
|
483 m_currentInputModel = models[i];
|
Chris@294
|
484 break;
|
Chris@294
|
485 }
|
Chris@294
|
486 }
|
Chris@294
|
487 }
|
Chris@294
|
488
|
Chris@294
|
489 connect(m_inputModels, SIGNAL(activated(int)),
|
Chris@294
|
490 this, SLOT(inputModelComboChanged(int)));
|
Chris@164
|
491 m_inputModelBox->show();
|
Chris@164
|
492 }
|
Chris@164
|
493
|
Chris@302
|
494 void
|
Chris@302
|
495 PluginParameterDialog::setShowSelectionOnlyOption(bool show)
|
Chris@302
|
496 {
|
Chris@302
|
497 if (!show) {
|
Chris@302
|
498 m_selectionOnly->hide();
|
Chris@302
|
499 if (!m_inputModels->isVisible()) m_inputModelBox->hide();
|
Chris@302
|
500 return;
|
Chris@302
|
501 }
|
Chris@302
|
502
|
Chris@302
|
503 QSettings settings;
|
Chris@302
|
504 settings.beginGroup("PluginParameterDialog");
|
Chris@302
|
505 bool lastSelectionOnly = settings.value("lastselectiononly", false).toBool();
|
Chris@302
|
506 settings.endGroup();
|
Chris@302
|
507
|
Chris@302
|
508 m_selectionOnly->setChecked(lastSelectionOnly);
|
Chris@309
|
509 m_currentSelectionOnly = lastSelectionOnly;
|
Chris@302
|
510
|
Chris@302
|
511 connect(m_selectionOnly, SIGNAL(stateChanged(int)),
|
Chris@302
|
512 this, SLOT(selectionOnlyChanged(int)));
|
Chris@302
|
513
|
Chris@302
|
514 m_selectionOnly->show();
|
Chris@302
|
515 m_inputModelBox->show();
|
Chris@302
|
516 }
|
Chris@302
|
517
|
Chris@164
|
518 QString
|
Chris@164
|
519 PluginParameterDialog::getInputModel() const
|
Chris@164
|
520 {
|
Chris@296
|
521 return m_currentInputModel;
|
Chris@164
|
522 }
|
Chris@164
|
523
|
Chris@302
|
524 bool
|
Chris@302
|
525 PluginParameterDialog::getSelectionOnly() const
|
Chris@302
|
526 {
|
Chris@309
|
527 return m_currentSelectionOnly;
|
Chris@302
|
528 }
|
Chris@302
|
529
|
Chris@164
|
530 void
|
Chris@807
|
531 PluginParameterDialog::getProcessingParameters(int &blockSize) const
|
Chris@145
|
532 {
|
Chris@145
|
533 blockSize = m_blockSize;
|
Chris@145
|
534 return;
|
Chris@145
|
535 }
|
Chris@145
|
536
|
Chris@145
|
537 void
|
Chris@807
|
538 PluginParameterDialog::getProcessingParameters(int &stepSize,
|
Chris@807
|
539 int &blockSize,
|
Chris@145
|
540 WindowType &windowType) const
|
Chris@145
|
541 {
|
Chris@145
|
542 stepSize = m_stepSize;
|
Chris@145
|
543 blockSize = m_blockSize;
|
Chris@145
|
544 windowType = m_windowType;
|
Chris@146
|
545 return;
|
Chris@145
|
546 }
|
Chris@145
|
547
|
Chris@145
|
548 void
|
Chris@155
|
549 PluginParameterDialog::blockSizeComboChanged(const QString &text)
|
Chris@145
|
550 {
|
Chris@145
|
551 m_blockSize = text.toInt();
|
Chris@682
|
552 cerr << "Block size changed to " << m_blockSize << endl;
|
Chris@145
|
553 }
|
Chris@145
|
554
|
Chris@145
|
555 void
|
Chris@155
|
556 PluginParameterDialog::incrementComboChanged(const QString &text)
|
Chris@145
|
557 {
|
Chris@145
|
558 m_stepSize = text.toInt();
|
Chris@146
|
559 //!!! rename increment to step size throughout
|
Chris@682
|
560 cerr << "Increment changed to " << m_stepSize << endl;
|
Chris@145
|
561 }
|
Chris@145
|
562
|
Chris@145
|
563 void
|
Chris@145
|
564 PluginParameterDialog::windowTypeChanged(WindowType type)
|
Chris@145
|
565 {
|
Chris@145
|
566 m_windowType = type;
|
Chris@145
|
567 }
|
Chris@145
|
568
|
Chris@145
|
569 void
|
Chris@440
|
570 PluginParameterDialog::moreInfo()
|
Chris@440
|
571 {
|
Chris@440
|
572 if (m_moreInfoUrl != "") {
|
Chris@440
|
573 QDesktopServices::openUrl(QUrl(m_moreInfoUrl));
|
Chris@440
|
574 }
|
Chris@440
|
575 }
|
Chris@440
|
576
|
Chris@440
|
577 void
|
Chris@143
|
578 PluginParameterDialog::advancedToggled()
|
Chris@143
|
579 {
|
Chris@163
|
580 setAdvancedVisible(!m_advancedVisible);
|
Chris@163
|
581 }
|
Chris@143
|
582
|
Chris@163
|
583 void
|
Chris@163
|
584 PluginParameterDialog::setAdvancedVisible(bool visible)
|
Chris@163
|
585 {
|
Chris@163
|
586 if (visible) {
|
Chris@163
|
587 m_advancedButton->setText(tr("Advanced <<"));
|
Chris@163
|
588 m_advancedButton->setChecked(true);
|
Chris@456
|
589 m_advanced->show();
|
Chris@163
|
590 } else {
|
Chris@456
|
591 m_advanced->hide();
|
Chris@163
|
592 m_advancedButton->setText(tr("Advanced >>"));
|
Chris@163
|
593 m_advancedButton->setChecked(false);
|
Chris@163
|
594 }
|
Chris@143
|
595
|
Chris@456
|
596 adjustSize();
|
Chris@456
|
597
|
Chris@456
|
598 m_advancedVisible = visible;
|
Chris@456
|
599
|
Chris@143
|
600 QSettings settings;
|
Chris@143
|
601 settings.beginGroup("PluginParameterDialog");
|
Chris@143
|
602 settings.setValue("advancedvisible", visible);
|
Chris@143
|
603 settings.endGroup();
|
Chris@143
|
604 }
|
Chris@143
|
605
|
Chris@143
|
606 void
|
Chris@69
|
607 PluginParameterDialog::channelComboChanged(int index)
|
Chris@69
|
608 {
|
Chris@69
|
609 m_channel = index - 1;
|
Chris@69
|
610 }
|
Chris@69
|
611
|
Chris@294
|
612 void
|
Chris@294
|
613 PluginParameterDialog::inputModelComboChanged(int index)
|
Chris@294
|
614 {
|
Chris@294
|
615 if (index >= m_inputModelList.size()) return;
|
Chris@296
|
616 m_currentInputModel = m_inputModelList[index];
|
Chris@296
|
617 emit inputModelChanged(m_currentInputModel);
|
Chris@294
|
618 }
|
Chris@294
|
619
|
Chris@294
|
620 void
|
Chris@302
|
621 PluginParameterDialog::selectionOnlyChanged(int state)
|
Chris@302
|
622 {
|
Chris@302
|
623 if (state == Qt::Checked) {
|
Chris@302
|
624 m_currentSelectionOnly = true;
|
Chris@302
|
625 } else {
|
Chris@302
|
626 m_currentSelectionOnly = false;
|
Chris@302
|
627 }
|
Chris@302
|
628 }
|
Chris@302
|
629
|
Chris@302
|
630 void
|
Chris@294
|
631 PluginParameterDialog::dialogAccepted()
|
Chris@294
|
632 {
|
Chris@294
|
633 QSettings settings;
|
Chris@294
|
634 settings.beginGroup("PluginParameterDialog");
|
Chris@302
|
635
|
Chris@302
|
636 if (m_inputModels->isVisible()) {
|
Chris@302
|
637 settings.setValue("lastinputmodel", getInputModel());
|
Chris@302
|
638 }
|
Chris@302
|
639
|
Chris@302
|
640 if (m_selectionOnly->isVisible()) {
|
Chris@302
|
641 settings.setValue("lastselectiononly", getSelectionOnly());
|
Chris@302
|
642 }
|
Chris@302
|
643
|
Chris@294
|
644 settings.endGroup();
|
Chris@294
|
645
|
Chris@294
|
646 accept();
|
Chris@294
|
647 }
|
Chris@294
|
648
|