diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/barstest/chart.cpp | 15 | ||||
-rw-r--r-- | tests/barstest/chart.h | 5 | ||||
-rw-r--r-- | tests/barstest/main.cpp | 12 |
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/barstest/chart.cpp b/tests/barstest/chart.cpp index 6ecd375a..0a8bef55 100644 --- a/tests/barstest/chart.cpp +++ b/tests/barstest/chart.cpp @@ -237,6 +237,10 @@ GraphModifier::GraphModifier(Q3DBars *barchart, QColorDialog *colorDialog) QObject::connect(&m_rotationTimer, &QTimer::timeout, this, &GraphModifier::triggerRotation); + QObject::connect(m_graph, &QAbstract3DGraph::currentFpsChanged, this, + &GraphModifier::handleFpsChange); + + resetTemperatureData(); } @@ -1213,6 +1217,12 @@ void GraphModifier::handleValueAxisLabelsChanged() qDebug() << __FUNCTION__; } +void GraphModifier::handleFpsChange(qreal fps) +{ + static const QString fpsPrefix(QStringLiteral("FPS: ")); + m_fpsLabel->setText(fpsPrefix + QString::number(qRound(fps))); +} + void GraphModifier::setBackgroundEnabled(int enabled) { m_graph->activeTheme()->setBackgroundEnabled(bool(enabled)); @@ -1235,6 +1245,11 @@ void GraphModifier::rotateY(int rotation) m_graph->scene()->activeCamera()->setCameraPosition(m_xRotation, m_yRotation); } +void GraphModifier::setFpsMeasurement(bool enable) +{ + m_graph->setMeasureFps(enable); +} + void GraphModifier::setSpecsRatio(int barwidth) { m_graph->setBarThickness((float)barwidth / 30.0f); diff --git a/tests/barstest/chart.h b/tests/barstest/chart.h index 52c46a8c..214c4e17 100644 --- a/tests/barstest/chart.h +++ b/tests/barstest/chart.h @@ -29,6 +29,7 @@ #include <QPointer> #include <QColorDialog> #include <QTimer> +#include <QLabel> using namespace QtDataVisualization; @@ -58,6 +59,7 @@ public: void changeFontSize(int fontsize); void rotateX(int rotation); void rotateY(int rotation); + void setFpsMeasurement(bool enable); void setBackgroundEnabled(int enabled); void setGridEnabled(int enabled); void setSpecsRatio(int barwidth); @@ -88,6 +90,7 @@ public: void useLogAxis(); void changeValueAxisFormat(const QString & text); void changeLogBase(const QString & text); + void setFpsLabel(QLabel *fpsLabel) { m_fpsLabel = fpsLabel; } public slots: void flipViews(); @@ -108,6 +111,7 @@ public slots: void triggerSelection(); void triggerRotation(); void handleValueAxisLabelsChanged(); + void handleFpsChange(qreal fps); signals: void shadowQualityChanged(int quality); @@ -157,6 +161,7 @@ private: QAbstract3DInputHandler *m_customInputHandler; QTimer m_selectionTimer; QTimer m_rotationTimer; + QLabel *m_fpsLabel; }; #endif diff --git a/tests/barstest/main.cpp b/tests/barstest/main.cpp index 112e8d4d..b1589e0f 100644 --- a/tests/barstest/main.cpp +++ b/tests/barstest/main.cpp @@ -187,6 +187,12 @@ int main(int argc, char **argv) gradientBtoYPB->setIcon(QIcon(pm)); gradientBtoYPB->setIconSize(QSize(100, 24)); + QLabel *fpsLabel = new QLabel(QStringLiteral("")); + + QCheckBox *fpsCheckBox = new QCheckBox(widget); + fpsCheckBox->setText(QStringLiteral("Measure Fps")); + fpsCheckBox->setChecked(false); + QCheckBox *backgroundCheckBox = new QCheckBox(widget); backgroundCheckBox->setText(QStringLiteral("Show background")); backgroundCheckBox->setChecked(true); @@ -345,6 +351,8 @@ int main(int argc, char **argv) vLayout2->addWidget(minSliderZ, 0, Qt::AlignTop); vLayout2->addWidget(minSliderY, 0, Qt::AlignTop); vLayout2->addWidget(maxSliderY, 0, Qt::AlignTop); + vLayout2->addWidget(fpsLabel, 0, Qt::AlignTop); + vLayout2->addWidget(fpsCheckBox, 0, Qt::AlignTop); vLayout2->addWidget(backgroundCheckBox, 0, Qt::AlignTop); vLayout2->addWidget(gridCheckBox, 0, Qt::AlignTop); vLayout2->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")), 0, Qt::AlignTop); @@ -454,6 +462,8 @@ int main(int argc, char **argv) QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier, &GraphModifier::changeFont); + QObject::connect(fpsCheckBox, &QCheckBox::stateChanged, modifier, + &GraphModifier::setFpsMeasurement); QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier, &GraphModifier::setBackgroundEnabled); QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier, @@ -507,6 +517,8 @@ int main(int argc, char **argv) &QSlider::setEnabled); QObject::connect(staticCheckBox, &QCheckBox::stateChanged, modifier, &GraphModifier::restart); + modifier->setFpsLabel(fpsLabel); + modifier->start(); return app.exec(); |