C++ (Qt)value<coord> pos; // общие ключи t (время) на 3 компоненты...value<float> x, y, z; // свои ключи у каждой компоненты
C++ (Qt) switch(interpolationType) { case QMetaType::Int: return castToInterpolator(_q_interpolateVariant<int>); case QMetaType::UInt: return castToInterpolator(_q_interpolateVariant<uint>); case QMetaType::Double: return castToInterpolator(_q_interpolateVariant<double>); case QMetaType::Float: return castToInterpolator(_q_interpolateVariant<float>); case QMetaType::QLine: return castToInterpolator(_q_interpolateVariant<QLine>); case QMetaType::QLineF: return castToInterpolator(_q_interpolateVariant<QLineF>); case QMetaType::QPoint: return castToInterpolator(_q_interpolateVariant<QPoint>); case QMetaType::QPointF: return castToInterpolator(_q_interpolateVariant<QPointF>); case QMetaType::QSize: return castToInterpolator(_q_interpolateVariant<QSize>); case QMetaType::QSizeF: return castToInterpolator(_q_interpolateVariant<QSizeF>); case QMetaType::QRect: return castToInterpolator(_q_interpolateVariant<QRect>); case QMetaType::QRectF: return castToInterpolator(_q_interpolateVariant<QRectF>); default: return 0; //this type is not handled }
ColorInerpolator : public AbstractInterpolator{ ColorInerpolator(CurveType t, Color c1, ...) {} // опорные параметры, тип кривой ColorInerpolator(std::vector<Color> &colors) {} // тупо массив точек Variant getValue(TimeType t) override {...} // например return this->m_colors[t];}
void interpolateAll(TimeType t){ std::map<Key, Variant> properies; for (auto key: requiredKeys) { auto interpolator = getInterpolatorForKey(key); properies.insert({key, interpolator->getValue(t)}); }}
C++ (Qt)struct CData { enum Type { type_Value, type_Coord, type_Color }; Type m_type; union { double m_value; double m_coord[3]; float m_color[4]; };};
struct CData { enum Type { type_Value, type_Coord, type_Color }; Type m_type; union { double m_value; double m_coord[3]; float m_color[4]; }; Some operator[](const int &i) { switch (i) { case 1: return Some{&this->m_value, i, sizeof (m_value)}; case 2: return Some{&this->m_coord, i, sizeof (m_coord)}; case 3: return Some{&this->m_color, i, sizeof (m_color)}; } return Some{}; }};struct Some{ void* ptr; int type; int size; Some operator=(const Some& other) { if( this->type != other.type ) qWarning()<<"!!!"; memcpy(this->ptr, other.ptr, this->size); return *this; }};
value = point0 * k0(t) + ctl0 * k1(t) + ctl1 * k2(t) + point1 * k3(t);