18#include <swabstractbarwidget.h>
38 QStringList list {
"#010130",
"#20014e",
"#0C0786",
"#40039C",
39 "#6A00A7",
"#8F0DA3",
"#B02A8F",
"#CA4678",
40 "#E06461",
"#F1824C",
"#FCA635",
"#FCCC25",
41 "#FFEE00",
"#EFF821" };
43 setColorRange( list );
44 _valueList.resize( list.length() );
45 _maxNumBarsBlocks = _numBars = _numBlocks = list.length();
130 Q_ASSERT( bars > 0 );
154 Q_ASSERT( blocks > 0 );
192 Q_ASSERT( newvalue >= _minValue );
193 Q_ASSERT( newvalue <= _maxValue );
204 Q_ASSERT( rangeFrom >= 0 );
205 Q_ASSERT( rangeFrom < rangeTo );
206 _rangeFrom = rangeFrom;
211void SWAbstractBarWidget::calcSizeRatio()
213 _sizeRatio = (double) _numBlocks / (
double) _maxNumBarsBlocks;
217QColor SWAbstractBarWidget::getBlockColor(
int x,
int y )
219 int virtIdx = _gradientMode ? _numBlocks - 1 - y : x ;
220 int realIdx = (int) ( (
double) virtIdx / _sizeRatio );
221 return _colors[ realIdx ];
236 double testvalue = qBound( _rangeFrom, newvalue, _rangeTo ) / 1000.0 * _value;
237 qDebug() <<
"SWAbstractBarWidget::onDialValueChanged" << newvalue <<
": " << testvalue;
239 if( testvalue == _value )
247void SWAbstractBarWidget::clearValueList()
250 _valueList.resize( _numBars );
254void SWAbstractBarWidget::onValueListChanged(
const SWDoubleVec& freshdata )
256 _valueList = freshdata;
257 _valueList.resize( _numBars );
263void SWAbstractBarWidget::setColorRange(
const QStringList& colorlist )
265 Q_ASSERT( !colorlist.empty() );
268 for(
const QString& color : colorlist )
269 _colors.append( QColor( color ) );
270 _maxNumBarsBlocks = _numBars = _numBlocks =_colors.size();
274void SWAbstractBarWidget::setColorRange(
const SWColorVec& colorlist )
276 Q_ASSERT( !colorlist.empty() );
279 for(
const QColor& color : colorlist )
280 _colors.append( color );
281 _maxNumBarsBlocks = _numBars = _numBlocks =_colors.size();