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