Added to GUI an info label and feeding text into it.
[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     myRoute->show();
437 }
438
439 /**
440   * Opens result dialog when show result button is clicked.
441   * Sends measures as parameter to the resultdialogs saveMeasuresToArray-function.
442   */
443 void CarMainWindow::on_pushButtonShowResultDialog_clicked()
444 {
445     result->saveMeasuresToArray(measures);
446     this->result->show();
447 }
448
449 void CarMainWindow::userLogin()
450 {
451     myHttpClient->checkLogin();
452 }
453
454 /**
455   * Resets Accelerometer measurement variables
456   */
457 void CarMainWindow::resetAccelerometerMeasurements()
458 {
459     currentAcceleration = 0;
460     currentAccelerationString = "";
461     currentSpeed = "";
462     currentTime = 0;
463     distanceTraveled = "";
464     firstAcceleration = 0;
465     //horsepower = null;
466     isNewRun = true;
467     //lastScreenUpdateInSeconds = 0;
468     previousTime = 0;
469     reverseAccelerationFlag = false;
470     stopWatch.setHMS(0, 0, 0, 0);
471     //accelerometer->stop();
472     totalTime = "";
473     vehicleStartedMoving = false;
474     calculate->reset();
475 }
476
477 /**
478   * This function is called to handle checkpoints
479   *@param totalTime total time elapsed since starting measurements
480   *@param currentSpeed current speed of the device
481   */
482 void CarMainWindow::handleCheckPoint(double totalTime, double currentSpeed)
483 {
484     switch (counterForSaveResults)
485     {
486     case 0:
487         measures->setTime10kmh(totalTime);
488         break;
489
490     case 1:
491         measures->setTime20kmh(totalTime);
492         break;
493
494     case 2:
495         measures->setTime30kmh(totalTime);
496         break;
497
498     case 3:
499         measures->setTime40kmh(totalTime);
500         break;
501
502     case 4:
503         measures->setTime50kmh(totalTime);
504         break;
505
506     case 5:
507         measures->setTime60kmh(totalTime);
508         break;
509
510     case 6:
511         measures->setTime70kmh(totalTime);
512         break;
513
514     case 7:
515         measures->setTime80kmh(totalTime);
516         break;
517
518     case 8:
519         measures->setTime90kmh(totalTime);
520         break;
521
522     case 9:
523         measures->setTime100kmh(totalTime);
524         break;
525
526     default:
527         break;
528     }
529     counterForSaveResults++;
530
531     if (choiceInt == 0 && measures->getTime40kmh() != 0)
532     {
533         setTimeAxisGapAndShowResult(measures->getTime40kmh());
534         this->timer->stop();
535         this->accelerometerTimer->stop();
536         this->time = 0;
537         this->speed = 0;
538         counterForSaveResults = 0;
539     }
540     else if (choiceInt == 1 && measures->getTime100kmh() != 0)
541     {
542         setTimeAxisGapAndShowResult(measures->getTime100kmh());
543         this->timer->stop();
544         this->accelerometerTimer->stop();
545         this->time = 0;
546         this->speed = 0;
547         counterForSaveResults = 0;
548     }
549     else if (choiceInt == 2 && measures->getTime10kmh() != 0)
550     {
551         setTimeAxisGapAndShowResult(measures->getTime10kmh());
552         this->timer->stop();
553         this->accelerometerTimer->stop();
554         this->time = 0;
555         this->speed = 0;
556         counterForSaveResults = 0;
557     }
558     else if (choiceInt != 1 && choiceInt != 0 && measures->getTime80kmh() != 0)
559     {
560         setTimeAxisGapAndShowResult(measures->getTime80kmh());
561         this->timer->stop();
562         this->accelerometerTimer->stop();
563         this->time = 0;
564         this->speed = 0;
565         counterForSaveResults = 0;
566     }
567     else
568     {
569         qDebug() << "something wrong in handleCheckPoint()";
570     }
571 }
572
573 /**
574   *This function is called to read (and process) data from the accelerometer
575   */
576 void CarMainWindow::readAccelerometerData()
577 {
578     QString s;
579     double changeInAcceleration = 0;
580     qreal x, y, z;
581
582     accelerometer->getAcceleration(x, y, z);
583     accelerometer->smoothData(x, y, z);
584
585     // Apply calibration
586     x -= accelerometer->getCalibrationX();
587     y -= accelerometer->getCalibrationY();
588     z -= accelerometer->getCalibrationZ();
589
590     QString str = QString("acc x: " + QString::number(x) + "\n" +
591                           "acc y: " + QString::number(y) + "\n" +
592                           "acc z: " + QString::number(z) + "\n");
593
594     if (!vehicleStartedMoving)
595     {
596         if (isNewRun)
597         {
598             firstAcceleration = sqrt(x*x + y*y + z*z);
599             //firstAcceleration = y; // first read
600             isNewRun = false;
601         }
602     }
603
604     currentAcceleration = sqrt(x*x + y*y + z*z);
605     changeInAcceleration = (currentAcceleration - firstAcceleration); // firstAcceleration only gets set once
606
607     if (((fabs(changeInAcceleration) <= accelerationStartThreshold)
608                 && !vehicleStartedMoving))
609     {
610         return;
611     }
612
613     if (reverseAccelerationFlag)
614     {
615         // will be false until after 1st calculation
616         if ((changeInAcceleration <= 0))
617         {
618             // actually increasing here...
619             changeInAcceleration = fabs(changeInAcceleration);
620         }
621         else
622         {
623             // actually decreasing here...
624             changeInAcceleration = (changeInAcceleration * -1);
625         }
626     }
627     if (!vehicleStartedMoving)
628     {
629         if ((changeInAcceleration < 0))
630         {
631             // we started to move backwards first time through
632             reverseAccelerationFlag = true;
633             changeInAcceleration = fabs(changeInAcceleration);
634         }
635         vehicleStartedMoving = true;
636
637         stopWatch.setHMS(0, 0, 0, 0);
638         stopWatch.start();
639     }
640     //  keep the following line as close to the SetKinematicsProperties method as possible
641     currentTime = stopWatch.elapsed();
642     calculate->calculateParameters(changeInAcceleration, (currentTime - previousTime)/1000);
643     previousTime = currentTime;
644
645     s.sprintf("%.2f", changeInAcceleration);
646     currentAccelerationString = s;
647
648     speed = 0.0;
649     speed = calculate->getCurrentSpeed();
650     speed = ((speed*1000)/kSecondsInHour);
651     s.sprintf("%.2f", speed);
652     currentSpeed = s;
653
654     s.sprintf("%.2f", calculate->getDistanceTraveled());
655     distanceTraveled = s;
656
657     // TODO
658     //distanceTraveled;
659     //horsepower;
660
661     time = calculate->getTotalTime();
662
663     s.sprintf("%.2f", time);
664     totalTime = s;
665
666     str.append("ca: " + currentAccelerationString + " G\n" );
667     str.append("cspeed: " + currentSpeed + " km/h \n" );
668     str.append("dist: " + distanceTraveled + " m \n" );
669     str.append("time: " + totalTime + " s \n" );
670
671     if ((stopTime > 0) && (previousTime >= stopTime))
672     {
673         // we want to end at a stopping point that the user chose
674         // output results
675         resetAccelerometerMeasurements();
676     }
677 }
678
679 /**
680   *This function is used to calibrate accelerometer
681   */
682 void CarMainWindow::calibrateAccelerometer()
683 {
684     resetAccelerometerMeasurements();
685     accelerometer->calibrate();
686 }
687
688 /**
689   *This slot function is called when GPS on checkbox state changed.  Route-tab view.
690   *@param int GPSState
691   */
692 void CarMainWindow::on_gpsOnCheckBox_stateChanged(int GPSState)
693 {
694     if (GPSState == 0)
695     {
696         ui->labelRouteTabGPSStatus->setText("GPS off");//testing
697         location->stopPollingGPS();
698     }
699     else
700     {
701         ui->labelRouteTabGPSStatus->setText("GPS on");//testing
702         location->startPollingGPS();
703     }
704 }
705
706 /**
707   *This slot function is called when GPS status changed.  Route-tab view.
708   */
709 void CarMainWindow::gpsStatus()
710 {
711     if (ui->gpsOnCheckBox->isChecked())
712     {
713         if (location->getSatellitesInUse() >= 4)
714         {
715             //Set status
716             //ui->labelRouteTabGPSStatus->setText("GPS ready");
717             ui->labelRouteTabGPSStatus->setText(QString::number(gpsData->roundCounter));
718
719             //Set time
720             gpsTime->setTime_t(location->getTime());
721             ui->labelRouteTabGPSTime->setText(gpsTime->toString());
722
723             //Set latitude & longitude
724             ui->labelRouteTabLatitude->setText("Lat: " + QString::number(location->getLatitude()));
725             ui->labelRouteTabLongitude->setText("Lon: " + QString::number(location->getLongitude()));
726         }
727
728         else
729         {
730             ui->labelRouteTabGPSStatus->setText("Waiting for GPS");
731         }
732     }
733     ui->labelRouteTabSpeed->setText(QString::number(location->getSpeed()));
734 }
735
736 void CarMainWindow::on_startRecPushButton_clicked()
737 {
738     ui->labelRouteTabRecStatus->setText("Recording started");
739     gpsData->startRouteRecording(ui->labelRouteTabGPSTime->text());
740 }
741
742 void CarMainWindow::on_stopRecPushButton_clicked()
743 {
744     ui->labelRouteTabRecStatus->setText("Recording stopped");
745     gpsData->stopRouteRecording(ui->labelRouteTabGPSTime->text());
746 }
747
748 /**
749   *Sets time axis right way in result dialog and shows target speed result.
750   *@param double pTime is the target speed result time which is shown to the user.
751   */
752 void CarMainWindow::setTimeAxisGapAndShowResult(double pTime)
753 {
754     ui->pushButtonShowResultDialog->setEnabled(true);
755     ui->pushButtonSendResult->setEnabled(true);
756     QString timeInteger;
757     timeInteger.setNum(pTime);
758     ui->labelMeasureTabResult->show();
759     ui->labelMeasureTabResult->setText(timeInteger);
760
761     if (floor(pTime) <= 5)
762     {
763         result->setDiagramGapHorizontal(80);
764     }
765
766     else if (floor(pTime) <= 10)
767     {
768         result->setDiagramGapHorizontal(40);
769     }
770
771     else
772     {
773         result->setDiagramGapHorizontal(20);
774     }
775 }