"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "uppsrc/ScatterDraw/DataSource.h" between
upp-x11-src-13648.tar.gz and upp-x11-src-13659.tar.gz

About: Ultimate++ is a C++ cross-platform rapid application development framework. Stable release.

DataSource.h  (upp-x11-src-13648):DataSource.h  (upp-x11-src-13659)
#ifndef _ScatterDraw_DataSource_h_ #ifndef _ScatterDraw_DataSource_h_
#define _ScatterDraw_DataSource_h_ #define _ScatterDraw_DataSource_h_
namespace Upp { namespace Upp {
class DataSource { class DataSource : public Pte<DataSource> {
public: public:
typedef double (DataSource::*Getdatafun)(int64 id); typedef double (DataSource::*Getdatafun)(int64 id);
DataSource() : isParam(false), isExplicit(false), key(111111) {} DataSource() : isParam(false), isExplicit(false) {}
virtual ~DataSource() {key = 0;} virtual ~DataSource() {}
virtual double y(int64 ) {NEVER(); r virtual double y(int64 ) = 0;
eturn Null;} virtual double x(int64 ) = 0;
virtual double x(int64 ) {NEVER(); r virtual double znx(int , int64 ) {NEVER(); r
eturn Null;} eturn Null;}
virtual double znx(int , int64 ) {NEVER(); return Nu virtual double zny(int , int64 ) {NEVER(); r
ll;} eturn Null;}
virtual double zny(int , int64 ) {NEVER(); return Nu virtual double znFixed(int , int64 ) {NEVER(); return Nu
ll;} ll;}
virtual double znFixed(int , int64 ) {NEVER(); return Null;} virtual double y(double ) {NEVER();
virtual double y(double ) {NEVER(); r return Null;}
eturn Null;} virtual double x(double ) {NEVER();
virtual double x(double ) {NEVER(); r return Null;}
eturn Null;} virtual double f(double ) {NEVER();
virtual double f(double ) {NEVER(); r return Null;}
eturn Null;} virtual double f(Vector<double> ) {NEVER(); r
virtual double f(Vector<double> ) {NEVER(); return Nu eturn Null;}
ll;} virtual int64 GetCount() const = 0;
virtual int64 GetCount() {NEVER(); r bool IsEmpty() const {return G
eturn Null;} etCount() == 0;}
bool IsEmpty() {return GetCount( virtual int GetznxCount(int64 ) {return 0;}
) == 0;} virtual int GetznyCount(int64 ) {return 0;}
virtual int GetznxCount(int64 ) {return 0;} virtual int GetznFixedCount() {return 0;}
virtual int GetznyCount(int64 ) {return 0;} bool IsParam() const {return i
virtual int GetznFixedCount() {return 0;} sParam;}
bool IsParam() {return isParam;} bool IsExplicit() const {return i
bool IsExplicit() {return isExplici sExplicit;}
t;}
bool IsDeleted() {return key != 11 void SetDestructor(Function <void(void)> _OnDestructor) {OnDestructor = _
1111;} OnDestructor;}
virtual double MinY(int64& id) {return Min(&DataSource::y, id);} double MinY(int64& id) {return Min(&DataSource::y, id);}
virtual double MinY() {int64 dummy; return Mi double MinY() {int64 dummy; return Mi
n(&DataSource::y, dummy);} n(&DataSource::y, dummy);}
virtual double MinX(int64& id) {return Min(&DataSource::x, id);} double MinX(int64& id) {return Min(&DataSource::x, id);}
virtual double MinX() {int64 dummy; return Mi double MinX() {int64 dummy; return Mi
n(&DataSource::x, dummy);} n(&DataSource::x, dummy);}
virtual double MaxY(int64& id) {return Max(&DataSource::y, id);} double MaxY(int64& id) {return Max(&DataSource::y, id);}
virtual double MaxY() {int64 dummy; return Ma double MaxY() {int64 dummy; return Ma
x(&DataSource::y, dummy);} x(&DataSource::y, dummy);}
virtual double MaxX(int64& id) {return Max(&DataSource::x, id);} double MaxX(int64& id) {return Max(&DataSource::x, id);}
virtual double MaxX() {int64 dummy; return Ma double MaxX() {int64 dummy; return Ma
x(&DataSource::x, dummy);} x(&DataSource::x, dummy);}
virtual double IsSortedY() {return IsSorted(&DataSou double IsSortedY() {return IsSorted(&DataSource::y);
rce::y);} }
virtual double IsSortedX() {return IsSorted(&DataSou double IsSortedX() {return IsSorted(&DataSource::x);
rce::x);} }
virtual double AvgY() {return Avg(&DataSource:: int64 Closest(double x,double y){return Closest(&DataSource::x, &DataSour
y);} ce::y, x, y);}
virtual double AvgX() {return Avg(&DataSource:: int64 ClosestY(double d) {return Closest(&DataSource::y, d
x);} );}
virtual double RMSY() {return RMS(&DataSource:: int64 ClosestX(double d) {return Closest(&DataSource::x, d
y);} );}
virtual double StdDevY(double avg = Null) {return StdDev(&DataSourc double AvgY() {return Avg(&DataSource::
e::y, avg);} y);}
virtual double VarianceY(double avg = Null) {return Variance(&DataSource: double AvgX() {return Avg(&DataSource::
:y, avg);} x);}
virtual Vector<int64> UpperEnvelopeY(double width) {return UpperEnve double RMSY() {return RMS(&DataSource::
lope(&DataSource::y, &DataSource::x, width);} y);}
virtual Vector<int64> LowerEnvelopeY(double width) {return LowerEnve double StdDevY(double avg = Null) {return S
lope(&DataSource::y, &DataSource::x, width);} tdDev(&DataSource::y, avg);}
virtual Vector<Pointf> CumulativeY() {return C double VarianceY(double avg = Null) {return Variance(
umulative(&DataSource::y, &DataSource::x);} &DataSource::y, avg);}
virtual Vector<Pointf> CumulativeAverageY() {return Cumulativ Vector<int64> UpperEnvelopeY(double width) {return UpperEnvelope(&Da
eAverage(&DataSource::y, &DataSource::x);} taSource::y, &DataSource::x, width);}
virtual Vector<Pointf> MovingAverageY(double width) {return MovingAverage Vector<int64> LowerEnvelopeY(double width) {return LowerEnvelope(&Da
(&DataSource::y, &DataSource::x, width);} taSource::y, &DataSource::x, width);}
virtual Vector<Pointf> SectorAverageY(double width) {return SectorAverage Vector<Pointf> CumulativeY() {return C
(&DataSource::y, &DataSource::x, width);} umulative(&DataSource::y, &DataSource::x);}
virtual void MaxListY(Vector<int64> &id, double width){MaxList(&DataSourc Vector<Pointf> CumulativeAverageY() {return Cumulativ
e::y, &DataSource::x, id, width);} eAverage(&DataSource::y, &DataSource::x);}
virtual Pointf MaxSubDataImpY(int64 maxId, int width) {return MaxSubDat Vector<Pointf> MovingAverageY(double width) {return MovingAverage(&Da
aImp(&DataSource::y, &DataSource::x, maxId, width);} taSource::y, &DataSource::x, width);}
virtual void ZeroCrossingY(bool ascending, bool descending, Vector<double Vector<Pointf> SectorAverageY(double width) {return SectorAverage(&Da
> &zeros, Vector<int64> &ids) { taSource::y, &DataSource::x, width);}
void MaxListY(Vector<int64> &id, double width) {MaxList(&DataSource::y,
&DataSource::x, id, width);}
Pointf MaxSubDataImpY(int64 maxId, int width) {return MaxSubDataImp(&Da
taSource::y, &DataSource::x, maxId, width);}
void ZeroCrossingY(bool ascending, bool descending, Vector<double> &zeros
, Vector<int64> &ids) {
return ZeroCrossing(&DataSource::y, &DataSource::x, ascending, de scending, zeros, ids);} return ZeroCrossing(&DataSource::y, &DataSource::x, ascending, de scending, zeros, ids);}
virtual double IntegralY() {return Integral(&DataSou double IntegralY() {return Integral(&DataSource::y,
rce::y, &DataSource::x);} &DataSource::x);}
virtual double IntegralY(double from, double to, double n) {return I double IntegralY(double from, double to, double n) {return Integral(
ntegral(from, to, n);} from, to, n);}
enum FFT_WINDOW {NO_WINDOW = 0, HAMMING, COS}; enum FFT_WINDOW {NO_WINDOW = 0, HAMMING, COS};
enum FFT_TYPE {T_FFT = 0, T_PHASE, T_PSD}; enum FFT_TYPE {T_FFT = 0, T_PHASE, T_PSD};
Upp::Vector<Pointf> FFTY(double tSample, bool frequency = false, int type = FFT_TYPE::T_FFT, Upp::Vector<Pointf> FFTY(double tSample, bool frequency = false, int type = FFT_TYPE::T_FFT,
int window = FFT_WINDOW::HAMMING, int num Sub = 1, double overlapping = 0) { int window = FFT_WINDOW::HAMMING, int num Sub = 1, double overlapping = 0) {
return FFT(&DataSource::y, tSample, frequency, type, window, numS ub, overlapping);} return FFT(&DataSource::y, tSample, frequency, type, window, numS ub, overlapping);}
static int GetFFTWindowCount() {return 3;} static int GetFFTWindowCount() {return 3;}
static const char *GetFFTWindowStr(int i) { static const char *GetFFTWindowStr(int i) {
const char *str[] = {"no window", "hamming", "cos"}; const char *str[] = {"no window", "hamming", "cos"};
if (i < 0 || i >= GetFFTWindowCount()) if (i < 0 || i >= GetFFTWindowCount())
return 0; return 0;
return str[i]; return str[i];
} }
void GetSpectralMomentsY(double from, double to, double n, bool frequency , void GetSpectralMomentsY(double from, double to, double n, bool frequency ,
double &m _1, double &m0, double &m1, double &m2) double &m _1, double &m0, double &m1, double &m2)
{GetSpectralMoments(from, to, n, frequency, m_1, m0, m1, m2);} {GetSpectralMoments(from, to, n, frequency, m_1, m0, m1, m2);}
void GetSpectralMomentsY(bool frequency, double &m_1, double &m0, double &m1, double &m2) void GetSpectralMomentsY(bool frequency, double &m_1, double &m0, double &m1, double &m2)
{GetSpectralMoments(&DataSource::y, &DataSource::x, frequency, m_ 1, m0, m1, m2);} {GetSpectralMoments(&DataSource::y, &DataSource::x, frequency, m_ 1, m0, m1, m2);}
Vector<double> SortDataY() {return SortData( Vector<double> SortDataY() {return SortData(
&DataSource::y);} &DataSource::y);}
Vector<double> PercentileY(double rate) {return Percentile(&DataSource::y Vector<double> PercentileY(double rate) {return Percentile(&DataS
, rate);} ource::y, rate);}
double PercentileAvgY(double rate) {return PercentileAvg(&Da double PercentileAvgY(double rate) {return PercentileAvg(&Da
taSource::y, rate);} taSource::y, rate);}
double Min(Getdatafun getdata, int64& id); double Min(Getdatafun getdata, int64& id);
double Max(Getdatafun getdata, int64& id); double Max(Getdatafun getdata, int64& id);
double Avg(Getdatafun getdata); double Avg(Getdatafun getdata);
int64 Closest(Getdatafun getdata, double d);
int64 Closest(Getdatafun getdataX, Getdatafun getdataY, double x, double
y);
double IsSorted(Getdatafun getdata); double IsSorted(Getdatafun getdata);
double RMS(Getdatafun getdata); double RMS(Getdatafun getdata);
double StdDev(Getdatafun getdata, double avg = Null); double StdDev(Getdatafun getdata, double avg = Null);
double Variance(Getdatafun getdata, double avg = Null); double Variance(Getdatafun getdata, double avg = Null);
Vector<int64> UpperEnvelope(Getdatafun getdataY, Getdatafun getdataX, dou ble width); Vector<int64> UpperEnvelope(Getdatafun getdataY, Getdatafun getdataX, dou ble width);
Vector<int64> LowerEnvelope(Getdatafun getdataY, Getdatafun getdataX, dou ble width); Vector<int64> LowerEnvelope(Getdatafun getdataY, Getdatafun getdataX, dou ble width);
Vector<Pointf> Cumulative(Getdatafun getdataY, Getdatafun getdataX); Vector<Pointf> Cumulative(Getdatafun getdataY, Getdatafun getdataX);
Vector<Pointf> CumulativeAverage(Getdatafun getdataY, Getdatafun getdataX ); Vector<Pointf> CumulativeAverage(Getdatafun getdataY, Getdatafun getdataX );
Vector<Pointf> MovingAverage(Getdatafun getdataY, Getdatafun getdataX, do uble width); Vector<Pointf> MovingAverage(Getdatafun getdataY, Getdatafun getdataX, do uble width);
Vector<Pointf> SectorAverage(Getdatafun getdataY, Getdatafun getdataX, do uble width); Vector<Pointf> SectorAverage(Getdatafun getdataY, Getdatafun getdataX, do uble width);
skipping to change at line 122 skipping to change at line 128
double &m_1, double &m0, double & m1, double &m2); double &m_1, double &m0, double & m1, double &m2);
bool SameX(DataSource &data); bool SameX(DataSource &data);
Vector<double> SortData(Getdatafun getdata); Vector<double> SortData(Getdatafun getdata);
Vector<double> Percentile(Getdatafun getdata, double rate); Vector<double> Percentile(Getdatafun getdata, double rate);
double PercentileAvg(Getdatafun getdata, double rate); double PercentileAvg(Getdatafun getdata, double rate);
protected: protected:
bool isParam, isExplicit; bool isParam, isExplicit;
private: private:
int key; Function <void(void)> OnDestructor;
Vector<int64> Envelope(Getdatafun getdataY, Getdatafun getdataX, double w idth, bool (*fun)(double a, double b)); Vector<int64> Envelope(Getdatafun getdataY, Getdatafun getdataX, double w idth, bool (*fun)(double a, double b));
}; };
class DataXRange : public DataSource { class DataXRange : public DataSource {
private: private:
DataSource *data; DataSource *data;
double xHigh, xLow; double xHigh, xLow;
int count; int count;
public: public:
skipping to change at line 147 skipping to change at line 152
data = &_data; data = &_data;
isExplicit = _data.IsExplicit(); isExplicit = _data.IsExplicit();
isParam = _data.IsParam(); isParam = _data.IsParam();
xLow = _xLow; xLow = _xLow;
xHigh = _xHigh; xHigh = _xHigh;
count = 1000; count = 1000;
} }
void SetCount(int _count) {count = _count;} void SetCount(int _count) {count = _count;}
void SetXLow(double _xLow) {xLow = _xLow;} void SetXLow(double _xLow) {xLow = _xLow;}
void SetXHigh(double _xHigh){xHigh = _xHigh;} void SetXHigh(double _xHigh){xHigh = _xHigh;}
bool Check(int64 id) { bool Check(int64 id) const {
double x = data->x(id); double x = data->x(id);
if (!IsNull(xHigh) && xHigh < x) if (!IsNull(xHigh) && xHigh < x)
return false; return false;
if (!IsNull(xLow) && xLow > x) if (!IsNull(xLow) && xLow > x)
return false; return false;
return true; return true;
} }
virtual inline double y(int64 id) { virtual inline double y(int64 id) {
if (isExplicit) if (isExplicit)
return f(xLow + id*(xHigh - xLow)/double(count - 1)); return f(xLow + id*(xHigh - xLow)/double(count - 1));
skipping to change at line 184 skipping to change at line 189
} }
virtual double f(double x) { virtual double f(double x) {
if (!IsNull(xHigh) && xHigh < x) if (!IsNull(xHigh) && xHigh < x)
return Null; return Null;
if (!IsNull(xLow) && xLow > x) if (!IsNull(xLow) && xLow > x)
return Null; return Null;
return data->f(x); return data->f(x);
} }
virtual double MinX() {return xLow;} virtual double MinX() {return xLow;}
virtual double MaxX() {return xHigh;} virtual double MaxX() {return xHigh;}
virtual inline int64 GetCount() { virtual inline int64 GetCount() const {
if (isExplicit) if (isExplicit)
return count; return count;
return data->GetCount(); return data->GetCount();
} }
}; };
class DataReverse : public DataSource { class DataReverse : public DataSource {
private: private:
DataSource *data; DataSource *data;
public: public:
DataReverse() : data(0) {} DataReverse() : data(0) {}
DataReverse(DataSource &_data) {Init(_data);} DataReverse(DataSource &_data) {Init(_data);}
void Init(DataSource *_data) {Init(*_data);} void Init(DataSource *_data) {Init(*_data);}
void Init(DataSource &_data) { void Init(DataSource &_data) {
ASSERT(!_data.IsExplicit() && !_data.IsParam()); ASSERT(!_data.IsExplicit() && !_data.IsParam());
data = &_data; data = &_data;
} }
virtual inline double y(int64 id) {return data->y(GetCount() - id - 1);} virtual inline double y(int64 id) {return data->y(GetCount() - id - 1);}
virtual inline double x(int64 id) {return data->x(GetCount() - id - 1);} virtual inline double x(int64 id) {return data->x(GetCount() - id - 1);}
virtual int64 GetCount() {return data->GetCount();} virtual int64 GetCount() const {return data->GetCount();}
}; };
class DataReverseX : public DataSource { class DataReverseX : public DataSource {
private: private:
DataSource *data; DataSource *data;
public: public:
DataReverseX() : data(0) {} DataReverseX() : data(0) {}
DataReverseX(DataSource &_data) {Init(_data);} DataReverseX(DataSource &_data) {Init(_data);}
void Init(DataSource &_data) { void Init(DataSource &_data) {
ASSERT(!_data.IsExplicit() && !_data.IsParam()); ASSERT(!_data.IsExplicit() && !_data.IsParam());
data = &_data; data = &_data;
} }
virtual inline double y(int64 id) {return data->y(id);} virtual inline double y(int64 id) {return data->y(id);}
virtual inline double x(int64 id) {return data->x(GetCount() - id - 1);} virtual inline double x(int64 id) {return data->x(GetCount() - id - 1);}
virtual int64 GetCount() {return data->GetCount();} virtual int64 GetCount() const {return data->GetCount();}
}; };
class DataAppend : public DataSource { class DataAppend : public DataSource {
protected: protected:
DataSource *data1, *data2; DataSource *data1, *data2;
public: public:
DataAppend() : data1(0), data2(0) {} DataAppend() : data1(0), data2(0) {}
DataAppend(DataSource &_data1, DataSource &_data2) {Init(_data1, _data2); } DataAppend(DataSource &_data1, DataSource &_data2) {Init(_data1, _data2); }
void Init(DataSource &_data1, DataSource &_data2) { void Init(DataSource &_data1, DataSource &_data2) {
skipping to change at line 248 skipping to change at line 253
if (id < count1) if (id < count1)
return data1->y(id); return data1->y(id);
return data2->y(id - count1); return data2->y(id - count1);
} }
virtual inline double x(int64 id) { virtual inline double x(int64 id) {
int64 count1 = data1->GetCount(); int64 count1 = data1->GetCount();
if (id < count1) if (id < count1)
return data1->x(id); return data1->x(id);
return data2->x(id - count1); return data2->x(id - count1);
} }
virtual int64 GetCount() {return data1->GetCount() + data2->GetCount();} virtual int64 GetCount() const {return data1->GetCount() + data2 ->GetCount();}
}; };
class DataRange : public DataAppend { class DataRange : public DataAppend {
public: public:
DataRange() : DataAppend() {} DataRange() : DataAppend() {}
DataRange(DataSource &_data1, DataSource &_data2) {Init(_data1, _data2);} DataRange(DataSource &_data1, DataSource &_data2) {Init(_data1, _data2);}
void Init(DataSource &_data1, DataSource &_data2) { void Init(DataSource &_data1, DataSource &_data2) {
ASSERT(!_data1.IsExplicit() && !_data1.IsParam() && !_data2.IsExp licit() && !_data2.IsParam()); ASSERT(!_data1.IsExplicit() && !_data1.IsParam() && !_data2.IsExp licit() && !_data2.IsParam());
data1 = &_data1; data1 = &_data1;
rev.Init(_data2); rev.Init(_data2);
skipping to change at line 312 skipping to change at line 317
} }
virtual inline double y(int64 id) { virtual inline double y(int64 id) {
return parent->GetY(index, id); return parent->GetY(index, id);
} }
double RealY(int64 id) { double RealY(int64 id) {
return data->y(id); return data->y(id);
} }
virtual inline double x(int64 id) { virtual inline double x(int64 id) {
return data->x(id); return data->x(id);
} }
virtual int64 GetCount() { virtual int64 GetCount() const {
return data->GetCount(); return data->GetCount();
} }
private: private:
DataSource *data = 0; DataSource *data = 0;
int index = -1; int index = -1;
DataStackedY *parent = 0; DataStackedY *parent = 0;
}; };
EachDataStackedY &Get(int id) {return eachData[id];} EachDataStackedY &Get(int id) {return eachData[id];}
skipping to change at line 338 skipping to change at line 343
class CArray : public DataSource { class CArray : public DataSource {
private: private:
double *yData, *xData, *zData; double *yData, *xData, *zData;
int64 numData; int64 numData;
double x0, deltaX; double x0, deltaX;
public: public:
CArray(double *_yData, int _numData, double _x0, double _deltaX) : yData( _yData), numData(_numData), x0(_x0), deltaX(_deltaX) {xData = NULL;} CArray(double *_yData, int _numData, double _x0, double _deltaX) : yData( _yData), numData(_numData), x0(_x0), deltaX(_deltaX) {xData = NULL;}
CArray(double *_yData, double *_xData, int _numData) : yData(_yData), xDa ta(_xData), numData(_numData) {zData = NULL; x0 = deltaX = 0;} CArray(double *_yData, double *_xData, int _numData) : yData(_yData), xDa ta(_xData), numData(_numData) {zData = NULL; x0 = deltaX = 0;}
CArray(double *_yData, double *_xData, double *_zData, int _numData) : yD ata(_yData), xData(_xData), zData(_zData), numData(_numData) {x0 = deltaX = 0;} CArray(double *_yData, double *_xData, double *_zData, int _numData) : yD ata(_yData), xData(_xData), zData(_zData), numData(_numData) {x0 = deltaX = 0;}
virtual inline double y(int64 id) {return yData[ptrdiff_t(id)];} virtual inline double y(int64 id) {return yData[ptrdiff_t(id)];}
virtual inline double x(int64 id) {return xData ? xData[ptrdiff_t(i virtual inline double x(int64 id) {return xData ? xData[ptrdiff_t(i
d)] : id*deltaX + x0;} d)] : id*deltaX + x0;}
virtual double znFixed(int n, int64 id); virtual double znFixed(int n, int64 id);
virtual int GetznFixedCount() {return 1;} virtual int GetznFixedCount() {return 1;}
virtual inline int64 GetCount() {return numData;} virtual inline int64 GetCount() const {return numData;}
}; };
template <class Y> template <class Y>
class VectorY : public DataSource { class VectorY : public DataSource {
private: private:
Vector<Y> *yData; Vector<Y> *yData;
double x0, deltaX; double x0, deltaX;
public: public:
VectorY() : yData(0), x0(0), deltaX(0) {} VectorY() : yData(0), x0(0), deltaX(0) {}
VectorY(Vector<Y> &_yData, double _x0, double _deltaX) {Init(_yData, _x0, _deltaX);} VectorY(Vector<Y> &_yData, double _x0, double _deltaX) {Init(_yData, _x0, _deltaX);}
void Init(Vector<Y> &_yData, double _x0, double _deltaX) { void Init(Vector<Y> &_yData, double _x0, double _deltaX) {
this->yData = &_yData; this->yData = &_yData;
this->x0 = _x0; this->x0 = _x0;
this->deltaX = _deltaX; this->deltaX = _deltaX;
} }
virtual inline double y(int64 id) {return (*yData)[int(id)];} virtual inline double y(int64 id) {return (*yData)[int(id)]
virtual inline double x(int64 id) {return id*deltaX + x0;} ;}
virtual inline int64 GetCount() {return yData->GetCount();} virtual inline double x(int64 id) {return id*deltaX + x0;}
virtual double MinX() {return x0;} virtual inline int64 GetCount() const {return yData->GetCount();}
virtual double MaxX() {return x0 + (yData->GetC virtual double MinX() {return x0;}
ount() - 1)*deltaX;} virtual double MaxX() {return x0 + (yDa
virtual double AvgX() {return x0 + ((yData->Get ta->GetCount() - 1)*deltaX;}
Count() - 1)*deltaX)/2.;} virtual double AvgX() {return x0 + ((yD
ata->GetCount() - 1)*deltaX)/2.;}
}; };
template <class Y> template <class Y>
class ArrayY : public DataSource { class ArrayY : public DataSource {
private: private:
Upp::Array<Y> *yData = 0; Upp::Array<Y> *yData = 0;
double x0 = 0, deltaX = 0; double x0 = 0, deltaX = 0;
public: public:
ArrayY() {} ArrayY() {}
ArrayY(Upp::Array<Y> &_yData, double _x0, double _deltaX) {Init(_yData, _ x0, _deltaX);} ArrayY(Upp::Array<Y> &_yData, double _x0, double _deltaX) {Init(_yData, _ x0, _deltaX);}
void Init(Upp::Array<Y> &_yData, double _x0, double _deltaX) { void Init(Upp::Array<Y> &_yData, double _x0, double _deltaX) {
this->yData = &_yData; this->yData = &_yData;
this->x0 = _x0; this->x0 = _x0;
this->deltaX = _deltaX; this->deltaX = _deltaX;
} }
virtual inline double y(int64 id) {return (*yData)[ptrdiff_t(id)];} virtual inline double y(int64 id) {return (*yData)[ptrdiff_
virtual inline double x(int64 id) {return id*deltaX + x0;} t(id)];}
virtual inline int64 GetCount() {return yData->GetCount();} virtual inline double x(int64 id) {return id*deltaX + x0;}
virtual double MinX() {return x0;} virtual inline int64 GetCount() const {return yData->GetCount();}
virtual double MaxX() {return x0 + yData->GetCo virtual double MinX() {return x0;}
unt()*deltaX;} virtual double MaxX() {return x0 + yDat
virtual double AvgX() {return (x0 + yData->GetC a->GetCount()*deltaX;}
ount()*deltaX)/2.;} virtual double AvgX() {return (x0 + yDa
ta->GetCount()*deltaX)/2.;}
}; };
template <class Y> template <class Y>
class VectorVectorY : public DataSource { class VectorVectorY : public DataSource {
private: private:
Vector<Vector<Y> > *data = 0; Vector<Vector<Y> > *data = 0;
bool useRows = true; bool useRows = true;
int idx = 0, idy = 1; int idx = 0, idy = 1;
Vector<int> idsx, idsy, idsFixed; Vector<int> idsx, idsy, idsFixed;
int beginData = 0; int beginData = 0;
skipping to change at line 432 skipping to change at line 437
else else
this->numData = _data[0].GetCount() - _be ginData; this->numData = _data[0].GetCount() - _be ginData;
} else } else
this->numData = _data.GetCount() - _beginData; this->numData = _data.GetCount() - _beginData;
} }
} }
void Init(Vector<Vector<Y> > &_data, int _idx, int _idy, bool _useRows = true, int _beginData = 0, int _numData = Null) { void Init(Vector<Vector<Y> > &_data, int _idx, int _idy, bool _useRows = true, int _beginData = 0, int _numData = Null) {
static Vector<int> idsVoid; static Vector<int> idsVoid;
Init(_data, _idx, _idy, idsVoid, idsVoid, idsVoid, _useRows, _beg inData, _numData); Init(_data, _idx, _idy, idsVoid, idsVoid, idsVoid, _useRows, _beg inData, _numData);
} }
virtual inline double y(int64 id) { virtual inline double y(int64 id) {
if (!IsNull(idy) && idy >= 0) { if (!IsNull(idy) && idy >= 0) {
if (useRows) if (useRows)
return (*data)[beginData + int(id)][idy]; return (*data)[beginData + int(id)][idy];
else else
return (*data)[idy][beginData + int(id)]; return (*data)[idy][beginData + int(id)];
} else { } else {
if (GetznyCount(id) == 0) if (GetznyCount(id) == 0)
return Null; return Null;
double ret = 0; double ret = 0;
for (int i = 0; i < GetznyCount(id); ++i) for (int i = 0; i < GetznyCount(id); ++i)
ret += zny(i, id); ret += zny(i, id);
return ret/GetznyCount(id); return ret/GetznyCount(id);
} }
} }
virtual inline double x(int64 id) {return useRows ? (*data)[beginData + i nt(id)][idx] : (*data)[idx][beginData + int(id)];} virtual inline double x(int64 id) {return useRows ? (*data)[beginData + int(id)][idx] : (*data)[idx][beginData + int(id)];}
//virtual inline double xn(int n, int64 id) {return useRows ? (*data) [beginData + int(id)][ids[n]] : (*data)[ids[n]][beginData + int(id)];} //virtual inline double xn(int n, int64 id) {return useRows ? (*data) [beginData + int(id)][ids[n]] : (*data)[ids[n]][beginData + int(id)];}
virtual inline int64 GetCount() {return numData;}; virtual inline int64 GetCount() const {return numData;};
virtual double znx(int n, int64 id) {return useRows ? (*data)[beginDa ta + int(id)][idsx[n]] : (*data)[idsx[n]][beginData + int(id)];} virtual double znx(int n, int64 id) {return useRows ? (*data)[beginDa ta + int(id)][idsx[n]] : (*data)[idsx[n]][beginData + int(id)];}
virtual double zny(int n, int64 id) { virtual double zny(int n, int64 id) const {
if (!IsNull(idy) && idy < 0) if (!IsNull(idy) && idy < 0)
return useRows ? (*data)[beginData + int(id)][n - idy] : (*data)[n - idy][beginData + int(id)]; return useRows ? (*data)[beginData + int(id)][n - idy] : (*data)[n - idy][beginData + int(id)];
return useRows ? (*data)[beginData + int(id)][idsy[n]] : (*data)[ idsy[n]][beginData + int(id)]; return useRows ? (*data)[beginData + int(id)][idsy[n]] : (*data)[ idsy[n]][beginData + int(id)];
} }
virtual double znFixed(int n, int64 id) {return useRows ? (*data)[beginDa ta + int(id)][idsFixed[n]] : (*data)[idsFixed[n]][beginData + int(id)];} virtual double znFixed(int n, int64 id) {return useRows ? (*data)[beginDa ta + int(id)][idsFixed[n]] : (*data)[idsFixed[n]][beginData + int(id)];}
int GetznxCount() {return i dsx.GetCount();} int GetznxCount() {return i dsx.GetCount();}
virtual int GetznyCount(int64 id) { virtual int GetznyCount(int64 id) const {
if (!IsNull(idy) && idy < 0) if (!IsNull(idy) && idy < 0)
return (useRows ? (*data)[beginData + int(id)].GetCount() : (*data).GetCount()) + idy; return (useRows ? (*data)[beginData + int(id)].GetCount() : (*data).GetCount()) + idy;
return idsy.GetCount(); return idsy.GetCount();
} }
virtual int GetznFixedCount() {return idsFixed.GetCount();} virtual int GetznFixedCount() {return idsFixed.GetCount();}
}; };
class VectorDouble : public DataSource { class VectorDouble : public DataSource {
private: private:
const Vector<double> *xData, *yData; const Vector<double> *xData, *yData;
public: public:
VectorDouble(const Vector<double> &_yData, Vector<double> &_xData) : xDat a(&_xData), yData(&_yData) {} VectorDouble(const Vector<double> &_yData, Vector<double> &_xData) : xDat a(&_xData), yData(&_yData) {}
virtual inline double y(int64 id) {return (*yData)[int(id)];} virtual inline double y(int64 id) {return (*yData)[int(id)]
virtual inline double x(int64 id) {return (*xData)[int(id)];} ;}
virtual inline int64 GetCount() {return min(xData->GetCount(), yD virtual inline double x(int64 id) {return (*xData)[int(id)]
ata->GetCount());} ;}
virtual inline int64 GetCount() const {return min(xData->GetCount(), yD
ata->GetCount());}
}; };
class ArrayDouble : public DataSource { class ArrayDouble : public DataSource {
private: private:
const Upp::Array<double> *xData, *yData; const Upp::Array<double> *xData, *yData;
public: public:
ArrayDouble(const Upp::Array<double> &_yData, Upp::Array<double> &_xData) : xData(&_xData), yData(&_yData) {} ArrayDouble(const Upp::Array<double> &_yData, Upp::Array<double> &_xData) : xData(&_xData), yData(&_yData) {}
virtual inline double y(int64 id) {return (*yData)[int(id)];} virtual inline double y(int64 id) {return (*yData)[int(id)]
virtual inline double x(int64 id) {return (*xData)[int(id)];} ;}
virtual inline int64 GetCount() {return min(xData->GetCount(), yD virtual inline double x(int64 id) {return (*xData)[int(id)]
ata->GetCount());} ;}
virtual inline int64 GetCount() const {return min(xData->GetCount(), yD
ata->GetCount());}
}; };
class VectorPointf : public DataSource { class VectorPointf : public DataSource {
private: private:
const Vector<Pointf> *data; const Vector<Pointf> *data;
public: public:
VectorPointf() : data(0) {} VectorPointf() : data(0) {}
VectorPointf(const Vector<Pointf> &_data) {Init(&_data);} VectorPointf(const Vector<Pointf> &_data) {Init(&_data);}
VectorPointf(Vector<Pointf> *_data) {Init(_data);} VectorPointf(Vector<Pointf> *_data) {Init(_data);}
void Init(const Vector<Pointf> *_data) {data = _data;} void Init(const Vector<Pointf> *_data) {data = _data;}
void Init(const Vector<Pointf> &_data) {data = &_data;} void Init(const Vector<Pointf> &_data) {data = &_data;}
virtual inline double y(int64 id) {return (*data)[i virtual inline double y(int64 id) {return (*data)[i
nt(id)].y;} nt(id)].y;}
virtual inline double x(int64 id) {return (*data)[i virtual inline double x(int64 id) {return (*data)[i
nt(id)].x;} nt(id)].x;}
virtual inline int64 GetCount() {return data->Get virtual inline int64 GetCount() const {return data->GetCount();
Count();} }
}; };
class ArrayPointf : public DataSource { class ArrayPointf : public DataSource {
private: private:
Upp::Array<Pointf> *data; Upp::Array<Pointf> *data;
public: public:
ArrayPointf(Upp::Array<Pointf> &_data) : data(&_data) {} ArrayPointf(Upp::Array<Pointf> &_data) : data(&_data) {}
virtual inline double y(int64 id) {return (*data)[int(id)].y;} virtual inline double y(int64 id) {return (*data)[int(id)].
virtual inline double x(int64 id) {return (*data)[int(id)].x;} y;}
virtual inline int64 GetCount() {return data->GetCount();} virtual inline double x(int64 id) {return (*data)[int(id)].x;}
virtual inline int64 GetCount() const {return data->GetCount();}
}; };
template <class X, class Y> template <class X, class Y>
class VectorMapXY : public DataSource { class VectorMapXY : public DataSource {
private: private:
VectorMap<X, Y> *data; VectorMap<X, Y> *data;
public: public:
VectorMapXY(VectorMap<X, Y> &_data) : data(&_data) {} VectorMapXY(VectorMap<X, Y> &_data) : data(&_data) {}
virtual inline double y(int64 id) {return (*data)[int(id)];} virtual inline double y(int64 id) {return (*data)[i
virtual inline double x(int64 id) {return (*data).GetKey(int(id));} nt(id)];}
virtual inline int64 GetCount() {return data->GetCount();} virtual inline double x(int64 id) {return (*data).GetKey(in
t(id));}
virtual inline int64 GetCount() const {return data->GetCount();
}
}; };
template <class X, class Y> template <class X, class Y>
class ArrayMapXY : public DataSource { class ArrayMapXY : public DataSource {
private: private:
ArrayMap<X, Y> *data; ArrayMap<X, Y> *data;
public: public:
ArrayMapXY(ArrayMap<X, Y> &_data) : data(&_data) {} ArrayMapXY(ArrayMap<X, Y> &_data) : data(&_data) {}
virtual inline double y(int64 id) {return (*data)[int(id)];} virtual inline double y(int64 id) {return (*data)[i
virtual inline double x(int64 id) {return (*data).GetKey(int(id));} nt(id)];}
virtual inline int64 GetCount() {return data->GetCount();} virtual inline double x(int64 id) {return (*data).G
etKey(int(id));}
virtual inline int64 GetCount() const {return data->GetCount();
}
}; };
class FuncSource : public DataSource { class FuncSource : public DataSource {
protected: protected:
Function <double(double)> function; Function <double(double)> function;
public: public:
FuncSource() {isExplicit = true;} FuncSource() {isExplicit = true;}
FuncSource(Function <double(double)> _function) : function(_function) {is Explicit = true;} FuncSource(Function <double(double)> _function) : function(_function) {is Explicit = true;}
virtual inline double f(double x) {return function(x);} virtual inline double f(double x) {return function(x);}
virtual double x(int64 ) {NEVER(); return
Null;}
virtual double y(int64 ) {NEVER(); return
Null;}
virtual inline int64 GetCount() const {NEVER(); return Null;}
}; };
class FuncSourceV : public DataSource { class FuncSourceV : public DataSource {
private: private:
Event<double&, double> function; Event<double&, double> function;
public: public:
FuncSourceV(Event<double&, double> _function) : function(_function) {isEx plicit = true;} FuncSourceV(Event<double&, double> _function) : function(_function) {isEx plicit = true;}
virtual inline double f(double x) {double y; function(y, x); return virtual inline double f(double x) {double y; function(y, x)
y;} ; return y;}
virtual double x(int64 ) {NEVER(); return
Null;}
virtual double y(int64 ) {NEVER(); return
Null;}
virtual inline int64 GetCount() const {NEVER(); return Null;}
}; };
class FuncSourcePara : public DataSource { class FuncSourcePara : public DataSource {
private: private:
Function <Pointf(double)> function; Function <Pointf(double)> function;
Pointf lastPointf; Pointf lastPointf;
double lastT; double lastT;
int numPoints; int numPoints;
double minT, maxT; double minT, maxT;
skipping to change at line 585 skipping to change at line 596
} }
return lastPointf.y; return lastPointf.y;
} }
virtual inline double x(double t) { virtual inline double x(double t) {
if (IsNull(lastT) || t != lastT) { if (IsNull(lastT) || t != lastT) {
lastPointf = function(minT + t*(maxT-minT)/numPoints); lastPointf = function(minT + t*(maxT-minT)/numPoints);
lastT = t; lastT = t;
} }
return lastPointf.x; return lastPointf.x;
} }
virtual inline int64 GetCount() {return numPoints;} virtual double x(int64 ) {NEVER(); return
Null;}
virtual double y(int64 ) {NEVER(); return
Null;}
virtual inline int64 GetCount() const {return numPoints;}
}; };
typedef Event<double&, double> PlotExplicFunc; typedef Event<double&, double> PlotExplicFunc;
typedef Function<void(Pointf&, double)> PlotParamFunc; typedef Function<void(Pointf&, double)> PlotParamFunc;
class PlotExplicFuncSource : public DataSource { class PlotExplicFuncSource : public DataSource {
private: private:
PlotExplicFunc function; PlotExplicFunc function;
public: public:
PlotExplicFuncSource(PlotExplicFunc &_function) : function(_function) {is Explicit = true;} PlotExplicFuncSource(PlotExplicFunc &_function) : function(_function) {is Explicit = true;}
virtual inline double f(double t) {double y; function(y, t); return y;} virtual inline double f(double t) {double y; function(y, t); return y;}
virtual double x(int64 ) {NEVER(); return
Null;}
virtual double y(int64 ) {NEVER(); return
Null;}
virtual inline int64 GetCount() const {NEVER(); return Null;}
}; };
class PlotParamFuncSource : public DataSource { class PlotParamFuncSource : public DataSource {
private: private:
PlotParamFunc function; PlotParamFunc function;
Pointf lastPointf; Pointf lastPointf;
double lastT; double lastT;
int numPoints; int numPoints;
double minT, maxT; double minT, maxT;
skipping to change at line 628 skipping to change at line 644
} }
return lastPointf.y; return lastPointf.y;
} }
inline double x(double t) { inline double x(double t) {
if (IsNull(lastT) || t != lastT) { if (IsNull(lastT) || t != lastT) {
function(lastPointf, minT + t*(maxT-minT)/numPoints); function(lastPointf, minT + t*(maxT-minT)/numPoints);
lastT = t; lastT = t;
} }
return lastPointf.x; return lastPointf.x;
} }
virtual inline int64 GetCount() {return numPoints;} virtual double x(int64 ) {NEVER(); return
Null;}
virtual double y(int64 ) {NEVER(); return
Null;}
virtual inline int64 GetCount() const {return numPoints;}
}; };
struct PointfLess { struct PointfLess {
bool operator () (const Pointf& a, const Pointf& b) const { return a.x < b.x; } bool operator () (const Pointf& a, const Pointf& b) const { return a.x < b.x; }
}; };
class DataSourceSurf { class DataSourceSurf {
public: public:
DataSourceSurf() : isExplicit(false), key(1212121) {} DataSourceSurf() : isExplicit(false), key(1212121) {}
virtual ~DataSourceSurf() {key = 0;} virtual ~DataSourceSurf() {key = 0;}
 End of changes. 34 change blocks. 
154 lines changed or deleted 198 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)