# HG changeset patch # User Chris Cannam # Date 1391711178 0 # Node ID 48410857b03c3f07f8e3c4defeb1db63cee825fa # Parent 12a6140b3ae00bcfbadbd2aad9ef5bf46a9f9381 Add bin-values and bin-value unit to EditableDense3DModel diff -r 12a6140b3ae0 -r 48410857b03c data/model/EditableDenseThreeDimensionalModel.cpp --- a/data/model/EditableDenseThreeDimensionalModel.cpp Thu Feb 06 15:31:16 2014 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Thu Feb 06 18:26:18 2014 +0000 @@ -410,6 +410,37 @@ } bool +EditableDenseThreeDimensionalModel::hasBinValues() const +{ + return !m_binValues.empty(); +} + +float +EditableDenseThreeDimensionalModel::getBinValue(size_t n) const +{ + if (n < m_binValues.size()) return m_binValues[n]; + else return 0.f; +} + +void +EditableDenseThreeDimensionalModel::setBinValues(std::vector values) +{ + m_binValues = values; +} + +QString +EditableDenseThreeDimensionalModel::getBinValueUnit() const +{ + return m_binValueUnit; +} + +void +EditableDenseThreeDimensionalModel::setBinValueUnit(QString unit) +{ + m_binValueUnit = unit; +} + +bool EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const { QReadLocker locker(&m_lock); diff -r 12a6140b3ae0 -r 48410857b03c data/model/EditableDenseThreeDimensionalModel.h --- a/data/model/EditableDenseThreeDimensionalModel.h Thu Feb 06 15:31:16 2014 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.h Thu Feb 06 18:26:18 2014 +0000 @@ -144,6 +144,40 @@ virtual void setBinNames(std::vector names); /** + * Return true if the bins have values as well as names. (The + * values may have been derived from the names, e.g. by parsing + * numbers from them.) If this returns true, getBinValue() may be + * used to retrieve the values. + */ + virtual bool hasBinValues() const; + + /** + * Return the value of bin n, if any. This is a "vertical scale" + * value which does not vary from one column to the next. This is + * only meaningful if hasBinValues() returns true. + */ + virtual float getBinValue(size_t n) const; + + /** + * Set the values of all bins (separate from their labels). These + * are "vertical scale" values which do not vary from one column + * to the next. + */ + virtual void setBinValues(std::vector values); + + /** + * Obtain the name of the unit of the values returned from + * getBinValue(), if any. + */ + virtual QString getBinValueUnit() const; + + /** + * Set the name of the unit of the values return from + * getBinValue() if any. + */ + virtual void setBinValueUnit(QString unit); + + /** * Return true if the distribution of values in the bins is such * as to suggest a log scale (mapping to colour etc) may be better * than a linear one. @@ -179,6 +213,8 @@ Column expandAndRetrieve(size_t index) const; std::vector m_binNames; + std::vector m_binValues; + QString m_binValueUnit; size_t m_startFrame; size_t m_sampleRate;