Mercurial > hg > svcore
changeset 1252:2ff5e411151d 3.0-integration
Ensure columns all have correct height when retrieved (to avoid e.g. empty columns because a feature extractor's start time was >0)
author | Chris Cannam |
---|---|
date | Fri, 04 Nov 2016 16:01:37 +0000 |
parents | 67aee57e32c8 |
children | 303039dd9e05 |
files | data/model/EditableDenseThreeDimensionalModel.cpp data/model/EditableDenseThreeDimensionalModel.h |
diffstat | 2 files changed, 24 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/data/model/EditableDenseThreeDimensionalModel.cpp Fri Nov 04 14:57:03 2016 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Fri Nov 04 16:01:37 2016 +0000 @@ -265,6 +265,17 @@ } EditableDenseThreeDimensionalModel::Column +EditableDenseThreeDimensionalModel::rightHeight(const Column &c) const +{ + if (int(c.size()) == m_yBinCount) return c; + else { + Column cc(c); + cc.resize(m_yBinCount, 0.0); + return cc; + } +} + +EditableDenseThreeDimensionalModel::Column EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const { // See comment above m_trunc declaration in header @@ -272,11 +283,11 @@ assert(index >= 0 && index < int(m_data.size())); Column c = m_data.at(index); if (index == 0) { - return c; + return rightHeight(c); } int trunc = (int)m_trunc[index]; if (trunc == 0) { - return c; + return rightHeight(c); } bool top = true; int tdist = trunc; @@ -316,8 +327,6 @@ bool allChange = false; -// if (values.size() > m_yBinCount) m_yBinCount = values.size(); - for (int i = 0; in_range_for(values, i); ++i) { float value = values[i]; if (ISNAN(value) || ISINF(value)) {
--- a/data/model/EditableDenseThreeDimensionalModel.h Fri Nov 04 14:57:03 2016 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.h Fri Nov 04 16:01:37 2016 +0000 @@ -44,7 +44,7 @@ EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate, int resolution, - int yBinCount, + int height, CompressionType compression, bool notifyOnAdd = true); @@ -75,12 +75,19 @@ virtual int getWidth() const; /** - * Return the number of bins in each set of bins. + * Return the number of bins in each column. */ virtual int getHeight() const; /** - * Set the number of bins in each set of bins. + * Set the number of bins in each column. + * + * You can set (via setColumn) a vector of any length as a column, + * but any column being retrieved will be resized to this height + * (or the height that was supplied to the constructor, if this is + * never called) on retrieval. That is, the model owner determines + * the height of the model at a single stroke; the columns + * themselves don't have any effect on the height of the model. */ virtual void setHeight(int sz); @@ -203,6 +210,7 @@ std::vector<signed char> m_trunc; void truncateAndStore(int index, const Column & values); Column expandAndRetrieve(int index) const; + Column rightHeight(const Column &c) const; std::vector<QString> m_binNames; std::vector<float> m_binValues;