added ui tweaks in traing mode for shell track

This commit is contained in:
2017-12-26 11:35:19 +01:00
parent 95b3471f49
commit 8fea1a1108
6 changed files with 258 additions and 26 deletions

View File

@@ -13,6 +13,77 @@ int QVectorHelper::getCurTime(const QVector<int> x) {
}
}
int QVectorHelper::getMinSec1(const QVector<QVector<int>> x) {
int min;
if (x.size() > 0) {
if (x.at(0).size() >= 3) {
min = getCurTime(x.at(0));
}
else {
return 9999;
}
}
else {
return 9999;
}
for (int i = 1; i < x.size(); i++) {
if(x.at(i).size() >= 1){
if (x.at(i).at(0) < min) {
min = x.at(i).at(0);
}
}
}
return min;
}
int QVectorHelper::getMinSec2(const QVector<QVector<int>> x) {
int min;
if (x.size() > 0) {
if (x.at(0).size() >= 3) {
min = getCurTime(x.at(1));
}
else {
return 9999;
}
}
else {
return 9999;
}
for (int i = 1; i < x.size(); i++) {
if (x.at(0).size() >= 2) {
if (x.at(i).at(1) < min) {
min = x.at(i).at(1);
}
}
}
return min;
}
int QVectorHelper::getMinSec3(const QVector<QVector<int>> x) {
int min;
if (x.size() > 0) {
if (x.at(0).size() >= 3) {
min = getCurTime(x.at(2));
}
else {
return 9999;
}
}
else {
return 9999;
}
for (int i = 1; i < x.size(); i++) {
if(x.at(i).size() >= 3){
if (x.at(i).at(2) < min) {
min = x.at(i).at(2);
}
}
}
return min;
}
int QVectorHelper::getMin(const QVector<QVector<int>> x) {
int min;
if (x.size() > 0) {

View File

@@ -2,12 +2,14 @@
#define QVECTORHELPER_H
#include <qvector.h>
class QVectorHelper
{
public:
class QVectorHelper {
public:
QVectorHelper();
static int getCurTime(const QVector<int> x);
static int getMin(const QVector<QVector<int>> x);
static int getMinSec1(const QVector<QVector<int>> x);
static int getMinSec2(const QVector<QVector<int>> x);
static int getMinSec3(const QVector<QVector<int>> x);
};
#endif // QVECTORHELPER_H

View File

@@ -25,13 +25,13 @@ QVariant TimeModel::headerData(int section, Qt::Orientation orientation,
if (orientation == Qt::Horizontal) {
switch (section) {
case 0:
return QString("Sektor 1");
return QString("Brücke");
case 1:
return QString("Sektor 2");
return QString("Gerade");
case 2:
return QString("Sektor 3");
return QString("Kruven");
case 3:
return QString("Runde");

View File

@@ -129,6 +129,18 @@ void Training::shellSlot(int time, int sector) {
timeModelShell = new TimeModel(VecShell, minSecTime, this);
this->ui->lWShellTime->setModel(timeModelShell);
this->ui->lbridgeShellTop->setText(QString::number(
(double)QVectorHelper::getMinSec1(VecShell) / 1000));
theoreticalMinShell = 9999;
theoreticalMinShell = QVectorHelper::getMinSec1(VecShell) +
QVectorHelper::getMinSec2(VecShell) +
QVectorHelper::getMinSec3(VecShell);
deltaShell =
QVectorHelper::getMin(VecShell) - theoreticalMinShell;
this->ui->lDeltaTopTimeShell->setText(
QString::number((double)deltaShell / 1000));
break;
case 2:
if (VecShell.size() > 0) {
@@ -141,6 +153,9 @@ void Training::shellSlot(int time, int sector) {
this->ui->lWShellTime->setModel(timeModelShell);
}
}
this->ui->lbridgeShellTop->setText(QString::number(
(double)QVectorHelper::getMinSec2(VecShell) / 1000));
break;
case 3:
if (VecShell.size() > 0) {
@@ -170,6 +185,9 @@ void Training::shellSlot(int time, int sector) {
1000));
}
this->ui->lbridgeShellTop->setText(QString::number(
(double)QVectorHelper::getMinSec3(VecShell) / 1000));
break;
}
ui->lWShellTime->scrollToBottom();

View File

@@ -1,33 +1,32 @@
#ifndef TRAINING_H
#define TRAINING_H
#include "hardwaresetup.h"
#include <vector>
#include <string>
#include "counter.h"
#include <QMainWindow>
#include "database.h"
#include "hardwaresetup.h"
#include "timemodel.h"
#include <QMainWindow>
#include <string>
#include <vector>
namespace Ui {
class Training;
}
class Training : public QMainWindow
{
class Training : public QMainWindow {
Q_OBJECT
public:
explicit Training(QWidget *parent, DataBase *db);
public:
explicit Training(QWidget * parent, DataBase * db);
~Training();
private:
private:
void prepareNextRace();
Ui::Training *ui;
Ui::Training * ui;
void closeEvent(QCloseEvent *event);
void closeEvent(QCloseEvent * event);
bool started;
HardwareSetup *Hardware;
HardwareSetup * Hardware;
bool firstTimeShell;
bool firstTimeDea;
QVector<QVector<int>> VecShell;
@@ -38,22 +37,24 @@ private:
bool finished;
Counter counterShell;
Counter counterDea;
DataBase *db;
DataBase * db;
long minTimeOneRound;
int minimumTime;
int theoreticalMinShell;
int deltaShell;
// timeModel
TimeModel *timeModelDea;
TimeModel *timeModelShell;
TimeModel * timeModelDea;
TimeModel * timeModelShell;
QVector<int> minSecTime;
public slots:
public slots:
void ResetShell();
void ResetDea();
void Reset();
void deaSlot(int time, int sector);
void shellSlot(int time, int sector);
};
#endif // TRAINING_H

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>907</width>
<height>600</height>
</rect>
</property>
@@ -37,7 +37,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="font">
@@ -90,6 +90,78 @@
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Brücke</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QLabel" name="lbridgeShellTop">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Gerade</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QLabel" name="lStraightShellTop">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Kurven</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QLabel" name="lCurvesShellTop">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Delta Topzeit</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<widget class="QLabel" name="lDeltaTopTimeShell">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
@@ -198,6 +270,74 @@
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QGroupBox" name="lbridgeDeaTop">
<property name="title">
<string>Brücke</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>Gerade</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
<widget class="QLabel" name="lStraightDeaTop">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="title">
<string>Kurven</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QLabel" name="lCurvesDeaTop">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Delta Topzeit</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
<item>
<widget class="QLabel" name="lDeltaTopTimeDea">
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
@@ -249,7 +389,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>907</width>
<height>25</height>
</rect>
</property>