Result dialog fixed.
authorJukka Kurttila <jukka.kurttila@fudeco.com>
Wed, 31 Mar 2010 08:15:01 +0000 (11:15 +0300)
committerJukka Kurttila <jukka.kurttila@fudeco.com>
Wed, 31 Mar 2010 08:15:01 +0000 (11:15 +0300)
Client/accelerationstart.cpp
Client/accelerationstart.h
Client/accelerometer.cpp
Client/accrealtimedialog.cpp
Client/accrealtimedialog.h
Client/calculate.cpp
Client/calculate.h
Client/calibratedialog.cpp
Client/calibratedialog.h
Client/calibratedialog.ui

index 3da0070..22a0a02 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Acceleration start dialog
+ *
+ * @author      Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright   (c) 2010 Speed Freak team
+ * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
 #include "accelerationstart.h"
 #include "ui_accelerationstartdialog.h"
 #include <QMessageBox>
index ecd2406..e524f88 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Acceleration start dialog
+ *
+ * @author      Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright   (c) 2010 Speed Freak team
+ * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
 #ifndef ACCELERATIONSTART_H
 #define ACCELERATIONSTART_H
 
index ecde13d..c2f0bab 100644 (file)
@@ -24,6 +24,7 @@
 Accelerometer::Accelerometer()
 {
     initValues();
+    calibrateDialog = NULL;
 }
 
 /**
@@ -32,6 +33,8 @@ Accelerometer::Accelerometer()
  */
 Accelerometer::~Accelerometer()
 {
+    if(calibrateDialog)
+        delete calibrateDialog;
 }
 
 /**
@@ -61,6 +64,7 @@ void Accelerometer::calibrate(void)
     calibrateDialog = new CalibrateDialog();
     calibrateDialog->show();
     calibrateDialog->resetProgressValue();
+    calibrateDialog->setMaxValue( kIterations + 1 );
 
     do {
         calibrateDialog->setProgressValue(iteration);
@@ -79,7 +83,7 @@ void Accelerometer::calibrate(void)
     calibrationY = calibrationY/kIterations;
     calibrationZ = calibrationZ/kIterations;
 
-    calibrateDialog->hide();
+    calibrateDialog->close();
 }
 
 /**
index dc58627..9b5bc3f 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Acceleration info in real time dialog
+ *
+ * @author      Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright   (c) 2010 Speed Freak team
+ * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
 #include "accrealtimedialog.h"
 #include "ui_accrealtimedialog.h"
 #include <math.h>
@@ -19,9 +27,7 @@ AccRealTimeDialog::AccRealTimeDialog(QWidget *parent) :
     updateScreenCounter = 0;
     resetAccelerometerMeasurements();
 
-    //Load image
-    QPixmap pixMap("back.png",0,Qt::AutoColor);
-    ui->pictureLabel->setPixmap(pixMap);
+    resultDialog = NULL;
 }
 
 AccRealTimeDialog::~AccRealTimeDialog()
@@ -31,6 +37,8 @@ AccRealTimeDialog::~AccRealTimeDialog()
     delete accelerometerTimer;
     delete calculate;
     delete movingAverageZ;
+    if(resultDialog)
+        delete resultDialog;
 }
 
 void AccRealTimeDialog::changeEvent(QEvent *e)
@@ -69,9 +77,9 @@ void AccRealTimeDialog::readAccelerometerData()
     y -= accelerometer->getCalibrationY();
     z -= accelerometer->getCalibrationZ();
 
-    QString str = QString("acc x: " + QString::number(x) + "\n" +
-                          "acc y: " + QString::number(y) + "\n" +
-                          "acc z: " + QString::number(z) + "\n");
+//    QString str = QString("acc x: " + QString::number(x) + "\n" +
+//                          "acc y: " + QString::number(y) + "\n" +
+//                          "acc z: " + QString::number(z) + "\n");
 
     currentAcceleration = z;//sqrt(x*x + y*y + z*z);
     changeInAcceleration = currentAcceleration;
@@ -128,9 +136,24 @@ void AccRealTimeDialog::readAccelerometerData()
     updateScreenCounter++;
 
     //Open result dialog if target speed reached
-    if( speed > stopMeasureSpeed )
+    if( (stopMeasureSpeed > 0) && (speed > stopMeasureSpeed) )
     {
         this->accelerometerTimer->stop();
+        if(!resultDialog)
+        {
+            resultDialog = new ResultDialog(this);
+        }
+        resultDialog->setEnd(stopMeasureSpeed);
+
+        //Put all times from all speeds
+        QMap<int,double> tempMap = calculate->getValuesMap();
+
+        for( int i = 1 ; i <= tempMap.count() ; i++ )
+        {
+            resultDialog->setValue(i*10,tempMap[i*10]);
+        }
+        resultDialog->show();
+        this->hide();
     }
 }
 
@@ -164,6 +187,9 @@ void AccRealTimeDialog::on_buttonAbort_clicked()
 }
 void AccRealTimeDialog::startAccelerationMeasure()
 {
+    double temp = stopMeasureSpeed;
+    resetAccelerometerMeasurements();
+    stopMeasureSpeed = temp;
     accelerometerTimer->start(40);
 }
 void AccRealTimeDialog::SetStopMeasureSpeed(double speed)
index b389818..4545c9c 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Acceleration info in real time dialog
+ *
+ * @author      Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright   (c) 2010 Speed Freak team
+ * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
 #ifndef ACCREALTIMEDIALOG_H
 #define ACCREALTIMEDIALOG_H
 
@@ -5,6 +12,8 @@
 #include <QTimer>
 #include "accelerometer.h"
 #include "movingaverage.h"
+#include "resultdialog.h"
+
 
 namespace Ui {
     class AccRealTimeDialog;
@@ -35,6 +44,7 @@ private:
     Accelerometer* accelerometer;
     Calculate *calculate;
     MovingAverage* movingAverageZ;
+    ResultDialog* resultDialog;
 
     int updateScreenCounter;
     double accelerationStartThreshold;
index fb56f12..edd4246 100644 (file)
@@ -2,6 +2,7 @@
  * Calculate class to process accelerometer data
  *
  * @author      Kai Rasilainen
+ * @author      Jukka Kurttila <jukka.kurttila@fudeco.com>
  * @copyright   (c) 2010 Speed Freak team
  * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
  */
