Skip to content

Commit

Permalink
updating wearables views
Browse files Browse the repository at this point in the history
  • Loading branch information
Hethsron committed Jun 19, 2020
1 parent 6ddab02 commit e439052
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 49 deletions.
Binary file modified resources/assets/qhc/summary.qhc
Binary file not shown.
48 changes: 48 additions & 0 deletions vera/include/model/measurements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,54 @@ class Measurements
*/
virtual double getMinGyroZ() const;

/**
* @fn getMaxTime
* @brief Virtual function that returns the maximum value of time
*
* @return Maximum value of time
*/
virtual double getMaxTime() const;

/**
* @fn getMinTime
* @brief Virtual function that returns the minimum value of time
*
* @return Minimum value of time
*/
virtual double getMinTime() const;

/**
* @fn getMaxAccel
* @brief Virtual function that returns the maximum value beetwen accelX, accelY and accelZ
*
* @return Maximum value between accelX, accelY and accelZ
*/
virtual double getMaxAccel() const;

/**
* @fn getMinAccel
* @brief Virtual function that returns the minimum value beetwen accelX, accelY and accelZ
*
* @return Minimum value between accelX, accelY and accelZ
*/
virtual double getMinAccel() const;

/**
* @fn getMaxGyro
* @brief Virtual function that returns the maximum value beetwen gyroX, gyroY and gyroZ
*
* @return Maximum value between gyroX, gyroY and gyroZ
*/
virtual double getMaxGyro() const;

/**
* @fn getMinGyro
* @brief Virtual function that returns the minimum value beetwen gyroX, gyroY and gyroZ
*
* @return Minimum value between gyroX, gyroY and gyroZ
*/
virtual double getMinGyro() const;

