colormapdatapart.cpp
56 lines
| 1.5 KiB
| text/x-c
|
CppLexer
winter
|
r0 | #include "colormapdatapart.h" | ||
QT_CHARTS_BEGIN_NAMESPACE | ||||
ColorMapDataPart::ColorMapDataPart() | ||||
{ | ||||
} | ||||
ColorMapDataPart::ColorMapDataPart(ColorMapDataPart *dataPart) | ||||
{/* | ||||
QVector<double> *m_timeSeries; | ||||
QVector<double> *m_ySeries; | ||||
QVector<double> *m_dataSeries;*/ | ||||
this->m_dataSeries = new QVector<double>(dataPart->dataSeries()); | ||||
this->m_ySeries = new QVector<double>(dataPart->ySeries()); | ||||
this->m_timeSeries = new QVector<double>(dataPart->timesSeries()); | ||||
} | ||||
ColorMapDataPart::ColorMapDataPart(QVector<double> *timeSeries, QVector<double> *ySeries, QVector<double> *dataSeries) | ||||
: m_timeSeries(timeSeries),m_ySeries(ySeries),m_dataSeries(dataSeries) | ||||
{ | ||||
} | ||||
ColorMapDataPart::~ColorMapDataPart() | ||||
{ | ||||
delete m_dataSeries; | ||||
delete m_ySeries; | ||||
delete m_timeSeries; | ||||
} | ||||
int ColorMapDataPart::find(double val, const QVector<double> &vect, bool more) | ||||
{ | ||||
if(val >=vect.last() && more) | ||||
return vect.count(); | ||||
if(val <= vect.first() && !more) | ||||
return -1; | ||||
int guessedIndex = (val-vect.first())*vect.count()/(vect.last()-vect.first()); | ||||
if(guessedIndex>(vect.count()-1))guessedIndex=vect.count()-1; | ||||
if(more) | ||||
while(vect[guessedIndex]<val){guessedIndex++;} | ||||
else | ||||
while(vect[guessedIndex--]>val){} | ||||
return guessedIndex; | ||||
} | ||||
QPair<int, int> ColorMapDataPart::getRange(const QVector<double> &vect, double start, double stop) | ||||
{ | ||||
return QPair<int, int>(find(start,vect, false),find(stop,vect, true)); | ||||
} | ||||
QT_CHARTS_END_NAMESPACE | ||||