@@ -303,3 +304,7 @@ void Calculate::setMaxSpeed(double value)
     maxSpeed = value;
 }
 
+QMap<int,double> Calculate::getValuesMap()
+{
+    return valuesMap;
+}
index bc3f81d..0100502 100644 (file)
@@ -2,6 +2,7 @@
  * Calculate class to process accelerometer data
  *
  * @author      Kai Rasilainen
+ * @author      Jukka Kurttila <jukka.kurttila@fudeco.com>
  * @copyright   (c) 2010 Speed Freak team
  * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
  */
@@ -25,6 +26,7 @@ public:
     void reset();
     void calculateParameters(double currentAcceleration, double seconds);
     void accelStoppedCheck(double currentAcceleration);
+    QMap<int,double> getValuesMap();
 
     double getAverageSpeed();
     void setAverageSpeed(double value);
@@ -82,7 +84,7 @@ private:
     double currentPower;
     double averagePower;
     QList<int> speedCheckPoints;
-public:
+
     QMap<int,double> valuesMap;
 
 signals:
index a2ac9bd..7194c89 100644 (file)
@@ -43,3 +43,8 @@ void CalibrateDialog::resetProgressValue()
 {
     ui->progressBar->reset();
 }
+
+void CalibrateDialog::setMaxValue(int max)
+{
+    ui->progressBar->setMaximum( max );
+}
index af7af1c..341e91c 100644 (file)
@@ -23,6 +23,7 @@ public:
 
     void setProgressValue(int value);
     void resetProgressValue();
+    void setMaxValue(int max);
 
 protected:
     void changeEvent(QEvent *e);
index ac7a81a..16e9bb9 100644 (file)
@@ -7,39 +7,17 @@
     <x>0</x>
     <y>0</y>
     <width>800</width>
-    <height>480</height>
+    <height>150</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Dialog</string>
   </property>
-  <widget class="QLabel" name="label">
-   <property name="geometry">
-    <rect>
-     <x>300</x>
-     <y>30</y>
-     <width>201</width>
-     <height>161</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string/>
-   </property>
-   <property name="pixmap">
-    <pixmap>line_chart.png</pixmap>
-   </property>
-   <property name="scaledContents">
-    <bool>true</bool>
-   </property>
-   <property name="alignment">
-    <set>Qt::AlignHCenter|Qt::AlignTop</set>
-   </property>
-  </widget>
   <widget class="QProgressBar" name="progressBar">
    <property name="geometry">
     <rect>
-     <x>60</x>
-     <y>220</y>
+     <x>50</x>
+     <y>40</y>
      <width>681</width>
      <height>71</height>
     </rect>