/**
* @fn isEmpty
* @brief Virtual function that returns true if time, accelerometer and gyroscope data are empty, false otherwise
Expand Down
120 changes: 120 additions & 0 deletions vera/src/model/measurements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,126 @@ double Measurements::getMinGyroZ() const {
return value;
}

double Measurements::getMaxTime() const {
double value = time.at(0);

for (int i = 0; i < time.size(); ++i) {
if (time.at(i) > value) {
value = time.at(i);
}
}

return value;
}

double Measurements::getMinTime() const {
double value = time.at(0);

for (int i = 0; i < time.size(); ++i) {
if (time.at(i) < value) {
value = time.at(i);
}
}

return value;
}

double Measurements::getMaxAccel() const {
double value = accelX.at(0);

for (int i = 0; i < accelX.size(); ++i) {
if (accelX.at(i) > value) {
value = accelX.at(i);
}
}

for (int i = 0; i < accelY.size(); ++i) {
if (accelY.at(i) > value) {
value = accelY.at(i);
}
}

for (int i = 0; i < accelZ.size(); ++i) {
if (accelZ.at(i) > value) {
value = accelZ.at(i);
}
}

return value;
}

double Measurements::getMinAccel() const {
double value = accelX.at(0);

for (int i = 0; i < accelX.size(); ++i) {
if (accelX.at(i) < value) {
value = accelX.at(i);
}
}

for (int i = 0; i < accelY.size(); ++i) {
if (accelY.at(i) < value) {
value = accelY.at(i);
}
}

for (int i = 0; i < accelZ.size(); ++i) {
if (accelZ.at(i) < value) {
value = accelZ.at(i);
}
}

return value;
}

double Measurements::getMaxGyro() const {
double value = gyroX.at(0);

for (int i = 0; i < gyroX.size(); ++i) {
if (gyroX.at(i) > value) {
value = gyroX.at(i);
}
}

for (int i = 0; i < gyroY.size(); ++i) {
if (gyroY.at(i) > value) {
value = gyroY.at(i);
}
}

for (int i = 0; i < gyroZ.size(); ++i) {
if (gyroZ.at(i) > value) {
value = gyroZ.at(i);
}
}

return value;
}

double Measurements::getMinGyro() const {
double value = gyroX.at(0);

for (int i = 0; i < gyroX.size(); ++i) {
if (gyroX.at(i) < value) {
value = gyroX.at(i);
}
}

for (int i = 0; i < gyroY.size(); ++i) {
if (gyroY.at(i) < value) {
value = gyroY.at(i);
}
}

for (int i = 0; i < gyroZ.size(); ++i) {
if (gyroZ.at(i) < value) {
value = gyroZ.at(i);
}
}

return value;
}

bool Measurements::isEmpty() const {
return (time.isEmpty() && accelX.isEmpty() && accelY.isEmpty() && accelZ.isEmpty() && gyroX.isEmpty() && gyroY.isEmpty() && gyroZ.isEmpty());
}
Expand Down
89 changes: 40 additions & 49 deletions vera/src/view/mainview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,51 +918,28 @@ void MainView::seek(int second) {
}

void MainView::nameClicked(QListWidgetItem* item) {
// Check accelerometer graph data X is empty
if (!accelX->data()->isEmpty()) {
// Clear graph data
accelX->data()->clear();
}

// Check accelerometer graph data Y is empty
if (!accelY->data()->isEmpty()) {
// Clear graph data
accelY->data()->clear();
}

// Check accelerometer graph data Z is empty
if (!accelZ->data()->isEmpty()) {
// Clear graph data
accelZ->data()->clear();
}

// Check gyroscope graph data X is empty
if (!gyroX->data()->isEmpty()) {
// Clear graph data
gyroX->data()->clear();
}

// Check gyroscope graph data Y is empty
if (!gyroY->data()->isEmpty()) {
// Clear graph data
gyroY->data()->clear();
}

// Check gyroscope graph data Z is empty
if (!gyroZ->data()->isEmpty()) {
// Clear graph data
gyroZ->data()->clear();
}

// Setting accelerometer graph data
accelX->addData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getAccelX());
accelY->addData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getAccelY());
accelZ->addData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getAccelZ());
accelX->setData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getAccelX());
accelY->setData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getAccelY());
accelZ->setData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getAccelZ());

// Setting xAxis range of accelerometer graph
accelAxis->axis(QCPAxis::atBottom)->setLabel(tr("Time (s)"));
accelAxis->axis(QCPAxis::atLeft)->setLabel(tr("Acceleration (m/s^2)"));
accelAxis->axis(QCPAxis::atLeft)->setRange(wearables->get(item->text())->getMinAccel(), wearables->get(item->text())->getMaxAccel());
accelAxis->parentPlot()->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

// Setting gyroscope graph data
gyroX->addData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getGyroX());
gyroY->addData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getGyroY());
gyroZ->addData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getGyroZ());
gyroX->setData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getGyroX());
gyroY->setData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getGyroY());
gyroZ->setData(wearables->get(item->text())->getTime(), wearables->get(item->text())->getGyroZ());

// Setting xAxis range of gyroscope graph
gyroAxis->axis(QCPAxis::atBottom)->setLabel(tr("Time (s)"));
gyroAxis->axis(QCPAxis::atBottom)->setRange(wearables->get(item->text())->getMinTime(), wearables->get(item->text())->getMaxTime());
gyroAxis->axis(QCPAxis::atLeft)->setLabel(tr("Rotation (°/s)"));
gyroAxis->axis(QCPAxis::atLeft)->setRange(wearables->get(item->text())->getMinGyro(), wearables->get(item->text())->getMaxGyro());
gyroAxis->parentPlot()->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

// Setting accelerometer graph range
accelX->valueAxis()->setRange(wearables->get(item->text())->getMinAccelX(), wearables->get(item->text())->getMaxAccelX());
Expand All @@ -973,6 +950,9 @@ void MainView::nameClicked(QListWidgetItem* item) {
gyroX->valueAxis()->setRange(wearables->get(item->text())->getMinGyroX(), wearables->get(item->text())->getMaxGyroX());
gyroY->valueAxis()->setRange(wearables->get(item->text())->getMinGyroY(), wearables->get(item->text())->getMaxGyroY());
gyroZ->valueAxis()->setRange(wearables->get(item->text())->getMinGyroZ(), wearables->get(item->text())->getMaxGyroZ());

// Setting xAxis range
customPlot->xAxis->setRange(wearables->get(item->text())->getMinTime(), wearables->get(item->text())->getMaxTime());

// Repaints graphs
customPlot->replot();
Expand Down Expand Up @@ -1461,17 +1441,28 @@ void MainView::wearablesVisualizer() {
// Define gyrosocope axis
gyroAxis = new QCPAxisRect(customPlot);

// Adding axis of accelerometer plots
customPlot->plotLayout()->addElement(0, 0, accelAxis);

// Adding title of accelerometer plots
customPlot->plotLayout()->addElement(1, 0, new QCPTextElement(customPlot, tr("Acceleration")));
customPlot->plotLayout()->addElement(0, 0, new QCPTextElement(customPlot, tr("Accelerometer graphs in one plot"), QFont("sans", 12, QFont::Bold)));

// Adding axis of gyroscope plots
customPlot->plotLayout()->addElement(2, 0, gyroAxis);
// Adding axis of accelerometer plots
customPlot->plotLayout()->addElement(1, 0, accelAxis);

// Adding title of gyroscope plots
customPlot->plotLayout()->addElement(3, 0, new QCPTextElement(customPlot, tr("Rotation")));
customPlot->plotLayout()->addElement(2, 0, new QCPTextElement(customPlot, tr("Gyroscope graphs in one plot"), QFont("sans", 12, QFont::Bold)));

// Adding axis of gyroscope plots
customPlot->plotLayout()->addElement(3, 0, gyroAxis);

// Adding title of legend
customPlot->plotLayout()->addElement(4, 0, new QCPTextElement(customPlot, tr("Graphs common legend")));

// Adding general legend
QCPLayoutGrid *subLayout = new QCPLayoutGrid();
customPlot->plotLayout()->addElement(5, 0, subLayout);
subLayout->setMargins(QMargins(20, 10, 20, 10));
QCPLegend* legend = new QCPLegend();
legend->setFillOrder(QCPLegend::foColumnsFirst);
subLayout->addElement(0, 0, legend);

// Creating plots of accel_x / time
accelX = customPlot->addGraph(accelAxis->axis(QCPAxis::atBottom), accelAxis->axis(QCPAxis::atLeft));
Expand Down

0 comments on commit e439052

Please sign in to comment.