##// END OF EJS Templates
fix painting coordinates and added LGPL
fix painting coordinates and added LGPL

File last commit:

r7:a8e6b5a8e8d0 tip default
r7:a8e6b5a8e8d0 tip default
Show More
colormapdatapart.cpp
78 lines | 2.6 KiB | text/x-c | CppLexer
/*------------------------------------------------------------------------------
-- This file is a part of the ColorMapChart API
-- Copyright (C) 2016, Plasma Physics Laboratory - CNRS
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Hugo Winter
-- Mail : hugo.winter@lpp.polytechnique.fr
----------------------------------------------------------------------------*/
#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