From e439052e3b802b0da08a9b1caab711d7cc40070e Mon Sep 17 00:00:00 2001 From: Boueya Hethsron Date: Fri, 19 Jun 2020 18:49:34 +0200 Subject: [PATCH] updating wearables views --- resources/assets/qhc/summary.qhc | Bin 73728 -> 73728 bytes vera/include/model/measurements.hpp | 48 +++++++++++ vera/src/model/measurements.cpp | 120 ++++++++++++++++++++++++++++ vera/src/view/mainview.cpp | 89 ++++++++++----------- 4 files changed, 208 insertions(+), 49 deletions(-) diff --git a/resources/assets/qhc/summary.qhc b/resources/assets/qhc/summary.qhc index 09794a9693b78d85280b412f3e152d54a5fd2fa3..3a91b9b0cb20edfac9b96d35d5a56c8f4a2a9115 100644 GIT binary patch delta 44 vcmZoTz|wGlWkX;-)2la=gYy@0TUePGSs5AVnHZaFD)>2{9m-!Oz$gF!f 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()); } diff --git a/vera/src/view/mainview.cpp b/vera/src/view/mainview.cpp index 2861448..8783fad 100644 --- a/vera/src/view/mainview.cpp +++ b/vera/src/view/mainview.cpp @@ -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()); @@ -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(); @@ -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));