2012-07-04 19:21:48 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file mixercurve.cpp
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup ConfigPlugin Config Plugin
|
|
|
|
* @{
|
|
|
|
* @brief A MixerCurve Gadget used to update settings in the firmware
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2012-07-06 20:28:46 +02:00
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include <QResizeEvent>
|
2012-06-30 23:35:38 +02:00
|
|
|
#include <math.h>
|
2012-06-29 01:01:27 +02:00
|
|
|
#include "mixercurve.h"
|
2012-07-09 17:59:52 +02:00
|
|
|
#include "dblspindelegate.h"
|
2012-06-29 01:01:27 +02:00
|
|
|
|
|
|
|
MixerCurve::MixerCurve(QWidget *parent) :
|
|
|
|
QFrame(parent),
|
2012-07-06 00:31:36 +02:00
|
|
|
m_mixerUI(new Ui::MixerCurve)
|
2012-06-29 01:01:27 +02:00
|
|
|
{
|
2012-06-30 23:35:38 +02:00
|
|
|
m_mixerUI->setupUi(this);
|
|
|
|
|
2012-07-06 23:01:53 +02:00
|
|
|
// setup some convienence pointers
|
2012-06-30 23:35:38 +02:00
|
|
|
m_curve = m_mixerUI->CurveWidget;
|
|
|
|
m_settings = m_mixerUI->CurveSettings;
|
|
|
|
|
2012-07-13 22:44:56 +02:00
|
|
|
|
|
|
|
m_mixerUI->SettingsGroup->hide();
|
|
|
|
m_curve->showCommands(false);
|
2012-07-14 16:25:57 +02:00
|
|
|
m_curve->showCommand("Reset", false);
|
|
|
|
m_curve->showCommand("Popup", false);
|
|
|
|
m_curve->showCommand("Commands", false);
|
2012-07-13 22:44:56 +02:00
|
|
|
|
2012-07-06 23:01:53 +02:00
|
|
|
// create our spin delegate
|
|
|
|
m_spinDelegate = new DoubleSpinDelegate();
|
|
|
|
|
|
|
|
// set the default mixer type
|
2012-07-06 00:31:36 +02:00
|
|
|
setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
|
2012-07-04 19:21:48 +02:00
|
|
|
|
2012-07-12 06:49:05 +02:00
|
|
|
// setup and turn off advanced mode
|
|
|
|
CommandActivated();
|
|
|
|
|
2012-07-06 23:01:53 +02:00
|
|
|
// paint the ui
|
2012-07-04 19:21:48 +02:00
|
|
|
UpdateCurveUI();
|
2012-06-30 23:35:38 +02:00
|
|
|
|
2012-07-06 23:01:53 +02:00
|
|
|
// wire up our signals
|
2012-07-12 06:49:05 +02:00
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
connect(m_mixerUI->CurveType, SIGNAL(currentIndexChanged(int)), this, SLOT(CurveTypeChanged()));
|
2012-06-30 23:35:38 +02:00
|
|
|
connect(m_mixerUI->ResetCurve, SIGNAL(clicked()), this, SLOT(ResetCurve()));
|
2012-07-14 16:25:57 +02:00
|
|
|
connect(m_mixerUI->PopupCurve, SIGNAL(clicked()),this,SLOT(PopupCurve()));
|
2012-06-30 23:35:38 +02:00
|
|
|
connect(m_mixerUI->GenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve()));
|
2012-07-04 19:21:48 +02:00
|
|
|
connect(m_curve, SIGNAL(curveUpdated()), this, SLOT(UpdateSettingsTable()));
|
2012-09-12 12:09:30 +02:00
|
|
|
connect(m_curve, SIGNAL(commandActivated(MixerNode*)),this, SLOT(CommandActivated(MixerNode*)));
|
2012-07-06 00:31:36 +02:00
|
|
|
connect(m_settings, SIGNAL(cellChanged(int,int)), this, SLOT(SettingsTableChanged()));
|
2012-06-30 23:35:38 +02:00
|
|
|
connect(m_mixerUI->CurveMin, SIGNAL(valueChanged(double)), this, SLOT(CurveMinChanged(double)));
|
|
|
|
connect(m_mixerUI->CurveMax, SIGNAL(valueChanged(double)), this, SLOT(CurveMaxChanged(double)));
|
|
|
|
connect(m_mixerUI->CurveStep, SIGNAL(valueChanged(double)), this, SLOT(GenerateCurve()));
|
2012-07-12 06:49:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-29 01:01:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MixerCurve::~MixerCurve()
|
|
|
|
{
|
2012-06-30 23:35:38 +02:00
|
|
|
delete m_mixerUI;
|
2012-07-06 22:38:46 +02:00
|
|
|
delete m_spinDelegate;
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
|
2012-07-02 19:46:21 +02:00
|
|
|
void MixerCurve::setMixerType(MixerCurveType curveType)
|
|
|
|
{
|
|
|
|
m_curveType = curveType;
|
2012-07-06 00:31:36 +02:00
|
|
|
|
2012-07-06 22:38:46 +02:00
|
|
|
m_mixerUI->CurveMin->setMaximum(1.0);
|
|
|
|
m_mixerUI->CurveMax->setMaximum(1.0);
|
|
|
|
|
2012-07-06 00:31:36 +02:00
|
|
|
switch (m_curveType) {
|
|
|
|
case MixerCurve::MIXERCURVE_THROTTLE:
|
|
|
|
{
|
2012-07-06 20:28:46 +02:00
|
|
|
m_mixerUI->SettingsGroup->setTitle("Throttle Curve");
|
2012-07-06 00:31:36 +02:00
|
|
|
m_curve->setRange(0.0, 1.0);
|
|
|
|
m_mixerUI->CurveMin->setMinimum(0.0);
|
|
|
|
m_mixerUI->CurveMax->setMinimum(0.0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MixerCurve::MIXERCURVE_PITCH:
|
|
|
|
{
|
2012-07-06 20:28:46 +02:00
|
|
|
m_mixerUI->SettingsGroup->setTitle("Pitch Curve");
|
2012-07-12 06:49:05 +02:00
|
|
|
m_curve->setRange(-1.0, 1.0);
|
2012-07-12 19:49:22 +02:00
|
|
|
m_curve->setPositiveColor("#0000aa", "#0000aa");
|
2012-07-06 00:31:36 +02:00
|
|
|
m_mixerUI->CurveMin->setMinimum(-1.0);
|
|
|
|
m_mixerUI->CurveMax->setMinimum(-1.0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:38:46 +02:00
|
|
|
m_spinDelegate->setRange(m_mixerUI->CurveMin->minimum(), m_mixerUI->CurveMax->maximum());
|
2012-07-06 00:31:36 +02:00
|
|
|
for (int i=0; i<MixerCurveWidget::NODE_NUMELEM; i++) {
|
2012-07-06 22:38:46 +02:00
|
|
|
m_settings->setItemDelegateForRow(i, m_spinDelegate);
|
2012-07-06 00:31:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ResetCurve();
|
2012-07-02 19:46:21 +02:00
|
|
|
}
|
|
|
|
|
2012-06-30 23:35:38 +02:00
|
|
|
void MixerCurve::ResetCurve()
|
|
|
|
{
|
2012-07-06 22:38:46 +02:00
|
|
|
m_mixerUI->CurveMin->setValue(m_mixerUI->CurveMin->minimum());
|
|
|
|
m_mixerUI->CurveMax->setValue(m_mixerUI->CurveMax->maximum());
|
2012-07-01 00:27:42 +02:00
|
|
|
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Linear"));
|
2012-06-30 23:35:38 +02:00
|
|
|
|
2012-07-06 22:38:46 +02:00
|
|
|
initLinearCurve(MixerCurveWidget::NODE_NUMELEM, getCurveMax(), getCurveMin());
|
2012-06-30 23:35:38 +02:00
|
|
|
|
2012-07-12 06:49:05 +02:00
|
|
|
m_curve->activateCommand("Linear");
|
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
UpdateSettingsTable();
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
|
2012-07-14 16:25:57 +02:00
|
|
|
void MixerCurve::PopupCurve()
|
|
|
|
{
|
|
|
|
if (!m_curve->isCommandActive("Popup")) {
|
|
|
|
|
|
|
|
m_mixerUI->SettingsGroup->show();
|
|
|
|
m_mixerUI->PopupCurve->hide();
|
|
|
|
|
|
|
|
PopupWidget* popup = new PopupWidget();
|
|
|
|
popup->popUp(this);
|
|
|
|
|
|
|
|
m_mixerUI->SettingsGroup->hide();
|
|
|
|
m_mixerUI->PopupCurve->show();
|
|
|
|
m_curve->showCommands(false);
|
|
|
|
}
|
|
|
|
}
|
2012-07-04 19:21:48 +02:00
|
|
|
void MixerCurve::UpdateCurveUI()
|
2012-06-30 23:35:38 +02:00
|
|
|
{
|
|
|
|
//get the user settings
|
|
|
|
QString curveType = m_mixerUI->CurveType->currentText();
|
|
|
|
|
2012-07-14 07:41:58 +02:00
|
|
|
m_curve->activateCommand(curveType);
|
|
|
|
bool cmdsActive = m_curve->isCommandActive("Commands");
|
|
|
|
|
|
|
|
m_curve->showCommand("StepPlus", cmdsActive && curveType != "Linear");
|
|
|
|
m_curve->showCommand("StepMinus", cmdsActive && curveType != "Linear");
|
|
|
|
m_curve->showCommand("StepValue", cmdsActive && curveType != "Linear");
|
|
|
|
|
2012-07-05 21:58:00 +02:00
|
|
|
m_mixerUI->CurveStep->setMinimum(0.0);
|
2012-06-30 23:35:38 +02:00
|
|
|
m_mixerUI->CurveStep->setMaximum(100.0);
|
2012-07-12 06:49:05 +02:00
|
|
|
m_mixerUI->CurveStep->setSingleStep(1.00);
|
2012-06-30 23:35:38 +02:00
|
|
|
|
|
|
|
//set default visible
|
|
|
|
m_mixerUI->minLabel->setVisible(true);
|
|
|
|
m_mixerUI->CurveMin->setVisible(true);
|
|
|
|
m_mixerUI->maxLabel->setVisible(false);
|
|
|
|
m_mixerUI->CurveMax->setVisible(false);
|
|
|
|
m_mixerUI->stepLabel->setVisible(false);
|
|
|
|
m_mixerUI->CurveStep->setVisible(false);
|
|
|
|
|
|
|
|
if ( curveType.compare("Flat")==0)
|
|
|
|
{
|
2012-07-14 07:41:58 +02:00
|
|
|
m_mixerUI->minLabel->setVisible(false);
|
|
|
|
m_mixerUI->CurveMin->setVisible(false);
|
|
|
|
m_mixerUI->stepLabel->setVisible(true);
|
|
|
|
m_mixerUI->CurveStep->setVisible(true);
|
2012-07-12 06:49:05 +02:00
|
|
|
m_mixerUI->CurveStep->setMinimum(m_mixerUI->CurveMin->minimum());
|
|
|
|
m_mixerUI->CurveStep->setMaximum(m_mixerUI->CurveMax->maximum());
|
|
|
|
m_mixerUI->CurveStep->setSingleStep(0.01);
|
|
|
|
m_mixerUI->CurveStep->setValue(m_mixerUI->CurveMax->value() / 2);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
if ( curveType.compare("Linear")==0)
|
|
|
|
{
|
|
|
|
m_mixerUI->maxLabel->setVisible(true);
|
|
|
|
m_mixerUI->CurveMax->setVisible(true);
|
|
|
|
}
|
|
|
|
if ( curveType.compare("Step")==0)
|
|
|
|
{
|
|
|
|
m_mixerUI->maxLabel->setVisible(true);
|
|
|
|
m_mixerUI->CurveMax->setVisible(true);
|
|
|
|
m_mixerUI->stepLabel->setText("Step at");
|
|
|
|
m_mixerUI->stepLabel->setVisible(true);
|
2012-07-08 06:56:07 +02:00
|
|
|
m_mixerUI->CurveStep->setVisible(true);
|
|
|
|
|
|
|
|
m_mixerUI->CurveStep->setMinimum(1.0);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
if ( curveType.compare("Exp")==0)
|
|
|
|
{
|
|
|
|
m_mixerUI->maxLabel->setVisible(true);
|
|
|
|
m_mixerUI->CurveMax->setVisible(true);
|
2012-07-12 06:49:05 +02:00
|
|
|
m_mixerUI->stepLabel->setText("Power");
|
2012-06-30 23:35:38 +02:00
|
|
|
m_mixerUI->stepLabel->setVisible(true);
|
|
|
|
m_mixerUI->CurveStep->setVisible(true);
|
2012-07-05 21:58:00 +02:00
|
|
|
|
|
|
|
m_mixerUI->CurveStep->setMinimum(1.0);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
if ( curveType.compare("Log")==0)
|
|
|
|
{
|
|
|
|
m_mixerUI->maxLabel->setVisible(true);
|
|
|
|
m_mixerUI->CurveMax->setVisible(true);
|
2012-07-12 06:49:05 +02:00
|
|
|
m_mixerUI->stepLabel->setText("Power");
|
2012-06-30 23:35:38 +02:00
|
|
|
m_mixerUI->stepLabel->setVisible(true);
|
2012-07-05 21:58:00 +02:00
|
|
|
m_mixerUI->CurveStep->setVisible(true);
|
|
|
|
m_mixerUI->CurveStep->setMinimum(1.0);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
2012-07-01 00:27:42 +02:00
|
|
|
|
|
|
|
GenerateCurve();
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MixerCurve::GenerateCurve()
|
|
|
|
{
|
|
|
|
double scale;
|
|
|
|
double newValue;
|
|
|
|
|
|
|
|
//get the user settings
|
2012-07-01 00:27:42 +02:00
|
|
|
double value1 = getCurveMin();
|
|
|
|
double value2 = getCurveMax();
|
|
|
|
double value3 = getCurveStep();
|
2012-06-30 23:35:38 +02:00
|
|
|
|
2012-07-12 06:49:05 +02:00
|
|
|
m_curve->setCommandText("StepValue", QString("%0").arg(value3));
|
|
|
|
|
2012-06-30 23:35:38 +02:00
|
|
|
QString CurveType = m_mixerUI->CurveType->currentText();
|
|
|
|
|
|
|
|
QList<double> points;
|
|
|
|
|
|
|
|
for (int i=0; i<MixerCurveWidget::NODE_NUMELEM; i++)
|
|
|
|
{
|
|
|
|
scale =((double)i/(double)(MixerCurveWidget::NODE_NUMELEM - 1));
|
|
|
|
|
|
|
|
if ( CurveType.compare("Flat")==0)
|
|
|
|
{
|
2012-07-12 06:49:05 +02:00
|
|
|
points.append(value3);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
if ( CurveType.compare("Linear")==0)
|
|
|
|
{
|
|
|
|
newValue =value1 +(scale*(value2-value1));
|
|
|
|
points.append(newValue);
|
|
|
|
}
|
|
|
|
if ( CurveType.compare("Step")==0)
|
|
|
|
{
|
2012-07-08 19:38:15 +02:00
|
|
|
if (scale*100<value3)
|
2012-06-30 23:35:38 +02:00
|
|
|
{
|
|
|
|
points.append(value1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
points.append(value2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( CurveType.compare("Exp")==0)
|
|
|
|
{
|
|
|
|
newValue =value1 +(((exp(scale*(value3/10))-1))/(exp((value3/10))-1)*(value2-value1));
|
|
|
|
points.append(newValue);
|
|
|
|
}
|
|
|
|
if ( CurveType.compare("Log")==0)
|
|
|
|
{
|
|
|
|
newValue = value1 +(((log(scale*(value3*2)+1))/(log(1+(value3*2))))*(value2-value1));
|
|
|
|
points.append(newValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
setCurve(&points);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
/**
|
|
|
|
Wrappers for mixercurvewidget.
|
|
|
|
*/
|
2012-06-30 23:35:38 +02:00
|
|
|
void MixerCurve::initCurve (const QList<double>* points)
|
|
|
|
{
|
2012-07-01 00:27:42 +02:00
|
|
|
m_curve->setCurve(points);
|
2012-07-04 19:21:48 +02:00
|
|
|
UpdateSettingsTable();
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
QList<double> MixerCurve::getCurve()
|
|
|
|
{
|
|
|
|
return m_curve->getCurve();
|
|
|
|
}
|
|
|
|
void MixerCurve::initLinearCurve(int numPoints, double maxValue, double minValue)
|
|
|
|
{
|
2012-07-04 19:21:48 +02:00
|
|
|
setMin(minValue);
|
|
|
|
setMax(maxValue);
|
|
|
|
|
2012-06-30 23:35:38 +02:00
|
|
|
m_curve->initLinearCurve(numPoints, maxValue, minValue);
|
2012-07-06 22:38:46 +02:00
|
|
|
|
|
|
|
if (m_spinDelegate)
|
|
|
|
m_spinDelegate->setRange(minValue, maxValue);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
void MixerCurve::setCurve(const QList<double>* points)
|
|
|
|
{
|
|
|
|
m_curve->setCurve(points);
|
2012-07-04 19:21:48 +02:00
|
|
|
UpdateSettingsTable();
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
void MixerCurve::setMin(double value)
|
|
|
|
{
|
2012-07-06 22:38:46 +02:00
|
|
|
//m_curve->setMin(value);
|
2012-07-04 19:21:48 +02:00
|
|
|
m_mixerUI->CurveMin->setMinimum(value);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
double MixerCurve::getMin()
|
|
|
|
{
|
|
|
|
return m_curve->getMin();
|
|
|
|
}
|
|
|
|
void MixerCurve::setMax(double value)
|
|
|
|
{
|
2012-07-06 22:38:46 +02:00
|
|
|
//m_curve->setMax(value);
|
2012-07-04 19:21:48 +02:00
|
|
|
m_mixerUI->CurveMax->setMaximum(value);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
double MixerCurve::getMax()
|
|
|
|
{
|
|
|
|
return m_curve->getMax();
|
|
|
|
}
|
2012-07-04 19:21:48 +02:00
|
|
|
double MixerCurve::setRange(double min, double max)
|
|
|
|
{
|
|
|
|
return m_curve->setRange(min, max);
|
|
|
|
}
|
|
|
|
|
2012-06-30 23:35:38 +02:00
|
|
|
|
2012-07-01 00:27:42 +02:00
|
|
|
double MixerCurve::getCurveMin()
|
|
|
|
{
|
|
|
|
return m_mixerUI->CurveMin->value();
|
|
|
|
}
|
|
|
|
double MixerCurve::getCurveMax()
|
|
|
|
{
|
|
|
|
return m_mixerUI->CurveMax->value();
|
|
|
|
}
|
|
|
|
|
|
|
|
double MixerCurve::getCurveStep()
|
2012-06-30 23:35:38 +02:00
|
|
|
{
|
|
|
|
return m_mixerUI->CurveStep->value();
|
|
|
|
}
|
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
void MixerCurve::UpdateSettingsTable()
|
2012-06-30 23:35:38 +02:00
|
|
|
{
|
|
|
|
QList<double> points = m_curve->getCurve();
|
|
|
|
int ptCnt = points.count();
|
2012-07-04 19:21:48 +02:00
|
|
|
|
2012-06-30 23:35:38 +02:00
|
|
|
for (int i=0; i<ptCnt; i++)
|
|
|
|
{
|
2012-07-04 19:21:48 +02:00
|
|
|
QTableWidgetItem* item = m_settings->item(i, 0);
|
2012-06-30 23:35:38 +02:00
|
|
|
if (item)
|
2012-07-04 19:21:48 +02:00
|
|
|
item->setText(QString().sprintf("%.2f",points.at( (ptCnt - 1) - i )));
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
void MixerCurve::SettingsTableChanged()
|
2012-06-30 23:35:38 +02:00
|
|
|
{
|
2012-07-04 19:21:48 +02:00
|
|
|
QList<double> points;
|
2012-06-30 23:35:38 +02:00
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
for (int i=0; i < m_settings->rowCount(); i++)
|
|
|
|
{
|
|
|
|
QTableWidgetItem* item = m_settings->item(i, 0);
|
|
|
|
|
|
|
|
if (item)
|
|
|
|
points.push_front(item->text().toDouble());
|
|
|
|
}
|
|
|
|
|
2012-07-07 00:16:54 +02:00
|
|
|
m_mixerUI->CurveMin->setValue(points.first());
|
|
|
|
m_mixerUI->CurveMax->setValue(points.last());
|
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
m_curve->setCurve(&points);
|
|
|
|
}
|
|
|
|
|
2012-09-12 12:09:30 +02:00
|
|
|
void MixerCurve::CommandActivated(MixerNode* node)
|
2012-07-12 06:49:05 +02:00
|
|
|
{
|
|
|
|
QString name = (node) ? node->getName() : "Reset";
|
|
|
|
|
2012-07-13 22:44:56 +02:00
|
|
|
if (name == "Reset") {
|
2012-07-12 06:49:05 +02:00
|
|
|
ResetCurve();
|
2012-07-13 22:44:56 +02:00
|
|
|
m_curve->showCommands(false);
|
|
|
|
}
|
|
|
|
else if (name == "Commands") {
|
|
|
|
|
|
|
|
}
|
2012-07-14 16:25:57 +02:00
|
|
|
else if (name == "Popup" ) {
|
|
|
|
PopupCurve();
|
2012-07-12 06:49:05 +02:00
|
|
|
}
|
|
|
|
else if (name == "Linear") {
|
|
|
|
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Linear"));
|
|
|
|
}
|
|
|
|
else if (name == "Log") {
|
|
|
|
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Log"));
|
|
|
|
}
|
|
|
|
else if (name == "Exp") {
|
|
|
|
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Exp"));
|
|
|
|
}
|
|
|
|
else if (name == "Flat") {
|
|
|
|
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Flat"));
|
|
|
|
}
|
|
|
|
else if (name == "Step") {
|
|
|
|
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Step"));
|
|
|
|
}
|
|
|
|
else if (name == "MinPlus") {
|
|
|
|
m_mixerUI->CurveMin->stepUp();
|
|
|
|
}
|
|
|
|
else if (name == "MinMinus") {
|
|
|
|
m_mixerUI->CurveMin->stepDown();
|
|
|
|
}
|
|
|
|
else if (name == "MaxPlus") {
|
|
|
|
m_mixerUI->CurveMax->stepUp();
|
|
|
|
}
|
|
|
|
else if (name == "MaxMinus"){
|
|
|
|
m_mixerUI->CurveMax->stepDown();
|
|
|
|
}
|
|
|
|
else if (name == "StepPlus") {
|
|
|
|
m_mixerUI->CurveStep->stepUp();
|
|
|
|
m_curve->setCommandText("StepValue", QString("%0").arg(getCurveStep()));
|
|
|
|
}
|
|
|
|
else if (name == "StepMinus") {
|
|
|
|
m_mixerUI->CurveStep->stepDown();
|
|
|
|
m_curve->setCommandText("StepValue", QString("%0").arg(getCurveStep()));
|
|
|
|
}
|
|
|
|
|
|
|
|
GenerateCurve();
|
|
|
|
}
|
|
|
|
|
2012-07-04 19:21:48 +02:00
|
|
|
void MixerCurve::CurveTypeChanged()
|
|
|
|
{
|
|
|
|
// setup the ui for this curvetype
|
|
|
|
UpdateCurveUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MixerCurve::CurveMinChanged(double value)
|
|
|
|
{
|
|
|
|
QList<double> points = m_curve->getCurve();
|
2012-07-14 07:41:58 +02:00
|
|
|
points.removeFirst();
|
|
|
|
points.push_front(value);
|
2012-06-30 23:35:38 +02:00
|
|
|
setCurve(&points);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MixerCurve::CurveMaxChanged(double value)
|
|
|
|
{
|
|
|
|
// the max changed so redraw the curve
|
|
|
|
// mixercurvewidget::setCurve will trim any points above max
|
2012-07-04 19:21:48 +02:00
|
|
|
QList<double> points = m_curve->getCurve();
|
2012-07-01 00:27:42 +02:00
|
|
|
points.removeLast();
|
|
|
|
points.append(value);
|
2012-06-30 23:35:38 +02:00
|
|
|
setCurve(&points);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MixerCurve::showEvent(QShowEvent *event)
|
|
|
|
{
|
2012-07-02 19:46:21 +02:00
|
|
|
Q_UNUSED(event);
|
2012-06-30 23:35:38 +02:00
|
|
|
|
2012-07-06 00:31:36 +02:00
|
|
|
m_settings->resizeColumnsToContents();
|
|
|
|
m_settings->setColumnWidth(0,(m_settings->width()- m_settings->verticalHeader()->width()));
|
|
|
|
|
2012-07-07 00:02:34 +02:00
|
|
|
int h = (m_settings->height() - m_settings->horizontalHeader()->height()) / m_settings->rowCount();
|
|
|
|
for (int i=0; i<m_settings->rowCount(); i++)
|
|
|
|
m_settings->setRowHeight(i, h);
|
|
|
|
|
2012-07-02 19:46:21 +02:00
|
|
|
m_curve->showEvent(event);
|
2012-06-30 23:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MixerCurve::resizeEvent(QResizeEvent* event)
|
|
|
|
{
|
2012-07-06 00:31:36 +02:00
|
|
|
m_settings->resizeColumnsToContents();
|
2012-07-06 20:28:46 +02:00
|
|
|
m_settings->setColumnWidth(0,(m_settings->width() - m_settings->verticalHeader()->width()));
|
|
|
|
|
2012-07-07 00:02:34 +02:00
|
|
|
int h = (m_settings->height() - m_settings->horizontalHeader()->height()) / m_settings->rowCount();
|
|
|
|
for (int i=0; i<m_settings->rowCount(); i++)
|
|
|
|
m_settings->setRowHeight(i, h);
|
|
|
|
|
2012-07-02 19:46:21 +02:00
|
|
|
m_curve->resizeEvent(event);
|
2012-06-29 01:01:27 +02:00
|
|
|
}
|