# HG changeset patch # User Chris Cannam # Date 1478342501 0 # Node ID ca9032dd28118165ae662063779203417b731786 # Parent 303039dd9e05770cd45e51741b383e0c21b53b8e# Parent cbdd534f517aa13d1df9fac1e415ebfd7d6f460c Merge from branch piper diff -r cbdd534f517a -r ca9032dd2811 base/ColumnOp.h --- a/base/ColumnOp.h Sat Nov 05 10:40:22 2016 +0000 +++ b/base/ColumnOp.h Sat Nov 05 10:41:41 2016 +0000 @@ -194,9 +194,9 @@ int by0 = int(sy0 + 0.0001); int by1 = int(sy1 + 0.0001); if (by1 < by0 + 1) by1 = by0 + 1; - if (by1 >= bins) by1 = by1 - 1; + if (by1 >= bins) by1 = bins - 1; - for (int bin = by0; bin < by1; ++bin) { + for (int bin = by0; bin <= by1; ++bin) { float value = in[bin]; diff -r cbdd534f517a -r ca9032dd2811 data/model/EditableDenseThreeDimensionalModel.cpp --- a/data/model/EditableDenseThreeDimensionalModel.cpp Sat Nov 05 10:40:22 2016 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Sat Nov 05 10:41:41 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)) { diff -r cbdd534f517a -r ca9032dd2811 data/model/EditableDenseThreeDimensionalModel.h --- a/data/model/EditableDenseThreeDimensionalModel.h Sat Nov 05 10:40:22 2016 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.h Sat Nov 05 10:41:41 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 m_trunc; void truncateAndStore(int index, const Column & values); Column expandAndRetrieve(int index) const; + Column rightHeight(const Column &c) const; std::vector m_binNames; std::vector m_binValues;