From 3a85396a2c7d4eed956e199d9081ff161599b07d Mon Sep 17 00:00:00 2001 From: Tomi Korpipaa Date: Wed, 27 Mar 2019 11:10:16 +0200 Subject: [PATCH] Update application style for kria cluster Also added FPS counter and possibility to use either RT1 or RT2. --- kria-cluster-3d-demo/kria-cluster-3d-demo.pro | 3 +- kria-cluster-3d-demo/kria3dclusterdemo.qrc | 1 + kria-cluster-3d-demo/main.cpp | 47 +++++----- kria-cluster-3d-demo/qml/FpsDisplay.qml | 35 +++++++ kria-cluster-3d-demo/qml/Navigation.qml | 9 +- kria-cluster-3d-demo/qml/main.qml | 92 +++++++++++++++++-- 6 files changed, 149 insertions(+), 38 deletions(-) create mode 100644 kria-cluster-3d-demo/qml/FpsDisplay.qml diff --git a/kria-cluster-3d-demo/kria-cluster-3d-demo.pro b/kria-cluster-3d-demo/kria-cluster-3d-demo.pro index 198ad2c..24c4f18 100644 --- a/kria-cluster-3d-demo/kria-cluster-3d-demo.pro +++ b/kria-cluster-3d-demo/kria-cluster-3d-demo.pro @@ -2,7 +2,8 @@ TEMPLATE = app QT += qml quick 3dstudioruntime2 -target.path = $$[QT_INSTALL_EXAMPLES]/studio3d/$$TARGET +#target.path = $$[QT_INSTALL_EXAMPLES]/studio3d/$$TARGET +target.path = /opt/$$TARGET INSTALLS += target SOURCES += main.cpp diff --git a/kria-cluster-3d-demo/kria3dclusterdemo.qrc b/kria-cluster-3d-demo/kria3dclusterdemo.qrc index 68f5425..9c4eb3a 100644 --- a/kria-cluster-3d-demo/kria3dclusterdemo.qrc +++ b/kria-cluster-3d-demo/kria3dclusterdemo.qrc @@ -39,5 +39,6 @@ presentation/GaugeCenter/gaugecenter.import presentation/Gauges/Gauges.import presentation/Needle/needle.import + qml/FpsDisplay.qml diff --git a/kria-cluster-3d-demo/main.cpp b/kria-cluster-3d-demo/main.cpp index c15022a..89ef213 100644 --- a/kria-cluster-3d-demo/main.cpp +++ b/kria-cluster-3d-demo/main.cpp @@ -47,42 +47,47 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -#include -#include -#include -#include +#include +#include #include #include int main(int argc, char *argv[]) { - qputenv("QML_DISABLE_DISK_CACHE", "true"); +// qputenv("Q3DS_NO_DRAGONWINGS", "1"); + qputenv("Q3DS_DRAGON", "1"); + qputenv("QT_QPA_EGLFS_HIDECURSOR", "1"); +// qputenv("QT_QPA_EGLFS_DISABLE_INPUT", "1"); + qputenv("QT_QPA_EGLFS_WIDTH", "1920"); + qputenv("QT_QPA_EGLFS_HEIGHT", "1080"); + qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", "293"); + qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", "110"); +// qputenv("QSG_RENDER_LOOP", "basic"); + qputenv("QSG_RENDER_LOOP", "threaded"); + + // Debugging +// qputenv("QT_QPA_EGLFS_DEBUG", "1"); +// qputenv("QSG_INFO", "1"); +// qputenv("QT_LOGGING_RULES", "qt.qpa.*=true"); + + // Disable all extra logging + qputenv("QT_LOGGING_RULES", "*=false"); + +// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat()); - QQuickView viewer; - QFontDatabase::addApplicationFont("qrc:/qml/fonts/TitilliumWeb-SemiBold.ttf"); QFont defaultFont; defaultFont.setFamily("Titillium Web"); QGuiApplication::setFont(defaultFont); - viewer.setSource(QUrl("qrc:/main.qml")); - - viewer.setTitle(QStringLiteral("Qt 3D Studio Kria 3D Cluster Demo")); - viewer.setResizeMode(QQuickView::SizeRootObjectToView); - viewer.setWidth(1920); - viewer.setHeight(720); - viewer.setColor(QColor("black")); -#if (defined Q_OS_ANDROID) - viewer.showFullScreen(); -#else - viewer.show(); -#endif + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; return app.exec(); } diff --git a/kria-cluster-3d-demo/qml/FpsDisplay.qml b/kria-cluster-3d-demo/qml/FpsDisplay.qml new file mode 100644 index 0000000..2e7667e --- /dev/null +++ b/kria-cluster-3d-demo/qml/FpsDisplay.qml @@ -0,0 +1,35 @@ +import QtQuick 2.11 + +Rectangle { + id: fpsDisplayControl + + property real fps: 0.0 + property alias textcolor: fpsText.color + property alias fpslabel: fpsLabelText.text + color: "black" + + Text { + id: fpsText + text: fps.toFixed(1) + font.family: "Helvetica" + font.pixelSize: fpsDisplayControl.width / 2 + font.weight: Font.Light + color: "white" + width: parent.width + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + Text { + id: fpsLabelText + text: "FPS" + font.family: "Helvetica" + font.pixelSize: fpsDisplayControl.width / 5 + font.weight: Font.Light + color: "white" + width: parent.width + anchors.top: fpsText.bottom + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } +} diff --git a/kria-cluster-3d-demo/qml/Navigation.qml b/kria-cluster-3d-demo/qml/Navigation.qml index c448bb5..08b4421 100644 --- a/kria-cluster-3d-demo/qml/Navigation.qml +++ b/kria-cluster-3d-demo/qml/Navigation.qml @@ -51,15 +51,12 @@ import QtQuick 2.0 Item { - width: 2560 - height: 960 - Image { id: fakeMap source: "qrc:/icons/Map.png" - y: -580 - width: 2560 - height: 1540 + y: -parent.width / 0.227 //-580 + width: parent.width //2560 + height: parent.width * 0.6 //1540 } PropertyAnimation { diff --git a/kria-cluster-3d-demo/qml/main.qml b/kria-cluster-3d-demo/qml/main.qml index 4adbde8..2912122 100644 --- a/kria-cluster-3d-demo/qml/main.qml +++ b/kria-cluster-3d-demo/qml/main.qml @@ -48,14 +48,20 @@ ** ****************************************************************************/ -import QtQuick 2.9 -import QtStudio3D 2.0 +import QtQuick 2.12 +import QtQuick.Window 2.12 +import QtStudio3D 2.3 +//import QtStudio3D 1.1 import QtQuick.Controls 2.1 -Item { +Window { id: mainview - - focus: true + width: 1920 + height: 1080 + visible: true + color: "#000000" + title: "Qt 3D Studio Kria 3D Cluster Demo" + visibility: Window.FullScreen property bool startupAnimation: true property bool allowSelection: true @@ -80,16 +86,36 @@ Item { property string chimesInfo: "Off" property string chimesWarning: "On" + // fps + property real avgFrames: 0.0 + property int avgCount: 0 + property int frames: 0 + property int framesUpdated: 0 + readonly property int framesBetweenUpdates: 5 // Use a 5 frame average for the FPS counter + readonly property int secondsBetweenUpdates: 60 // Use a 1 minute average for the average FPS counter + + // RT1 +// onFrameSwapped: { +// frames++; +// avgFrames++; +// } + Studio3D { id: studio3D width: parent.width height: parent.height anchors.verticalCenter: parent.verticalCenter - ViewerSettings { - scaleMode: ViewerSettings.ScaleModeFit + // RT2 + onFrameUpdate: { + frames++; + avgFrames++; } +// ViewerSettings { +// scaleMode: ViewerSettings.ScaleModeFit +// } + Presentation { id: cluster source: "qrc:/presentation/mainPresentation.uia" @@ -154,8 +180,8 @@ Item { visible: active source: "" asynchronous: true - width: 2560 - height: 960 + width: mainview.width //2560 + height: mainview.width * 0.375 //960 } } ] @@ -171,7 +197,7 @@ Item { OverlayContainer { id: indicatorPane scale: mainview.width / 2560 - anchors.centerIn: mainview + anchors.centerIn: studio3D visible: false } @@ -357,4 +383,50 @@ Item { mouse.accepted = false; } } + + // + // FpsDisplay + // + FpsDisplay { + id: fpsDisplay + anchors.left: parent.left + anchors.top: parent.top + anchors.margins: 10 + width: 40 + height: 40 + textcolor: "red" + fpslabel: "FPS" + } + FpsDisplay { + id: avgFpsDisplay + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + width: 40 + height: 40 + textcolor: "green" + fpslabel: "1 min AVG" + } + Timer { + interval: 1000 + repeat: true + running: !fpsDisplay.hidden + onTriggered: { + if (++framesUpdated == framesBetweenUpdates) { + fpsDisplay.fps = frames / framesBetweenUpdates; + frames = 0; + framesUpdated = 0; + } + if (++avgCount == secondsBetweenUpdates) { + avgFpsDisplay.fps = avgFrames / secondsBetweenUpdates; + avgFrames = 0.0; + avgCount = 0; + } + } + onRunningChanged: { + avgFrames = 0; + frames = 0; + framesUpdated = 0; + } + } } -- GitLab