annotate widgets/PluginParameterDialog.cpp @ 430:bcaeb2ba9b74

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