Rev 646 | Rev 648 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 646 | Rev 647 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | 10 | ||
11 | class LayeredGridBase
|
11 | class LayeredGridBase
|
12 | {
|
12 | {
|
13 | public: |
13 | public: |
14 | // access to properties
|
14 | // access to properties
|
15 | int sizeX() const; |
15 | virtual int sizeX() const=0; |
16 | int sizeY() const; |
16 | virtual int sizeY() const=0; |
17 | QRectF metricRect() const; |
17 | virtual QRectF metricRect() const=0; |
- | 18 | virtual QRectF cellRect(const QPoint &p) const=0; |
|
18 | // available variables
|
19 | // available variables
|
19 | virtual const QStringList names() const=0; |
20 | virtual const QStringList names() const=0; |
20 | // statistics
|
21 | // statistics
|
21 | /// retrieve min and max of variable 'index'
|
22 | /// retrieve min and max of variable 'index'
|
22 | void range(double &rMin, double &rMax, const int index); |
23 | virtual void range(double &rMin, double &rMax, const int index) const=0; |
23 | 24 | ||
24 | // data access functions
|
25 | // data access functions
|
25 | double value(const float x, const float y, const int index) const; |
26 | virtual double value(const float x, const float y, const int index) const = 0; |
- | 27 | virtual double value(const int ix, const int iy, const int index) const = 0; |
|
26 | double value(const int grid_index, const int index) const; |
28 | virtual double value(const int grid_index, const int index) const = 0; |
27 | }; |
29 | }; |
28 | 30 | ||
29 | template <class T> |
31 | template <class T> |
30 | class LayeredGrid: public LayeredGridBase |
32 | class LayeredGrid: public LayeredGridBase |
31 | {
|
33 | {
|
32 | public: |
34 | public: |
33 | LayeredGrid(const Grid<T>& grid) { mGrid = &grid; } |
35 | LayeredGrid(const Grid<T>& grid) { mGrid = &grid; } |
34 | LayeredGrid() { mGrid = 0; } |
36 | LayeredGrid() { mGrid = 0; } |
- | 37 | QRectF cellRect(const QPoint &p) const { return mGrid->cellRect(p); } |
|
- | 38 | QRectF metricRect() const { return mGrid->metricRect(); } |
|
- | 39 | int sizeX() const { return mGrid->sizeX(); } |
|
- | 40 | int sizeY() const { return mGrid->sizeY();} |
|
- | 41 | ||
35 | double value(const T& data, const int index) const; |
42 | virtual double value(const T& data, const int index) const = 0; |
36 | double value(const T* ptr, const int index) const { return value(mGrid->constValueAtIndex(mGrid->indexOf(ptr)), index); } |
43 | double value(const T* ptr, const int index) const { return value(mGrid->constValueAtIndex(mGrid->indexOf(ptr)), index); } |
37 | double value(const int grid_index, const int index) const { return value(mGrid->constValueAtIndex(grid_index), index); } |
44 | double value(const int grid_index, const int index) const { return value(mGrid->constValueAtIndex(grid_index), index); } |
38 | double value(const float x, const float y, const int index) const { return value(mGrid->constValueAt(x,y), index); } |
45 | double value(const float x, const float y, const int index) const { return value(mGrid->constValueAt(x,y), index); } |
- | 46 | double value(const int ix, const int iy, const int index) const { return value(mGrid->constValueAtIndex(ix, iy), index); } |
|
39 | void range(double &rMin, double &rMax, const int index) { rMin=9999999999.; rMax=-99999999999.; |
47 | void range(double &rMin, double &rMax, const int index) const { rMin=9999999999.; rMax=-99999999999.; |
40 | for (int i=0;i<mGrid->count(); ++i) { |
48 | for (int i=0;i<mGrid->count(); ++i) { |
41 | rMin=qMin(rMin, value(i, index)); |
49 | rMin=qMin(rMin, value(i, index)); |
42 | rMax=qMax(rMax, value(i,index));}} |
50 | rMax=qMax(rMax, value(i,index));}} |
43 | 51 | ||
44 | protected: |
52 | protected: |