annotate widgets/PluginParameterDialog.cpp @ 456:035d62c4cddf

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