annotate widgets/PluginParameterDialog.cpp @ 305:013a37723c0a

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