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
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
......
......@@ -39,5 +39,6 @@
<file>presentation/GaugeCenter/gaugecenter.import</file>
<file>presentation/Gauges/Gauges.import</file>
<file>presentation/Needle/needle.import</file>
<file alias="FpsDisplay.qml">qml/FpsDisplay.qml</file>
</qresource>
</RCC>
......@@ -47,42 +47,47 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui/QGuiApplication>
#include <QtCore/QDir>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlEngine>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtGui/QFontDatabase>
#include <q3dsruntimeglobal.h>
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();
}
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 @@
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 {
......
......@@ -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;
}
}
}
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