Fix curves param losing params on copy/paste, don't allow more than 5 points...

Fix curves param losing params on copy/paste, don't allow more than 5 points in curve (effect doesn't support more)
Fixes #588
parent dd6f3078
......@@ -209,14 +209,21 @@ void AssetParameterModel::internalSetParameter(const QString &name, const QStrin
QStringList vals = paramValue.split(QLatin1Char(';'), QString::SkipEmptyParts);
int points = vals.size();
m_asset->set("3", points / 10.);
m_params[QStringLiteral("3")].value = points / 10.;
// for the curve, inpoints are numbered: 6, 8, 10, 12, 14
// outpoints, 7, 9, 11, 13,15 so we need to deduce these enums
for (int i = 0; i < points; i++) {
const QString &pointVal = vals.at(i);
int idx = 2 * i + 6;
m_asset->set(QString::number(idx).toLatin1().constData(), pointVal.section(QLatin1Char('/'), 0, 0).toDouble());
QString pName = QString::number(idx);
double val = pointVal.section(QLatin1Char('/'), 0, 0).toDouble();
m_asset->set(pName.toLatin1().constData(), val);
m_params[pName].value = val;
idx++;
m_asset->set(QString::number(idx).toLatin1().constData(), pointVal.section(QLatin1Char('/'), 1, 1).toDouble());
pName = QString::number(idx);
val = pointVal.section(QLatin1Char('/'), 1, 1).toDouble();
m_asset->set(pName.toLatin1().constData(), val);
m_params[pName].value = val;
}
}
bool conversionSuccess;
......
......@@ -60,6 +60,7 @@ KisCurveWidget::KisCurveWidget(QWidget *parent)
m_pixmapCache = nullptr;
m_maxPoints = 0;
m_curve = KisCubicCurve();
setMaxPoints(5);
update();
}
......@@ -134,6 +135,7 @@ void KisCurveWidget::mousePressEvent(QMouseEvent *e)
if (e->button() == Qt::RightButton && closest_point_index > 0 && closest_point_index < m_curve.points().count() - 1) {
m_currentPointIndex = closest_point_index;
slotDeleteCurrentPoint();
return;
} else if (e->button() != Qt::LeftButton) {
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment