Connecting users choice on GUI to relevant category name.
[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 //tkk  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"; //<< "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";
227     QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
228     ui->listViewStartTabAccelerationCategories->setModel(model);
229 }
230
231 /**
232   *This function is used to set items to listViewStartTabAccelerationCategories. Start-tab view.
233   *@param QStringlist accelerationCategoriesStartTab
234   */
235 void CarMainWindow::setListViewStartTabAccelerationCategories(QStringList accelerationCategoriesStartTab)
236 {
237     QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
238     ui->listViewStartTabAccelerationCategories->setModel(model);
239 }
240
241 /**
242   *This function is used to set items to category combobox. Top-tab view.
243   *@param
244   */
245 void CarMainWindow::setCategoryCompoBox()
246 {
247     qDebug() << "_setCategoryCompoBox";
248     ui->comboBoxTopCategory->addItems(myHttpClient->myXmlreader->myCategoryList->getCategoryList());
249 }
250
251 /**
252   *This function prcesses UI updating after a new top10List has been received.
253   *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
254   */
255 void CarMainWindow::showTop10()
256 {
257     int limitNr = 5;
258     setListViewTopList(recentCategory, limitNr);
259 }
260
261 /**
262   *This function is used to set items to labelTopList. Top-tab view.
263   *@param Category
264   *@param Size, number of results.
265   */
266 void CarMainWindow::setListViewTopList(QString category, int size)
267 {
268     qDebug() << "_setListViewTopList";
269     QString topList;
270     topList.append(myHttpClient->myXmlreader->myCategoryList->getTopList(category, size));
271     ui->labelTopList->setText(topList);
272 }
273
274 /**
275   *This slot function is called when speed is achieved in measure dialog. Opens result dialog.
276   */
277 void CarMainWindow::openResultView()
278 {
279
280 }
281
282 /**
283   *This slot function is called when registrate button is clicked.
284   */
285 void CarMainWindow::on_registratePushButton_clicked()
286 {
287     myRegistration->show();
288 }
289
290 /**
291   *This slot function is called when ever refresh button clicked. Top-tab view.
292   */
293 void CarMainWindow::on_buttonTopRefresh_clicked()
294 {
295     myHttpClient->requestCategories();
296 }
297
298 /**
299   *This slot function is called when ever category combobox current index changed. Top-tab view.
300   *@param QString category.
301   *@todo Check where limitNr is taken, fixed or user input, see showTop10.
302   */
303 void CarMainWindow::on_comboBoxTopCategory_currentIndexChanged(QString category)
304 {
305     qDebug() << "_on_comboBoxTopCategory_currentIndexChanged: " << category;
306     recentCategory = category;      //for showTop10()
307     int limitNr = 5;
308     QString limit = QString::number(limitNr);
309     myHttpClient->requestTopList(category, limit);
310 }
311
312 /**
313   *This slot function is called when set/change user button is clicked.
314   */
315 void CarMainWindow::on_setUserPushButton_clicked()
316 {
317     myLogin->show();
318 }
319
320 /**
321   *@brief Just for development, for the real button is not shown until
322   *measurin started and there are results.
323   *@todo Implement with real code and yet leave sendXml in the bottom in use.
324   */
325 void CarMainWindow::on_manualStartButton_clicked()
326 {
327
328 }
329
330 /**
331   * This slot function is called when timer gives timeout signal. Checks current speed
332   * and stores times in measure class.
333   */
334 void CarMainWindow::after_timeout()
335 {
336     QString timeString, speedString;
337     //time++;
338     //speed = speed +10;
339     timeString.setNum(time);
340     speedString.setNum(speed);
341     ui->labelMeasureTabTime->setText(timeString);
342     ui->labelMeasureTabSpeed->setText(speedString);
343
344     //handleCheckPoint(time, speed);
345 }
346
347 /**
348   * Initializes measures class's member variables.
349   */
350 void CarMainWindow::initializeMeasures()
351 {
352     measures->setTime10kmh(0);
353     measures->setTime20kmh(0);
354     measures->setTime30kmh(0);
355     measures->setTime40kmh(0);
356     measures->setTime50kmh(0);
357     measures->setTime60kmh(0);
358     measures->setTime70kmh(0);
359     measures->setTime80kmh(0);
360     measures->setTime90kmh(0);
361     measures->setTime100kmh(0);
362 }
363
364 /**
365   * This slot function is called when Abort button is clicked.
366   */
367 void CarMainWindow::on_pushButtonMeasureTabAbort_clicked()
368 {
369     ui->pushButtonSendResult->setEnabled(false);
370     ui->pushButtonShowResultDialog->setEnabled(false);
371     ui->labelMeasureTabResult->hide();
372     ui->labelMeasureTabTime->setText("");
373     ui->labelMeasureTabSpeed->setText("");
374     measures->setTime10kmh(0);
375     measures->setTime20kmh(0);
376     measures->setTime30kmh(0);
377     measures->setTime40kmh(0);
378     measures->setTime50kmh(0);
379     measures->setTime60kmh(0);
380     measures->setTime70kmh(0);
381     measures->setTime80kmh(0);
382     measures->setTime90kmh(0);
383     measures->setTime100kmh(0);
384     this->accelerometerTimer->stop();
385     this->timer->stop();
386     this->time = 0;
387     this->speed = 0;
388     ui->tabWidget->setCurrentWidget(this->ui->StartTab);
389     //this->close();
390 }
391
392 /**
393   *This slot function is called when pushButtonSendResult is clicked.
394   *@todo Use real category value.
395   */
396 void CarMainWindow::on_pushButtonSendResult_clicked()
397 {
398     //Pick up relevant category name and pass it to the server
399     myHttpClient->sendResultXml(catList.at(choiceInt));
400     ui->pushButtonSendResult->setEnabled(false);
401 }
402
403 void CarMainWindow::updateUserName()
404 {
405     QString newUserName;
406
407     newUserName = myLogin->getUserName();
408     ui->userNameLabel->setText( "User: " + newUserName);
409
410     if (newUserName.length())
411     {
412        ui->setUserPushButton->setText( "Change User");
413        this->setWindowTitle("Speed Freak - " + newUserName);
414     }
415     else
416     {
417         ui->setUserPushButton->setText( "Set User");
418         this->setWindowTitle("Speed Freak");
419     }
420 }
421
422 void CarMainWindow::regUserToServer()
423 {
424     myHttpClient->requestRegistration();
425 }
426
427
428 void CarMainWindow::on_drawRoutePushButton_clicked()
429 {
430     myRoute->show();
431 }
432
433 /**
434   * Opens result dialog when show result button is clicked.
435   * Sends measures as parameter to the resultdialogs saveMeasuresToArray-function.
436   */
437 void CarMainWindow::on_pushButtonShowResultDialog_clicked()
438 {
439     result->saveMeasuresToArray(measures);
440     this->result->show();
441 }
442
443 void CarMainWindow::userLogin()
444 {
445     myHttpClient->checkLogin();
446 }
447
448 /**
449   * Resets Accelerometer measurement variables
450   */
451 void CarMainWindow::resetAccelerometerMeasurements()
452 {
453     currentAcceleration = 0;
454     currentAccelerationString = "";
455     currentSpeed = "";
456     currentTime = 0;
457     distanceTraveled = "";
458     firstAcceleration = 0;
459     //horsepower = null;
460     isNewRun = true;
461     //lastScreenUpdateInSeconds = 0;
462     previousTime = 0;
463     reverseAccelerationFlag = false;
464     stopWatch.setHMS(0, 0, 0, 0);
465     //accelerometer->stop();
466     totalTime = "";
467     vehicleStartedMoving = false;
468     calculate->reset();
469 }
470
471 /**
472   * This function is called to handle checkpoints
473   *@param totalTime total time elapsed since starting measurements
474   *@param currentSpeed current speed of the device
475   */
476 void CarMainWindow::handleCheckPoint(double totalTime, double currentSpeed)
477 {
478     switch (counterForSaveResults)
479     {
480     case 0:
481         measures->setTime10kmh(totalTime);
482         break;
483
484     case 1:
485         measures->setTime20kmh(totalTime);
486         break;
487
488     case 2:
489         measures->setTime30kmh(totalTime);
490         break;
491
492     case 3:
493         measures->setTime40kmh(totalTime);
494         break;
495
496     case 4:
497         measures->setTime50kmh(totalTime);
498         break;
499
500     case 5:
501         measures->setTime60kmh(totalTime);
502         break;
503
504     case 6:
505         measures->setTime70kmh(totalTime);
506         break;
507
508     case 7:
509         measures->setTime80kmh(totalTime);
510         break;
511
512     case 8:
513         measures->setTime90kmh(totalTime);
514         break;
515
516     case 9:
517         measures->setTime100kmh(totalTime);
518         break;
519
520     default:
521         break;
522     }
523     counterForSaveResults++;
524
525     if (choiceInt == 0 && measures->getTime40kmh() != 0)
526     {
527         setTimeAxisGapAndShowResult(measures->getTime40kmh());
528         this->timer->stop();
529         this->accelerometerTimer->stop();
530         this->time = 0;
531         this->speed = 0;
532         counterForSaveResults = 0;
533     }
534     else if (choiceInt == 1 && measures->getTime100kmh() != 0)
535     {
536         setTimeAxisGapAndShowResult(measures->getTime100kmh());
537         this->timer->stop();
538         this->accelerometerTimer->stop();
539         this->time = 0;
540         this->speed = 0;
541         counterForSaveResults = 0;
542     }
543     else if (choiceInt == 2 && measures->getTime10kmh() != 0)
544     {
545         setTimeAxisGapAndShowResult(measures->getTime10kmh());
546         this->timer->stop();
547         this->accelerometerTimer->stop();
548         this->time = 0;
549         this->speed = 0;
550         counterForSaveResults = 0;
551     }
552     else if (choiceInt != 1 && choiceInt != 0 && measures->getTime80kmh() != 0)
553     {
554         setTimeAxisGapAndShowResult(measures->getTime80kmh());
555         this->timer->stop();
556         this->accelerometerTimer->stop();
557         this->time = 0;
558         this->speed = 0;
559         counterForSaveResults = 0;
560     }
561     else
562     {
563         qDebug() << "something wrong in handleCheckPoint()";
564     }
565 }
566
567 /**
568   *This function is called to read (and process) data from the accelerometer
569   */
570 void CarMainWindow::readAccelerometerData()
571 {
572     QString s;
573     double changeInAcceleration = 0;
574     qreal x, y, z;
575
576     accelerometer->getAcceleration(x, y, z);
577     accelerometer->smoothData(x, y, z);
578
579     // Apply calibration
580     x -= accelerometer->getCalibrationX();
581     y -= accelerometer->getCalibrationY();
582     z -= accelerometer->getCalibrationZ();
583
584     QString str = QString("acc x: " + QString::number(x) + "\n" +
585                           "acc y: " + QString::number(y) + "\n" +
586                           "acc z: " + QString::number(z) + "\n");
587
588     if (!vehicleStartedMoving)
589     {
590         if (isNewRun)
591         {
592             firstAcceleration = sqrt(x*x + y*y + z*z);
593             //firstAcceleration = y; // first read
594             isNewRun = false;
595         }
596     }
597
598     currentAcceleration = sqrt(x*x + y*y + z*z);
599     changeInAcceleration = (currentAcceleration - firstAcceleration); // firstAcceleration only gets set once
600
601     if (((fabs(changeInAcceleration) <= accelerationStartThreshold)
602                 && !vehicleStartedMoving))
603     {
604         return;
605     }
606
607     if (reverseAccelerationFlag)
608     {
609         // will be false until after 1st calculation
610         if ((changeInAcceleration <= 0))
611         {
612             // actually increasing here...
613             changeInAcceleration = fabs(changeInAcceleration);
614         }
615         else
616         {
617             // actually decreasing here...
618             changeInAcceleration = (changeInAcceleration * -1);
619         }
620     }
621     if (!vehicleStartedMoving)
622     {
623         if ((changeInAcceleration < 0))
624         {
625             // we started to move backwards first time through
626             reverseAccelerationFlag = true;
627             changeInAcceleration = fabs(changeInAcceleration);
628         }
629         vehicleStartedMoving = true;
630
631         stopWatch.setHMS(0, 0, 0, 0);
632         stopWatch.start();
633     }
634     //  keep the following line as close to the SetKinematicsProperties method as possible
635     currentTime = stopWatch.elapsed();
636     calculate->calculateParameters(changeInAcceleration, (currentTime - previousTime)/1000);
637     previousTime = currentTime;
638
639     s.sprintf("%.2f", changeInAcceleration);
640     currentAccelerationString = s;
641
642     speed = 0.0;
643     speed = calculate->getCurrentSpeed();
644     speed = ((speed*1000)/kSecondsInHour);
645     s.sprintf("%.2f", speed);
646     currentSpeed = s;
647
648     s.sprintf("%.2f", calculate->getDistanceTraveled());
649     distanceTraveled = s;
650
651     // TODO
652     //distanceTraveled;
653     //horsepower;
654
655     time = calculate->getTotalTime();
656
657     s.sprintf("%.2f", time);
658     totalTime = s;
659
660     str.append("ca: " + currentAccelerationString + " G\n" );
661     str.append("cspeed: " + currentSpeed + " km/h \n" );
662     str.append("dist: " + distanceTraveled + " m \n" );
663     str.append("time: " + totalTime + " s \n" );
664
665     if ((stopTime > 0) && (previousTime >= stopTime))
666     {
667         // we want to end at a stopping point that the user chose
668         // output results
669         resetAccelerometerMeasurements();
670     }
671 }
672
673 /**
674   *This function is used to calibrate accelerometer
675   */
676 void CarMainWindow::calibrateAccelerometer()
677 {
678     resetAccelerometerMeasurements();
679     accelerometer->calibrate();
680 }
681
682 /**
683   *This slot function is called when GPS on checkbox state changed.  Route-tab view.
684   *@param int GPSState
685   */
686 void CarMainWindow::on_gpsOnCheckBox_stateChanged(int GPSState)
687 {
688     if (GPSState == 0)
689     {
690         ui->labelRouteTabGPSStatus->setText("GPS off");//testing
691         location->stopPollingGPS();
692     }
693     else
694     {
695         ui->labelRouteTabGPSStatus->setText("GPS on");//testing
696         location->startPollingGPS();
697     }
698 }
699
700 /**
701   *This slot function is called when GPS status changed.  Route-tab view.
702   */
703 void CarMainWindow::gpsStatus()
704 {
705     if (ui->gpsOnCheckBox->isChecked())
706     {
707         if (location->getSatellitesInUse() >= 4)
708         {
709             //Set status
710             //ui->labelRouteTabGPSStatus->setText("GPS ready");
711             ui->labelRouteTabGPSStatus->setText(QString::number(gpsData->roundCounter));
712
713             //Set time
714             gpsTime->setTime_t(location->getTime());
715             ui->labelRouteTabGPSTime->setText(gpsTime->toString());
716
717             //Set latitude & longitude
718             ui->labelRouteTabLatitude->setText("Lat: " + QString::number(location->getLatitude()));
719             ui->labelRouteTabLongitude->setText("Lon: " + QString::number(location->getLongitude()));
720         }
721
722         else
723         {
724             ui->labelRouteTabGPSStatus->setText("Waiting for GPS");
725         }
726     }
727     ui->labelRouteTabSpeed->setText(QString::number(location->getSpeed()));
728 }
729
730 void CarMainWindow::on_startRecPushButton_clicked()
731 {
732     ui->labelRouteTabRecStatus->setText("Recording started");
733     gpsData->startRouteRecording(ui->labelRouteTabGPSTime->text());
734 }
735
736 void CarMainWindow::on_stopRecPushButton_clicked()
737 {
738     ui->labelRouteTabRecStatus->setText("Recording stopped");
739     gpsData->stopRouteRecording(ui->labelRouteTabGPSTime->text());
740 }
741
742 /**
743   *Sets time axis right way in result dialog and shows target speed result.
744   *@param double pTime is the target speed result time which is shown to the user.
745   */
746 void CarMainWindow::setTimeAxisGapAndShowResult(double pTime)
747 {
748     ui->pushButtonShowResultDialog->setEnabled(true);
749     ui->pushButtonSendResult->setEnabled(true);
750     QString timeInteger;
751     timeInteger.setNum(pTime);
752     ui->labelMeasureTabResult->show();
753     ui->labelMeasureTabResult->setText(timeInteger);
754
755     if (floor(pTime) <= 5)
756     {
757         result->setDiagramGapHorizontal(80);
758     }
759
760     else if (floor(pTime) <= 10)
761     {
762         result->setDiagramGapHorizontal(40);
763     }
764
765     else
766     {
767         result->setDiagramGapHorizontal(20);
768     }
769 }