00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PLOT_DICT
00011 #define QWT_PLOT_DICT
00012
00013 #include "qwt_global.h"
00014 #include "qwt_plot_classes.h"
00015 #include <qintdict.h>
00016
00017
00018
00019
00020
00021 template<class type>
00022 class QWT_EXPORT QwtSeqDict : public QIntDict<type>
00023 {
00024 public:
00025 QwtSeqDict(): QIntDict<type>() {}
00026 void insert(long key, const type *item)
00027 {
00028 uint prime;
00029 if ((uint(key) >= this->size()) && (prime = nextPrime(uint(key))))
00030 this->resize(prime);
00031 QIntDict<type>::insert(key, item);
00032 }
00033 private:
00034 uint nextPrime(uint i)
00035 {
00036
00037 uint primes[] =
00038 {
00039 17,
00040 37,
00041 67,
00042 131,
00043 257,
00044 521,
00045 1031,
00046 2053,
00047 4099,
00048 8209,
00049 16411,
00050 32771,
00051 };
00052
00053 for (uint j=0; j<sizeof(primes); j++)
00054 {
00055 if (i<primes[j])
00056 return primes[j];
00057 }
00058
00059 return 0;
00060 }
00061 };
00062
00063 class QWT_EXPORT QwtCurveDict : public QwtSeqDict<QwtPlotCurve>
00064 {
00065 public:
00066 QwtCurveDict() { setAutoDelete(TRUE); }
00067 };
00068
00069 class QWT_EXPORT QwtMarkerDict : public QwtSeqDict<QwtPlotMarker>
00070 {
00071 public:
00072 QwtMarkerDict() { setAutoDelete(TRUE); }
00073 };
00074
00075 typedef QIntDictIterator<QwtPlotCurve> QwtPlotCurveIterator;
00076 typedef QIntDictIterator<QwtPlotMarker> QwtPlotMarkerIterator;
00077
00078 #endif