/*Window {
visible: true
width: 640
height: 480
title: qsTr("Random Values Display")
property var points: []
property var interpolatedPoints: []
Rectangle {
id: right
anchors {
top: parent.top
right: parent.right
rightMargin: 10
bottom: parent.bottom
bottomMargin: 10
}
width: parent.width * 0.7
color: "black"
Rectangle {
id: graph1
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: parent.height * 0.5
color: "black"
border.color: "white"
Text {
id: graph1Title
text: "Capnography / mmHg"
color: "#00ff95"
anchors {
top: parent.top
horizontalCenter: parent.horizontalCenter
topMargin: 10
}
font.pixelSize: 20
font.family: "Arial"
}
Canvas {
id: canvas
anchors.fill: parent
onPaint: {
var ctx = canvas.getContext("2d")
ctx.clearRect(0, 0, canvas.width, canvas.height)
// Draw axes
ctx.strokeStyle = "#ffffff"
ctx.lineWidth = 2
ctx.beginPath()
ctx.moveTo(30, canvas.height - 30)
ctx.lineTo(30, 30)
ctx.lineTo(canvas.width - 30, 30)
ctx.stroke()
// Draw original points and lines
ctx.strokeStyle = "#00ff95"
ctx.lineWidth = 1
ctx.beginPath()
for (var i = 0; i < points.length; i++) {
var point = points[i]
var x = 30 + (point.xValue / 100) * (canvas.width - 60)
var y = canvas.height - 30 - ((point.yValue - 20) / 20) * (canvas.height - 60)
if (i === 0) {
ctx.moveTo(x, y)
} else {
ctx.lineTo(x, y)
}
ctx.arc(x, y, 2, 0, 2 * Math.PI)
}
ctx.stroke()
// Draw interpolated points and lines
ctx.strokeStyle = "#ff0000"
ctx.lineWidth = 1
ctx.beginPath()
for (var j = 0; j < interpolatedPoints.length; j++) {
var interpPoint = interpolatedPoints[j]
var interpX = 30 + (interpPoint.xValue / 100) * (canvas.width - 60)
var interpY = canvas.height - 30 - ((interpPoint.yValue - 20) / 20) * (canvas.height - 60)
if (j === 0) {
ctx.moveTo(interpX, interpY)
} else {
ctx.lineTo(interpX, interpY)
}
ctx.arc(interpX, interpY, 2, 0, 2 * Math.PI)
}
ctx.stroke()
}
Connections {
target: dataGenerator
function onXValueChanged(newValue) {
points.push({ xValue: dataGenerator.xValue, yValue: dataGenerator.yValue });
if (points.length > 100) {
points.shift();
}
// Interpolate points
interpolatedPoints = dataGenerator.interpolatePoints(points, 10);
canvas.requestPaint();
}
function onYValueChanged(newValue) {
canvas.requestPaint();
}
}
}
}
Rectangle {
id: graph2
anchors {
top: graph1.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
color: "black"
border.color: "white"
Text {
id: graph2Title
text: "O2 / %"
color: "#00ff95"
anchors {
top: parent.top
horizontalCenter: parent.horizontalCenter
topMargin: 10
}
font.pixelSize: 20
font.family: "Arial"
}
// Scale
Row {
anchors {
top: graph2Title.bottom
left: parent.left
leftMargin: 10
bottom: parent.bottom
bottomMargin: 10
}
spacing: 10
Column {
spacing: 11
Repeater {
model: 11
Text {
text: 100 - index * 10
color: "#ffff00"
font.pixelSize: 14
font.family: "Arial"
}
}
}
Column {
spacing: (parent.height) / 50
Repeater {
model: 51
Rectangle {
width: index % 5 == 0 ? 15 : 10
height: 1
color: "#ffff00"
}
}
}
}
}
}
}*/