|
Toshihiro Shimizu |
890ddd |
#include "plugin_param_interface.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "plugin_utilities.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "../include/ttonecurveparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "../include/toonzqt/fxsettings.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "plugin_param_traits.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* 公開インターフェイスからは削除 */
|
|
Toshihiro Shimizu |
890ddd |
enum toonz_param_value_type_enum {
|
|
Shinya Kitaoka |
120a6e |
/* deprecated */
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_VALUE_TYPE_CHAR = 1,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_VALUE_TYPE_INT = 4,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_VALUE_TYPE_DOUBLE = 8,
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_VALUE_TYPE_NB,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_VALUE_TYPE_MAX = 0x7FFFFFFF
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum toonz_value_unit_enum {
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_NONE,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_LENGTH,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_ANGLE,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_SCALE,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_PERCENTAGE,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_PERCENTAGE2,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_SHEAR,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_COLOR_CHANNEL,
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_NB,
|
|
Shinya Kitaoka |
120a6e |
TOONZ_PARAM_UNIT_MAX = 0x7FFFFFFF
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static int set_value_unit(TDoubleParamP param, toonz_value_unit_enum unit);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int hint_default_value(toonz_param_handle_t param, int size_in_bytes,
|
|
Shinya Kitaoka |
120a6e |
const void *default_value) {
|
|
Shinya Kitaoka |
120a6e |
if (Param *_ = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = _->param();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TDoubleParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(values[0]);
|
|
Shinya Kitaoka |
120a6e |
} else if (TRangeParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double) * 2) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(std::make_pair(values[0], values[1]));
|
|
Shinya Kitaoka |
120a6e |
} else if (TPixelParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double) * 4) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(
|
|
Shinya Kitaoka |
120a6e |
toPixel32(TPixelD(values[0], values[1], values[2], values[3])));
|
|
Shinya Kitaoka |
120a6e |
} else if (TPointParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double) * 2) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(TPointD(values[0], values[1]));
|
|
Shinya Kitaoka |
120a6e |
} else if (TIntEnumParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(int)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const int *values = reinterpret_cast<const *="" int="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(values[0]);
|
|
Shinya Kitaoka |
120a6e |
} else if (TIntParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(int)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const int *values = reinterpret_cast<const *="" int="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(values[0]);
|
|
Shinya Kitaoka |
120a6e |
} else if (TBoolParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(int)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const int *values = reinterpret_cast<const *="" int="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(values[0]);
|
|
Shinya Kitaoka |
120a6e |
} else if (TSpectrumParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
const int count = size_in_bytes / (sizeof(double) * 5);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tspectrum::colorkey> keys(count);</tspectrum::colorkey>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < count; i++) {
|
|
Shinya Kitaoka |
120a6e |
keys[i].first = values[5 * i + 0];
|
|
Shinya Kitaoka |
120a6e |
keys[i].second =
|
|
Shinya Kitaoka |
120a6e |
toPixel32(TPixelD(values[5 * i + 1], values[5 * i + 2],
|
|
Shinya Kitaoka |
120a6e |
values[5 * i + 3], values[5 * i + 4]));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(TSpectrum(count, keys.data()));
|
|
Shinya Kitaoka |
120a6e |
} else if (TStringParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes < 1) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const char *values = reinterpret_cast<const *="" char="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(QString::fromStdString(values).toStdWString());
|
|
Shinya Kitaoka |
120a6e |
} else if (TToneCurveParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(default_value);</const>
|
|
Shinya Kitaoka |
120a6e |
const int count = size_in_bytes / (sizeof(double) * 2);
|
|
Shinya Kitaoka |
120a6e |
QList<tpointd> list;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < count; ++i) {
|
|
Shinya Kitaoka |
120a6e |
list.push_back(TPointD(values[2 * i + 0], values[2 * i + 1]));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(list);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int hint_value_range(toonz_param_handle_t param, const void *minvalue,
|
|
Shinya Kitaoka |
120a6e |
const void *maxvalue) {
|
|
Shinya Kitaoka |
120a6e |
if (Param *_ = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = _->param();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TDoubleParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
p->setValueRange(*reinterpret_cast<const *="" double="">(minvalue),</const>
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" double="">(maxvalue));</const>
|
|
Shinya Kitaoka |
120a6e |
} else if (TRangeParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
const double minv = *reinterpret_cast<const *="" double="">(minvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
const double maxv = *reinterpret_cast<const *="" double="">(maxvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
p->getMin()->setValueRange(minv, maxv);
|
|
Shinya Kitaoka |
120a6e |
p->getMax()->setValueRange(minv, maxv);
|
|
Shinya Kitaoka |
120a6e |
} else if (TPointParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
const double minv = *reinterpret_cast<const *="" double="">(minvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
const double maxv = *reinterpret_cast<const *="" double="">(maxvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
p->getX()->setValueRange(minv, maxv);
|
|
Shinya Kitaoka |
120a6e |
p->getY()->setValueRange(minv, maxv);
|
|
Shinya Kitaoka |
120a6e |
} else if (TIntParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
p->setValueRange(*reinterpret_cast<const *="" int="">(minvalue),</const>
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" int="">(maxvalue));</const>
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int hint_unit(toonz_param_handle_t param, int unit) {
|
|
Shinya Kitaoka |
120a6e |
if (Param *_ = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = _->param();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TDoubleParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
return set_value_unit(p, toonz_value_unit_enum(unit));
|
|
Shinya Kitaoka |
120a6e |
} else if (TRangeParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (const int retval =
|
|
Shinya Kitaoka |
120a6e |
set_value_unit(p->getMin(), toonz_value_unit_enum(unit))) {
|
|
Shinya Kitaoka |
120a6e |
return retval;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return set_value_unit(p->getMax(), toonz_value_unit_enum(unit));
|
|
Shinya Kitaoka |
120a6e |
} else if (TPointParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (const int retval =
|
|
Shinya Kitaoka |
120a6e |
set_value_unit(p->getX(), toonz_value_unit_enum(unit))) {
|
|
Shinya Kitaoka |
120a6e |
return retval;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return set_value_unit(p->getY(), toonz_value_unit_enum(unit));
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int hint_item(toonz_param_handle_t param, int item, const char *caption) {
|
|
Shinya Kitaoka |
120a6e |
if (Param *_ = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = _->param();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TIntEnumParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
p->addItem(item, caption);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int set_description(toonz_param_handle_t param, const char *description) {
|
|
Shinya Kitaoka |
120a6e |
if (Param *_ = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = _->param();
|
|
Shinya Kitaoka |
120a6e |
param->setDescription(description);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static int set_value_unit(TDoubleParamP param, toonz_value_unit_enum unit) {
|
|
Shinya Kitaoka |
120a6e |
switch (unit) {
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_NONE:
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_LENGTH:
|
|
Shinya Kitaoka |
120a6e |
param->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_ANGLE:
|
|
Shinya Kitaoka |
120a6e |
param->setMeasureName("angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_SCALE:
|
|
Shinya Kitaoka |
120a6e |
param->setMeasureName("scale");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_PERCENTAGE:
|
|
Shinya Kitaoka |
120a6e |
param->setMeasureName("percentage");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_PERCENTAGE2:
|
|
Shinya Kitaoka |
120a6e |
param->setMeasureName("percentage2");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_SHEAR:
|
|
Shinya Kitaoka |
120a6e |
param->setMeasureName("shear");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_UNIT_COLOR_CHANNEL:
|
|
Shinya Kitaoka |
120a6e |
param->setMeasureName("colorChannel");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
printf("invalid param unit");
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_VALUE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int get_value_type(toonz_param_handle_t param, int *pvalue_type) {
|
|
Shinya Kitaoka |
120a6e |
if (!pvalue_type) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (Param *_ = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = _->param();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TDoubleParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_DOUBLE;
|
|
Shinya Kitaoka |
120a6e |
} else if (TRangeParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_DOUBLE;
|
|
Shinya Kitaoka |
120a6e |
} else if (TPixelParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_DOUBLE;
|
|
Shinya Kitaoka |
120a6e |
} else if (TPointParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_DOUBLE;
|
|
Shinya Kitaoka |
120a6e |
} else if (TIntEnumParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_INT;
|
|
Shinya Kitaoka |
120a6e |
} else if (TIntParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_INT;
|
|
Shinya Kitaoka |
120a6e |
} else if (TBoolParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_INT;
|
|
Shinya Kitaoka |
120a6e |
} else if (TSpectrumParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_DOUBLE;
|
|
Shinya Kitaoka |
120a6e |
} else if (TStringParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_CHAR;
|
|
Shinya Kitaoka |
120a6e |
} else if (TToneCurveParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
*pvalue_type = TOONZ_PARAM_VALUE_TYPE_DOUBLE;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int get_type(toonz_param_handle_t param, double frame, int *ptype,
|
|
Shinya Kitaoka |
120a6e |
int *pcount) {
|
|
Shinya Kitaoka |
120a6e |
/* size はほとんどの型で自明なので返さなくてもいいよね? */
|
|
Shinya Kitaoka |
120a6e |
if (!ptype || !pcount) return TOONZ_ERROR_NULL;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (Param *p = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
toonz_param_type_enum e = toonz_param_type_enum(p->desc()->traits_tag);
|
|
Shinya Kitaoka |
120a6e |
if (e >= TOONZ_PARAM_TYPE_NB) return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
size_t v;
|
|
Shinya Kitaoka |
120a6e |
if (parameter_type_check(p->param().getPointer(), p->desc(), v)) {
|
|
Shinya Kitaoka |
120a6e |
*ptype = p->desc()->traits_tag;
|
|
Shinya Kitaoka |
120a6e |
if (e == TOONZ_PARAM_TYPE_STRING) {
|
|
Shinya Kitaoka |
120a6e |
TStringParam *r =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<tstringparam *="">(p->param().getPointer());</tstringparam>
|
|
Shinya Kitaoka |
120a6e |
const std::string str =
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(r->getValue()).toStdString();
|
|
Shinya Kitaoka |
120a6e |
*pcount = str.length() + 1;
|
|
Shinya Kitaoka |
120a6e |
} else if (e == TOONZ_PARAM_TYPE_TONECURVE) {
|
|
Shinya Kitaoka |
120a6e |
TToneCurveParam *r =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<ttonecurveparam *="">(p->param().getPointer());</ttonecurveparam>
|
|
Shinya Kitaoka |
120a6e |
auto lst = r->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
*pcount = lst.size();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
*pcount = 1; // static_cast< int >(v);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int get_value(toonz_param_handle_t param, double frame, int *psize_in_bytes,
|
|
Shinya Kitaoka |
120a6e |
void *pvalue) {
|
|
Shinya Kitaoka |
120a6e |
if (!psize_in_bytes) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!pvalue) {
|
|
Shinya Kitaoka |
120a6e |
int type = 0;
|
|
Shinya Kitaoka |
120a6e |
return get_type(param, frame, &type, psize_in_bytes);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (Param *p = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
toonz_param_type_enum e = toonz_param_type_enum(p->desc()->traits_tag);
|
|
Shinya Kitaoka |
120a6e |
if (e >= TOONZ_PARAM_TYPE_NB) return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
size_t v;
|
|
Shinya Kitaoka |
120a6e |
int icounts = *psize_in_bytes;
|
|
Shinya Kitaoka |
120a6e |
if (parameter_read_value(p->param().getPointer(), p->desc(), pvalue, frame,
|
|
Shinya Kitaoka |
120a6e |
icounts, v)) {
|
|
Shinya Kitaoka |
120a6e |
*psize_in_bytes = v;
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int get_string_value(toonz_param_handle_t param, int *wholesize, int rcvbufsize,
|
|
Shinya Kitaoka |
120a6e |
char *pvalue) {
|
|
Shinya Kitaoka |
120a6e |
if (!pvalue) return TOONZ_ERROR_NULL;
|
|
Shinya Kitaoka |
120a6e |
if (Param *p = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc = p->desc();
|
|
Shinya Kitaoka |
120a6e |
toonz_param_type_enum e = toonz_param_type_enum(desc->traits_tag);
|
|
Shinya Kitaoka |
120a6e |
size_t vsz;
|
|
Shinya Kitaoka |
120a6e |
TParam *pp = p->param().getPointer();
|
|
Shinya Kitaoka |
120a6e |
if (param_type_check_<tpbind_str_t>(pp, desc, vsz)) {</tpbind_str_t>
|
|
Shinya Kitaoka |
120a6e |
size_t isize = rcvbufsize;
|
|
Shinya Kitaoka |
120a6e |
size_t osize = 0;
|
|
Shinya Kitaoka |
120a6e |
if (param_read_value_<tpbind_str_t>(pp, desc, pvalue, 0, isize, osize)) {</tpbind_str_t>
|
|
Shinya Kitaoka |
120a6e |
if (wholesize) *wholesize = static_cast<int>(osize);</int>
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int get_spectrum_value(toonz_param_handle_t param, double frame, double x,
|
|
Shinya Kitaoka |
120a6e |
toonz_param_spectrum_t *pvalue) {
|
|
Shinya Kitaoka |
120a6e |
if (!pvalue) return TOONZ_ERROR_NULL;
|
|
Shinya Kitaoka |
120a6e |
if (Param *p = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc = p->desc();
|
|
Shinya Kitaoka |
120a6e |
toonz_param_type_enum e = toonz_param_type_enum(desc->traits_tag);
|
|
Shinya Kitaoka |
120a6e |
size_t vsz;
|
|
Shinya Kitaoka |
120a6e |
TParam *pp = p->param().getPointer();
|
|
Shinya Kitaoka |
120a6e |
if (param_type_check_<tpbind_spc_t>(pp, desc, vsz)) {</tpbind_spc_t>
|
|
Shinya Kitaoka |
120a6e |
size_t isize = 1;
|
|
Shinya Kitaoka |
120a6e |
size_t osize = 0;
|
|
Shinya Kitaoka |
120a6e |
pvalue->w = x;
|
|
Shinya Kitaoka |
120a6e |
if (param_read_value_<tpbind_spc_t>(pp, desc, pvalue, frame, isize,</tpbind_spc_t>
|
|
Shinya Kitaoka |
120a6e |
osize)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int set_value(toonz_param_handle_t param, double frame, int size_in_bytes,
|
|
Shinya Kitaoka |
120a6e |
const void *pvalue) {
|
|
Shinya Kitaoka |
120a6e |
if (Param *_ = reinterpret_cast<param *="">(param)) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = _->param();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TDoubleParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setValue(frame, *reinterpret_cast<const *="" double="">(pvalue));</const>
|
|
Shinya Kitaoka |
120a6e |
} else if (TRangeParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double) * 2) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const double *const pvalues = reinterpret_cast<const *="" double="">(pvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setValue(frame, std::make_pair(pvalues[0], pvalues[1]));
|
|
Shinya Kitaoka |
120a6e |
} else if (TPixelParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double) * 4) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const double *const pvalues = reinterpret_cast<const *="" double="">(pvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setValueD(frame,
|
|
Shinya Kitaoka |
120a6e |
TPixelD(pvalues[0], pvalues[1], pvalues[2], pvalues[3]));
|
|
Shinya Kitaoka |
120a6e |
} else if (TPointParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(double) * 2) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const double *const pvalues = reinterpret_cast<const *="" double="">(pvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setValue(frame, TPointD(pvalues[0], pvalues[1]));
|
|
Shinya Kitaoka |
120a6e |
} else if (TIntEnumParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(int)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setValue(*reinterpret_cast<const *="" int="">(pvalue));</const>
|
|
Shinya Kitaoka |
120a6e |
} else if (TIntParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(int)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setValue(*reinterpret_cast<const *="" int="">(pvalue));</const>
|
|
Shinya Kitaoka |
120a6e |
} else if (TBoolParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes != sizeof(int)) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setValue(*reinterpret_cast<const *="" int="">(pvalue) != 0);</const>
|
|
Shinya Kitaoka |
120a6e |
} else if (TSpectrumParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(pvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
const int count = size_in_bytes / (sizeof(double) * 5);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tspectrum::colorkey> keys(count);</tspectrum::colorkey>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < count; i++) {
|
|
Shinya Kitaoka |
120a6e |
keys[i].first = values[5 * i + 0];
|
|
Shinya Kitaoka |
120a6e |
keys[i].second =
|
|
Shinya Kitaoka |
120a6e |
toPixel32(TPixelD(values[5 * i + 1], values[5 * i + 2],
|
|
Shinya Kitaoka |
120a6e |
values[5 * i + 3], values[5 * i + 4]));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setValue(frame, TSpectrum(count, keys.data()));
|
|
Shinya Kitaoka |
120a6e |
} else if (TStringParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
if (size_in_bytes < 1) {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_SIZE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const char *values = reinterpret_cast<const *="" char="">(pvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setValue(QString::fromStdString(values).toStdWString());
|
|
Shinya Kitaoka |
120a6e |
} else if (TToneCurveParamP p = param) {
|
|
Shinya Kitaoka |
120a6e |
const double *values = reinterpret_cast<const *="" double="">(pvalue);</const>
|
|
Shinya Kitaoka |
120a6e |
const int count = size_in_bytes / (sizeof(double) * 2);
|
|
Shinya Kitaoka |
120a6e |
QList<tpointd> list;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < count; ++i) {
|
|
Shinya Kitaoka |
120a6e |
list.push_back(TPointD(values[2 * i + 0], values[2 * i + 1]));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setValue(frame, list);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_NOT_IMPLEMENTED;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_ERROR_INVALID_HANDLE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return TOONZ_OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|