Mercurial > hg > svcore
comparison data/model/SparseValueModel.h @ 256:9c85517ff0f5
* Fix #1706927 NaNs from plugin outputs should not be used
author | Chris Cannam |
---|---|
date | Fri, 27 Apr 2007 15:39:48 +0000 |
parents | 4b2ea82fd0ed |
children | 46398ab6ff58 |
comparison
equal
deleted
inserted
replaced
255:7033e188b2b2 | 256:9c85517ff0f5 |
---|---|
28 template <typename PointType> | 28 template <typename PointType> |
29 class SparseValueModel : public SparseModel<PointType> | 29 class SparseValueModel : public SparseModel<PointType> |
30 { | 30 { |
31 public: | 31 public: |
32 SparseValueModel(size_t sampleRate, size_t resolution, | 32 SparseValueModel(size_t sampleRate, size_t resolution, |
33 bool notifyOnAdd = true) : | |
34 SparseModel<PointType>(sampleRate, resolution, notifyOnAdd), | |
35 m_valueMinimum(0.f), | |
36 m_valueMaximum(0.f), | |
37 m_haveExtents(false) | |
38 { } | |
39 | |
40 SparseValueModel(size_t sampleRate, size_t resolution, | |
33 float valueMinimum, float valueMaximum, | 41 float valueMinimum, float valueMaximum, |
34 bool notifyOnAdd = true) : | 42 bool notifyOnAdd = true) : |
35 SparseModel<PointType>(sampleRate, resolution, notifyOnAdd), | 43 SparseModel<PointType>(sampleRate, resolution, notifyOnAdd), |
36 m_valueMinimum(valueMinimum), | 44 m_valueMinimum(valueMinimum), |
37 m_valueMaximum(valueMaximum) | 45 m_valueMaximum(valueMaximum), |
46 m_haveExtents(true) | |
38 { } | 47 { } |
39 | 48 |
40 using SparseModel<PointType>::m_points; | 49 using SparseModel<PointType>::m_points; |
41 using SparseModel<PointType>::modelChanged; | 50 using SparseModel<PointType>::modelChanged; |
42 | 51 |
50 } | 59 } |
51 | 60 |
52 virtual void addPoint(const PointType &point) | 61 virtual void addPoint(const PointType &point) |
53 { | 62 { |
54 bool allChange = false; | 63 bool allChange = false; |
55 if (m_points.empty() || point.value < m_valueMinimum) { | 64 |
56 m_valueMinimum = point.value; allChange = true; | 65 if (!isnan(point.value) && !isinf(point.value)) { |
57 } | 66 if (!m_haveExtents || point.value < m_valueMinimum) { |
58 if (m_points.empty() || point.value > m_valueMaximum) { | 67 m_valueMinimum = point.value; allChange = true; |
59 m_valueMaximum = point.value; allChange = true; | 68 } |
60 } | 69 if (!m_haveExtents || point.value > m_valueMaximum) { |
70 m_valueMaximum = point.value; allChange = true; | |
71 } | |
72 m_haveExtents = true; | |
73 } | |
61 | 74 |
62 SparseModel<PointType>::addPoint(point); | 75 SparseModel<PointType>::addPoint(point); |
63 if (allChange) emit modelChanged(); | 76 if (allChange) emit modelChanged(); |
64 } | 77 } |
65 | 78 |
101 } | 114 } |
102 | 115 |
103 protected: | 116 protected: |
104 float m_valueMinimum; | 117 float m_valueMinimum; |
105 float m_valueMaximum; | 118 float m_valueMaximum; |
119 bool m_haveExtents; | |
106 QString m_units; | 120 QString m_units; |
107 }; | 121 }; |
108 | 122 |
109 | 123 |
110 #endif | 124 #endif |