Rev 38 | Rev 40 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 38 | Rev 39 | ||
---|---|---|---|
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/stampcontainer.h': |
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/stampcontainer.h': |
2 | #ifndef STAMPCONTAINER_H
|
2 | #ifndef STAMPCONTAINER_H
|
3 | #define STAMPCONTAINER_H
|
3 | #define STAMPCONTAINER_H
|
4 | 4 | ||
5 | #include "stamp.h"
|
5 | #include "stamp.h"
|
6 | #include "grid.h"
|
6 | #include "grid.h"
|
7 | 7 | ||
8 | /** Collection of @class Stamp for one tree species.
|
8 | /** Collection of @class Stamp for one tree species.
|
9 | Per species several stamps are stored (different BHD, different HD relations). This class
|
9 | Per species several stamps are stored (different BHD, different HD relations). This class
|
10 | encapsulates storage and access to these stamps. The design goal is to deliver high
|
10 | encapsulates storage and access to these stamps. The design goal is to deliver high
|
11 | access speeds for the "stamp()" method.
|
11 | access speeds for the "stamp()" method.
|
12 | Use getStamp(bhd, hd) or getStamp(bhd, height) to access. */
|
12 | Use getStamp(bhd, hd) or getStamp(bhd, height) to access. */
|
13 | class StampContainer
|
13 | class StampContainer
|
14 | {
|
14 | {
|
15 | public: |
15 | public: |
16 | StampContainer(); |
16 | StampContainer(); |
17 | ~StampContainer(); |
17 | ~StampContainer(); |
18 | void useLookup(const bool use) { m_useLookup = use; } |
18 | void useLookup(const bool use) { m_useLookup = use; } |
19 | /// addStamp() add a pre-allocated stamp @param stamp to internal collection. Caller must allocate stamp on the heap,
|
19 | /// addStamp() add a pre-allocated stamp @param stamp to internal collection. Caller must allocate stamp on the heap,
|
20 | /// freeing is done by this class.
|
20 | /// freeing is done by this class.
|
21 | int addStamp(Stamp* stamp, const float bhd, const float hd_value); |
21 | int addStamp(Stamp* stamp, const float bhd, const float hd_value); |
22 | const Stamp* stamp(const float bhd_cm, const float height_m); |
- | |
- | 22 | const Stamp* stamp(const float bhd_cm, const float height_m) const; |
|
- | 23 | const int count() const { return m_stamps.count(); } |
|
23 | /// save the content of the StampContainer to the output stream (binary encoding)
|
24 | /// save the content of the StampContainer to the output stream (binary encoding)
|
24 | void save(QDataStream &out); |
25 | void save(QDataStream &out); |
25 | /// load the content of the StampContainer to the output stream (binary encoding)
|
26 | /// load the content of the StampContainer to the output stream (binary encoding)
|
26 | void load(QDataStream &in); |
27 | void load(QDataStream &in); |
27 | 28 | ||
28 | /** factory creation function for stamps of different size.
|
29 | /** factory creation function for stamps of different size.
|
29 | newStamp() creates new Stamp-Objects on the heap with a given type (see @enum Stamp::StampType).*/
|
30 | newStamp() creates new Stamp-Objects on the heap with a given type (see @enum Stamp::StampType).*/
|
30 | static Stamp* newStamp(const Stamp::StampType type); |
31 | static Stamp* newStamp(const Stamp::StampType type); |
31 | 32 | ||
32 | QString dump(); |
33 | QString dump(); |
33 | 34 | ||
34 | private: |
35 | private: |
35 | static const int cBHDclassWidth; |
36 | static const int cBHDclassWidth; |
36 | static const int cHDclassWidth; |
37 | static const int cHDclassWidth; |
37 | static const int cBHDclassLow; ///< bhd classes start with 2: class 0 = 2..6, class1 = 6..10 |
38 | static const int cBHDclassLow; ///< bhd classes start with 2: class 0 = 2..6, class1 = 6..10 |
38 | static const int cHDclassLow; ///< hd classes offset is 40: class 0 = 40-50, class 1 = 50-60 |
39 | static const int cHDclassLow; ///< hd classes offset is 40: class 0 = 40-50, class 1 = 50-60 |
39 | static const int cBHDclassCount; ///< class count, 50: highest class = 50*4 +- 2 = 198 - 202 |
40 | static const int cBHDclassCount; ///< class count, 50: highest class = 50*4 +- 2 = 198 - 202 |
40 | static const int cHDclassCount; ///< class count. highest class: 140-150 |
41 | static const int cHDclassCount; ///< class count. highest class: 140-150 |
41 | struct StampItem { |
42 | struct StampItem { |
42 | Stamp* stamp; |
43 | Stamp* stamp; |
43 | float bhd; |
44 | float bhd; |
44 | float hd; |
45 | float hd; |
45 | }; |
46 | }; |
46 | inline int getKey(const float bhd, const float hd_value); |
47 | inline int getKey(const float bhd, const float hd_value); |
47 | int m_maxBhd; |
48 | int m_maxBhd; |
48 | bool m_useLookup; // use lookup table? |
49 | bool m_useLookup; // use lookup table? |
49 | QList<StampItem> m_stamps; |
50 | QList<StampItem> m_stamps; |
50 | Grid<Stamp*> m_lookup; |
51 | Grid<Stamp*> m_lookup; |
51 | }; |
52 | }; |
52 | 53 | ||
53 | #endif // STAMPCONTAINER_H
|
54 | #endif // STAMPCONTAINER_H
|
54 | 55 |