changeset 62:50429a56680f

* Add plugin parameter dialog, and use it to set up parameters for feature extraction plugins via a semi-opaque (translucent?) configurationXml string which is associated with a given transform instance. This is not yet saved to and restored from the SV file properly. * Remove no-longer-relevant BeatDetect and BeatDetectionFunction transforms (replaced a long time ago with the beat detector plugin).
author Chris Cannam
date Wed, 22 Mar 2006 17:38:29 +0000
parents d072a3b59a0d
children fb02fe13ff47
files widgets/PluginParameterBox.cpp widgets/PluginParameterBox.h widgets/PluginParameterDialog.cpp widgets/PluginParameterDialog.h
diffstat 4 files changed, 161 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/PluginParameterBox.cpp	Mon Mar 20 18:42:42 2006 +0000
+++ b/widgets/PluginParameterBox.cpp	Wed Mar 22 17:38:29 2006 +0000
@@ -25,7 +25,8 @@
 #include <iostream>
 #include <string>
 
-PluginParameterBox::PluginParameterBox(PluginInstance *plugin) :
+PluginParameterBox::PluginParameterBox(PluginInstance *plugin, QWidget *parent) :
+    QFrame(parent),
     m_plugin(plugin)
 {
     m_layout = new QGridLayout;
@@ -44,6 +45,12 @@
 
     m_params.clear();
 
+    if (params.empty()) {
+        m_layout->addWidget
+            (new QLabel(tr("This plugin has no adjustable parameters.")),
+             0, 0);
+    }
+
     for (size_t i = 0; i < params.size(); ++i) {
 
         QString name = params[i].name.c_str();
@@ -53,6 +60,7 @@
         float min = params[i].minValue;
         float max = params[i].maxValue;
         float deft = params[i].defaultValue;
+        float value = m_plugin->getParameter(params[i].name);
 
         float qtz = 0.0;
         if (params[i].isQuantized) qtz = params[i].quantizeStep;
@@ -80,6 +88,9 @@
         dial->setPageStep(1);
         dial->setNotchesVisible((imax - imin) <= 12);
         dial->setDefaultValue(int((deft - min) / qtz));
+        dial->setValue(int((value - min) / qtz));
+	dial->setFixedWidth(32);
+	dial->setFixedHeight(32);
         connect(dial, SIGNAL(valueChanged(int)),
                 this, SLOT(dialChanged(int)));
         m_layout->addWidget(dial, i, 1);
@@ -88,9 +99,9 @@
         spinbox->setObjectName(name);
         spinbox->setMinimum(min);
         spinbox->setMaximum(max);
-        spinbox->setSuffix(unit);
+        spinbox->setSuffix(QString(" %1").arg(unit));
         spinbox->setSingleStep(qtz);
-        spinbox->setValue(deft);
+        spinbox->setValue(value);
         connect(spinbox, SIGNAL(valueChanged(double)),
                 this, SLOT(spinBoxChanged(double)));
         m_layout->addWidget(spinbox, i, 2);
--- a/widgets/PluginParameterBox.h	Mon Mar 20 18:42:42 2006 +0000
+++ b/widgets/PluginParameterBox.h	Wed Mar 22 17:38:29 2006 +0000
@@ -30,7 +30,7 @@
     Q_OBJECT
     
 public:
-    PluginParameterBox(PluginInstance *);
+    PluginParameterBox(PluginInstance *, QWidget *parent = 0);
     ~PluginParameterBox();
 
     PluginInstance *getPlugin() { return m_plugin; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/widgets/PluginParameterDialog.cpp	Wed Mar 22 17:38:29 2006 +0000
@@ -0,0 +1,98 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "PluginParameterDialog.h"
+
+#include "PluginParameterBox.h"
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QPushButton>
+
+PluginParameterDialog::PluginParameterDialog(PluginInstance *plugin,
+					     QWidget *parent) :
+    QDialog(parent),
+    m_plugin(plugin),
+    m_parameterBox(0)
+{
+    QGridLayout *grid = new QGridLayout;
+    setLayout(grid);
+
+    QGroupBox *pluginBox = new QGroupBox;
+    pluginBox->setTitle(tr("Plugin"));
+    grid->addWidget(pluginBox, 0, 0);
+
+    QGridLayout *subgrid = new QGridLayout;
+    pluginBox->setLayout(subgrid);
+
+    QFont font(pluginBox->font());
+    font.setBold(true);
+
+    QLabel *nameLabel = new QLabel(plugin->getDescription().c_str());
+    nameLabel->setFont(font);
+
+    QLabel *makerLabel = new QLabel(plugin->getMaker().c_str());
+    makerLabel->setFont(font);
+
+    QLabel *versionLabel = new QLabel(QString("%1")
+                                      .arg(plugin->getPluginVersion()));
+    versionLabel->setFont(font);
+
+    QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str());
+    copyrightLabel->setFont(font);
+
+    subgrid->addWidget(new QLabel(tr("Name:")), 0, 0);
+    subgrid->addWidget(nameLabel, 0, 1);
+
+    subgrid->addWidget(new QLabel(tr("Maker:")), 1, 0);
+    subgrid->addWidget(makerLabel, 1, 1);
+
+    subgrid->addWidget(new QLabel(tr("Copyright:")), 2, 0);
+    subgrid->addWidget(copyrightLabel, 2, 1);
+
+    subgrid->addWidget(new QLabel(tr("Version:")), 3, 0);
+    subgrid->addWidget(versionLabel, 3, 1);
+
+    subgrid->setColumnStretch(1, 2);
+
+    QGroupBox *paramBox = new QGroupBox;
+    paramBox->setTitle(tr("Plugin Parameters"));
+    grid->addWidget(paramBox, 1, 0);
+    grid->setRowStretch(1, 10);
+
+    QHBoxLayout *paramLayout = new QHBoxLayout;
+    paramBox->setLayout(paramLayout);
+
+    m_parameterBox = new PluginParameterBox(m_plugin);
+    paramLayout->addWidget(m_parameterBox);
+
+    QHBoxLayout *hbox = new QHBoxLayout;
+    grid->addLayout(hbox, 2, 0);
+    
+    QPushButton *ok = new QPushButton(tr("OK"));
+    QPushButton *cancel = new QPushButton(tr("Cancel"));
+    hbox->addStretch(10);
+    hbox->addWidget(ok);
+    hbox->addWidget(cancel);
+    connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
+    connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
+}
+
+PluginParameterDialog::~PluginParameterDialog()
+{
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/widgets/PluginParameterDialog.h	Wed Mar 22 17:38:29 2006 +0000
@@ -0,0 +1,48 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef _PLUGIN_PARAMETER_DIALOG_H_
+#define _PLUGIN_PARAMETER_DIALOG_H_
+
+#include <QDialog>
+
+class PluginInstance;
+class PluginParameterBox;
+
+/**
+ * A dialog for editing the parameters of a given plugin, using a
+ * PluginParameterBox.  This dialog does not contain any mechanism for
+ * selecting the plugin in the first place.  Note that the dialog
+ * directly modifies the parameters of the plugin, so they will remain
+ * modified even if the dialog is then cancelled.
+ */
+
+class PluginParameterDialog : public QDialog
+{
+    Q_OBJECT
+    
+public:
+    PluginParameterDialog(PluginInstance *, QWidget *parent = 0);
+    ~PluginParameterDialog();
+
+    PluginInstance *getPlugin() { return m_plugin; }
+
+protected:
+    PluginInstance *m_plugin;
+    PluginParameterBox *m_parameterBox;
+};
+
+#endif
+