|
From: Gustavo P. B. <gb...@us...> - 2005-06-28 22:11:44
|
Update of /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32105 Modified Files: ktcalculation.cpp ktcalculation.h Log Message: No need for two functions for parsing the results (just one gives us problems enough already) No need for a float array too. Using QValueList the data gets automatically deleted. Index: ktcalculation.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktcalculation.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ktcalculation.h 23 Jun 2005 23:19:41 -0000 1.3 +++ ktcalculation.h 28 Jun 2005 22:11:34 -0000 1.4 @@ -43,7 +43,7 @@ typedef struct { - float *inputs; + QValueList<float> inputs; int sampleClass; } dataEntry; @@ -71,8 +71,7 @@ void setWindowSize(bool type, int height, int width); window_size windowSize(); - void parseResults(const QValueList<float> &results); - void parseSampleResults(const QValueList<float> &results, int sampleClass); + void parseResults(const QValueList<float> &results, int sampleClass); public slots: void calculateSampleData(); Index: ktcalculation.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktcalculation.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ktcalculation.cpp 27 Jun 2005 19:51:05 -0000 1.5 +++ ktcalculation.cpp 28 Jun 2005 22:11:33 -0000 1.6 @@ -275,71 +275,28 @@ } } -void KTCalculation::parseResults(const QValueList<float> &results) -{ - float *inputs = new float[m_inputs]; - - QValueList<float>::const_iterator it; - - if (m_first) - { - for (int j = 0; j < m_inputs; ++j) - m_min[j] = m_max[j] = inputs[j]; - m_first = false; - } - - int i = 0; - - //prepare the input - for ( it = results.begin(); it != results.end(); ++it) - { - inputs[i] = (*it); - if (inputs[i] > m_max[i]) - m_max[i] = inputs[i]; - else if (inputs[i] < m_min[i]) - m_min[i] = inputs[i]; - ++i; - } - - dataEntry entry ; - entry.inputs = inputs; - entry.sampleClass = 0; - m_data.append(entry); - -} - -void KTCalculation::parseSampleResults(const QValueList<float> &results, int sampleClass) +void KTCalculation::parseResults(const QValueList<float> &results, int sampleClass) { - float *inputs = new float[m_inputs]; - - QValueList<float>::const_iterator it; - - if (m_first) { for (int j = 0; j < m_inputs; ++j) - m_min[j] = m_max[j] = inputs[j]; + m_min[j] = m_max[j] = results[j]; m_first = false; } - int i = 0; - //prepare the input - for ( it = results.begin(); it != results.end(); ++it) + for (int i=0; i < results.count(); ++i) { - inputs[i] = (*it); - if (inputs[i] > m_max[i]) - m_max[i] = inputs[i]; - else if (inputs[i] < m_min[i]) - m_min[i] = inputs[i]; - ++i; + if (results[i] > m_max[i]) + m_max[i] = results[i]; + else if (results[i] < m_min[i]) + m_min[i] = results[i]; } dataEntry entry; - entry.inputs = inputs; + entry.inputs = results; entry.sampleClass = sampleClass; m_data.append(entry); - } void KTCalculation::setWindowSize(bool type, int height, int width) |