Commit 3a85396a authored by Tomi Korpipää's avatar Tomi Korpipää

Update application style for kria cluster

Also added FPS counter and possibility to use either
RT1 or RT2.
parent c3c6dc94
...@@ -2,7 +2,8 @@ TEMPLATE = app ...@@ -2,7 +2,8 @@ TEMPLATE = app
QT += qml quick 3dstudioruntime2 QT += qml quick 3dstudioruntime2
target.path = $$[QT_INSTALL_EXAMPLES]/studio3d/$$TARGET #target.path = $$[QT_INSTALL_EXAMPLES]/studio3d/$$TARGET
target.path = /opt/$$TARGET
INSTALLS += target INSTALLS += target
SOURCES += main.cpp SOURCES += main.cpp
......
...@@ -39,5 +39,6 @@ ...@@ -39,5 +39,6 @@
<file>presentation/GaugeCenter/gaugecenter.import</file> <file>presentation/GaugeCenter/gaugecenter.import</file>
<file>presentation/Gauges/Gauges.import</file> <file>presentation/Gauges/Gauges.import</file>
<file>presentation/Needle/needle.import</file> <file>presentation/Needle/needle.import</file>
<file alias="FpsDisplay.qml">qml/FpsDisplay.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -47,42 +47,47 @@ ...@@ -47,42 +47,47 @@
** $QT_END_LICENSE$ ** $QT_END_LICENSE$
** **
****************************************************************************/ ****************************************************************************/
#include <QGuiApplication>
#include <QtGui/QGuiApplication> #include <QQmlApplicationEngine>
#include <QtCore/QDir>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlEngine>
#include <QtGui/QFontDatabase> #include <QtGui/QFontDatabase>
#include <q3dsruntimeglobal.h> #include <q3dsruntimeglobal.h>
int main(int argc, char *argv[]) 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); QGuiApplication app(argc, argv);
QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat()); QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat());
QQuickView viewer;
QFontDatabase::addApplicationFont("qrc:/qml/fonts/TitilliumWeb-SemiBold.ttf"); QFontDatabase::addApplicationFont("qrc:/qml/fonts/TitilliumWeb-SemiBold.ttf");
QFont defaultFont; QFont defaultFont;
defaultFont.setFamily("Titillium Web"); defaultFont.setFamily("Titillium Web");
QGuiApplication::setFont(defaultFont); QGuiApplication::setFont(defaultFont);
viewer.setSource(QUrl("qrc:/main.qml")); QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
viewer.setTitle(QStringLiteral("Qt 3D Studio Kria 3D Cluster Demo")); if (engine.rootObjects().isEmpty())
viewer.setResizeMode(QQuickView::SizeRootObjectToView); return -1;
viewer.setWidth(1920);
viewer.setHeight(720);
viewer.setColor(QColor("black"));
#if (defined Q_OS_ANDROID)
viewer.showFullScreen();
#else
viewer.show();
#endif
return app.exec(); return app.exec();
} }
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
}
}
...@@ -51,15 +51,12 @@ ...@@ -51,15 +51,12 @@
import QtQuick 2.0 import QtQuick 2.0
Item { Item {
width: 2560
height: 960
Image { Image {
id: fakeMap id: fakeMap
source: "qrc:/icons/Map.png" source: "qrc:/icons/Map.png"
y: -580 y: -parent.width / 0.227 //-580
width: 2560 width: parent.width //2560
height: 1540 height: parent.width * 0.6 //1540
} }
PropertyAnimation { PropertyAnimation {
......
...@@ -48,14 +48,20 @@ ...@@ -48,14 +48,20 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.9 import QtQuick 2.12
import QtStudio3D 2.0 import QtQuick.Window 2.12
import QtStudio3D 2.3
//import QtStudio3D 1.1
import QtQuick.Controls 2.1 import QtQuick.Controls 2.1
Item { Window {
id: mainview id: mainview
width: 1920
focus: true height: 1080
visible: true
color: "#000000"
title: "Qt 3D Studio Kria 3D Cluster Demo"
visibility: Window.FullScreen
property bool startupAnimation: true property bool startupAnimation: true
property bool allowSelection: true property bool allowSelection: true
...@@ -80,16 +86,36 @@ Item { ...@@ -80,16 +86,36 @@ Item {
property string chimesInfo: "Off" property string chimesInfo: "Off"
property string chimesWarning: "On" 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 { Studio3D {
id: studio3D id: studio3D
width: parent.width width: parent.width
height: parent.height height: parent.height
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
ViewerSettings { // RT2
scaleMode: ViewerSettings.ScaleModeFit onFrameUpdate: {
frames++;
avgFrames++;
} }
// ViewerSettings {
// scaleMode: ViewerSettings.ScaleModeFit
// }
Presentation { Presentation {
id: cluster id: cluster
source: "qrc:/presentation/mainPresentation.uia" source: "qrc:/presentation/mainPresentation.uia"
...@@ -154,8 +180,8 @@ Item { ...@@ -154,8 +180,8 @@ Item {
visible: active visible: active
source: "" source: ""
asynchronous: true asynchronous: true
width: 2560 width: mainview.width //2560
height: 960 height: mainview.width * 0.375 //960
} }
} }
] ]
...@@ -171,7 +197,7 @@ Item { ...@@ -171,7 +197,7 @@ Item {
OverlayContainer { OverlayContainer {
id: indicatorPane id: indicatorPane
scale: mainview.width / 2560 scale: mainview.width / 2560
anchors.centerIn: mainview anchors.centerIn: studio3D
visible: false visible: false
} }
...@@ -357,4 +383,50 @@ Item { ...@@ -357,4 +383,50 @@ Item {
mouse.accepted = false; 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;
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment