Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

qwt_plot_dict.h

Go to the documentation of this file.
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
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 //   Template classes used by QwtPlot
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         // first primes bigger than 1<<n for n = 2, 3, .., 15
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

Generated on Fri Nov 7 14:11:45 2003 for Qwt Developer's Guide by doxygen 1.3.2