Merge branch 'feature/startgui'
[speedfreak] / Client / carmainwindow.cpp
1 /*
2  * CarMainWindow main class
3  *
4  * @author     Toni Jussila <toni.jussila@fudeco.com>
5  * @author     Janne Änäkkälä <janne.anakkala@fudeco.com>
6  * @author     Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
7  * @author     Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
8  * @author     Rikhard Kuutti <rikhard.kuutti@fudeco.com>
9  * @author     Kai Rasilainen <kai.rasilainen@fudeco.com>
10  * @copyright  (c) 2010 Speed Freak team
11  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
12  */
13
14 #include "carmainwindow.h"
15 #include "math.h"
16
17 #define kAccelerometerSampleRate    50
18 #define kFilteringFactor            0.2
19 #define kSecondsInHour              3600
20
21 /**
22   *Constructor of this class.
23   *@param QWidget pointer to parent object. By default the value is NULL.
24   */
25 CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::CarMainWindow)
26 {
27     ui->setupUi(this);
28     ui->tabWidget->setCurrentWidget(this->ui->StartTab);
29     result = new ResultDialog();
30     //measure = new MeasureDialog();
31     welcomeDialog = new WelcomeDialog();
32     welcomeDialog->show();
33
34     initComboBoxStartTabUnits();
35     initListViewStartTabAccelerationCategories();
36
37     myLogin = new LoginWindow(this);
38     myCategorylist = new CategoryList();
39     myHttpClient = new HttpClient(this);
40     myRegistration = new Registration(this);
41     connect(myRegistration,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
42     connect(myLogin,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
43     connect(myHttpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
44     connect(myHttpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
45     myRoute = new RouteDialog( this);
46
47     //GPS
48     location = new Maemo5Location(this);
49     gpsData = new GPSData(location);
50     connect(location,SIGNAL(agnss()),this,SLOT(gpsStatus()));
51     gpsTime = new QDateTime();
52
53     this->time = 0;
54     this->speed = 0;
55     counterForSaveResults = 0;
56     timer = new QTimer();
57
58     // Accelerometer
59     accelerometer = new Accelerometer();
60
61     reverseAccelerationFlag = false;
62     vehicleStartedMoving = false;
63     isNewRun = true;
64     isSetup = false;
65     stopTime = 0;
66     accelerationStartThreshold = 0.02;
67
68     accelerometerTimer = new QTimer(this);
69     connect(accelerometerTimer, SIGNAL(timeout()), this, SLOT(readAccelerometerData()));
70     //accelerometerTimer->start(kAccelerometerSampleRate);
71
72     // Calculate
73     calculate = new Calculate();
74     connect(calculate, SIGNAL(checkPointReached()), this, SLOT(handleCheckPoint()));
75
76     resetAccelerometerMeasurements();
77
78     measures = new Measures();
79     this->initializeMeasures();
80
81     this->timer->setInterval(300);
82
83     connect(this->timer, SIGNAL(timeout()), this, SLOT(after_timeout()));
84     connect(myLogin, SIGNAL( userNameChanged()), this, SLOT(updateUserName()));
85
86     ui->labelMeasureTabResult->hide();
87     ui->pushButtonShowResultDialog->setEnabled(false);
88
89     this->setWindowTitle("Speed Freak");
90
91 }
92
93 /**
94   *Destructor of this class. Deletes all dynamic objects and sets them to NULL.
95   */
96 CarMainWindow::~CarMainWindow()
97 {
98     delete ui;
99     ui = NULL;
100     //delete result;
101     //delete measure;
102     delete myCategorylist;
103     myCategorylist = NULL;
104     delete welcomeDialog;
105     welcomeDialog = NULL;
106     delete myRoute;
107     myRoute = NULL;
108     delete gpsData;
109     gpsData = NULL;
110     delete gpsTime;
111     gpsTime = NULL;
112 }
113
114 /**
115   *This function is used to .
116   *@param
117   */
118 void CarMainWindow::changeEvent(QEvent *e)
119 {
120     QMainWindow::changeEvent(e);
121     switch (e->type()) {
122     case QEvent::LanguageChange:
123         ui->retranslateUi(this);
124         break;
125     default:
126         break;
127     }
128 }
129
130 /**
131   *This slot function is called when ever list view is update. Start-tab view.
132   */
133 void CarMainWindow::on_listViewStartTabAccelerationCategories_clicked(QModelIndex index)
134 {
135     QString str = index.data().toString();
136     QStringList list = str.split("-");
137     QStringList list2 = list[1].split(" ");
138
139     ui->lineEditStartTabMin->setText(list[0]);
140     ui->lineEditStartTabMax->setText(list2[0]);
141     updateComboBoxStartTabUnits(list2[1]);
142 }
143
144 /**
145   *This slot function is called when ever auto start button clicked. Start-tab view.
146   *@todo Check setDiagramGapStem(100) <- (choiceInt == 2)
147   */
148 void CarMainWindow::on_autoStartButton_clicked()
149 {
150     initializeMeasures();
151     resetAccelerometerMeasurements();
152     ui->pushButtonSendResult->setEnabled(false);
153     ui->pushButtonShowResultDialog->setEnabled(false);
154     choice = ui->listViewStartTabAccelerationCategories->currentIndex();
155     choiceInt = choice.row();
156     //qDebug() << "choiceInt" << choiceInt << " " << catList.at(choiceInt);
157     if (choiceInt == 0)
158     {
159         ui->labelMeasureTabHeader->setText("Accelerate to 40 km/h");
160         result->setDiagramGapStem(75);
161     }
162     else if (choiceInt == 1)
163     {
164         ui->labelMeasureTabHeader->setText("Accelerate to 100 km/h");
165         result->setDiagramGapStem(30);
166     }   
167     else if (choiceInt == 2)
168     {
169         ui->labelMeasureTabHeader->setText("Accelerate to 10 km/h");
170         result->setDiagramGapStem(100);
171     }
172     else
173     {
174         ui->labelMeasureTabHeader->setText("Accelerate to 80 km/h");
175         result->setDiagramGapStem(37.5);
176     }
177     ui->labelMeasureTabResult->setText("");
178
179     this->accelerometerTimer->start(kAccelerometerSampleRate);
180     this->timer->start();
181     this->time = 0;
182     this->speed = 0;
183     ui->tabWidget->setCurrentWidget(this->ui->tabMeasureResult);
184 }
185
186 /**
187   *This slot function is called when ever list view is update. Start-tab view.
188   *@param QString unit.
189   */
190 void CarMainWindow::updateComboBoxStartTabUnits(QString unit)
191 {
192     ui->comboBoxStartTabUnits->setCurrentIndex(ui->comboBoxStartTabUnits->findText(unit, Qt::MatchExactly));
193 }
194
195 /**
196   *This function is used to init unit combobox. Start-tab view.
197   */
198 void CarMainWindow::initComboBoxStartTabUnits()
199 {
200     units << "km/h" << "km" << "h" << "m" << "min" << "Mile" << "Mph" << "in" << "ft" << "yrd";
201     ui->comboBoxStartTabUnits->addItems(units);
202 }
203
204 /**
205   *This function is used to set items to unit combobox. Start-tab view.
206   *@param QStringlist units
207   */
208 void CarMainWindow::setComboBoxStartTabUnits(QStringList units)
209 {
210     ui->comboBoxStartTabUnits->addItems(units);
211 }
212
213 /**
214   *This function is used to init listViewStartTabAccelerationCategories. Start-tab view.
215   *@todo During development categories index values that are used for measuring are hardcoded
216   *@todo and accelerationCategoriesStartTab and catList are used instead of using
217   *@todo CategoryList::categoryList and CategoryList::cats.
218   */
219 void CarMainWindow::initListViewStartTabAccelerationCategories()
220 {
221     //Connect the user`s choice fron GUI to a correct variable name
222     catList.insert(0,"acceleration-0-40");
223     catList.insert(1,"acceleration-0-100");
224     catList.insert(2,"acceleration-0-10");
225
226     accelerationCategoriesStartTab << "0-40 km/h" << "0-100 km/h" << "0-10 km/h";
227     //<< "0-1/4 Mile" << "0-1/8 Mile" << "50-100 Mile" << "0-60 Mph" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
228     QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
229     ui->listViewStartTabAccelerationCategories->setModel(model);
230 }
231
232 /**
233   *This function is used to set items to listViewStartTabAccelerationCategories. Start-tab view.
234   *@param QStringlist accelerationCategoriesStartTab
235   */
236 void CarMainWindow::setListViewStartTabAccelerationCategories(QStringList accelerationCategoriesStartTab)
237 {
238     QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
239     ui->listViewStartTabAccelerationCategories->setModel(model);
240 }
241
242 void CarMainWindow::setLabelInfoToUser(QString infoText)
243 {
244     ui->labelInfoToUser->setText(infoText);
245 }
246
247 /**
248   *This function is used to set items to category combobox. Top-tab view.
249   *@param
250   */
251 void CarMainWindow::setCategoryCompoBox()
252 {
253     qDebug() << "_setCategoryCompoBox";
254     ui->comboBoxTopCategory->addItems(myHttpClient->myXmlreader->myCategoryList->getCategoryList());
255 }
256
257 /**
258   *This function prcesses UI updating after a new top10List has been received.
259   *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
260   */
261 void CarMainWindow::showTop10()
262 {
263     int limitNr = 5;
264     setListViewTopList(recentCategory, limitNr);
265 }
266
267 /**
268   *This function is used to set items to labelTopList. Top-tab view.
269   *@param Category
270   *@param Size, number of results.
271   */
272 void CarMainWindow::setListViewTopList(QString category, int size)
273 {
274     qDebug() << "_setListViewTopList";
275     QString topList;
276     topList.append(myHttpClient->myXmlreader->myCategoryList->getTopList(category, size));
277     ui->labelTopList->setText(topList);
278 }
279
280 /**
281   *This slot function is called when speed is achieved in measure dialog. Opens result dialog.
282   */
283 void CarMainWindow::openResultView()
284 {
285
286 }
287
288 /**
289   *This slot function is called when registrate button is clicked.
290   */
291 void CarMainWindow::on_registratePushButton_clicked()
292 {
293     myRegistration->show();
294 }
295
296 /**
297   *This slot function is called when ever refresh button clicked. Top-tab view.
298   */
299 void CarMainWindow::on_buttonTopRefresh_clicked()
300 {
301     myHttpClient->requestCategories();
302 }
303
304 /**
305   *This slot function is called when ever category combobox current index changed. Top-tab view.
306   *@param QString category.
307   *@todo Check where limitNr is taken, fixed or user input, see showTop10.
308   */
309 void CarMainWindow::on_comboBoxTopCategory_currentIndexChanged(QString category)
310 {
311     qDebug() << "_on_comboBoxTopCategory_currentIndexChanged: " << category;
312     recentCategory = category;      //for showTop10()
313     int limitNr = 5;
314     QString limit = QString::number(limitNr);
315     myHttpClient->requestTopList(category, limit);
316 }
317
318 /**
319   *This slot function is called when set/change user button is clicked.
320   */
321 void CarMainWindow::on_setUserPushButton_clicked()
322 {
323     myLogin->show();
324 }
325
326 /**
327   *@brief Just for development, for the real button is not shown until
328   *measurin started and there are results.
329   *@todo Implement with real code and yet leave sendXml in the bottom in use.
330   */
331 void CarMainWindow::on_manualStartButton_clicked()
332 {
333
334 }
335
336 /**
337   * This slot function is called when timer gives timeout signal. Checks current speed
338   * and stores times in measure class.
339   */
340 void CarMainWindow::after_timeout()
341 {
342     QString timeString, speedString;
343     //time++;
344     //speed = speed +10;
345     timeString.setNum(time);
346     speedString.setNum(speed);
347     ui->labelMeasureTabTime->setText(timeString);
348     ui->labelMeasureTabSpeed->setText(speedString);
349
350     //handleCheckPoint(time, speed);
351 }
352
353 /**
354   * Initializes measures class's member variables.
355   */
356 void CarMainWindow::initializeMeasures()
357 {
358     measures->setTime10kmh(0);
359     measures->setTime20kmh(0);
360     measures->setTime30kmh(0);
361     measures->setTime40kmh(0);
362     measures->setTime50kmh(0);
363     measures->setTime60kmh(0);
364     measures->setTime70kmh(0);
365     measures->setTime80kmh(0);
366     measures->setTime90kmh(0);
367     measures->setTime100kmh(0);
368 }
369
370 /**
371   * This slot function is called when Abort button is clicked.
372   */
373 void CarMainWindow::on_pushButtonMeasureTabAbort_clicked()
374 {
375     ui->pushButtonSendResult->setEnabled(false);
376     ui->pushButtonShowResultDialog->setEnabled(false);
377     ui->labelMeasureTabResult->hide();
378     ui->labelMeasureTabTime->setText("");
379     ui->labelMeasureTabSpeed->setText("");
380     measures->setTime10kmh(0);
381     measures->setTime20kmh(0);
382     measures->setTime30kmh(0);
383     measures->setTime40kmh(0);
384     measures->setTime50kmh(0);
385     measures->setTime60kmh(0);
386     measures->setTime70kmh(0);
387     measures->setTime80kmh(0);
388     measures->setTime90kmh(0);
389     measures->setTime100kmh(0);
390     this->accelerometerTimer->stop();
391     this->timer->stop();
392     this->time = 0;
393     this->speed = 0;
394     ui->tabWidget->setCurrentWidget(this->ui->StartTab);
395     //this->close();
396 }
397
398 /**
399   *This slot function is called when pushButtonSendResult is clicked.
400   *@todo Use real category value.
401   */
402 void CarMainWindow::on_pushButtonSendResult_clicked()
403 {
404     //Pick up relevant category name and pass it to the server
405     myHttpClient->sendResultXml(catList.at(choiceInt));
406     ui->pushButtonSendResult->setEnabled(false);
407 }
408
409 void CarMainWindow::updateUserName()
410 {
411     QString newUserName;
412
413     newUserName = myLogin->getUserName();
414     ui->userNameLabel->setText( "User: " + newUserName);
415
416     if (newUserName.length())
417     {
418        ui->setUserPushButton->setText( "Change User");
419        this->setWindowTitle("Speed Freak - " + newUserName);
420     }
421     else
422     {
423         ui->setUserPushButton->setText( "Set User");
424         this->setWindowTitle("Speed Freak");
425     }
426 }
427
428 void CarMainWindow::regUserToServer()
429 {
430     myHttpClient->requestRegistration();
431 }
432
433
434 void CarMainWindow::on_drawRoutePushButton_clicked()
435 {
436     QString routeFile = QString("route.txt");
437     if (myRoute->readRouteFromFile( routeFile) == true)
438     {
439         myRoute->show();
440     }
441 }
442
443 /**
444   * Opens result dialog when show result button is clicked.
445   * Sends measures as parameter to the resultdialogs saveMeasuresToArray-function.
446   */
447 void CarMainWindow::on_pushButtonShowResultDialog_clicked()
448 {
449     result->saveMeasuresToArray(measures);
450     this->result->show();
451 }
452
453 void CarMainWindow::userLogin()
454 {
455     myHttpClient->checkLogin();
456 }
457
458 /**
459   * Resets Accelerometer measurement variables
460   */
461 void CarMainWindow::resetAccelerometerMeasurements()
462 {
463     currentAcceleration = 0;
464     currentAccelerationString = "";
465     currentSpeed = "";
466     currentTime = 0;
467     distanceTraveled = "";
468     firstAcceleration = 0;
469     //horsepower = null;
470     isNewRun = true;
471     //lastScreenUpdateInSeconds = 0;
472     previousTime = 0;
473     reverseAccelerationFlag = false;
474     stopWatch.setHMS(0, 0, 0, 0);
475     //accelerometer->stop();
476     totalTime = "";
477     vehicleStartedMoving = false;
478     calculate->reset();
479 }
480
481 /**
482   * This function is called to handle checkpoints
483   *@param totalTime total time elapsed since starting measurements
484   *@param currentSpeed current speed of the device
485   */
486 void CarMainWindow::handleCheckPoint(double totalTime, double currentSpeed)
487 {
488     switch (counterForSaveResults)
489     {
490     case 0:
491         measures->setTime10kmh(totalTime);
492         break;
493
494     case 1:
495         measures->setTime20kmh(totalTime);
496         break;
497
498     case 2:
499         measures->setTime30kmh(totalTime);
500         break;
501
502     case 3:
503         measures->setTime40kmh(totalTime);
504         break;
505
506     case 4:
507         measures->setTime50kmh(totalTime);
508         break;
509
510     case 5:
511         measures->setTime60kmh(totalTime);
512         break;
513
514     case 6:
515         measures->setTime70kmh(totalTime);
516         break;
517
518     case 7:
519         measures->setTime80kmh(totalTime);
520         break;
521
522     case 8:
523         measures->setTime90kmh(totalTime);
524         break;
525
526     case 9:
527         measures->setTime100kmh(totalTime);
528         break;
529
530     default:
531         break;
532     }
533     counterForSaveResults++;
534
535     if (choiceInt == 0 && measures->getTime40kmh() != 0)
536     {
537         setTimeAxisGapAndShowResult(measures->getTime40kmh());
538         this->timer->stop();
539         this->accelerometerTimer->stop();
540         this->time = 0;
541         this->speed = 0;
542         counterForSaveResults = 0;
543     }
544     else if (choiceInt == 1 && measures->getTime100kmh() != 0)
545     {
546         setTimeAxisGapAndShowResult(measures->getTime100kmh());
547         this->timer->stop();
548         this->accelerometerTimer->stop();
549         this->time = 0;
550         this->speed = 0;
551         counterForSaveResults = 0;
552     }
553     else if (choiceInt == 2 && measures->getTime10kmh() != 0)
554     {
555         setTimeAxisGapAndShowResult(measures->getTime10kmh());
556         this->timer->stop();
557         this->accelerometerTimer->stop();
558         this->time = 0;
559         this->speed = 0;
560         counterForSaveResults = 0;
561     }
562     else if (choiceInt != 1 && choiceInt != 0 && measures->getTime80kmh() != 0)
563     {
564         setTimeAxisGapAndShowResult(measures->getTime80kmh());
565         this->timer->stop();
566         this->accelerometerTimer->stop();
567         this->time = 0;
568         this->speed = 0;
569         counterForSaveResults = 0;
570     }
571     else
572     {
573         qDebug() << "something wrong in handleCheckPoint()";
574     }
575 }
576
577 /**
578   *This function is called to read (and process) data from the accelerometer
579   */
580 void CarMainWindow::readAccelerometerData()
581 {
582     QString s;
583     double changeInAcceleration = 0;
584     qreal x, y, z;
585
586     accelerometer->getAcceleration(x, y, z);
587     accelerometer->smoothData(x, y, z);
588
589     // Apply calibration
590     x -= accelerometer->getCalibrationX();
591     y -= accelerometer->getCalibrationY();
592     z -= accelerometer->getCalibrationZ();
593
594     QString str = QString("acc x: " + QString::number(x) + "\n" +
595                           "acc y: " + QString::number(y) + "\n" +
596                           "acc z: " + QString::number(z) + "\n");
597
598     if (!vehicleStartedMoving)
599     {
600         if (isNewRun)
601         {
602             firstAcceleration = sqrt(x*x + y*y + z*z);
603             //firstAcceleration = y; // first read
604             isNewRun = false;
605         }
606     }
607
608     currentAcceleration = sqrt(x*x + y*y + z*z);
609     changeInAcceleration = (currentAcceleration - firstAcceleration); // firstAcceleration only gets set once
610
611     if (((fabs(changeInAcceleration) <= accelerationStartThreshold)
612                 && !vehicleStartedMoving))
613     {
614         return;
615     }
616
617     if (reverseAccelerationFlag)
618     {
619         // will be false until after 1st calculation
620         if ((changeInAcceleration <= 0))
621         {
622             // actually increasing here...
623             changeInAcceleration = fabs(changeInAcceleration);
624         }
625         else
626         {
627             // actually decreasing here...
628             changeInAcceleration = (changeInAcceleration * -1);
629         }
630     }
631     if (!vehicleStartedMoving)
632     {
633         if ((changeInAcceleration < 0))
634         {
635             // we started to move backwards first time through
636             reverseAccelerationFlag = true;
637             changeInAcceleration = fabs(changeInAcceleration);
638         }
639         vehicleStartedMoving = true;
640
641         stopWatch.setHMS(0, 0, 0, 0);
642         stopWatch.start();
643     }
644     //  keep the following line as close to the SetKinematicsProperties method as possible
645     currentTime = stopWatch.elapsed();
646     calculate->calculateParameters(changeInAcceleration, (currentTime - previousTime)/1000);
647     previousTime = currentTime;
648
649     s.sprintf("%.2f", changeInAcceleration);
650     currentAccelerationString = s;
651
652     speed = 0.0;
653     speed = calculate->getCurrentSpeed();
654     speed = ((speed*1000)/kSecondsInHour);
655     s.sprintf("%.2f", speed);
656     currentSpeed = s;
657
658     s.sprintf("%.2f", calculate->getDistanceTraveled());
659     distanceTraveled = s;
660
661     // TODO
662     //distanceTraveled;
663     //horsepower;
664
665     time = calculate->getTotalTime();
666
667     s.sprintf("%.2f", time);
668     totalTime = s;
669
670     str.append("ca: " + currentAccelerationString + " G\n" );
671     str.append("cspeed: " + currentSpeed + " km/h \n" );
672     str.append("dist: " + distanceTraveled + " m \n" );
673     str.append("time: " + totalTime + " s \n" );
674
675     if ((stopTime > 0) && (previousTime >= stopTime))
676     {
677         // we want to end at a stopping point that the user chose
678         // output results
679         resetAccelerometerMeasurements();
680     }
681 }
682
683 /**
684   *This function is used to calibrate accelerometer
685   */
686 void CarMainWindow::calibrateAccelerometer()
687 {
688     resetAccelerometerMeasurements();
689     accelerometer->calibrate();
690 }
691
692 /**
693   *This slot function is called when GPS on checkbox state changed.  Route-tab view.
694   *@param int GPSState
695   */
696 void CarMainWindow::on_gpsOnCheckBox_stateChanged(int GPSState)
697 {
698     if (GPSState == 0)
699     {
700         ui->labelRouteTabGPSStatus->setText("GPS off");//testing
701         location->stopPollingGPS();
702     }
703     else
704     {
705         ui->labelRouteTabGPSStatus->setText("GPS on");//testing
706         location->startPollingGPS();
707     }
708 }
709
710 /**
711   *This slot function is called when GPS status changed.  Route-tab view.
712   */
713 void CarMainWindow::gpsStatus()
714 {
715     if (ui->gpsOnCheckBox->isChecked())
716     {
717         if (location->getSatellitesInUse() >= 4)
718         {
719             //Set status
720             //ui->labelRouteTabGPSStatus->setText("GPS ready");
721             ui->labelRouteTabGPSStatus->setText(QString::number(gpsData->roundCounter));
722
723             //Set time
724             gpsTime->setTime_t(location->getTime());
725             ui->labelRouteTabGPSTime->setText(gpsTime->toString());
726
727             //Set latitude & longitude
728             ui->labelRouteTabLatitude->setText("Lat: " + QString::number(location->getLatitude()));
729             ui->labelRouteTabLongitude->setText("Lon: " + QString::number(location->getLongitude()));
730         }
731
732         else
733         {
734             ui->labelRouteTabGPSStatus->setText("Waiting for GPS");
735         }
736     }
737     ui->labelRouteTabSpeed->setText(QString::number(location->getSpeed()));
738 }
739
740 void CarMainWindow::on_startRecPushButton_clicked()
741 {
742     ui->labelRouteTabRecStatus->setText("Recording started");
743     gpsData->startRouteRecording(ui->labelRouteTabGPSTime->text());
744 }
745
746 void CarMainWindow::on_stopRecPushButton_clicked()
747 {
748     ui->labelRouteTabRecStatus->setText("Recording stopped");
749     gpsData->stopRouteRecording(ui->labelRouteTabGPSTime->text());
750 }
751
752 /**
753   *Sets time axis right way in result dialog and shows target speed result.
754   *@param double pTime is the target speed result time which is shown to the user.
755   */
756 void CarMainWindow::setTimeAxisGapAndShowResult(double pTime)
757 {
758     ui->pushButtonShowResultDialog->setEnabled(true);
759     ui->pushButtonSendResult->setEnabled(true);
760     QString timeInteger;
761     timeInteger.setNum(pTime);
762     ui->labelMeasureTabResult->show();
763     ui->labelMeasureTabResult->setText(timeInteger);
764
765     if (floor(pTime) <= 5)
766     {
767         result->setDiagramGapHorizontal(80);
768     }
769
770     else if (floor(pTime) <= 10)
771     {
772         result->setDiagramGapHorizontal(40);
773     }
774
775     else
776     {
777         result->setDiagramGapHorizontal(20);
778     }
779 }