|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Shinya Kitaoka |
810553 |
|
|
Shinya Kitaoka |
810553 |
#if !defined(TOONZ_PLUGIN_PARAM_TRAITS_H__)
|
|
Toshihiro Shimizu |
890ddd |
#define TOONZ_PLUGIN_PARAM_TRAITS_H__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <toonz_params.h></toonz_params.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <functional></functional>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename first,="" second="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct param_bind_t {
|
|
Shinya Kitaoka |
120a6e |
typedef First traittype;
|
|
Shinya Kitaoka |
120a6e |
typedef Second realtype;
|
|
Shinya Kitaoka |
120a6e |
typedef typename std::is_compound<typename first::valuetype="">::value_type</typename>
|
|
Shinya Kitaoka |
120a6e |
complextype;
|
|
Shinya Kitaoka |
120a6e |
typedef typename First::valuetype valuetype;
|
|
Shinya Kitaoka |
120a6e |
static const int RANGED = First::RANGED;
|
|
Shinya Kitaoka |
120a6e |
static const size_t valuesize = sizeof(typename First::valuetype);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_double_t, tdoubleparam=""> tpbind_dbl_t;</toonz_param_traits_double_t,>
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_range_t, trangeparam=""> tpbind_rng_t;</toonz_param_traits_range_t,>
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_color_t, tpixelparam=""> tpbind_col_t;</toonz_param_traits_color_t,>
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_point_t, tpointparam=""> tpbind_pnt_t;</toonz_param_traits_point_t,>
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_enum_t, tintenumparam=""> tpbind_enm_t;</toonz_param_traits_enum_t,>
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_int_t, tintparam=""> tpbind_int_t;</toonz_param_traits_int_t,>
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_bool_t, tboolparam=""> tpbind_bool_t;</toonz_param_traits_bool_t,>
|
|
Shinya Kitaoka |
120a6e |
typedef param_bind_t<toonz_param_traits_spectrum_t, tspectrumparam=""></toonz_param_traits_spectrum_t,>
|
|
Shinya Kitaoka |
120a6e |
tpbind_spc_t;
|
|
Toshihiro Shimizu |
890ddd |
typedef param_bind_t<toonz_param_traits_string_t, tstringparam=""> tpbind_str_t;</toonz_param_traits_string_t,>
|
|
Shinya Kitaoka |
120a6e |
typedef param_bind_t<toonz_param_traits_tonecurve_t, ttonecurveparam=""></toonz_param_traits_tonecurve_t,>
|
|
Shinya Kitaoka |
120a6e |
tpbind_tcv_t;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline bool is_type_of(const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
if (desc->traits_tag == T::E) return true;
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/* Complex なパラメータは直接 setRangeValue()
|
|
Shinya Kitaoka |
120a6e |
* などを持たず、集約しているサブタイプを返すものがあるので、そのサブタイプを得る関数を取得する
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
template <typename f="TDoubleParamP" rt,="" typename=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline F &get_func_a(RT *t) {
|
|
Shinya Kitaoka |
120a6e |
assert(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
template <typename f="TDoubleParamP" rt,="" typename=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline F &get_func_b(RT *t) {
|
|
Shinya Kitaoka |
120a6e |
assert(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* TRangeParam */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline TDoubleParamP &get_func_a<trangeparam, tdoubleparamp="">(TRangeParam *t) {</trangeparam,>
|
|
Shinya Kitaoka |
120a6e |
printf("get_func_a< TRangeParam, TDoubleParamP& >(TRangeParam* t)\n");
|
|
Shinya Kitaoka |
120a6e |
return std::mem_fun(&TRangeParam::getMin)(t);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
inline TDoubleParamP &get_func_b<trangeparam, tdoubleparamp="">(TRangeParam *t)</trangeparam,>
|
|
Shinya Kitaoka |
120a6e |
// template<> std::mem_fun_ref_t< TDoubleParamP&, TRangeParam > get_func_b<
|
|
Shinya Kitaoka |
120a6e |
// TRangeParam, std::mem_fun_ref_t< TDoubleParamP&, TRangeParam > >(TRangeParam*
|
|
Shinya Kitaoka |
120a6e |
// t)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
printf("get_func_b< TRangeParam, TDoubleParamP& >(TRangeParam* t)\n");
|
|
Shinya Kitaoka |
120a6e |
return std::mem_fun(&TRangeParam::getMax)(t);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* TPointParam */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
inline TDoubleParamP &get_func_a<tpointparam, tdoubleparamp="">(TPointParam *t)</tpointparam,>
|
|
Shinya Kitaoka |
120a6e |
// template<> std::mem_fun_ref_t< TDoubleParamP&, TPointParam > get_func_a<
|
|
Shinya Kitaoka |
120a6e |
// TPointParam, std::mem_fun_ref_t< TDoubleParamP&, TPointParam > >(TPointParam*
|
|
Shinya Kitaoka |
120a6e |
// t)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
printf("get_func_a< TPointParam, TDoubleParamP& >(TPointParam* t)\n");
|
|
Shinya Kitaoka |
120a6e |
return std::mem_fun(&TPointParam::getX)(t);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
inline TDoubleParamP &get_func_b<tpointparam, tdoubleparamp="">(TPointParam *t)</tpointparam,>
|
|
Shinya Kitaoka |
120a6e |
// template<> std::mem_fun_ref_t< TDoubleParamP&, TPointParam > get_func_b<
|
|
Shinya Kitaoka |
120a6e |
// TPointParam, std::mem_fun_ref_t< TDoubleParamP&, TPointParam > >(TPointParam*
|
|
Shinya Kitaoka |
120a6e |
// t)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
printf("get_func_b< TPointParam, TDoubleParamP& >(TPointParam* t)\n");
|
|
Shinya Kitaoka |
120a6e |
return std::mem_fun(&TPointParam::getY)(t);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* valuetype が集約型の場合、 スカラを取得するための関数 */
|
|
Toshihiro Shimizu |
890ddd |
template <typename t,="" typename="" v=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
inline V get_1st_value(const T &) {}
|
|
Toshihiro Shimizu |
890ddd |
template <typename t,="" typename="" v=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
inline V get_2nd_value(const T &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline double get_1st_value(const toonz_param_traits_range_t::valuetype &r) {
|
|
Shinya Kitaoka |
120a6e |
return r.a;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline double get_2nd_value(const toonz_param_traits_range_t::valuetype &r) {
|
|
Shinya Kitaoka |
120a6e |
return r.b;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline double get_1st_value(const toonz_param_traits_point_t::valuetype &p) {
|
|
Shinya Kitaoka |
120a6e |
return p.x;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline double get_2nd_value(const toonz_param_traits_point_t::valuetype &p) {
|
|
Shinya Kitaoka |
120a6e |
return p.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
template
|
|
Shinya Kitaoka |
120a6e |
typename Comp =
|
|
Shinya Kitaoka |
120a6e |
typename std::is_compound<typename bind::valuetype="">::type,</typename>
|
|
Shinya Kitaoka |
120a6e |
int Ranged = Bind::RANGED>
|
|
Shinya Kitaoka |
120a6e |
// template < int Ranged, typename Comp, typename Bind >
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_range_t {
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_range(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
/* 範囲を持たない(Ranged == std::false_type)なら何もすることはない */
|
|
Shinya Kitaoka |
120a6e |
printf("(none)set_param_range: p:%p type:%s (Comp:%s Ranged:%d)\n", param,
|
|
Shinya Kitaoka |
120a6e |
typeid(Bind).name(), typeid(Comp).name(), Ranged);
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// static_assert(std::is_compound< const char* >(), "false");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ranged complextype */
|
|
Toshihiro Shimizu |
890ddd |
template <typename bind=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_range_t<bind, 1="" std::true_type,=""> {</bind,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_range(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
typename Bind::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<typename *="" bind::realtype="">(smartptr.getPointer());</typename>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const typename Bind::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" bind::traittype="" typename="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
auto subtype_a = get_func_a<typename bind::realtype="">(p);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto subtype_b = get_func_b<typename bind::realtype="">(p);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto a_minval = get_1st_value<typename bind::valuetype,="" double="">(t.min);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto a_maxval = get_2nd_value<typename bind::valuetype,="" double="">(t.min);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto b_minval = get_1st_value<typename bind::valuetype,="" double="">(t.max);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto b_maxval = get_2nd_value<typename bind::valuetype,="" double="">(t.max);</typename>
|
|
Shinya Kitaoka |
120a6e |
printf("a->set_param_range: (%g, %g)\n", a_minval, a_maxval);
|
|
Shinya Kitaoka |
120a6e |
printf("b->set_param_range: (%g, %g)\n", b_minval, b_maxval);
|
|
Shinya Kitaoka |
120a6e |
(subtype_a)->setValueRange(a_minval, a_maxval);
|
|
Shinya Kitaoka |
120a6e |
(subtype_b)->setValueRange(b_minval, b_maxval);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/* range
|
|
Shinya Kitaoka |
120a6e |
のとき、スライダの左と右それぞれに限界が設定できるように見えるが、そうではない.
|
|
Toshihiro Shimizu |
890ddd |
getMin(), getMax() の結果それぞれに range を設定できるように見えて
|
|
Shinya Kitaoka |
120a6e |
実際は getMin() には (min, max) のうち min, getMax() には (min, max) のうち
|
|
Shinya Kitaoka |
120a6e |
max しか有効でないように見える.
|
|
Toshihiro Shimizu |
890ddd |
このため range に対しても特殊版を用意するハメになった. */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_range_t<tpbind_rng_t, 1="" std::true_type,=""> {</tpbind_rng_t,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_range(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
tpbind_rng_t::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<tpbind_rng_t::realtype *="">(smartptr.getPointer());</tpbind_rng_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const tpbind_rng_t::traittype &t = desc->traits.rd;
|
|
Shinya Kitaoka |
120a6e |
auto subtype_a = get_func_a<tpbind_rng_t::realtype>(p);</tpbind_rng_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
auto subtype_b = get_func_b<tpbind_rng_t::realtype>(p);</tpbind_rng_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
auto a_minval = get_1st_value<tpbind_rng_t::valuetype, double="">(t.minmax);</tpbind_rng_t::valuetype,>
|
|
Shinya Kitaoka |
120a6e |
auto a_maxval = get_2nd_value<tpbind_rng_t::valuetype, double="">(t.minmax);</tpbind_rng_t::valuetype,>
|
|
Shinya Kitaoka |
120a6e |
(subtype_a)->setValueRange(a_minval, a_maxval);
|
|
Shinya Kitaoka |
120a6e |
(subtype_b)->setValueRange(a_minval, a_maxval);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_range_t< tpbind_pnt_t, std::true_type, 1 > {
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_range(Param* param, const toonz_param_desc_t*
|
|
Shinya Kitaoka |
120a6e |
desc)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
tpbind_pnt_t::realtype* p = reinterpret_cast<
|
|
Shinya Kitaoka |
120a6e |
tpbind_pnt_t::realtype* >(smartptr.getPointer());
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const tpbind_pnt_t::traittype& t = *reinterpret_cast<
|
|
Shinya Kitaoka |
120a6e |
const tpbind_pnt_t::traittype* >(&desc->traits.d);
|
|
Shinya Kitaoka |
120a6e |
auto subtype_a = get_func_a< tpbind_pnt_t::realtype
|
|
Shinya Kitaoka |
120a6e |
>(p);
|
|
Shinya Kitaoka |
120a6e |
auto subtype_b = get_func_b< tpbind_pnt_t::realtype
|
|
Shinya Kitaoka |
120a6e |
>(p);
|
|
Shinya Kitaoka |
120a6e |
auto a_minval = get_1st_value< tpbind_pnt_t::valuetype,
|
|
Shinya Kitaoka |
120a6e |
double >(t.min);
|
|
Shinya Kitaoka |
120a6e |
auto a_maxval = get_2nd_value< tpbind_pnt_t::valuetype,
|
|
Shinya Kitaoka |
120a6e |
double >(t.min);
|
|
Shinya Kitaoka |
120a6e |
auto b_minval = get_1st_value< tpbind_pnt_t::valuetype,
|
|
Shinya Kitaoka |
120a6e |
double >(t.max);
|
|
Shinya Kitaoka |
120a6e |
auto b_maxval = get_2nd_value< tpbind_pnt_t::valuetype,
|
|
Shinya Kitaoka |
120a6e |
double >(t.max);
|
|
Shinya Kitaoka |
120a6e |
printf("a->set_param_range: pnt(%g, %g)\n", a_minval,
|
|
Shinya Kitaoka |
120a6e |
a_maxval);
|
|
Shinya Kitaoka |
120a6e |
printf("b->set_param_range: pnt(%g, %g)\n", b_minval,
|
|
Shinya Kitaoka |
120a6e |
b_maxval);
|
|
Shinya Kitaoka |
120a6e |
(subtype_a)->setValueRange(a_minval, a_maxval);
|
|
Shinya Kitaoka |
120a6e |
(subtype_b)->setValueRange(b_minval, b_maxval);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ranged primitive: */
|
|
Toshihiro Shimizu |
890ddd |
template <typename bind=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_range_t<bind, 1="" std::false_type,=""> {</bind,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_range(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
if (!is_type_of<typename bind::traittype="">(desc)) return false;</typename>
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
typename Bind::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<typename *="" bind::realtype="">(smartptr.getPointer());</typename>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const typename Bind::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" bind::traittype="" typename="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
printf("p(%p)->set_param_range: typeid:%s desc:%p (%p)\n", p,
|
|
Shinya Kitaoka |
120a6e |
typeid(typename Bind::traittype).name(), desc, &desc->traits.d);
|
|
Shinya Kitaoka |
120a6e |
p->setValueRange(t.min, t.max);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename bind=""></typename>
|
|
Shinya Kitaoka |
120a6e |
bool set_param_range(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
if (!is_type_of<typename bind::traittype="">(desc)) return false;</typename>
|
|
Shinya Kitaoka |
120a6e |
return set_param_range_t<bind>::set_param_range(param, desc);</bind>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
template
|
|
Shinya Kitaoka |
120a6e |
typename Comp =
|
|
Shinya Kitaoka |
120a6e |
typename std::is_compound<typename bind::valuetype="">::type></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t {
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Default complextype */
|
|
Toshihiro Shimizu |
890ddd |
/* Point/Range */
|
|
Toshihiro Shimizu |
890ddd |
template <typename bind=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<bind, std::true_type=""> {</bind,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
typename Bind::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<typename *="" bind::realtype="">(smartptr.getPointer());</typename>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const typename Bind::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" bind::traittype="" typename="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
auto subtype_a = get_func_a<typename bind::realtype="">(p);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto subtype_b = get_func_b<typename bind::realtype="">(p);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto a_defval = get_1st_value<typename bind::valuetype,="" double="">(t.def);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto b_defval = get_2nd_value<typename bind::valuetype,="" double="">(t.def);</typename>
|
|
Shinya Kitaoka |
120a6e |
printf("a->set_param_default: double (%g, %g)\n", a_defval, b_defval);
|
|
Shinya Kitaoka |
120a6e |
(subtype_a)->setDefaultValue(a_defval);
|
|
Shinya Kitaoka |
120a6e |
(subtype_b)->setDefaultValue(b_defval);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Default Color */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<tpbind_col_t, std::true_type=""> {</tpbind_col_t,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
tpbind_col_t::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<tpbind_col_t::realtype *="">(smartptr.getPointer());</tpbind_col_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const tpbind_col_t::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" tpbind_col_t::traittype="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(TPixel32(t.def.c0, t.def.c1, t.def.c2, t.def.m));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Default String */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<tpbind_str_t, std::true_type=""> {</tpbind_str_t,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
tpbind_str_t::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<tpbind_str_t::realtype *="">(smartptr.getPointer());</tpbind_str_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const tpbind_str_t::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" tpbind_str_t::traittype="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
printf("a->set_param_default: str\n");
|
|
Shinya Kitaoka |
120a6e |
std::wstring wstr = QString::fromStdString(t.def).toStdWString();
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(wstr);
|
|
Shinya Kitaoka |
120a6e |
p->setValue(wstr, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Default Spectrum */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<tpbind_spc_t, std::true_type=""> {</tpbind_spc_t,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
/* unfortunatly, TSpectrumParam's default values must be set within the
|
|
Shinya Kitaoka |
120a6e |
constructor, for now.
|
|
Shinya Kitaoka |
120a6e |
see param_factory_< TSpectrumParam >() */
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Default ToneCurve */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<tpbind_tcv_t, std::true_type=""> {</tpbind_tcv_t,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
tpbind_tcv_t::realtype* p = reinterpret_cast< tpbind_tcv_t::realtype*
|
|
Shinya Kitaoka |
120a6e |
>(smartptr.getPointer());
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const tpbind_tcv_t::traittype& t = *reinterpret_cast< const
|
|
Shinya Kitaoka |
120a6e |
tpbind_tcv_t::traittype* >(&desc->traits.d);
|
|
Shinya Kitaoka |
120a6e |
printf("a->set_param_default: spec\n");
|
|
Shinya Kitaoka |
120a6e |
QList< TPointD > pt;
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < t.cps; i ++) {
|
|
Shinya Kitaoka |
120a6e |
pt.push_back(TPointD(t.array[i].x, t.array[i].y));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(pt);
|
|
Shinya Kitaoka |
120a6e |
p->setIsLinear(!(t.intep));
|
|
Shinya Kitaoka |
120a6e |
}*/
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* primitive: TDoubleParam */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<tpbind_dbl_t, std::false_type=""> {</tpbind_dbl_t,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
tpbind_dbl_t::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<tpbind_dbl_t::realtype *="">(smartptr.getPointer());</tpbind_dbl_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const tpbind_dbl_t::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" tpbind_dbl_t::traittype="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
printf("p(%p)->set_param_default: typeid:%s desc:%p (%p)\n", p,
|
|
Shinya Kitaoka |
120a6e |
typeid(tpbind_dbl_t::traittype).name(), desc, &desc->traits.d);
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(t.def);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* primitive: TNotAnimatableParam */
|
|
Toshihiro Shimizu |
890ddd |
template <typename bind=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<bind, std::false_type=""> {</bind,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
typename Bind::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<typename *="" bind::realtype="">(smartptr.getPointer());</typename>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const typename Bind::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" bind::traittype="" typename="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
printf("p(%p)->set_param_default: typeid:%s desc:%p (%p)\n", p,
|
|
Shinya Kitaoka |
120a6e |
typeid(typename Bind::traittype).name(), desc, &desc->traits.d);
|
|
Shinya Kitaoka |
120a6e |
p->setDefaultValue(t.def);
|
|
Shinya Kitaoka |
120a6e |
p->setValue(t.def, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Default Enum */
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct set_param_default_t<tpbind_enm_t, std::false_type=""> {</tpbind_enm_t,>
|
|
Shinya Kitaoka |
120a6e |
static bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
auto smartptr = param->param();
|
|
Shinya Kitaoka |
120a6e |
tpbind_enm_t::realtype *p =
|
|
Shinya Kitaoka |
120a6e |
reinterpret_cast<tpbind_enm_t::realtype *="">(smartptr.getPointer());</tpbind_enm_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
if (p) {
|
|
Shinya Kitaoka |
120a6e |
const tpbind_enm_t::traittype &t =
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<const *="" tpbind_enm_t::traittype="">(&desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < t.enums; i++) {
|
|
Shinya Kitaoka |
120a6e |
p->addItem(i, t.array[i]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p->setValue(t.def, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename bind=""></typename>
|
|
Shinya Kitaoka |
120a6e |
bool set_param_default(Param *param, const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
if (!is_type_of<typename bind::traittype="">(desc)) return false;</typename>
|
|
Shinya Kitaoka |
120a6e |
return set_param_default_t<bind>::set_param_default(param, desc);</bind>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline T *param_factory_(const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
return new T;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline TPointParam *param_factory_(const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
return new TPointParam(TPointD(), true /* instanciate from plugin */);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline TSpectrumParam *param_factory_(const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_traits_spectrum_t &t = desc->traits.g;
|
|
Shinya Kitaoka |
120a6e |
if (t.points) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tspectrum::colorkey> keys(t.points);</tspectrum::colorkey>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < t.points; i++) {
|
|
Shinya Kitaoka |
120a6e |
keys[i].first = t.array[i].w;
|
|
Shinya Kitaoka |
120a6e |
keys[i].second = toPixel32(
|
|
Shinya Kitaoka |
120a6e |
TPixelD(t.array[i].c0, t.array[i].c1, t.array[i].c2, t.array[i].m));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return new TSpectrumParam(t.points, keys.data());
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
return new TSpectrumParam(); /* use default constructor: デフォルトでは
|
|
Shinya Kitaoka |
120a6e |
[black:white] の単純なものが設定される */
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TParam *parameter_factory(const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
switch (desc->traits_tag) {
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_DOUBLE:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tdoubleparam>(desc);</tdoubleparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_RANGE:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<trangeparam>(desc);</trangeparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_PIXEL:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tpixelparam>(desc);</tpixelparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_POINT:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tpointparam>(desc);</tpointparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_ENUM:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tintenumparam>(desc);</tintenumparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_INT:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tintparam>(desc);</tintparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_BOOL:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tboolparam>(desc);</tboolparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_SPECTRUM:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tspectrumparam>(desc);</tspectrumparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_STRING:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<tstringparam>(desc);</tstringparam>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_TONECURVE:
|
|
Shinya Kitaoka |
120a6e |
return param_factory_<ttonecurveparam>(desc);</ttonecurveparam>
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return NULL;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline int check_pollution_(const T &t) {
|
|
Shinya Kitaoka |
120a6e |
if (t.reserved_) return TOONZ_PARAM_ERROR_POLLUTED;
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline int check_traits_sanity_(const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
const T &t = reinterpret_cast<const &="" t="">(desc->traits.d);</const>
|
|
Shinya Kitaoka |
120a6e |
return check_pollution_<t>(t);</t>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline int check_traits_sanity_<toonz_param_traits_double_t>(</toonz_param_traits_double_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
int err = 0;
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_traits_double_t &t = desc->traits.d;
|
|
Shinya Kitaoka |
120a6e |
err |= check_pollution_(t);
|
|
Shinya Kitaoka |
120a6e |
if (t.min > t.max) err |= TOONZ_PARAM_ERROR_MIN_MAX;
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline int check_traits_sanity_<toonz_param_traits_range_t>(</toonz_param_traits_range_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
int err = 0;
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_traits_range_t &t = desc->traits.rd;
|
|
Shinya Kitaoka |
120a6e |
err |= check_pollution_(t);
|
|
Shinya Kitaoka |
120a6e |
if (t.minmax.a == 0 && t.minmax.b == 0)
|
|
Shinya Kitaoka |
120a6e |
return err; /* range に興味がない場合の 0,0 を許す */
|
|
Shinya Kitaoka |
120a6e |
if (t.minmax.a > t.minmax.b) err |= TOONZ_PARAM_ERROR_MIN_MAX;
|
|
Shinya Kitaoka |
120a6e |
return err;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline int check_traits_sanity_<toonz_param_traits_enum_t>(</toonz_param_traits_enum_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
int err = 0;
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_traits_enum_t &t = desc->traits.e;
|
|
Shinya Kitaoka |
120a6e |
err |= check_pollution_(t);
|
|
Shinya Kitaoka |
120a6e |
if (t.enums == 0) return err;
|
|
Shinya Kitaoka |
120a6e |
if (t.enums < 0) err |= TOONZ_PARAM_ERROR_ARRAY_NUM;
|
|
Shinya Kitaoka |
120a6e |
if (t.array == NULL) err |= TOONZ_PARAM_ERROR_ARRAY;
|
|
Shinya Kitaoka |
120a6e |
return err;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline int check_traits_sanity_<toonz_param_traits_spectrum_t>(</toonz_param_traits_spectrum_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
int err = 0;
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_traits_spectrum_t &t = desc->traits.g;
|
|
Shinya Kitaoka |
120a6e |
err |= check_pollution_(t);
|
|
Shinya Kitaoka |
120a6e |
if (t.points == 0) return err;
|
|
Shinya Kitaoka |
120a6e |
if (t.points < 0) err |= TOONZ_PARAM_ERROR_ARRAY_NUM;
|
|
Shinya Kitaoka |
120a6e |
if (t.array == NULL) err |= TOONZ_PARAM_ERROR_ARRAY;
|
|
Shinya Kitaoka |
120a6e |
return err;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Shinya Kitaoka |
120a6e |
template <> int check_traits_sanity_< toonz_param_traits_tonecurve_t >(const
|
|
Shinya Kitaoka |
120a6e |
toonz_param_desc_t* desc)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
int err = 0;
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_traits_tonecurve_t& t = desc->traits.tcv;
|
|
Shinya Kitaoka |
120a6e |
err |= check_pollution_(t);
|
|
Shinya Kitaoka |
120a6e |
if (t.points == 0)
|
|
Shinya Kitaoka |
120a6e |
return err;
|
|
Shinya Kitaoka |
120a6e |
if (t.points < 0)
|
|
Shinya Kitaoka |
120a6e |
err |= TOONZ_PARAM_ERROR_ARRAY_NUM;
|
|
Shinya Kitaoka |
120a6e |
if (t.array == NULL)
|
|
Shinya Kitaoka |
120a6e |
err |= TOONZ_PARAM_ERROR_ARRAY;
|
|
Shinya Kitaoka |
120a6e |
return err;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline int check_traits_sanity(const toonz_param_desc_t *desc) {
|
|
Shinya Kitaoka |
120a6e |
int err = 0;
|
|
Shinya Kitaoka |
120a6e |
switch (desc->traits_tag) {
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_DOUBLE:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_double_t>(desc);</toonz_param_traits_double_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_RANGE:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_range_t>(desc);</toonz_param_traits_range_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_PIXEL:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_color_t>(desc);</toonz_param_traits_color_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_POINT:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_point_t>(desc);</toonz_param_traits_point_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_ENUM:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_enum_t>(desc);</toonz_param_traits_enum_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_INT:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_int_t>(desc);</toonz_param_traits_int_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_BOOL:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_bool_t>(desc);</toonz_param_traits_bool_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_SPECTRUM:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_spectrum_t>(desc);</toonz_param_traits_spectrum_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_STRING:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_string_t>(desc);</toonz_param_traits_string_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_TONECURVE:
|
|
Shinya Kitaoka |
120a6e |
err = check_traits_sanity_<toonz_param_traits_tonecurve_t>(desc);</toonz_param_traits_tonecurve_t>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
err = TOONZ_PARAM_ERROR_TRAITS;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return err;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_type_check_(TParam *p, const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
size_t &vsz) {
|
|
Shinya Kitaoka |
120a6e |
if (typename T::realtype *d = dynamic_cast<typename *="" t::realtype="">(p)) {</typename>
|
|
Shinya Kitaoka |
120a6e |
if (is_type_of<typename t::traittype="">(desc)) {</typename>
|
|
Shinya Kitaoka |
120a6e |
vsz = sizeof(typename T::traittype::iovaluetype);
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline bool parameter_type_check(TParam *p, const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
size_t &vsz) {
|
|
Shinya Kitaoka |
120a6e |
switch (desc->traits_tag) {
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_DOUBLE:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_dbl_t>(p, desc, vsz);</tpbind_dbl_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_RANGE:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_rng_t>(p, desc, vsz);</tpbind_rng_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_PIXEL:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_col_t>(p, desc, vsz);</tpbind_col_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_POINT:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_pnt_t>(p, desc, vsz);</tpbind_pnt_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_ENUM:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_enm_t>(p, desc, vsz);</tpbind_enm_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_INT:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_int_t>(p, desc, vsz);</tpbind_int_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_BOOL:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_bool_t>(p, desc, vsz);</tpbind_bool_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_SPECTRUM:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_spc_t>(p, desc, vsz);</tpbind_spc_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_STRING:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_str_t>(p, desc, vsz);</tpbind_str_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_TONECURVE:
|
|
Shinya Kitaoka |
120a6e |
return param_type_check_<tpbind_tcv_t>(p, desc, vsz);</tpbind_tcv_t>
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_(TParam *p, const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame, size_t isize,
|
|
Shinya Kitaoka |
120a6e |
size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
/* isize は iovaluetype の size でなく count になったのでサイズチェックは無効
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
// if (isize == sizeof(typename T::traittype::iovaluetype)) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<typename *="" t::realtype="">(p);</typename>
|
|
Shinya Kitaoka |
120a6e |
auto v = r->getValue();
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<typename *="" t::traittype::iovaluetype="">(ptr) = v;</typename>
|
|
Shinya Kitaoka |
120a6e |
osize = 1;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
//}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_<tpbind_dbl_t>(TParam *p,</tpbind_dbl_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame,
|
|
Shinya Kitaoka |
120a6e |
size_t isize, size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
// if (isize == sizeof(tpbind_dbl_t::traittype::iovaluetype)) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<tpbind_dbl_t::realtype *="">(p);</tpbind_dbl_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
auto v = r->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
*reinterpret_cast<tpbind_dbl_t::traittype::iovaluetype *="">(ptr) = v;</tpbind_dbl_t::traittype::iovaluetype>
|
|
Shinya Kitaoka |
120a6e |
osize = 1;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
//}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_<tpbind_str_t>(TParam *p,</tpbind_str_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame,
|
|
Shinya Kitaoka |
120a6e |
size_t isize, size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<tpbind_str_t::realtype *="">(p);</tpbind_str_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
const std::string str = QString::fromStdWString(r->getValue()).toStdString();
|
|
Shinya Kitaoka |
120a6e |
std::size_t len = str.length() + 1;
|
|
Shinya Kitaoka |
120a6e |
/* get_type() の返す大きさも文字列長+1 を含んでいる */
|
|
Shinya Kitaoka |
120a6e |
if (isize < len)
|
|
Shinya Kitaoka |
38fd86 |
len = isize; /* 要求サイズが実際の長さより短くても良いが切り詰める(ただし 1
|
|
Shinya Kitaoka |
38fd86 |
以上であること) */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (len > 0) {
|
|
Shinya Kitaoka |
120a6e |
auto dst = reinterpret_cast<char *="">(ptr);</char>
|
|
Shinya Kitaoka |
120a6e |
strncpy(dst, str.c_str(), len - 1);
|
|
Shinya Kitaoka |
120a6e |
dst[len - 1] = '\0';
|
|
Shinya Kitaoka |
120a6e |
osize = len;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_<tpbind_rng_t>(TParam *p,</tpbind_rng_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame,
|
|
Shinya Kitaoka |
120a6e |
size_t isize, size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
// if (isize == sizeof(tpbind_rng_t::traittype::iovaluetype)) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<tpbind_rng_t::realtype *="">(p);</tpbind_rng_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
auto v = r->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
auto dst = reinterpret_cast<tpbind_rng_t::traittype::iovaluetype *="">(ptr);</tpbind_rng_t::traittype::iovaluetype>
|
|
Shinya Kitaoka |
120a6e |
dst->a = v.first;
|
|
Shinya Kitaoka |
120a6e |
dst->b = v.second;
|
|
Shinya Kitaoka |
120a6e |
osize = 1;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
//}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_<tpbind_col_t>(TParam *p,</tpbind_col_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame,
|
|
Shinya Kitaoka |
120a6e |
size_t isize, size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
// if (isize == sizeof(tpbind_col_t::traittype::iovaluetype)) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<tpbind_col_t::realtype *="">(p);</tpbind_col_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
/* getValueD() だと 16bit * 4 が返る */
|
|
Shinya Kitaoka |
120a6e |
// auto v = r->getValueD(frame);
|
|
Shinya Kitaoka |
120a6e |
auto v = r->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
auto dst = reinterpret_cast<tpbind_col_t::traittype::iovaluetype *="">(ptr);</tpbind_col_t::traittype::iovaluetype>
|
|
Shinya Kitaoka |
120a6e |
dst->c0 = v.r;
|
|
Shinya Kitaoka |
120a6e |
dst->c1 = v.g;
|
|
Shinya Kitaoka |
120a6e |
dst->c2 = v.b;
|
|
Shinya Kitaoka |
120a6e |
dst->m = v.m;
|
|
Shinya Kitaoka |
120a6e |
osize = 1;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
//}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_<tpbind_pnt_t>(TParam *p,</tpbind_pnt_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame,
|
|
Shinya Kitaoka |
120a6e |
size_t isize, size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
// if (isize == sizeof(tpbind_pnt_t::traittype::iovaluetype)) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<tpbind_pnt_t::realtype *="">(p);</tpbind_pnt_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
auto v = r->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
auto dst = reinterpret_cast<tpbind_pnt_t::traittype::iovaluetype *="">(ptr);</tpbind_pnt_t::traittype::iovaluetype>
|
|
Shinya Kitaoka |
120a6e |
dst->x = v.x;
|
|
Shinya Kitaoka |
120a6e |
dst->y = v.y;
|
|
Shinya Kitaoka |
120a6e |
osize = 1;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
//}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_<tpbind_spc_t>(TParam *p,</tpbind_spc_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame,
|
|
Shinya Kitaoka |
120a6e |
size_t isize, size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
// if (isize == sizeof(tpbind_spc_t::traittype::iovaluetype)) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<tpbind_spc_t::realtype *="">(p);</tpbind_spc_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
auto dst = reinterpret_cast<tpbind_spc_t::traittype::iovaluetype *="">(ptr);</tpbind_spc_t::traittype::iovaluetype>
|
|
Shinya Kitaoka |
120a6e |
/* getValue64() だと 1channle 16bit が返るがデフォルト型に合わせる */
|
|
Shinya Kitaoka |
120a6e |
auto v = r->getValue(frame).getValue(dst->w);
|
|
Shinya Kitaoka |
120a6e |
dst->c0 = v.r;
|
|
Shinya Kitaoka |
120a6e |
dst->c1 = v.g;
|
|
Shinya Kitaoka |
120a6e |
dst->c2 = v.b;
|
|
Shinya Kitaoka |
120a6e |
dst->m = v.m;
|
|
Shinya Kitaoka |
120a6e |
osize = 1;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
//}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
inline bool param_read_value_<tpbind_tcv_t>(TParam *p,</tpbind_tcv_t>
|
|
Shinya Kitaoka |
120a6e |
const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame,
|
|
Shinya Kitaoka |
120a6e |
size_t isize, size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
auto r = reinterpret_cast<tpbind_tcv_t::realtype *="">(p);</tpbind_tcv_t::realtype>
|
|
Shinya Kitaoka |
120a6e |
QList<tpointd> points = r->getValue(frame);</tpointd>
|
|
Shinya Kitaoka |
120a6e |
size_t ps = points.size();
|
|
Shinya Kitaoka |
120a6e |
/* コントロールポイントのリストしか戻って来ない! */
|
|
Shinya Kitaoka |
120a6e |
if (isize >= ps) {
|
|
Shinya Kitaoka |
120a6e |
int channel = r->getCurrentChannel();
|
|
Shinya Kitaoka |
120a6e |
int interp = !r->isLinear();
|
|
Shinya Kitaoka |
120a6e |
int c = isize < points.size() ? isize : points.size();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < c; i++) {
|
|
Shinya Kitaoka |
120a6e |
auto dst = reinterpret_cast<tpbind_tcv_t::traittype::iovaluetype *="">(ptr);</tpbind_tcv_t::traittype::iovaluetype>
|
|
Shinya Kitaoka |
120a6e |
dst[i].x = points[i].x;
|
|
Shinya Kitaoka |
120a6e |
dst[i].y = points[i].y;
|
|
Shinya Kitaoka |
120a6e |
dst[i].channel = channel;
|
|
Shinya Kitaoka |
120a6e |
dst[i].interp = interp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
osize = c;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool parameter_read_value(TParam *p, const toonz_param_desc_t *desc,
|
|
Shinya Kitaoka |
120a6e |
void *ptr, double frame, size_t isize,
|
|
Shinya Kitaoka |
120a6e |
size_t &osize) {
|
|
Shinya Kitaoka |
120a6e |
size_t sz = 0;
|
|
Shinya Kitaoka |
120a6e |
if (!parameter_type_check(p, desc, sz)) { // typecheck
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (desc->traits_tag) {
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_DOUBLE:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_dbl_t>(p, desc, ptr, frame, isize, osize);</tpbind_dbl_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_RANGE:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_rng_t>(p, desc, ptr, frame, isize, osize);</tpbind_rng_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_PIXEL:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_col_t>(p, desc, ptr, frame, isize, osize);</tpbind_col_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_POINT:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_pnt_t>(p, desc, ptr, frame, isize, osize);</tpbind_pnt_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_ENUM:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_enm_t>(p, desc, ptr, frame, isize, osize);</tpbind_enm_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_INT:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_int_t>(p, desc, ptr, frame, isize, osize);</tpbind_int_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_BOOL:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_bool_t>(p, desc, ptr, frame, isize, osize);</tpbind_bool_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_SPECTRUM:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_spc_t>(p, desc, ptr, frame, isize, osize);</tpbind_spc_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_STRING:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_str_t>(p, desc, ptr, frame, isize, osize);</tpbind_str_t>
|
|
Shinya Kitaoka |
120a6e |
case TOONZ_PARAM_TYPE_TONECURVE:
|
|
Shinya Kitaoka |
120a6e |
return param_read_value_<tpbind_tcv_t>(p, desc, ptr, frame, isize, osize);</tpbind_tcv_t>
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|