12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include "valueindicator.h"
- #include <limits>
- #include <cmath>
- #include <QDebug>
- ValueIndicator::ValueIndicator(ValueIndicatorDense *dense) : QObject()
- , m_value(0)
- , m_dense(dense)
- {
- }
- qreal ValueIndicator::value() const
- {
- return (m_value - m_dense->min())/(m_dense->max() - m_dense->min());
- }
- ValueIndicatorDense::ValueIndicatorDense(int rows, int columns, const QList<ValueIndicator*>& data) : AbstractDense(rows, columns, data)
- , m_max(std::numeric_limits<double>::min())
- , m_min(std::numeric_limits<double>::max())
- {
- }
- void ValueIndicatorDense::updateValues(const Dense& dense)
- {
- m_max = std::numeric_limits<double>::min();
- m_min = std::numeric_limits<double>::max();
- int i = 0;
- for (auto value : m_data) {
- double val = dense.rawValue(i);
- if (val > m_max) {
- m_max = val;
- }
- if (val < m_min) {
- m_min = val;
- }
- value->setValue(val);
- i++;
- }
- }
- ValueIndicatorDense::~ValueIndicatorDense()
- {
- qDeleteAll(m_data);
- }
|