C++ (Qt)struct Key { double time; Vector vec; int splineOption1; ... double splineOptionN; };
C++ (Qt)template <class Key, class Data, class Option>struct CurvePoint{ Key key; Data data; Option option;}; enum class SplineType{ Type_1, Type_2; ...}; template <class Point, SplineType _SplineType>struct Curve{ vector<Point> points;};
C++ (Qt)template <class Key, class Data, class Option>struct CurvePoint{ Key key; Data data; Option option;};
struct Options { int arg1, arg2;};struct Color{char r,g,b,a;};struct Vector3{float x,y,z;};class UnionData {public: enum DataType { NO,DOUBLE, COLOR, VECTOR3 };private: enum TYPE_SPLINE{T1, T2} typeSpline; Options options; DataType dataType = NO;public: union {double d; Color c; Vector3 v3;}; bool isDataType(DataType dataType) {return dataType == this->dataType;} UnionData() { dataType = NO; } UnionData(double d){ dataType = DOUBLE; this->d = d;} UnionData(Color c){ dataType = COLOR; this->c = c;} UnionData(Vector3 v3){ dataType = VECTOR3; this->v3 = v3;}};class Spline { QMap<double /*time*/, UnionData> map; void getData(double time, double *data){if(map[time].isDataType(UnionData::DOUBLE)) *data = map[time].d;} void getData(double time, Color *data){if(map[time].isDataType(UnionData::COLOR)) *data = map[time].c;} void getData(double time, Vector3 *data){if(map[time].isDataType(UnionData::VECTOR3)) *data = map[time].v3;}public: template <typename T> void set(double time, T data) { map[time] = UnionData(data); } template<typename T> T get(double time) {T data; getData(time, &data); return data; }};
double inRatioVector; // Incoming Vectordouble outRatioVector; // Outgoing Vector
C++ (Qt)using QuadraticBezierPoint = CurvePoint<DateTimeKey, Vector3D, QuadraticBezierOption>;using CubicBezierPoint = CurvePoint<DateTimeKey, Vector3D, CubicBezierOption>;using OneMorePoint = CurvePoint<DateTimeKey, Vector3D, OneMoreOption>; using QuadraticBezierCurve = Curve<QuadraticBezierPoint, SplineType::QuadraticBezier>using CubicBezierCurve = Curve<CubicBezierPoint, SplineType::CubicBezier>using OneMoreCurve = Curve<OneMorePoint, SplineType::OneMoreCurve>
C++ (Qt)void Curve::SetSplineType( SplineType type );
C++ (Qt)int GetIntValue( const QWidget * widget );
C++ (Qt)double Curve::GetDoubleValue( double time ) const;
C++ (Qt)template <class Data, class Key>struct Curve : AbstractCurve { map<Key, Data> data;}
C++ (Qt)void doSomething( AbstractCurve * curve ){ if (dynamic_cast<Curve<double, DateTime>*>(curve)) { ... } else if (dynamic_cast<Curve<Vector3D, DateTime>*>(curve)) { ... } else if (dynamic_cast<Curve<Color, DateTime>*>(curve)) { ... }}
C++ (Qt)struct CurveDouble {.. void AddKey ( double time, double value ); // добавить контрольную точку void DelNthKey ( int keyIndex ); // удалить контрольную точку double GetNthKeyTime( int keyIndex ) const; // получить время double SetNthKeyValue( int keyIndex, double value ) const; // получить значение void SetNthKeyTime( int keyIndex, double time ); // установить время void SetNthKeyValue( int keyIndex, double value ); // установить значение double GetInterpolatedValue( double time ) const; // получить интерполированное значение const SplineOptions & GetNthSplineOptions( int keyIndex ) const; // получить параметры сплайна void SetNthSplineOptions( int keyIndex, const SplineOptions & opt ) const; // установить параметры сплайна...};
C++ (Qt)Curve<double>Curve<Vector>Curve<Color>
C++ (Qt)QImage<format_ARGB32> QImage<format_GrayScale>... // еще десяток таких
template<typename T> Curve { template <typename T>struct Value<T>{T data, in, out; float someOptions[];} QMap<double,Value> }