Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 066583bb authored by sarrazij's avatar sarrazij
Browse files

FIXED: std:: methods are properly called

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@644 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 68952b4a
......@@ -193,15 +193,15 @@ void convertMml::plotMonitor()
if ( ui->mmlRadioButton->isChecked() ) {
if ( ui->monitorListWidget->count() !=0 ) {
// First stage is to compute a csv from ./mml2csv with files in the box above
list <dataMonitoredList> monitors;
std::list <dataMonitoredList> monitors;
for ( int i = 0; i< ui->monitorListWidget->count(); i++ ) {
monitors.push_back ( dataMonitoredList ( ui->monitorListWidget->item ( i )->text().toStdString() ) );
}
list<string> mmlFiles;
std::list<std::string> mmlFiles;
for ( int j = 0; j< ui->mmlListWidget->count(); j++ ) {
mmlFiles.push_back ( ui->mmlListWidget->item ( j )->text().toStdString() );
}
string output= "untitled.csv";
std::string output= "untitled.csv";
if ( !ui->saveMonitorslineEdit->text().isEmpty() ) {
output = ui->saveMonitorslineEdit->text().toStdString();
} else {
......@@ -220,7 +220,7 @@ void convertMml::plotMonitor()
}
//Now we can plotting with the qcustomplot library and ./csv2plot
// csv2Plot plot ;
list<string> liste;
std::list<std::string> liste;
liste.push_back ( ui->plotComboBox->currentText().toStdString() );
csv2Plot plot ( inputFile.toStdString(),liste );
ui->customPlot->clearPlottables();
......@@ -278,15 +278,15 @@ void convertMml::generateCommandLines()
//---------------generateCsvFile---------------------------------------------------------
void convertMml::generateCsvFile()
{
string saveMMLFile= ui->saveMonitorslineEdit->text().toStdString();
std::string saveMMLFile= ui->saveMonitorslineEdit->text().toStdString();
if ( ui->mmlListWidget->count() != 0 ) {
// Case where ./mml2csv must be launch first
if ( ui->mmlRadioButton->isChecked() ) {
list <dataMonitoredList> monitors;
std::list <dataMonitoredList> monitors;
for ( int i = 0; i< ui->monitorListWidget->count(); i++ ) {
monitors.push_back ( dataMonitoredList ( ui->monitorListWidget->item ( i )->text().toStdString() ) );
}
list<string> mmlFiles;
std::list<std::string> mmlFiles;
for ( int j = 0; j< ui->mmlListWidget->count(); j++ ) {
mmlFiles.push_back ( ui->mmlListWidget->item ( j )->text().toStdString() );
}
......@@ -302,12 +302,12 @@ void convertMml::generateCsvFile()
saveMMLFile=ui->mmlListWidget->item ( 0 )->text().toStdString();
}
// get a list where stats name are saved
list<string> statsName;
std::list<std::string> statsName;
for ( int i =0; i< ui->statsListWidget->count(); i++ ) {
statsName.push_back ( ( ui->statsListWidget->item ( i )->text() ).toStdString() );
}
// compute statistics
string output ="untitledSTATS.csv";
std::string output ="untitledSTATS.csv";
if ( !ui->saveStatsLineEdit->text().isEmpty() ) {
output = ui->saveStatsLineEdit->text().toStdString();
} else {
......
......@@ -34,17 +34,16 @@
#include <fstream>
#include <complex>
#include <stdlib.h>
#include <vector>
#include "plotWindow.h"
#include <bits/stl_algo.h>
//--------Constructor----------------------------------------------------------------------
csv2Plot::csv2Plot(string file, list< string > whichPlot, list< dataMonitoredList > results): csv2Sthing(file, whichPlot, results)
csv2Plot::csv2Plot(std::string file, std::list< std::string > whichPlot, std::list< dataMonitoredList > results): csv2Sthing(file, whichPlot, results)
{
}
//------------constructor----------------------------------------------------
csv2Plot::csv2Plot(string file, list< string > whichPlot): csv2Sthing(file, whichPlot)
csv2Plot::csv2Plot(std::string file, std::list< std::string > whichPlot): csv2Sthing(file, whichPlot)
{
}
......@@ -55,10 +54,10 @@ csv2Plot::~csv2Plot() {
//-------------drawMeMyPlots-----------------------------------------------------------
void csv2Plot::drawMeMyPlots()
{
list<dataMonitoredList> monitoredValues =results;
std::list<dataMonitoredList> monitoredValues =results;
// Iterator
list<dataMonitoredList>::iterator listDataResults;
list<string>::iterator plotName;
std::list<dataMonitoredList>::iterator listDataResults;
std::list<std::string>::iterator plotName;
// for each type of given plot
for (plotName=item.begin(); plotName!= item.end();plotName++) {
......@@ -72,7 +71,7 @@ void csv2Plot::drawMeMyPlots()
} else if ((*plotName)=="BARCHART") {
drawBarChart(p->getCustomPlot(),(*listDataResults).getMonitorName());
}
string title = (*listDataResults).getMonitorName()+"-"+(*plotName);
std::string title = (*listDataResults).getMonitorName()+"-"+(*plotName);
p->getCustomPlot()->replot();
p->setWindowTitle(QString(title.c_str()));
p->show();
......@@ -81,15 +80,15 @@ void csv2Plot::drawMeMyPlots()
}
//--------------drawBarChart-------------------------------------------------------------
bool csv2Plot::drawBarChart(QCustomPlot *plot, string monitor)
bool csv2Plot::drawBarChart(QCustomPlot *plot, std::string monitor)
{
list<dataMonitoredList>::iterator listDR =results.begin();
std::list<dataMonitoredList>::iterator listDR =results.begin();
while (listDR != results.end()) {
if ((*listDR).getMonitorName() == monitor) {
// create empty bar chart objects:
QCPBars *dataToMonitor= new QCPBars(plot->xAxis, plot->yAxis);
plot->addPlottable(dataToMonitor);
vector<double> v= (*listDR).getResultData();
std::vector<double> v= (*listDR).getResultData();
//calculate number of classes k=1+ (10*log(size)/3)
double k = 1 + (10 * log10((*listDR).getResultData().size())/3);
......@@ -107,14 +106,13 @@ bool csv2Plot::drawBarChart(QCustomPlot *plot, string monitor)
QVector<double> xData (k,0);
QVector<double> yData(k,0);
QVector<double>::iterator ite;
double sup,inf = 0.0;
for (int i =0; i<k ; i++) {
inf = (*listDR).getMin() + (i*h);
sup = (*listDR).getMin()+((i+1)*h);
xData[i]=(inf+sup)/2.0;
vector<double>::iterator ite;
std::vector<double>::iterator ite;
for (ite = v.begin(); ite != v.end();ite++) {
if ((*ite >= inf) && (*ite < sup)) {
yData[i] += 1;
......@@ -137,7 +135,7 @@ bool csv2Plot::drawBarChart(QCustomPlot *plot, string monitor)
plot->xAxis->setAutoSubTicks(false);
plot->xAxis->setSubTickCount(9);
// setup Y-Axis:
int max = (int)*max_element(yData.begin(),yData.end());
int max = (int)*std::max_element(yData.begin(),yData.end());
plot->yAxis->setRange(0, max+1);
plot->yAxis->setAutoTickStep(false);
plot->yAxis->setTickStep(1);
......@@ -168,9 +166,9 @@ bool csv2Plot::drawBarChart(QCustomPlot *plot, string monitor)
//-------------drawBox-------------------------------------
bool csv2Plot::drawBoxChart(QCustomPlot *plot, string monitor)
bool csv2Plot::drawBoxChart(QCustomPlot *plot, std::string monitor)
{
list<dataMonitoredList>::iterator listDR =results.begin();
std::list<dataMonitoredList>::iterator listDR =results.begin();
while (listDR != results.end()) {
if ((*listDR).getMonitorName() == monitor) {
// create empty statistical box plottables:
......@@ -185,11 +183,11 @@ bool csv2Plot::drawBoxChart(QCustomPlot *plot, string monitor)
sample1->setLowerQuartile((*listDR).firstQuartile());
sample1->setMedian((*listDR).median());
sample1->setUpperQuartile((*listDR).thirdQuartile());
vector<double> v = (*listDR).outliers();
std::vector<double> v = (*listDR).outliers();
int up=0,down = 0;
if (v.size()>0) {
sample1->setOutliers(QVector<double>::fromStdVector(v));
for (vector<double>::iterator it = v.begin(); it != v.end();it++) {
for (std::vector<double>::iterator it = v.begin(); it != v.end();it++) {
if (*it < (*listDR).firstQuartile()) {
down++;
} else if (*it > (*listDR).thirdQuartile()) {
......@@ -198,7 +196,7 @@ bool csv2Plot::drawBoxChart(QCustomPlot *plot, string monitor)
}
}
vector<double> temp = (*listDR).getResultData();
std::vector<double> temp = (*listDR).getResultData();
std::sort(temp.begin(),temp.end());
if (up!=0) {
int val = temp.size()-up-1;
......
......@@ -52,23 +52,23 @@ public:
/**
* Constructor
* @param file path+filename where csv file is
* @param whichPlot list which contains plot to draw
* @param results list of @see dataMonitoredList
* @param whichPlot std::list which contains plot to draw
* @param results std::list of @see dataMonitoredList
*/
csv2Plot(string file, list<string> whichPlot, list<dataMonitoredList> results);
csv2Plot(std::string file, std::list<std::string> whichPlot, std::list<dataMonitoredList> results);
/**
* Constructor
* @param file path+filename where csv file is
* @param whichPlot list which contains plot to draw
* @param whichPlot std::list which contains plot to draw
*/
csv2Plot(string file, list<string> whichPlot);
csv2Plot(std::string file, std::list<std::string> whichPlot);
/// destructor
virtual ~csv2Plot();
/**
* method to call the method allowing to draw a kind of plot.
* @param data list of data to display
* @param data std::list of data to display
*/
void drawMeMyPlots();
......@@ -78,7 +78,7 @@ public:
* @param monitor which monitor will be plotted
* @return true if success, false otherwise
*/
bool drawBarChart (QCustomPlot *plot, string monitor);
bool drawBarChart (QCustomPlot *plot, std::string monitor);
/**
* Allows to draw a box chart.
......@@ -86,7 +86,7 @@ public:
* @param monitor which monitor will be plotted
* @return true if success, false otherwise
*/
bool drawBoxChart (QCustomPlot *plot, string monitor);
bool drawBoxChart (QCustomPlot *plot, std::string monitor);
};
......
......@@ -226,9 +226,9 @@ double csv2StatsVal::statsCalculation(string name,vector< double > l)
return RMSCalculationExact(l);
} else if ((name)=="RMS") {
return RMSCalculation(l);
} else {
cout<<"ERROR: "<<(name)<<" is not yet implemented !"<<endl;
}
cout<<"ERROR: "<<(name)<<" is not yet implemented !"<<endl;
return 0.0;
}
......
......@@ -32,8 +32,6 @@
#ifndef CSV2STATSVAL_H
#define CSV2STATSVAL_H
#include <string>
#include <list>
#include "../../mml2Csv/dataMonitoredList.h"
#include "../csv2Sthing.h"
......@@ -52,14 +50,14 @@ public:
* @param statsName list of given stats to compute
* @param results list of @see dataMonitoredList
*/
csv2StatsVal(string saveFile, string file, list<string> statsName, list<dataMonitoredList> results);
csv2StatsVal(std::string saveFile, std::string file, std::list<std::string> statsName, std::list<dataMonitoredList> results);
/**
* Constructor
* @param saveFile path where the stats csv file will be saved
* @param file path to the input csv file @see mml2Csv
* @param statsName list of given stats to compute
*/
csv2StatsVal(string saveFile, string file, list<string> statsName);
csv2StatsVal(std::string saveFile, std::string file, std::list<std::string> statsName);
/// destructor
virtual ~csv2StatsVal();
......@@ -69,38 +67,38 @@ public:
* WARNING: use this method when you're initial values in mml are not exact (Apparent error is calculated)
* @param l data vector
*/
double RMSCalculation(vector<double> l);
double RMSCalculation(std::vector<double> l);
/**
* generate the rms error of a given data list.
* WARNING: use this method when you're initial values in mml are exact (Real Error is calculated)
* @param l data vector
*/
double RMSCalculationExact(vector<double> l);
double RMSCalculationExact(std::vector<double> l);
/**
* generate the mean error of a given data list
* @param l data vector
*/
double mean(vector<double> l);
double mean(std::vector<double> l);
/**
* find the max error in a given list
* @param l the data vector
*/
double getMax(vector<double> l);
double getMax(std::vector<double> l);
/**
* find the min error in a given list
* @param l the data vector
*/
double getMin(vector<double> l);
double getMin(std::vector<double> l);
/**
* find the standard deviation of a given list
* @param l the data vector
*/
double standardDeviation(vector<double> l);
double standardDeviation(std::vector<double> l);
/**
* Allows you to write some stats in a csv file @param saveFile to a csv file @param filename.
......@@ -109,7 +107,7 @@ public:
* @param statsName name of the stats to calculate
* @param values object type @class dataMonitoredList which contains all data to calculate stats.
*/
void writeStatsCSV(string filename, string saveFile, list<string>statsName,list<dataMonitoredList> values );
void writeStatsCSV(std::string filename, std::string saveFile, std::list<std::string>statsName,std::list<dataMonitoredList> values );
/**
* Allows to write computed statistics as a text
......@@ -117,29 +115,29 @@ public:
* @param statsName statistics will be computed
* @param values values which allow to compute statistics
*/
void writeStatsText(string filename, list<string>statsName, list<dataMonitoredList> values );
void writeStatsText(std::string filename, std::list<std::string>statsName, std::list<dataMonitoredList> values );
/**
* Get the results as text
* @return results in pre-formated string
*/
string getResultsAsText();
std::string getResultsAsText();
/**
* Set the string which contains results under a simple pre-formated text
* @param file the new text
*/
void setResultsAsText(string file);
void setResultsAsText(std::string file);
private:
/// path where generated csv file will be saved
string saveFile;
std::string saveFile;
/// method to match the name of a stat with its method.
double statsCalculation(string name, std::vector< double > l);
double statsCalculation(std::string name, std::vector< double > l);
/// string which contains results in csv format
string resultsAsText;
std::string resultsAsText;
};
......
......@@ -58,7 +58,7 @@ csv2Sthing::~csv2Sthing()
}
//------------------------------------getResultsData--------------------------------------------------
list< dataMonitoredList > csv2Sthing::getResultsData()
std::list< dataMonitoredList > csv2Sthing::getResultsData()
{
return results;
}
......@@ -67,30 +67,30 @@ return results;
//-----------------------------------------------------------------------------createDataMonitoredList----
std::list< dataMonitoredList, std::allocator< dataMonitoredList > > csv2Sthing::createDataMonitoredList()
{
std::istringstream stm;
std::stringstream stm;
double d;
string line;
std::string line;
//open the csv file
ifstream myfile (file.c_str());
vector<double> tempResults;
list<dataMonitoredList> list;
string tempName ="";
string parser="";
std::ifstream myfile (file.c_str());
std::vector<double> tempResults;
std::list<dataMonitoredList> list;
std::string tempName ="";
std::string parser="";
if (myfile.is_open())
{
while ( myfile.good() )
{
//get the current line in the csv file
getline (myfile,line);
std::getline (myfile,line);
//get the name of the monitor
if (line.length()!=0) {
tempName = line.substr(0,line.find_first_of(","));
//get values after the monitor
parser=line.substr(line.find_first_of(",")+1);
//search the next "," in the line
size_t j=parser.find_first_of(",");
std::size_t j=parser.find_first_of(",");
while (j!=string::npos) {
while (j!=std::string::npos) {
stm.str(parser.substr(0,j));
stm >> d;
tempResults.push_back(d);
......@@ -107,7 +107,7 @@ std::list< dataMonitoredList, std::allocator< dataMonitoredList > > csv2Sthing::
myfile.close();
}
else {
cerr<<"Warning: Cannot open the file !"<<endl;
std::cerr<<"Warning: Cannot open the file !"<<std::endl;
}
return list;
}
......@@ -32,9 +32,8 @@
#ifndef CSV2STHING_H
#define CSV2STHING_H
#include <string>
#include <list>
#include "../mml2Csv/dataMonitoredList.h"
#include <list>
/**
* Generic class to construct objects from csv file.
......@@ -45,24 +44,24 @@ class csv2Sthing {
public:
/// constructor
csv2Sthing(string file, list<string> item, list<dataMonitoredList> results);
csv2Sthing(std::string file, std::list<std::string> item, std::list<dataMonitoredList> results);
/// constructor
csv2Sthing(string file, list<string> item);
csv2Sthing(std::string file, std::list<std::string> item);
/// destructor
virtual ~csv2Sthing();
/**
* Get data from a @class dataMonitoredList
*/
list<dataMonitoredList> getResultsData();
std::list<dataMonitoredList> getResultsData();
protected:
list<string> item;
list<dataMonitoredList> results;
string file;
std::list<std::string> item;
std::list<dataMonitoredList> results;
std::string file;
/// allows to create an object which contains results and associated items
list< dataMonitoredList > createDataMonitoredList();
std::list< dataMonitoredList > createDataMonitoredList();
};
#endif // CSV2STHING_H
......@@ -44,13 +44,13 @@ dataMonitoredList::dataMonitoredList(std::string monitorName, std::vector< doubl
}
//-----------------constructor--------------------------
dataMonitoredList::dataMonitoredList(string monitorName)
dataMonitoredList::dataMonitoredList(std::string monitorName)
{
this->monitorName=monitorName;
}
//------------------------getMonitorName--
string dataMonitoredList::getMonitorName()
std::string dataMonitoredList::getMonitorName()
{
return monitorName;
}
......@@ -75,9 +75,10 @@ void dataMonitoredList::addResults(std::vector< double > results)
//------------------------getMax---
double dataMonitoredList::getMax()
{
vector<double>::iterator it=resultData.begin();
double max=*it;
for (it; it != resultData.end (); ++it) {
// std::vector<double>::iterator it=resultData.begin();
// double max=*it;
double max = *resultData.begin();
for (std::vector<double>::iterator it= resultData.begin(); it != resultData.end (); ++it) {
if (*it>max) {
max=*it;
}
......@@ -88,9 +89,10 @@ double dataMonitoredList::getMax()
//------------------------getMin--
double dataMonitoredList::getMin()
{
vector<double>::iterator it=resultData.begin();
double min=*it;
for (it; it != resultData.end() ;++it) {
// std::vector<double>::iterator it=resultData.begin();
// double min=*it;
double min = *resultData.begin();
for (std::vector<double>::iterator it= resultData.begin(); it != resultData.end() ;++it) {
if (*it<min) {
min=*it;
}
......@@ -103,7 +105,7 @@ double dataMonitoredList::firstQuartile()
{
// From a sorted vector, the first quartile is the value
// separating a vector of data from first 25% to the rest of data.
vector<double> r(resultData.size());
std::vector<double> r(resultData.size());
copy(resultData.begin(),resultData.end(),r.begin());
//sort the vector
std::sort (r.begin(),r.end());
......@@ -114,7 +116,7 @@ double dataMonitoredList::firstQuartile()
//---------------median-----------------------------
double dataMonitoredList::median()
{
vector<double> r(resultData.size());
std::vector<double> r(resultData.size());
copy(resultData.begin(),resultData.end(),r.begin());
std::sort (r.begin(),r.end());
double pair= r.size()%2;
......@@ -130,7 +132,7 @@ double dataMonitoredList::thirdQuartile()
{
// From a sorted vector, the third quartile is the value
// separating a vector of data from last 25% to the rest of data.
vector<double> r(resultData.size());
std::vector<double> r(resultData.size());
copy(resultData.begin(),resultData.end(),r.begin());
std::sort (r.begin(),r.end());
double quart3 = ceil(3*(r.size())/4) -1;
......@@ -141,8 +143,8 @@ std::vector< double > dataMonitoredList::outliers()
{
//WARNING: outlier definition => totally empiric;
//For most of software, it is data which are <1.5*Q1 or >1.5*Q3
vector<double> outliers;
vector<double>::iterator ite;
std::vector<double> outliers;
std::vector<double>::iterator ite;
double IQR = thirdQuartile()-firstQuartile();
double belowOut = firstQuartile() - (IQR*1.5);
double aboveOut = thirdQuartile() + (IQR*1.5);
......
......@@ -43,39 +43,39 @@ class dataMonitoredList{
public:
/// constructor
dataMonitoredList(string monitorName, vector<double> resultData);
dataMonitoredList(std::string monitorName, std::vector<double> resultData);
/// constructor
dataMonitoredList(string monitorName);
dataMonitoredList(std::string monitorName);
/// destructor
virtual ~dataMonitoredList();
/// get the name of monitor
string getMonitorName();
std::string getMonitorName();
/// get the list of result data
vector<double> getResultData();
std::vector<double> getResultData();
/// method to add data in a vector
void addResults(vector<double> results);
/// method to add data in a std::vector
void addResults(std::vector<double> results);
/**
* return the minimum of a vector @param resultData
* @return the minimum in the vector
* return the minimum of a std::vector @param resultData
* @return the minimum in the std::vector
*/
double getMin();
/**
* return the maximum of a vector @param resultData
* @return the maximum in the vector
* return the maximum of a std::vector @param resultData
* @return the maximum in the std::vector
*/
double getMax();
/**