00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include "PointsOrdering.h"
00025
00027
00041 template <class T>
00042 class CChartPointsArray
00043 {
00044 public:
00046
00050 CChartPointsArray(unsigned iResize = 1000);
00052 ~CChartPointsArray();
00053
00055 unsigned GetPointsCount() const { return m_iCurrentPoints; }
00057 void SetResize(int iResize) { m_iResize = iResize; }
00058
00060
00064 void AddPoint(const T& newPoint);
00066
00073 void AddPoints(T* pPoints, unsigned uCount);
00075
00083 void SetPoints(T* pPoints, unsigned uCount);
00085 void Clear();
00087 void RemovePointsFromBegin(unsigned Count);
00089 void RemovePointsFromEnd(unsigned Count);
00091 T& operator[](unsigned Index);
00093 const T& operator[](unsigned Index) const;
00094
00096 bool GetSerieXMinMax(double& Min, double& Max) const;
00098 bool GetSerieYMinMax(double& Min, double& Max) const;
00099
00101
00108 void SetOrdering(PointsOrdering newOrdering);
00110 PointsOrdering GetOrdering() const { return m_Ordering; }
00112 void ReorderPoints();
00113
00115
00128 bool GetVisiblePoints(double dAxisMin, double dAxisMax,
00129 unsigned& uFirstPt, unsigned& uLastPt) const;
00130
00131
00133 T* GetInternalBuffer() const { return m_pPoints; }
00134
00135 private:
00137 double m_dXMinVal;
00139 double m_dXMaxVal;
00141 double m_dYMinVal;
00143 double m_dYMaxVal;
00144
00146 void RefreshMinMax();
00148 void InsertNewPoint(const T& newPoint);
00150 void InsertPointAtPos(const T& newPoint, int iPos);
00152 static int ComparePointsOnX(void const* pA, void const* pB);
00154 static int ComparePointsOnY(void const* pA, void const* pB);
00156 int BinarySearch(unsigned uLeft, unsigned uRight, double dFind) const;
00157
00159 T* m_pPoints;
00161 unsigned m_iMaxPoints;
00163 unsigned m_iCurrentPoints;
00165 unsigned m_iResize;
00167 PointsOrdering m_Ordering;
00168 };
00169
00170 #include "ChartPointsArray.inl"